Skip to content

Commit ff4909c

Browse files
Ivan-JohnsonRahix
authored andcommitted
arduino-hal: Add support for Arduino Micro
Fixes #161
1 parent 0f7fa4d commit ff4909c

File tree

14 files changed

+142
-4
lines changed

14 files changed

+142
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
- type: board
5151
name: arduino-nano
5252
examples: true
53+
- type: board
54+
name: arduino-micro
55+
examples: true
5356
- type: board
5457
name: nano168
5558
examples: true

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ members = [
2828
"examples/arduino-mega2560",
2929
"examples/arduino-mega1280",
3030
"examples/arduino-nano",
31+
"examples/arduino-micro",
3132
"examples/arduino-uno",
3233
"examples/atmega2560",
3334
"examples/nano168",

arduino-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ arduino-leonardo = ["mcu-atmega", "atmega-hal/atmega32u4", "board-selected"]
2222
arduino-mega2560 = ["mcu-atmega", "atmega-hal/atmega2560", "board-selected"]
2323
arduino-mega1280 = ["mcu-atmega", "atmega-hal/atmega1280", "board-selected"]
2424
arduino-nano = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-adc", "board-selected"]
25+
arduino-micro = ["mcu-atmega", "atmega-hal/atmega32u4", "board-selected"]
2526
arduino-uno = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"]
2627
trinket-pro = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"]
2728
sparkfun-promicro = ["mcu-atmega", "atmega-hal/atmega32u4", "board-selected"]

arduino-hal/src/clock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) mod default {
2020
feature = "arduino-mega2560",
2121
feature = "arduino-mega1280",
2222
feature = "arduino-nano",
23+
feature = "arduino-micro",
2324
feature = "arduino-uno",
2425
feature = "sparkfun-promicro",
2526
feature = "sparkfun-promini-5v",

arduino-hal/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![cfg_attr(feature = "arduino-leonardo", doc = "**Arduino Leonardo**.")]
1111
#![cfg_attr(feature = "arduino-mega2560", doc = "**Arduino Mega 2560**.")]
1212
#![cfg_attr(feature = "arduino-mega1280", doc = "**Arduino Mega 1280**.")]
13+
#![cfg_attr(feature = "arduino-micro", doc = "**Arduino Micro**.")]
1314
#![cfg_attr(feature = "arduino-nano", doc = "**Arduino Nano**.")]
1415
#![cfg_attr(feature = "arduino-uno", doc = "**Arduino Uno**.")]
1516
#![cfg_attr(feature = "sparkfun-promicro", doc = "**SparkFun ProMicro**.")]
@@ -64,6 +65,7 @@ compile_error!(
6465
* arduino-leonardo
6566
* arduino-mega2560
6667
* arduino-mega1280
68+
* arduino-micro
6769
* arduino-nano
6870
* arduino-uno
6971
* sparkfun-promicro
@@ -238,7 +240,7 @@ macro_rules! pins {
238240
/// let pins = arduino_hal::pins!(dp);
239241
/// let serial = arduino_hal::default_serial!(dp, pins, 57600);
240242
/// ```
241-
#[cfg(any(feature = "arduino-leonardo"))]
243+
#[cfg(any(feature = "arduino-leonardo", feature = "arduino-micro"))]
242244
#[macro_export]
243245
macro_rules! default_serial {
244246
($p:expr, $pins:expr, $baud:expr) => {

arduino-hal/src/port/leonardo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub use atmega_hal::port::{mode, Pin, PinMode, PinOps};
22

33
avr_hal_generic::renamed_pins! {
4-
/// Pins of the **Arduino Leonardo**.
4+
/// Pins of the **Arduino Leonardo** and **Arduno Micro**.
55
///
66
/// This struct is best initialized via the [`arduino_hal::pins!()`][crate::pins] macro.
77
pub struct Pins {

arduino-hal/src/port/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
mod diecimila;
2020
#[cfg(feature = "arduino-diecimila")]
2121
pub use diecimila::*;
22-
#[cfg(feature = "arduino-leonardo")]
22+
#[cfg(any(feature = "arduino-leonardo", feature = "arduino-micro"))]
2323
mod leonardo;
24-
#[cfg(feature = "arduino-leonardo")]
24+
#[cfg(any(feature = "arduino-leonardo", feature = "arduino-micro"))]
2525
pub use leonardo::*;
2626
#[cfg(any(feature = "arduino-mega2560", feature = "arduino-mega1280"))]
2727
mod mega;

examples/arduino-leonardo/src/bin/leonardo-usart.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*!
2+
* Demonstration of writing to and reading from the serial console.
3+
*
4+
* Note: To communicate with the Arduino over its hardware serial port, you must
5+
* connect an external USB-to-UART adapter to the board’s RX and TX pins.
6+
*/
17
#![no_std]
28
#![no_main]
39

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[build]
2+
target = "avr-none"
3+
rustflags = ["-C", "target-cpu=atmega32u4"]
4+
5+
[target.'cfg(target_arch = "avr")']
6+
runner = "ravedude"
7+
8+
[unstable]
9+
build-std = ["core"]

examples/arduino-micro/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "arduino-micro-examples"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
panic-halt = "1.0.0"
9+
ufmt = "0.2.0"
10+
nb = "1.1.0"
11+
12+
[dependencies.arduino-hal]
13+
path = "../../arduino-hal/"
14+
features = ["arduino-micro"]

0 commit comments

Comments
 (0)