Skip to content

Commit

Permalink
Support the SparkFun ProMini 5V
Browse files Browse the repository at this point in the history
  • Loading branch information
ani authored Oct 24, 2023
1 parent 01029ae commit 190f2c3
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- type: board
name: sparkfun-promicro
examples: true
- type: board
name: sparkfun-promini-5v
examples: true
- type: board
name: trinket-pro
examples: true
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ members = [
"examples/arduino-uno",
"examples/nano168",
"examples/sparkfun-promicro",
"examples/sparkfun-promini-5v",
"examples/trinket-pro",
"examples/trinket",
]
Expand Down
1 change: 1 addition & 0 deletions arduino-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ arduino-nano = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-
arduino-uno = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"]
trinket-pro = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"]
sparkfun-promicro = ["mcu-atmega", "atmega-hal/atmega32u4", "board-selected"]
sparkfun-promini-5v = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-adc", "board-selected"]
trinket = ["mcu-attiny", "attiny-hal/attiny85", "board-selected"]
nano168 = ["mcu-atmega", "atmega-hal/atmega168", "atmega-hal/enable-extra-adc", "board-selected"]

Expand Down
1 change: 1 addition & 0 deletions arduino-hal/src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) mod default {
feature = "arduino-nano",
feature = "arduino-uno",
feature = "sparkfun-promicro",
feature = "sparkfun-promini-5v",
feature = "trinket-pro",
feature = "nano168",
))]
Expand Down
4 changes: 3 additions & 1 deletion arduino-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![cfg_attr(feature = "arduino-nano", doc = "**Arduino Nano**.")]
#![cfg_attr(feature = "arduino-uno", doc = "**Arduino Uno**.")]
#![cfg_attr(feature = "sparkfun-promicro", doc = "**SparkFun ProMicro**.")]
#![cfg_attr(feature = "sparkfun-promini-5v", doc = "**SparkFun ProMini 5V (16MHz)**.")]
#![cfg_attr(feature = "trinket-pro", doc = "**Trinket Pro**.")]
#![cfg_attr(feature = "trinket", doc = "**Trinket**.")]
#![cfg_attr(feature = "nano168", doc = "**Nano clone (ATmega168)**.")]
Expand Down Expand Up @@ -59,6 +60,7 @@ compile_error!(
* arduino-nano
* arduino-uno
* sparkfun-promicro
* sparkfun-promini-5v
* trinket-pro
* trinket
* nano168
Expand Down Expand Up @@ -257,7 +259,7 @@ macro_rules! default_serial {
)
};
}
#[cfg(any(feature = "arduino-nano", feature = "nano168"))]
#[cfg(any(feature = "arduino-nano", feature = "nano168", feature = "sparkfun-promini-5v"))]
#[macro_export]
macro_rules! default_serial {
($p:expr, $pins:expr, $baud:expr) => {
Expand Down
4 changes: 2 additions & 2 deletions arduino-hal/src/port/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub use leonardo::*;
mod mega;
#[cfg(any(feature = "arduino-mega2560", feature = "arduino-mega1280"))]
pub use mega::*;
#[cfg(any(feature = "arduino-nano", feature = "arduino-uno", feature = "nano168"))]
#[cfg(any(feature = "arduino-nano", feature = "arduino-uno", feature = "nano168", feature = "sparkfun-promini-5v"))]
mod uno;
#[cfg(any(feature = "arduino-nano", feature = "arduino-uno", feature = "nano168"))]
#[cfg(any(feature = "arduino-nano", feature = "arduino-uno", feature = "nano168", feature = "sparkfun-promini-5v"))]
pub use uno::*;
#[cfg(feature = "sparkfun-promicro")]
mod promicro;
Expand Down
2 changes: 1 addition & 1 deletion arduino-hal/src/port/uno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use atmega_hal::port::{mode, Pin, PinOps, PinMode};
avr_hal_generic::renamed_pins! {
type Pin = Pin;

/// Pins of the **Arduino Uno**.
/// Pins of the **Arduino Uno**, **Arduino Nano**, and **SparkFun ProMini 5V (16MHz)**.
///
/// This struct is best initialized via the [`arduino_hal::pins!()`][crate::pins] macro.
pub struct Pins from atmega_hal::Pins {
Expand Down
8 changes: 8 additions & 0 deletions examples/sparkfun-promini-5v/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build]
target = "../../avr-specs/avr-atmega328p.json"

[target.'cfg(target_arch = "avr")']
runner = "ravedude promini-5v"

[unstable]
build-std = ["core"]
16 changes: 16 additions & 0 deletions examples/sparkfun-promini-5v/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "sparkfun-promini-5v-examples"
version = "0.0.0"
authors = ["Rahix <[email protected]>"]
edition = "2018"
publish = false

[dependencies]
panic-halt = "0.2.0"
ufmt = "0.1.0"
nb = "0.1.2"
embedded-hal = "0.2.3"

[dependencies.arduino-hal]
path = "../../arduino-hal/"
features = ["sparkfun-promini-5v"]
25 changes: 25 additions & 0 deletions examples/sparkfun-promini-5v/src/bin/promini-5v-blink.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![no_std]
#![no_main]

use panic_halt as _;

#[arduino_hal::entry]
fn main() -> ! {
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);

// Digital pin 13 is also connected to an onboard LED marked "L"
let mut led = pins.d13.into_output();
led.set_high();

loop {
led.toggle();
arduino_hal::delay_ms(100);
led.toggle();
arduino_hal::delay_ms(100);
led.toggle();
arduino_hal::delay_ms(100);
led.toggle();
arduino_hal::delay_ms(800);
}
}
26 changes: 26 additions & 0 deletions ravedude/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn get_board(board: &str) -> Option<Box<dyn Board>> {
"mega1280" => Box::new(ArduinoMega1280),
"diecimila" => Box::new(ArduinoDiecimila),
"promicro" => Box::new(SparkFunProMicro),
"promini-5v" => Box::new(SparkFunProMini5V),
"trinket-pro" => Box::new(TrinketPro),
"trinket" => Box::new(Trinket),
"nano168" => Box::new(Nano168),
Expand Down Expand Up @@ -316,6 +317,31 @@ impl Board for SparkFunProMicro {
}
}

struct SparkFunProMini5V;

impl Board for SparkFunProMini5V {
fn display_name(&self) -> &str {
"SparkFun Pro Mini 5V (16MHz)"
}

fn needs_reset(&self) -> Option<&str> {
None
}

fn avrdude_options(&self) -> avrdude::AvrdudeOptions {
avrdude::AvrdudeOptions {
programmer: "arduino",
partno: "atmega328p",
baudrate: Some(57600),
do_chip_erase: true,
}
}

fn guess_port(&self) -> Option<anyhow::Result<std::path::PathBuf>> {
Some(Err(anyhow::anyhow!("Not able to guess port")))
}
}

struct TrinketPro;

impl Board for TrinketPro {
Expand Down
1 change: 1 addition & 0 deletions ravedude/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct Args {
/// * mega1280
/// * diecimila
/// * promicro
/// * promini-5v
/// * trinket-pro
/// * trinket
/// * nano168
Expand Down

0 comments on commit 190f2c3

Please sign in to comment.