From 882db12855567c6b51163c5b989605d63ba5d42a Mon Sep 17 00:00:00 2001 From: Jacob Vanderkarr <44854763+splicedbread@users.noreply.github.com> Date: Sat, 28 May 2022 15:42:05 -0700 Subject: [PATCH] Add BSP for Arduino RP2040 Nano Connect (#345) * Modifies: * Cargo toml to include arduino_nano_connect package * README to update documentation to reflect a board being added Adds: * Basic support package for Arduino's RP2040 Nano Connect board * blinky example Co-authored-by: splicedbread Co-authored-by: 9names <60134748+9names@users.noreply.github.com> --- Cargo.toml | 1 + README.md | 11 + boards/arduino_nano_connect/.gitignore | 11 + boards/arduino_nano_connect/Cargo.toml | 50 ++ boards/arduino_nano_connect/README.md | 98 +++ .../examples/nano_blinky.rs | 95 +++ boards/arduino_nano_connect/src/lib.rs | 753 ++++++++++++++++++ 7 files changed, 1019 insertions(+) create mode 100644 boards/arduino_nano_connect/.gitignore create mode 100644 boards/arduino_nano_connect/Cargo.toml create mode 100644 boards/arduino_nano_connect/README.md create mode 100644 boards/arduino_nano_connect/examples/nano_blinky.rs create mode 100644 boards/arduino_nano_connect/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 51942b9..6b88f0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "boards/adafruit-macropad", "boards/adafruit-qt-py-rp2040", "boards/adafruit-trinkey-qt2040", + "boards/arduino_nano_connect", "boards/pimoroni-pico-explorer", "boards/pimoroni-pico-lipo-16mb", "boards/pimoroni-plasma-2040", diff --git a/README.md b/README.md index ac57744..4757b33 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,17 @@ RP2040 chip according to how it is connected up on the Thing Plus RP2040. [Sparkfun Thing Plus RP2040]: https://www.sparkfun.com/products/17745 [sparkfun-thing-plus-rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/sparkfun-thing-plus-rp2040 +### [arduino_nano_connect] - Board Support for the [Arduino Nano RP2040 Connect] + +You should include this crate if you are writing code that you want to run on +an [Arduino Nano RP2040 Connect] - a development pcb with shortwave communication, IMU, and BLE package. + +This crate includes the [rp2040-hal], but also configures each pin of the +RP2040 chip according to how it is connected up on the nano connect. + +[Arduino Nano RP2040 Connect]: https://store-usa.arduino.cc/collections/boards/products/arduino-nano-rp2040-connect +[arduino_nano_connect]: https://github.com/rp-rs/rp-hal/tree/main/boards/arduino_nano_connect + ## Programming diff --git a/boards/arduino_nano_connect/.gitignore b/boards/arduino_nano_connect/.gitignore new file mode 100644 index 0000000..ff47c2d --- /dev/null +++ b/boards/arduino_nano_connect/.gitignore @@ -0,0 +1,11 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/boards/arduino_nano_connect/Cargo.toml b/boards/arduino_nano_connect/Cargo.toml new file mode 100644 index 0000000..c1ee2b7 --- /dev/null +++ b/boards/arduino_nano_connect/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "arduino_nano_connect" +version = "0.1.0" +authors = ["splicedbread ", "The rp-rs Developers"] +edition = "2018" +homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/arduino_nano_connect" +description = "Board Support Package for the Arduino Nano RP2040 Connect" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rp-rs/rp-hal.git" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cortex-m = "0.7.3" +rp2040-boot2 = { version = "0.2.0", optional = true } +rp2040-hal = { path = "../../rp2040-hal", version = "0.4.0" } +cortex-m-rt = { version = "0.7.0", optional = true } +embedded-hal = { version = "0.2.4", features = ["unproven"] } +panic-probe = { version = "0.2.0", features = ["print-defmt"] } +embedded-time = "0.12.0" +# usb-device= "0.2.8" +# usbd-serial = "0.1.1" +# usbd-hid = "0.5.1" +futures = { version = "0.3", default-features = false, optional = true } + +[dependencies.embassy] +git = "https://github.com/embassy-rs/embassy" +rev = "6d6e6f55b8a9ecd38b5a6d3bb11f74b2654afdeb" +optional = true + +# namespaced features will let use use "dep:embassy-traits" in the features rather than using this +# trick of renaming the crate. +[dependencies.embassy_traits] +git = "https://github.com/embassy-rs/embassy" +rev = "6d6e6f55b8a9ecd38b5a6d3bb11f74b2654afdeb" +package = "embassy-traits" +optional = true + +[dev-dependencies] +panic-halt= "0.2.0" +embedded-hal ="0.2.5" +cortex-m-rtic = "0.6.0-alpha.5" +nb = "1.0" +# i2c-pio = { git = "https://github.com/ithinuel/i2c-pio-rs", rev = "afc2dad0e955da2b712d7f7cd78c7af88ddc6a45" } + +[features] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] +rt = ["cortex-m-rt","rp2040-hal/rt"] +embassy-traits = ["futures", "embassy", "embassy_traits"] diff --git a/boards/arduino_nano_connect/README.md b/boards/arduino_nano_connect/README.md new file mode 100644 index 0000000..368be68 --- /dev/null +++ b/boards/arduino_nano_connect/README.md @@ -0,0 +1,98 @@ +# [arduino_nano_connect] - Board Support for the [Arduino Nano RP2040 Connect] + +You should include this crate if you are writing code that you want to run on +an [Arduino Nano RP2040 Connect] - a development pcb with shortwave communication, IMU, and BLE package. + +This crate includes the [rp2040-hal], but also configures each pin of the +RP2040 chip according to how it is connected up on the nano connect. + +[Arduino Nano RP2040 Connect]: https://store-usa.arduino.cc/collections/boards/products/arduino-nano-rp2040-connect +[arduino_nano_connect]: https://github.com/rp-rs/rp-hal/tree/main/boards/arduino_nano_connect +[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal +[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/ + +## Using + +To use this crate, your `Cargo.toml` file should contain: + +```toml +arduino_nano_connect = { git = "https://github.com/rp-rs/rp-hal.git" } +``` +# TODO - down and out +In your program, you will need to call `arduino_nano_connect::Pins::new` to create +a new `Pins` structure. This will set up all the GPIOs for any on-board +devices. See the [examples](./examples) folder for more details. + +## Examples + +[nano_blinky](./examples/nano_blinky.rs) + +### General Instructions + +To compile an example, clone the _rp-hal_ repository and run: + +```console +rp-hal/boards/arduino_nano_connect $ cargo build --release --example +``` + +You will get an ELF file called +`./target/thumbv6m-none-eabi/release/examples/`, where the `target` +folder is located at the top of the _rp-hal_ repository checkout. Normally +you would also need to specify `--target=thumbv6m-none-eabi` but when +building examples from this git repository, that is set as the default. + +If you want to convert the ELF file to a UF2 and automatically copy it to the +USB drive exported by the RP2040 bootloader, simply boot your board into +bootloader mode and run: + +```console +rp-hal/boards/arduino_nano_connect $ cargo run --release --example +``` + +If you get an error about not being able to find `elf2uf2-rs`, try: + +```console +$ cargo install elf2uf2-rs +``` +then try repeating the `cargo run` command above. + +### [nano_blinky](./examples/nano_blinky.rs) + +Flashes the Arduino Nano Connect's on-board LED on and off. + + +## Contributing + +Contributions are what make the open source community such an amazing place to +be learn, inspire, and create. Any contributions you make are **greatly +appreciated**. + +The steps are: + +1. Fork the Project by clicking the 'Fork' button at the top of the page. +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) +3. Make some changes to the code or documentation. +4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) +5. Push to the Feature Branch (`git push origin feature/AmazingFeature`) +6. Create a [New Pull Request](https://github.com/rp-rs/rp-hal/pulls) +7. An admin will review the Pull Request and discuss any changes that may be required. +8. Once everyone is happy, the Pull Request can be merged by an admin, and your work is part of our project! + +## Code of Conduct + +Contribution to this crate is organized under the terms of the [Rust Code of +Conduct][CoC], and the maintainer of this crate, the [rp-rs team], promises +to intervene to uphold that code of conduct. + +[CoC]: CODE_OF_CONDUCT.md +[rp-rs team]: https://github.com/orgs/rp-rs/teams/rp-rs + +## License + +The contents of this repository are dual-licensed under the _MIT OR Apache +2.0_ License. That means you can chose either the MIT license or the +Apache-2.0 license when you re-use this code. See `MIT` or `APACHE2.0` for more +information on each specific license. + +Any submissions to this project (e.g. as Pull Requests) must be made available +under these terms. diff --git a/boards/arduino_nano_connect/examples/nano_blinky.rs b/boards/arduino_nano_connect/examples/nano_blinky.rs new file mode 100644 index 0000000..04c1dd3 --- /dev/null +++ b/boards/arduino_nano_connect/examples/nano_blinky.rs @@ -0,0 +1,95 @@ +//! # Nano Blinky Example +//! +//! Blinks the LED on a Arduino Nano Connect board. +//! +//! This will blink an LED attached to GP25, which is the pin the Nano uses for +//! the on-board LED. +//! +//! See the `Cargo.toml` file for Copyright and license details. + +#![no_std] +#![no_main] + +// The macro for our start-up function +use cortex_m_rt::entry; + +use embedded_hal::digital::v2::OutputPin; +// // Time handling traits +use embedded_time::rate::*; + +// Ensure we halt the program on panic (if we don't mention this crate it won't +// be linked) +use panic_halt as _; + +use arduino_nano_connect as bsp; + +// Pull in any important traits +use bsp::hal::prelude::*; + +// A shorter alias for the Peripheral Access Crate, which provides low-level +// register access +use bsp::hal::pac; + +// A shorter alias for the Hardware Abstraction Layer, which provides +// higher-level drivers. +use bsp::hal; + +/// Entry point to our bare-metal application. +/// +/// The `#[entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables are initialised. +/// +/// The function configures the RP2040 peripherals, then blinks the LED in an +/// infinite loop. +#[entry] +fn main() -> ! { + // Grab our singleton objects + let mut pac = pac::Peripherals::take().unwrap(); + let core = pac::CorePeripherals::take().unwrap(); + + // Set up the watchdog driver - needed by the clock setup code + let mut watchdog = hal::Watchdog::new(pac.WATCHDOG); + + // Configure the clocks + // + // The default is to generate a 125 MHz system clock + let clocks = hal::clocks::init_clocks_and_plls( + bsp::XOSC_CRYSTAL_FREQ, + pac.XOSC, + pac.CLOCKS, + pac.PLL_SYS, + pac.PLL_USB, + &mut pac.RESETS, + &mut watchdog, + ) + .ok() + .unwrap(); + + // The delay object lets us wait for specified amounts of time (in + // milliseconds) + let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); + + // The single-cycle I/O block controls our GPIO pins + let sio = hal::Sio::new(pac.SIO); + + // Set the pins up according to their function on this particular board + let pins = bsp::Pins::new( + pac.IO_BANK0, + pac.PADS_BANK0, + sio.gpio_bank0, + &mut pac.RESETS, + ); + + // Set the LED to be an output + let mut led_pin = pins.sck0.into_push_pull_output(); + + // Blink the LED at 1 Hz + loop { + led_pin.set_high().unwrap(); + delay.delay_ms(500); + led_pin.set_low().unwrap(); + delay.delay_ms(500); + } +} + +// End of file diff --git a/boards/arduino_nano_connect/src/lib.rs b/boards/arduino_nano_connect/src/lib.rs new file mode 100644 index 0000000..2309e5a --- /dev/null +++ b/boards/arduino_nano_connect/src/lib.rs @@ -0,0 +1,753 @@ +#![no_std] + +pub extern crate rp2040_hal as hal; + +#[cfg(feature = "rt")] +extern crate cortex_m_rt; +#[cfg(feature = "rt")] +pub use cortex_m_rt::entry; + +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_AT25SF128A; + +pub use hal::pac; + +// borrowed some pin defs from rp-pico from a dicussion on the bsp_pins! macro +// stripped out functions from connected lines that are no available through +// any of the header pins +hal::bsp_pins!( + /// GPIO 0 supports following functions: + /// | Default | UART0 TX (arduino nano connect) + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 RX` | [crate::Gp0Spi0Rx] | + /// | `UART0 TX` | [crate::Gp0Uart0Tx] | + /// | `I2C0 SDA` | [crate::Gp0I2C0Sda] | + /// | `PWM0 A` | [crate::Gp0Pwm0A] | + /// | `PIO0` | [crate::Gp0Pio0] | + /// | `PIO1` | [crate::Gp0Pio1] | + Gpio0 { + name: tx, + aliases: + { + /// UART Function alias for pin [crate::Pins::gpio0]. + FunctionUart: Gp0Uart0Tx + } + }, + + /// GPIO 1 supports following functions: + /// | Default | UART0 RX (arduino nano connect) + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 CSn` | [crate::Gp1Spi0Csn] | + /// | `UART0 RX` | [crate::Gp1Uart0Rx] | + /// | `I2C0 SCL` | [crate::Gp1I2C0Scl] | + /// | `PWM0 B` | [crate::Gp1Pwm0B] | + /// | `PIO0` | [crate::Gp1Pio0] | + /// | `PIO1` | [crate::Gp1Pio1] | + Gpio1 { + name: rx, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio1]. + FunctionUart: Gp1Uart0Rx + } + }, + + /// GPIO 2 supports following functions: + /// | Default | GPIO0 on nina, relates to BLE CTS + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 SCK` | [crate::Gp2Spi0Sck] | + /// | `UART0 CTS` | [crate::Gp2Uart0Cts] | + /// | `I2C1 SDA` | [crate::Gp2I2C1Sda] | + /// | `PWM1 A` | [crate::Gp2Pwm1A] | + /// | `PIO0` | [crate::Gp2Pio0] | + /// | `PIO1` | [crate::Gp2Pio1] | + Gpio2 { + // name indicates BLE CTS on nina module, so outgoing line is bleRts using UART + name: ble_rts, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio2]. + FunctionUart: Gp2Uart0Cts + } + }, + + /// GPIO 3 supports following functions: + /// | Default | Line for reset of Nina Wifi Module + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 TX` | [crate::Gp3Spi0Tx] | + /// | `UART0 RTS` | [crate::Gp3Uart0Rts] | + /// | `I2C1 SCL` | [crate::Gp3I2C1Scl] | + /// | `PWM1 B` | [crate::Gp3Pwm1B] | + /// | `PIO0` | [crate::Gp3Pio0] | + /// | `PIO1` | [crate::Gp3Pio1] | + Gpio3 { + name: nina_reset_n + }, + + /// GPIO 4 supports following functions: + /// | Default | SpiRx + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 RX` | [crate::Gp4Spi0Rx] | + /// | `UART1 TX` | [crate::Gp4Uart1Tx] | + /// | `I2C0 SDA` | [crate::Gp4I2C0Sda] | + /// | `PWM2 A` | [crate::Gp4Pwm2A] | + /// | `PIO0` | [crate::Gp4Pio0] | + /// | `PIO1` | [crate::Gp4Pio1] | + Gpio4 { + // Conflicting information between schematic and 'latest' pinnout diagram. + // MISO in schematic, CIPO in 'latest' arduino pinnout diagram. same thing really + // SPIRX in schematic line label. + name: cipo, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio4]. + FunctionUart: Gp4Uart1Tx, + /// SPI Function alias for pin [crate::Pins::gpio4]. + FunctionSpi: Gp4Spi0Rx, + /// I2C Function alias for pin [crate::Pins::gpio4]. + FunctionI2C: Gp4I2C0Sda, + /// PWM Function alias for pin [crate::Pins::gpio4]. + FunctionPwm: Gp4Pwm2A, + /// PIO0 Function alias for pin [crate::Pins::gpio4]. + FunctionPio0: Gp4Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio4]. + FunctionPio1: Gp4Pio1 + } + }, + + /// GPIO 5 supports following functions: + /// | Default | Generic Digital pin D10 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 CSn` | [crate::Gp5Spi0Csn] | + /// | `UART1 RX` | [crate::Gp5Uart1Rx] | + /// | `I2C0 SCL` | [crate::Gp5I2C0Scl] | + /// | `PWM2 B` | [crate::Gp5Pwm2B] | + /// | `PIO0` | [crate::Gp5Pio0] | + /// | `PIO1` | [crate::Gp5Pio1] | + Gpio5 { + name: d10, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio5]. + FunctionUart: Gp5Uart1Rx, + /// SPI Function alias for pin [crate::Pins::gpio5]. + FunctionSpi: Gp5Spi0Csn, + /// I2C Function alias for pin [crate::Pins::gpio5]. + FunctionI2C: Gp5I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio5]. + FunctionPwm: Gp5Pwm2B, + /// PIO0 Function alias for pin [crate::Pins::gpio5]. + FunctionPio0: Gp5Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio5]. + FunctionPio1: Gp5Pio1 + } + }, + + /// GPIO 6 supports following functions: + /// | Default | SPI0 SCK (tied to on board led) + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 SCK` | [crate::Gp6Spi0Sck] | + /// | `UART1 CTS` | [crate::Gp6Uart1Cts] | + /// | `I2C1 SDA` | [crate::Gp6I2C1Sda] | + /// | `PWM3 A` | [crate::Gp6Pwm3A] | + /// | `PIO0` | [crate::Gp6Pio0] | + /// | `PIO1` | [crate::Gp6Pio1] | + Gpio6 { + // also tied to on board led, on pin 13 + name: sck0, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio6]. + FunctionUart: Gp6Uart1Cts, + /// SPI Function alias for pin [crate::Pins::gpio6]. + FunctionSpi: Gp6Spi0Sck, + /// I2C Function alias for pin [crate::Pins::gpio6]. + FunctionI2C: Gp6I2C1Sda, + /// PWM Function alias for pin [crate::Pins::gpio6]. + FunctionPwm: Gp6Pwm3A, + /// PIO0 Function alias for pin [crate::Pins::gpio6]. + FunctionPio0: Gp6Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio6]. + FunctionPio1: Gp6Pio1 + } + }, + + /// GPIO 7 supports following functions: + /// | Default | SPI0 TX + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 TX` | [crate::Gp7Spi0Tx] | + /// | `UART1 RTS` | [crate::Gp7Uart1Rts] | + /// | `I2C1 SCL` | [crate::Gp7I2C1Scl] | + /// | `PWM3 B` | [crate::Gp7Pwm3B] | + /// | `PIO0` | [crate::Gp7Pio0] | + /// | `PIO1` | [crate::Gp7Pio1] | + Gpio7 { + // Conflicting information between schematic and 'latest' pinnout diagram. + // MOSI in schematic, COPI in 'latest' arduino pinnout diagram. + // SPITX in schematic line label. + name: copi, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio7]. + FunctionUart: Gp7Uart1Rts, + /// SPI Function alias for pin [crate::Pins::gpio7]. + FunctionSpi: Gp7Spi0Tx, + /// I2C Function alias for pin [crate::Pins::gpio7]. + FunctionI2C: Gp7I2C1Scl, + /// PWM Function alias for pin [crate::Pins::gpio7]. + FunctionPwm: Gp7Pwm3B, + /// PIO0 Function alias for pin [crate::Pins::gpio7]. + FunctionPio0: Gp7Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio7]. + FunctionPio1: Gp7Pio1 + } + }, + + /// GPIO 8 supports following functions: + /// | Default | SPI1 CIPO / UART1 TX connection to Nina Module + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 RX` | [crate::Gp8Spi1Rx] | + /// | `UART1 TX` | [crate::Gp8Uart1Tx] | + /// | `I2C0 SDA` | [crate::Gp8I2C0Sda] | + /// | `PWM4 A` | [crate::Gp8Pwm4A] | + /// | `PIO0` | [crate::Gp8Pio0] | + /// | `PIO1` | [crate::Gp8Pio1] | + Gpio8 { + // name indicates port to BLE RX on nina module and SPI CIPO for wifi + name: ble_tx_cipo, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio8]. + FunctionUart: Gp8Uart1Tx, + /// SPI Function alias for pin [crate::Pins::gpio8]. + FunctionSpi: Gp8Spi1Rx + } + }, + + /// GPIO 9 supports following functions: + /// | Default | SPI1 CS / UART1 RX + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 CSn` | [crate::Gp9Spi1Csn] | + /// | `UART1 RX` | [crate::Gp9Uart1Rx] | + /// | `I2C0 SCL` | [crate::Gp9I2C0Scl] | + /// | `PWM4 B` | [crate::Gp9Pwm4B] | + /// | `PIO0` | [crate::Gp9Pio0] | + /// | `PIO1` | [crate::Gp9Pio1] | + Gpio9 { + // name indicates BLE TX on nina module and spi1 cs signal to wifi + name: ble_rx_cs, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio9]. + FunctionUart: Gp9Uart1Rx, + /// SPI Function alias for pin [crate::Pins::gpio9]. + FunctionSpi: Gp9Spi1Csn + } + }, + + /// GPIO 10 supports following functions: + /// | Default | SPI1 ACK / UART1 CTS + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 SCK` | [crate::Gp10Spi1Sck] | + /// | `UART1 CTS` | [crate::Gp10Uart1Cts] | + /// | `I2C1 SDA` | [crate::Gp10I2C1Sda] | + /// | `PWM5 A` | [crate::Gp10Pwm5A] | + /// | `PIO0` | [crate::Gp10Pio0] | + /// | `PIO1` | [crate::Gp10Pio1] | + Gpio10 { + // name indicates BLE RTS on nina module and spi1 ack + name: ble_cts_ack, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio10]. + FunctionUart: Gp10Uart1Cts, + /// SPI Function alias for pin [crate::Pins::gpio10]. + FunctionSpi: Gp10Spi1Sck + } + }, + + /// GPIO 11 supports following functions: + /// | Default | SPI1 COPI / UART1 RTS + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 TX` | [crate::Gp11Spi1Tx] | + /// | `UART1 RTS` | [crate::Gp11Uart1Rts] | + /// | `I2C1 SCL` | [crate::Gp11I2C1Scl] | + /// | `PWM5 B` | [crate::Gp11Pwm5B] | + /// | `PIO0` | [crate::Gp11Pio0] | + /// | `PIO1` | [crate::Gp11Pio1] | + Gpio11 { + // ninaCOPI is + name: nina_copi, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio11]. + FunctionUart: Gp11Uart1Rts, + /// SPI Function alias for pin [crate::Pins::gpio11]. + FunctionSpi: Gp11Spi1Tx + } + }, + + /// GPIO 12 supports following functions: + /// | Default | I2C0 SDA / A4 ~ goes to pullups and auth + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 RX` | [crate::Gp12Spi1Rx] | + /// | `UART0 TX` | [crate::Gp12Uart0Tx] | + /// | `I2C0 SDA` | [crate::Gp12I2C0Sda] | + /// | `PWM6 A` | [crate::Gp12Pwm6A] | + /// | `PIO0` | [crate::Gp12Pio0] | + /// | `PIO1` | [crate::Gp12Pio1] | + Gpio12 { + // Also SDA Crypto + name: a4, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio12]. + FunctionUart: Gp12Uart0Tx, + /// SPI Function alias for pin [crate::Pins::gpio12]. + FunctionSpi: Gp12Spi1Rx, + /// I2C Function alias for pin [crate::Pins::gpio12]. + FunctionI2C: Gp12I2C0Sda, + /// PWM Function alias for pin [crate::Pins::gpio12]. + FunctionPwm: Gp12Pwm6A, + /// PIO0 Function alias for pin [crate::Pins::gpio12]. + FunctionPio0: Gp12Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio12]. + FunctionPio1: Gp12Pio1 + } + }, + + /// GPIO 13 supports following functions: + /// | Default | I2C0 SCL / A5 ~ goes to pullups + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 CSn` | [crate::Gp13Spi1Csn] | + /// | `UART0 RX` | [crate::Gp13Uart0Rx] | + /// | `I2C0 SCL` | [crate::Gp13I2C0Scl] | + /// | `PWM6 B` | [crate::Gp13Pwm6B] | + /// | `PIO0` | [crate::Gp13Pio0] | + /// | `PIO1` | [crate::Gp13Pio1] | + Gpio13 { + // Also SCL Crypto + name: a5, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio13]. + FunctionUart: Gp13Uart0Rx, + /// SPI Function alias for pin [crate::Pins::gpio13]. + FunctionSpi: Gp13Spi1Csn, + /// I2C Function alias for pin [crate::Pins::gpio13]. + FunctionI2C: Gp13I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio13]. + FunctionPwm: Gp13Pwm6B, + /// PIO0 Function alias for pin [crate::Pins::gpio13]. + FunctionPio0: Gp13Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio13]. + FunctionPio1: Gp13Pio1 + } + }, + + /// GPIO 14 supports following functions: + /// | Default | SPI1 SCK ~ nina SCK + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 SCK` | [crate::Gp14Spi1Sck] | + /// | `UART0 CTS` | [crate::Gp14Uart0Cts] | + /// | `I2C1 SDA` | [crate::Gp14I2C1Sda] | + /// | `PWM7 A` | [crate::Gp14Pwm7A] | + /// | `PIO0` | [crate::Gp14Pio0] | + /// | `PIO1` | [crate::Gp14Pio1] | + Gpio14 { + name: nina_sck, + aliases: { + /// SPI Function alias for pin [crate::Pins::gpio14]. + FunctionSpi: Gp14Spi1Sck + } + }, + + /// GPIO 15 supports following functions: + /// | Default | General Digital pin D3 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 TX` | [crate::Gp15Spi1Tx] | + /// | `UART0 RTS` | [crate::Gp15Uart0Rts] | + /// | `I2C1 SCL` | [crate::Gp15I2C1Scl] | + /// | `PWM7 B` | [crate::Gp15Pwm7B] | + /// | `PIO0` | [crate::Gp15Pio0] | + /// | `PIO1` | [crate::Gp15Pio1] | + Gpio15 { + name: d3, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio15]. + FunctionUart: Gp15Uart0Rts, + /// SPI Function alias for pin [crate::Pins::gpio15]. + FunctionSpi: Gp15Spi1Tx, + /// I2C Function alias for pin [crate::Pins::gpio15]. + FunctionI2C: Gp15I2C1Scl, + /// PWM Function alias for pin [crate::Pins::gpio15]. + FunctionPwm: Gp15Pwm7B, + /// PIO0 Function alias for pin [crate::Pins::gpio15]. + FunctionPio0: Gp15Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio15]. + FunctionPio1: Gp15Pio1 + } + }, + + /// GPIO 16 supports following functions: + /// | Default | General Digital pin D4 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 RX` | [crate::Gp16Spi0Rx] | + /// | `UART0 TX` | [crate::Gp16Uart0Tx] | + /// | `I2C0 SDA` | [crate::Gp16I2C0Sda] | + /// | `PWM0 A` | [crate::Gp16Pwm0A] | + /// | `PIO0` | [crate::Gp16Pio0] | + /// | `PIO1` | [crate::Gp16Pio1] | + Gpio16 { + name: d4, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio16]. + FunctionUart: Gp16Uart0Tx, + /// SPI Function alias for pin [crate::Pins::gpio16]. + FunctionSpi: Gp16Spi0Rx, + /// I2C Function alias for pin [crate::Pins::gpio16]. + FunctionI2C: Gp16I2C0Sda, + /// PWM Function alias for pin [crate::Pins::gpio16]. + FunctionPwm: Gp16Pwm0A, + /// PIO0 Function alias for pin [crate::Pins::gpio16]. + FunctionPio0: Gp16Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio16]. + FunctionPio1: Gp16Pio1 + } + }, + + /// GPIO 17 supports following functions: + /// | Default | General Digital pin D5 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 CSn` | [crate::Gp17Spi0Csn] | + /// | `UART0 RX` | [crate::Gp17Uart0Rx] | + /// | `I2C0 SCL` | [crate::Gp17I2C0Scl] | + /// | `PWM0 B` | [crate::Gp17Pwm0B] | + /// | `PIO0` | [crate::Gp17Pio0] | + /// | `PIO1` | [crate::Gp17Pio1] | + Gpio17 { + name: d5, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio17]. + FunctionUart: Gp17Uart0Rx, + /// SPI Function alias for pin [crate::Pins::gpio17]. + FunctionSpi: Gp17Spi0Csn, + /// I2C Function alias for pin [crate::Pins::gpio17]. + FunctionI2C: Gp17I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio17]. + FunctionPwm: Gp17Pwm0B, + /// PIO0 Function alias for pin [crate::Pins::gpio17]. + FunctionPio0: Gp17Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio17]. + FunctionPio1: Gp17Pio1 + } + }, + + /// GPIO 18 supports following functions: + /// | Default | General Digital pin D6 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 SCK` | [crate::Gp18Spi0Sck] | + /// | `UART0 CTS` | [crate::Gp18Uart0Cts] | + /// | `I2C1 SDA` | [crate::Gp18I2C1Sda] | + /// | `PWM1 A` | [crate::Gp18Pwm1A] | + /// | `PIO0` | [crate::Gp18Pio0] | + /// | `PIO1` | [crate::Gp18Pio1] | + Gpio18 { + name: d6, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio18]. + FunctionUart: Gp18Uart0Cts, + /// SPI Function alias for pin [crate::Pins::gpio18]. + FunctionSpi: Gp18Spi0Sck, + /// I2C Function alias for pin [crate::Pins::gpio18]. + FunctionI2C: Gp18I2C1Sda, + /// PWM Function alias for pin [crate::Pins::gpio18]. + FunctionPwm: Gp18Pwm1A, + /// PIO0 Function alias for pin [crate::Pins::gpio18]. + FunctionPio0: Gp18Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio18]. + FunctionPio1: Gp18Pio1 + } + }, + + /// GPIO 19 supports following functions: + /// | Default | General Digital Pin D7 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 TX` | [crate::Gp19Spi0Tx] | + /// | `UART0 RTS` | [crate::Gp19Uart0Rts] | + /// | `I2C1 SCL` | [crate::Gp19I2C1Scl] | + /// | `PWM1 B` | [crate::Gp19Pwm1B] | + /// | `PIO0` | [crate::Gp19Pio0] | + /// | `PIO1` | [crate::Gp19Pio1] | + Gpio19 { + name: d7, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio19]. + FunctionUart: Gp19Uart0Rts, + /// SPI Function alias for pin [crate::Pins::gpio19]. + FunctionSpi: Gp19Spi0Tx, + /// I2C Function alias for pin [crate::Pins::gpio19]. + FunctionI2C: Gp19I2C1Scl, + /// PWM Function alias for pin [crate::Pins::gpio19]. + FunctionPwm: Gp19Pwm1B, + /// PIO0 Function alias for pin [crate::Pins::gpio19]. + FunctionPio0: Gp19Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio19]. + FunctionPio1: Gp19Pio1 + } + }, + + /// GPIO 20 supports following functions: + /// | Default | General Digital pin D8 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 RX` | [crate::Gp20Spi0Rx] | + /// | `UART1 TX` | [crate::Gp20Uart1Tx] | + /// | `I2C0 SDA` | [crate::Gp20I2C0Sda] | + /// | `PWM2 A` | [crate::Gp20Pwm2A] | + /// | `PIO0` | [crate::Gp20Pio0] | + /// | `PIO1` | [crate::Gp20Pio1] | + Gpio20 { + name: d8, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio20]. + FunctionUart: Gp20Uart1Tx, + /// SPI Function alias for pin [crate::Pins::gpio20]. + FunctionSpi: Gp20Spi0Rx, + /// I2C Function alias for pin [crate::Pins::gpio20]. + FunctionI2C: Gp20I2C0Sda, + /// PWM Function alias for pin [crate::Pins::gpio20]. + FunctionPwm: Gp20Pwm2A, + /// PIO0 Function alias for pin [crate::Pins::gpio20]. + FunctionPio0: Gp20Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio20]. + FunctionPio1: Gp20Pio1 + } + }, + + /// GPIO 21 supports following functions: + /// | Default | General Digital pin D9 + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 CSn` | [crate::Gp21Spi0Csn] | + /// | `UART1 RX` | [crate::Gp21Uart1Rx] | + /// | `I2C0 SCL` | [crate::Gp21I2C0Scl] | + /// | `PWM2 B` | [crate::Gp21Pwm2B] | + /// | `PIO0` | [crate::Gp21Pio0] | + /// | `PIO1` | [crate::Gp21Pio1] | + Gpio21 { + name: d9, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio21]. + FunctionUart: Gp21Uart1Rx, + /// SPI Function alias for pin [crate::Pins::gpio21]. + FunctionSpi: Gp21Spi0Csn, + /// I2C Function alias for pin [crate::Pins::gpio21]. + FunctionI2C: Gp21I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio21]. + FunctionPwm: Gp21Pwm2B, + /// PIO0 Function alias for pin [crate::Pins::gpio21]. + FunctionPio0: Gp21Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio21]. + FunctionPio1: Gp21Pio1 + } + }, + + /// GPIO 22 supports following functions: + /// | Default | PDMDIN + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 SCK` | [crate::Gp22Spi0Sck] | + /// | `UART1 CTS` | [crate::Gp22Uart1Cts] | + /// | `I2C1 SDA` | [crate::Gp22I2C1Sda] | + /// | `PWM3 A` | [crate::Gp22Pwm3A] | + /// | `PIO0` | [crate::Gp22Pio0] | + /// | `PIO1` | [crate::Gp22Pio1] | + Gpio22 { + // this connects to the microphone module + name: pdmdin + }, + + /// GPIO 23 supports following functions: + /// | Default | PDMCLK + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI0 TX` | [crate::Gp23Spi0Tx] | + /// | `UART1 RTS` | [crate::Gp23Uart1Rts] | + /// | `I2C1 SCL` | [crate::Gp23I2C1Scl] | + /// | `PWM3 B` | [crate::Gp23Pwm3B] | + /// | `PIO0` | [crate::Gp23Pio0] | + /// | `PIO1` | [crate::Gp23Pio1] | + Gpio23 { + name: pdmclk + }, + + /// GPIO 24 supports following functions: + /// | Default | INT1 ~ connected to INT1 on the IMU + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 RX` | [crate::Gp24Spi1Rx] | + /// | `UART1 TX` | [crate::Gp24Uart1Tx] | + /// | `I2C0 SDA` | [crate::Gp24I2C0Sda] | + /// | `PWM4 A` | [crate::Gp24Pwm4A] | + /// | `PIO0` | [crate::Gp24Pio0] | + /// | `PIO1` | [crate::Gp24Pio1] | + Gpio24 { + name: int1 + }, + + /// GPIO 25 supports following functions: + /// | Default | + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 CSn` | [crate::Gp25Spi1Csn] | + /// | `UART1 RX` | [crate::Gp25Uart1Rx] | + /// | `I2C0 SCL` | [crate::Gp25I2C0Scl] | + /// | `PWM4 B` | [crate::Gp25Pwm4B] | + /// | `PIO0` | [crate::Gp25Pio0] | + /// | `PIO1` | [crate::Gp25Pio1] | + Gpio25 { + name: d2, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio25]. + FunctionUart: Gp25Uart1Rx, + /// SPI Function alias for pin [crate::Pins::gpio25]. + FunctionSpi: Gp25Spi1Csn, + /// I2C Function alias for pin [crate::Pins::gpio25]. + FunctionI2C: Gp25I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio25]. + FunctionPwm: Gp25Pwm4B, + /// PIO0 Function alias for pin [crate::Pins::gpio25]. + FunctionPio0: Gp25Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio25]. + FunctionPio1: Gp25Pio1 + } + }, + + /// GPIO 26 supports following functions: + /// + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 SCK` | [crate::Gp26Spi1Sck] | + /// | `UART1 CTS` | [crate::Gp26Uart1Cts] | + /// | `I2C1 SDA` | [crate::Gp26I2C1Sda] | + /// | `PWM5 A` | [crate::Gp26Pwm5A] | + /// | `PIO0` | [crate::Gp26Pio0] | + /// | `PIO1` | [crate::Gp26Pio1] | + Gpio26 { + name: a0, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio26]. + FunctionUart: Gp26Uart1Cts, + /// SPI Function alias for pin [crate::Pins::gpio26]. + FunctionSpi: Gp26Spi1Sck, + /// I2C Function alias for pin [crate::Pins::gpio26]. + FunctionI2C: Gp26I2C1Sda, + /// PWM Function alias for pin [crate::Pins::gpio26]. + FunctionPwm: Gp26Pwm5A, + /// PIO0 Function alias for pin [crate::Pins::gpio26]. + FunctionPio0: Gp26Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio26]. + FunctionPio1: Gp26Pio1 + } + }, + + /// GPIO 27 supports following functions: + /// + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 TX` | [crate::Gp27Spi1Tx] | + /// | `UART1 RTS` | [crate::Gp27Uart1Rts] | + /// | `I2C1 SCL` | [crate::Gp27I2C1Scl] | + /// | `PWM5 B` | [crate::Gp27Pwm5B] | + /// | `PIO0` | [crate::Gp27Pio0] | + /// | `PIO1` | [crate::Gp27Pio1] | + Gpio27 { + name: a1, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio27]. + FunctionUart: Gp27Uart1Rts, + /// SPI Function alias for pin [crate::Pins::gpio27]. + FunctionSpi: Gp27Spi1Tx, + /// I2C Function alias for pin [crate::Pins::gpio27]. + FunctionI2C: Gp27I2C1Scl, + /// PWM Function alias for pin [crate::Pins::gpio27]. + FunctionPwm: Gp27Pwm5B, + /// PIO0 Function alias for pin [crate::Pins::gpio27]. + FunctionPio0: Gp27Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio27]. + FunctionPio1: Gp27Pio1 + } + }, + + /// GPIO 28 supports following functions: + /// + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 RX` | [crate::Gp28Spi1Rx] | + /// | `UART0 TX` | [crate::Gp28Uart0Tx] | + /// | `I2C0 SDA` | [crate::Gp28I2C0Sda] | + /// | `PWM6 A` | [crate::Gp28Pwm6A] | + /// | `PIO0` | [crate::Gp28Pio0] | + /// | `PIO1` | [crate::Gp28Pio1] | + Gpio28 { + name: a2, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio28]. + FunctionUart: Gp28Uart0Tx, + /// SPI Function alias for pin [crate::Pins::gpio28]. + FunctionSpi: Gp28Spi1Rx, + /// I2C Function alias for pin [crate::Pins::gpio28]. + FunctionI2C: Gp28I2C0Sda, + /// PWM Function alias for pin [crate::Pins::gpio28]. + FunctionPwm: Gp28Pwm6A, + /// PIO0 Function alias for pin [crate::Pins::gpio28]. + FunctionPio0: Gp28Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio28]. + FunctionPio1: Gp28Pio1 + } + }, + + /// GPIO 29 supports following functions: + /// + /// | Function | Alias with applied function | + /// |--------------|-----------------------------| + /// | `SPI1 CS` | [crate::Gp29Spi1CSn] | + /// | `UART0 RX` | [crate::Gp29Uart0Rx] | + /// | `I2C0 SCL` | [crate::Gp29I2C0Scl] | + /// | `PWM6 B` | [crate::Gp29Pwm6B] | + /// | `PIO0` | [crate::Gp29Pio0] | + /// | `PIO1` | [crate::Gp29Pio1] | + Gpio29 { + name: a3, + aliases: { + /// UART Function alias for pin [crate::Pins::gpio28]. + FunctionUart: Gp29Uart0Rx, + /// SPI Function alias for pin [crate::Pins::gpio28]. + FunctionSpi: Gp29Spi1CSn, + /// I2C Function alias for pin [crate::Pins::gpio28]. + FunctionI2C: Gp29I2C0Scl, + /// PWM Function alias for pin [crate::Pins::gpio28]. + FunctionPwm: Gp29Pwm6B, + /// PIO0 Function alias for pin [crate::Pins::gpio28]. + FunctionPio0: Gp29Pio0, + /// PIO1 Function alias for pin [crate::Pins::gpio28]. + FunctionPio1: Gp29Pio1 + } + }, +); + +pub const XOSC_CRYSTAL_FREQ: u32 = 12_000_000;