Add the Pimoroni Servo 2040 board (#450)

* Add the Pimoroni Servo 2040 board

This PR adds the board support package and two simple examples.
* Animates a rainbow wheel across the RGB LEDs on the board.
* Moves a servo that's connected to GPIO0 back and forth.

* Format pimoroni-servo2040 board files

* Use us_to_duty function in servo example, clean up comments.

* Fix bad types

* Add Servo2040 description to top-level readme
This commit is contained in:
Paul Daniel Faria 2022-09-17 07:04:16 -04:00 committed by GitHub
parent cbed25944a
commit 19e2fbea1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1159 additions and 0 deletions

View file

@ -14,6 +14,7 @@ members = [
"boards/pimoroni-pico-explorer", "boards/pimoroni-pico-explorer",
"boards/pimoroni-pico-lipo-16mb", "boards/pimoroni-pico-lipo-16mb",
"boards/pimoroni-plasma-2040", "boards/pimoroni-plasma-2040",
"boards/pimoroni-servo2040",
"boards/pimoroni-tiny2040", "boards/pimoroni-tiny2040",
"boards/rp-pico", "boards/rp-pico",
"boards/seeeduino-xiao-rp2040", "boards/seeeduino-xiao-rp2040",

View file

@ -243,6 +243,18 @@ RP2040 chip according to how it is connected up on the Pimoroni Plasma 2040.
[Pimoroni Plasma 2040]: https://shop.pimoroni.com/products/plasma-2040 [Pimoroni Plasma 2040]: https://shop.pimoroni.com/products/plasma-2040
[pimoroni-plasma-2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pimoroni-plasma-2040 [pimoroni-plasma-2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pimoroni-plasma-2040
### [pimoroni-servo2040] - Board Support for the [Pimoroni Servo2040]
You should include this crate if you are writing code that you want to run on
a [Pimoroni Servo2040] - a standalone servo motor controller for up to 18 servos
and 6 sensors.
This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Servo2040.
[Pimoroni Servo2040]: https://shop.pimoroni.com/products/servo-2040
[pimoroni-servo2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pimoroni-servo2040
### [pimoroni-tiny2040] - Board Support for the [Pimoroni Tiny2040] ### [pimoroni-tiny2040] - Board Support for the [Pimoroni Tiny2040]
You should include this crate if you are writing code that you want to run on You should include this crate if you are writing code that you want to run on

11
boards/pimoroni-servo2040/.gitignore vendored Normal file
View file

@ -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

View file

@ -0,0 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
## 0.1.0 - 2022-09-06
### Changed

View file

@ -0,0 +1,34 @@
[package]
name = "pimoroni-servo2040"
version = "0.1.0"
authors = ["Paul Daniel Faria <nashenas88@gmail.com>", "The rp-rs Developers"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/pimoroni-servo2040"
description = "Board Support Package for the Pimoroni Servo2040"
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.2"
rp2040-boot2 = { version = "0.2.0", optional = true }
rp2040-hal = { path = "../../rp2040-hal", version = "0.6.0" }
cortex-m-rt = { version = "0.7", optional = true }
[dev-dependencies]
rp2040-hal = { path = "../../rp2040-hal", version = "0.6.0", features = [ "defmt" ] }
panic-halt= "0.2.0"
defmt = "0.3.0"
defmt-rtt = "0.3.0"
embedded-hal ="0.2.5"
fugit = "0.3.5"
nb = "1.0.0"
smart-leds = "0.3.0"
ws2812-pio = "0.4.0"
[features]
default = ["boot2", "rt", "critical-section-impl"]
critical-section-impl = ["rp2040-hal/critical-section-impl"]
boot2 = ["rp2040-boot2"]
rt = ["cortex-m-rt","rp2040-hal/rt"]

View file

@ -0,0 +1,96 @@
# [pimoroni-servo2040] - Board Support for the [Pimoroni Servo2040]
You should include this crate if you are writing code that you want to run on
a [Pimoroni Servo2040] - a standalone servo motor controller for up to 18 servos
and 6 sensors.
This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Servo2040.
[Pimoroni Servo2040]: https://shop.pimoroni.com/products/servo-2040
[pimoroni-servo2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pimoroni-servo2040
[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
pimoroni-servo2040 = "0.1.0"
```
In your program, you will need to call `pimoroni_servo2040::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
### General Instructions
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/pimoroni-servo2040 $ cargo build --release --example <name>
```
You will get an ELF file called
`./target/thumbv6m-none-eabi/release/examples/<name>`, 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/pimoroni-servo2040 $ cargo run --release --example <name>
```
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.
### [pimorono_servo2040_rainbow](./examples/pimorono_servo2040_rainbow.rs)
Animates a rainbow wheel on the Servo2040's six on-board LEDs in sequence.
## 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 choose 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.

View file

@ -0,0 +1,6 @@
//! This build script makes sure the linker flag -Tdefmt.x is added
//! for the examples.
fn main() {
println!("cargo:rustc-link-arg-examples=-Tdefmt.x");
}

View file

@ -0,0 +1,115 @@
//! # Pimoroni Servo2040 PWM Micro Servo Example
//!
//! Moves the micro servo on a Servo2040 board using the PWM peripheral.
//!
//! This will move in different positions the motor attached to GP0.
#![no_std]
#![no_main]
// GPIO traits
use embedded_hal::timer::CountDown;
use embedded_hal::PwmPin;
// Traits for converting integers to amounts of time
use fugit::ExtU64;
// Ensure we halt the program on panic (if we don't mention this crate it won't
// be linked)
use panic_halt as _;
// A shorter alias for the Peripheral Access Crate, which provides low-level
// register access
use pimoroni_servo2040::hal::pac;
// A shorter alias for the Hardware Abstraction Layer, which provides
// higher-level drivers.
use pimoroni_servo2040::hal;
/// Number of microseconds for the pwm signal period.
const PERIOD_US: u32 = 20_000;
/// Max resolution for the pwm signal.
const TOP: u16 = u16::MAX;
#[pimoroni_servo2040::entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
let sio = hal::Sio::new(pac.SIO);
let _clocks = hal::clocks::init_clocks_and_plls(
pimoroni_servo2040::XOSC_CRYSTAL_FREQ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
// Configure the Timer peripheral in count-down mode
let timer = hal::Timer::new(pac.TIMER, &mut pac.RESETS);
let mut count_down = timer.count_down();
let pins = pimoroni_servo2040::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let pwm_slices = hal::pwm::Slices::new(pac.PWM, &mut pac.RESETS);
const MIN_PULSE: u16 = 1000;
const MID_PULSE: u16 = 1500;
const MAX_PULSE: u16 = 2000;
let mut pwm: hal::pwm::Slice<_, _> = pwm_slices.pwm0;
pwm.set_ph_correct();
// 50Hz
pwm.set_div_int(38);
pwm.set_div_frac(3);
pwm.set_top(TOP);
pwm.enable();
// Output channel A on PWM0 to the GPIO0/servo1 pin
let mut channel_a = pwm.channel_a;
let _channel_a_pin = channel_a.output_to(pins.servo1);
let movement_delay = 400.millis();
// Infinite loop, moving micro servo from one position to another.
// You may need to adjust the pulse width since several servos from
// different manufacturers respond differently.
loop {
// move to 0°
channel_a.set_duty(us_to_duty(MID_PULSE));
count_down.start(movement_delay);
let _ = nb::block!(count_down.wait());
// 0° to 90°
channel_a.set_duty(us_to_duty(MAX_PULSE));
count_down.start(movement_delay);
let _ = nb::block!(count_down.wait());
// 90° to 0°
channel_a.set_duty(us_to_duty(MID_PULSE));
count_down.start(movement_delay);
let _ = nb::block!(count_down.wait());
// 0° to -90°
channel_a.set_duty(us_to_duty(MIN_PULSE));
count_down.start(movement_delay);
let _ = nb::block!(count_down.wait());
}
}
/// Convert microseconds to duty value.
///
/// This function uses the constants TOP and PERIOD_US defined at the top of the file.
fn us_to_duty(us: u16) -> u16 {
// Do math in u32 so we maintain higher precision. If we do math in u16, we need to divide first
// and lose some precision when truncating the remainder.
(TOP as u32 * us as u32 / PERIOD_US) as u16
}

View file

@ -0,0 +1,107 @@
//! Animates a rainbow wheel on the 6 color LEDs on a Servo2040 in sequence
#![no_std]
#![no_main]
use bsp::entry;
use bsp::hal::{
clocks::{init_clocks_and_plls, Clock},
pac,
sio::Sio,
watchdog::Watchdog,
};
use defmt::*;
use defmt_rtt as _;
use embedded_hal::timer::CountDown;
use fugit::ExtU32;
use panic_halt as _;
use pimoroni_servo2040 as bsp;
use rp2040_hal::pio::PIOExt;
use rp2040_hal::Timer;
use smart_leds::{brightness, SmartLedsWrite, RGB8};
use ws2812_pio::Ws2812;
#[entry]
fn main() -> ! {
info!("Program start");
let mut pac = pac::Peripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let sio = Sio::new(pac.SIO);
let 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();
let pins = bsp::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let timer = Timer::new(pac.TIMER, &mut pac.RESETS);
let mut delay = timer.count_down();
// Configure the addressable LED
let (mut pio, sm0, _, _, _) = pac.PIO0.split(&mut pac.RESETS);
let mut ws = Ws2812::new(
pins.led_data.into_mode(),
&mut pio,
sm0,
clocks.peripheral_clock.freq(),
timer.count_down(),
);
// Infinite color wheel loop
let mut n: u8 = 128;
let offset = (256u16 / bsp::NUM_LEDS as u16) as u8;
loop {
ws.write(brightness(
IntoIterator::into_iter([
wheel(n),
wheel(n.wrapping_add(offset)),
wheel(n.wrapping_add(offset * 2)),
wheel(n.wrapping_add(offset * 3)),
wheel(n.wrapping_add(offset * 4)),
wheel(n.wrapping_add(offset * 5)),
]),
32,
))
.unwrap();
n = n.wrapping_add(1);
delay.start(25.millis());
let _ = nb::block!(delay.wait());
}
}
/// Convert a number from `0..=255` to an RGB color triplet.
///
/// The colours are a transition from red, to green, to blue and back to red.
fn wheel(mut wheel_pos: u8) -> RGB8 {
wheel_pos = 255 - wheel_pos;
if wheel_pos < 85 {
// No green in this sector - red and blue only
(255 - (wheel_pos * 3), 0, wheel_pos * 3).into()
} else if wheel_pos < 170 {
// No red in this sector - green and blue only
wheel_pos -= 85;
(0, wheel_pos * 3, 255 - (wheel_pos * 3)).into()
} else {
// No blue in this sector - red and green only
wheel_pos -= 170;
(wheel_pos * 3, 255 - (wheel_pos * 3), 0).into()
}
}
// End of file

View file

@ -0,0 +1,765 @@
#![no_std]
pub extern crate rp2040_hal as hal;
#[cfg(feature = "rt")]
extern crate cortex_m_rt;
#[cfg(feature = "rt")]
pub use hal::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_W25Q080;
pub const NUM_SERVOS: u8 = 18;
pub const NUM_SENSORS: u8 = 6;
pub const NUM_LEDS: u8 = 6;
pub const SENSOR_1_ADDR: u8 = 0b_0000;
pub const SENSOR_2_ADDR: u8 = 0b_0001;
pub const SENSOR_3_ADDR: u8 = 0b_0010;
pub const SENSOR_4_ADDR: u8 = 0b_0011;
pub const SENSOR_5_ADDR: u8 = 0b_0100;
pub const SENSOR_6_ADDR: u8 = 0b_0101;
pub const VOLTAGE_SENSE_ADDR: u8 = 0b_0110;
pub const CURRENT_SENSE_ADDR: u8 = 0b_0111;
pub const VOLTAGE_GAIN: f32 = 0.28058;
pub const SHUNT_RESISTOR: f32 = 0.003;
pub const CURRENT_GAIN: u8 = 69;
pub const CURRENT_OFFSET: f32 = -0.02;
pub use hal::pac;
hal::bsp_pins!(
/// GPIO 0 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 RX` | [crate::Servo1Spi0Rx] |
/// | `UART0 TX` | [crate::Servo1Uart0Tx] |
/// | `I2C0 SDA` | [crate::Servo1I2C0Sda] |
/// | `PWM0 A` | [crate::Servo1Pwm0A] |
/// | `PIO0` | [crate::Servo1Pio0] |
/// | `PIO1` | [crate::Servo1Pio1] |
Gpio0 {
name: servo1,
aliases: {
/// UART Function alias for pin [crate::Pins::servo1].
FunctionUart: Servo1Uart0Tx,
/// SPI Function alias for pin [crate::Pins::servo1].
FunctionSpi: Servo1Spi0Rx,
/// I2C Function alias for pin [crate::Pins::servo1].
FunctionI2C: Servo1I2C0Sda,
/// PWM Function alias for pin [crate::Pins::servo1].
FunctionPwm: Servo1Pwm0A,
/// PIO0 Function alias for pin [crate::Pins::servo1].
FunctionPio0: Servo1Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo1].
FunctionPio1: Servo1Pio1
}
},
/// GPIO 1 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 CSn` | [crate::Servo2Spi0Csn] |
/// | `UART0 RX` | [crate::Servo2Uart0Rx] |
/// | `I2C0 SCL` | [crate::Servo2I2C0Scl] |
/// | `PWM0 B` | [crate::Servo2Pwm0B] |
/// | `PIO0` | [crate::Servo2Pio0] |
/// | `PIO1` | [crate::Servo2Pio1] |
Gpio1 {
name: servo2,
aliases: {
/// UART Function alias for pin [crate::Pins::servo2].
FunctionUart: Servo2Uart0Rx,
/// SPI Function alias for pin [crate::Pins::servo2].
FunctionSpi: Servo2Spi0Csn,
/// I2C Function alias for pin [crate::Pins::servo2].
FunctionI2C: Servo2I2C0Scl,
/// PWM Function alias for pin [crate::Pins::servo2].
FunctionPwm: Servo2Pwm0B,
/// PIO0 Function alias for pin [crate::Pins::servo2].
FunctionPio0: Servo2Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo2].
FunctionPio1: Servo2Pio1
}
},
/// GPIO 2 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 SCK` | [crate::Servo3Spi0Sck] |
/// | `UART0 CTS` | [crate::Servo3Uart0Cts] |
/// | `I2C1 SDA` | [crate::Servo3I2C1Sda] |
/// | `PWM1 A` | [crate::Servo3Pwm1A] |
/// | `PIO0` | [crate::Servo3Pio0] |
/// | `PIO1` | [crate::Servo3Pio1] |
Gpio2 {
name: servo3,
aliases: {
/// UART Function alias for pin [crate::Pins::servo3].
FunctionUart: Servo3Uart0Cts,
/// SPI Function alias for pin [crate::Pins::servo3].
FunctionSpi: Servo3Spi0Sck,
/// I2C Function alias for pin [crate::Pins::servo3].
FunctionI2C: Servo3I2C1Sda,
/// PWM Function alias for pin [crate::Pins::servo3].
FunctionPwm: Servo3Pwm1A,
/// PIO0 Function alias for pin [crate::Pins::servo3].
FunctionPio0: Servo3Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo3].
FunctionPio1: Servo3Pio1
}
},
/// GPIO 3 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 TX` | [crate::Servo4Spi0Tx] |
/// | `UART0 RTS` | [crate::Servo4Uart0Rts] |
/// | `I2C1 SCL` | [crate::Servo4I2C1Scl] |
/// | `PWM1 B` | [crate::Servo4Pwm1B] |
/// | `PIO0` | [crate::Servo4Pio0] |
/// | `PIO1` | [crate::Servo4Pio1] |
Gpio3 {
name: servo4,
aliases: {
/// UART Function alias for pin [crate::Pins::servo4].
FunctionUart: Servo4Uart0Rts,
/// SPI Function alias for pin [crate::Pins::servo4].
FunctionSpi: Servo4Spi0Tx,
/// I2C Function alias for pin [crate::Pins::servo4].
FunctionI2C: Servo4I2C1Scl,
/// PWM Function alias for pin [crate::Pins::servo4].
FunctionPwm: Servo4Pwm1B,
/// PIO0 Function alias for pin [crate::Pins::servo4].
FunctionPio0: Servo4Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo4].
FunctionPio1: Servo4Pio1
}
},
/// GPIO 4 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 RX` | [crate::Servo5Spi0Rx] |
/// | `UART1 TX` | [crate::Servo5Uart1Tx] |
/// | `I2C0 SDA` | [crate::Servo5I2C0Sda] |
/// | `PWM2 A` | [crate::Servo5Pwm2A] |
/// | `PIO0` | [crate::Servo5Pio0] |
/// | `PIO1` | [crate::Servo5Pio1] |
Gpio4 {
name: servo5,
aliases: {
/// UART Function alias for pin [crate::Pins::servo5].
FunctionUart: Servo5Uart1Tx,
/// SPI Function alias for pin [crate::Pins::servo5].
FunctionSpi: Servo5Spi0Rx,
/// I2C Function alias for pin [crate::Pins::servo5].
FunctionI2C: Servo5I2C0Sda,
/// PWM Function alias for pin [crate::Pins::servo5].
FunctionPwm: Servo5Pwm2A,
/// PIO0 Function alias for pin [crate::Pins::servo5].
FunctionPio0: Servo5Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo5].
FunctionPio1: Servo5Pio1
}
},
/// GPIO 5 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 CSn` | [crate::Servo6Spi0Csn] |
/// | `UART1 RX` | [crate::Servo6Uart1Rx] |
/// | `I2C0 SCL` | [crate::Servo6I2C0Scl] |
/// | `PWM2 B` | [crate::Servo6Pwm2B] |
/// | `PIO0` | [crate::Servo6Pio0] |
/// | `PIO1` | [crate::Servo6Pio1] |
Gpio5 {
name: servo6,
aliases: {
/// UART Function alias for pin [crate::Pins::servo6].
FunctionUart: Servo6Uart1Rx,
/// SPI Function alias for pin [crate::Pins::servo6].
FunctionSpi: Servo6Spi0Csn,
/// I2C Function alias for pin [crate::Pins::servo6].
FunctionI2C: Servo6I2C0Scl,
/// PWM Function alias for pin [crate::Pins::servo6].
FunctionPwm: Servo6Pwm2B,
/// PIO0 Function alias for pin [crate::Pins::servo6].
FunctionPio0: Servo6Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo6].
FunctionPio1: Servo6Pio1
}
},
/// GPIO 6 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 SCK` | [crate::Servo7Spi0Sck] |
/// | `UART1 CTS` | [crate::Servo7Uart1Cts] |
/// | `I2C1 SDA` | [crate::Servo7I2C1Sda] |
/// | `PWM3 A` | [crate::Servo7Pwm3A] |
/// | `PIO0` | [crate::Servo7Pio0] |
/// | `PIO1` | [crate::Servo7Pio1] |
Gpio6 {
name: servo7,
aliases: {
/// UART Function alias for pin [crate::Pins::servo7].
FunctionUart: Servo7Uart1Cts,
/// SPI Function alias for pin [crate::Pins::servo7].
FunctionSpi: Servo7Spi0Sck,
/// I2C Function alias for pin [crate::Pins::servo7].
FunctionI2C: Servo7I2C1Sda,
/// PWM Function alias for pin [crate::Pins::servo7].
FunctionPwm: Servo7Pwm3A,
/// PIO0 Function alias for pin [crate::Pins::servo7].
FunctionPio0: Servo7Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo7].
FunctionPio1: Servo7Pio1
}
},
/// GPIO 7 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 TX` | [crate::Servo8Spi0Tx] |
/// | `UART1 RTS` | [crate::Servo8Uart1Rts] |
/// | `I2C1 SCL` | [crate::Servo8I2C1Scl] |
/// | `PWM3 B` | [crate::Servo8Pwm3B] |
/// | `PIO0` | [crate::Servo8Pio0] |
/// | `PIO1` | [crate::Servo8Pio1] |
Gpio7 {
name: servo8,
aliases: {
/// UART Function alias for pin [crate::Pins::servo8].
FunctionUart: Servo8Uart1Rts,
/// SPI Function alias for pin [crate::Pins::servo8].
FunctionSpi: Servo8Spi0Tx,
/// I2C Function alias for pin [crate::Pins::servo8].
FunctionI2C: Servo8I2C1Scl,
/// PWM Function alias for pin [crate::Pins::servo8].
FunctionPwm: Servo8Pwm3B,
/// PIO0 Function alias for pin [crate::Pins::servo8].
FunctionPio0: Servo8Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo8].
FunctionPio1: Servo8Pio1
}
},
/// GPIO 8 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 RX` | [crate::Servo9Spi1Rx] |
/// | `UART1 TX` | [crate::Servo9Uart1Tx] |
/// | `I2C0 SDA` | [crate::Servo9I2C0Sda] |
/// | `PWM4 A` | [crate::Servo9Pwm4A] |
/// | `PIO0` | [crate::Servo9Pio0] |
/// | `PIO1` | [crate::Servo9Pio1] |
Gpio8 {
name: servo9,
aliases: {
/// UART Function alias for pin [crate::Pins::servo9].
FunctionUart: Servo9Uart1Tx,
/// SPI Function alias for pin [crate::Pins::servo9].
FunctionSpi: Servo9Spi1Rx,
/// I2C Function alias for pin [crate::Pins::servo9].
FunctionI2C: Servo9I2C0Sda,
/// PWM Function alias for pin [crate::Pins::servo9].
FunctionPwm: Servo9Pwm4A,
/// PIO0 Function alias for pin [crate::Pins::servo9].
FunctionPio0: Servo9Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo9].
FunctionPio1: Servo9Pio1
}
},
/// GPIO 9 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 CSn` | [crate::Servo10Spi1Csn] |
/// | `UART1 RX` | [crate::Servo10Uart1Rx] |
/// | `I2C0 SCL` | [crate::Servo10I2C0Scl] |
/// | `PWM4 B` | [crate::Servo10Pwm4B] |
/// | `PIO0` | [crate::Servo10Pio0] |
/// | `PIO1` | [crate::Servo10Pio1] |
Gpio9 {
name: servo10,
aliases: {
/// UART Function alias for pin [crate::Pins::servo10].
FunctionUart: Servo10Uart1Rx,
/// SPI Function alias for pin [crate::Pins::servo10].
FunctionSpi: Servo10Spi1Csn,
/// I2C Function alias for pin [crate::Pins::servo10].
FunctionI2C: Servo10I2C0Scl,
/// PWM Function alias for pin [crate::Pins::servo10].
FunctionPwm: Servo10Pwm4B,
/// PIO0 Function alias for pin [crate::Pins::servo10].
FunctionPio0: Servo10Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo10].
FunctionPio1: Servo10Pio1
}
},
/// GPIO 10 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 SCK` | [crate::Servo11Spi1Sck] |
/// | `UART1 CTS` | [crate::Servo11Uart1Cts] |
/// | `I2C1 SDA` | [crate::Servo11I2C1Sda] |
/// | `PWM5 A` | [crate::Servo11Pwm5A] |
/// | `PIO0` | [crate::Servo11Pio0] |
/// | `PIO1` | [crate::Servo11Pio1] |
Gpio10 {
name: servo11,
aliases: {
/// UART Function alias for pin [crate::Pins::servo11].
FunctionUart: Servo11Uart1Cts,
/// SPI Function alias for pin [crate::Pins::servo11].
FunctionSpi: Servo11Spi1Sck,
/// I2C Function alias for pin [crate::Pins::servo11].
FunctionI2C: Servo11I2C1Sda,
/// PWM Function alias for pin [crate::Pins::servo11].
FunctionPwm: Servo11Pwm5A,
/// PIO0 Function alias for pin [crate::Pins::servo11].
FunctionPio0: Servo11Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo11].
FunctionPio1: Servo11Pio1
}
},
/// GPIO 11 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 TX` | [crate::Servo12Spi1Tx] |
/// | `UART1 RTS` | [crate::Servo12Uart1Rts] |
/// | `I2C1 SCL` | [crate::Servo12I2C1Scl] |
/// | `PWM5 B` | [crate::Servo12Pwm5B] |
/// | `PIO0` | [crate::Servo12Pio0] |
/// | `PIO1` | [crate::Servo12Pio1] |
Gpio11 {
name: servo12,
aliases: {
/// UART Function alias for pin [crate::Pins::servo12].
FunctionUart: Servo12Uart1Rts,
/// SPI Function alias for pin [crate::Pins::servo12].
FunctionSpi: Servo12Spi1Tx,
/// I2C Function alias for pin [crate::Pins::servo12].
FunctionI2C: Servo12I2C1Scl,
/// PWM Function alias for pin [crate::Pins::servo12].
FunctionPwm: Servo12Pwm5B,
/// PIO0 Function alias for pin [crate::Pins::servo12].
FunctionPio0: Servo12Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo12].
FunctionPio1: Servo12Pio1
}
},
/// GPIO 12 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 RX` | [crate::Servo13Spi1Rx] |
/// | `UART0 TX` | [crate::Servo13Uart0Tx] |
/// | `I2C0 SDA` | [crate::Servo13I2C0Sda] |
/// | `PWM6 A` | [crate::Servo13Pwm6A] |
/// | `PIO0` | [crate::Servo13Pio0] |
/// | `PIO1` | [crate::Servo13Pio1] |
Gpio12 {
name: servo13,
aliases: {
/// UART Function alias for pin [crate::Pins::servo13].
FunctionUart: Servo13Uart0Tx,
/// SPI Function alias for pin [crate::Pins::servo13].
FunctionSpi: Servo13Spi1Rx,
/// I2C Function alias for pin [crate::Pins::servo13].
FunctionI2C: Servo13I2C0Sda,
/// PWM Function alias for pin [crate::Pins::servo13].
FunctionPwm: Servo13Pwm6A,
/// PIO0 Function alias for pin [crate::Pins::servo13].
FunctionPio0: Servo13Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo13].
FunctionPio1: Servo13Pio1
}
},
/// GPIO 13 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 CSn` | [crate::Servo14Spi1Csn] |
/// | `UART0 RX` | [crate::Servo14Uart0Rx] |
/// | `I2C0 SCL` | [crate::Servo14I2C0Scl] |
/// | `PWM6 B` | [crate::Servo14Pwm6B] |
/// | `PIO0` | [crate::Servo14Pio0] |
/// | `PIO1` | [crate::Servo14Pio1] |
Gpio13 {
name: servo14,
aliases: {
/// UART Function alias for pin [crate::Pins::servo14].
FunctionUart: Servo14Uart0Rx,
/// SPI Function alias for pin [crate::Pins::servo14].
FunctionSpi: Servo14Spi1Csn,
/// I2C Function alias for pin [crate::Pins::servo14].
FunctionI2C: Servo14I2C0Scl,
/// PWM Function alias for pin [crate::Pins::servo14].
FunctionPwm: Servo14Pwm6B,
/// PIO0 Function alias for pin [crate::Pins::servo14].
FunctionPio0: Servo14Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo14].
FunctionPio1: Servo14Pio1
}
},
/// GPIO 14 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 SCK` | [crate::Servo15Spi1Sck] |
/// | `UART0 CTS` | [crate::Servo15Uart0Cts] |
/// | `I2C1 SDA` | [crate::Servo15I2C1Sda] |
/// | `PWM7 A` | [crate::Servo15Pwm7A] |
/// | `PIO0` | [crate::Servo15Pio0] |
/// | `PIO1` | [crate::Servo15Pio1] |
Gpio14 {
name: servo15,
aliases: {
/// UART Function alias for pin [crate::Pins::servo15].
FunctionUart: Servo15Uart0Cts,
/// SPI Function alias for pin [crate::Pins::servo15].
FunctionSpi: Servo15Spi1Sck,
/// I2C Function alias for pin [crate::Pins::servo15].
FunctionI2C: Servo15I2C1Sda,
/// PWM Function alias for pin [crate::Pins::servo15].
FunctionPwm: Servo15Pwm7A,
/// PIO0 Function alias for pin [crate::Pins::servo15].
FunctionPio0: Servo15Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo15].
FunctionPio1: Servo15Pio1
}
},
/// GPIO 15 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI1 TX` | [crate::Servo16Spi1Tx] |
/// | `UART0 RTS` | [crate::Servo16Uart0Rts] |
/// | `I2C1 SCL` | [crate::Servo16I2C1Scl] |
/// | `PWM7 B` | [crate::Servo16Pwm7B] |
/// | `PIO0` | [crate::Servo16Pio0] |
/// | `PIO1` | [crate::Servo16Pio1] |
Gpio15 {
name: servo16,
aliases: {
/// UART Function alias for pin [crate::Pins::servo16].
FunctionUart: Servo16Uart0Rts,
/// SPI Function alias for pin [crate::Pins::servo16].
FunctionSpi: Servo16Spi1Tx,
/// I2C Function alias for pin [crate::Pins::servo16].
FunctionI2C: Servo16I2C1Scl,
/// PWM Function alias for pin [crate::Pins::servo16].
FunctionPwm: Servo16Pwm7B,
/// PIO0 Function alias for pin [crate::Pins::servo16].
FunctionPio0: Servo16Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo16].
FunctionPio1: Servo16Pio1
}
},
/// GPIO 16 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 RX` | [crate::Servo17Spi0Rx] |
/// | `UART0 TX` | [crate::Servo17Uart0Tx] |
/// | `I2C0 SDA` | [crate::Servo17I2C0Sda] |
/// | `PWM0 A` | [crate::Servo17Pwm0A] |
/// | `PIO0` | [crate::Servo17Pio0] |
/// | `PIO1` | [crate::Servo17Pio1] |
Gpio16 {
name: servo17,
aliases: {
/// UART Function alias for pin [crate::Pins::servo17].
FunctionUart: Servo17Uart0Tx,
/// SPI Function alias for pin [crate::Pins::servo17].
FunctionSpi: Servo17Spi0Rx,
/// I2C Function alias for pin [crate::Pins::servo17].
FunctionI2C: Servo17I2C0Sda,
/// PWM Function alias for pin [crate::Pins::servo17].
FunctionPwm: Servo17Pwm0A,
/// PIO0 Function alias for pin [crate::Pins::servo17].
FunctionPio0: Servo17Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo17].
FunctionPio1: Servo17Pio1
}
},
/// GPIO 17 supports following functions:
///
/// | Function | Alias with applied function |
/// |--------------|-----------------------------|
/// | `SPI0 CSn` | [crate::Servo18Spi0Csn] |
/// | `UART0 RX` | [crate::Servo18Uart0Rx] |
/// | `I2C0 SCL` | [crate::Servo18I2C0Scl] |
/// | `PWM0 B` | [crate::Servo18Pwm0B] |
/// | `PIO0` | [crate::Servo18Pio0] |
/// | `PIO1` | [crate::Servo18Pio1] |
Gpio17 {
name: servo18,
aliases: {
/// UART Function alias for pin [crate::Pins::servo18].
FunctionUart: Servo18Uart0Rx,
/// SPI Function alias for pin [crate::Pins::servo18].
FunctionSpi: Servo18Spi0Csn,
/// I2C Function alias for pin [crate::Pins::servo18].
FunctionI2C: Servo18I2C0Scl,
/// PWM Function alias for pin [crate::Pins::servo18].
FunctionPwm: Servo18Pwm0B,
/// PIO0 Function alias for pin [crate::Pins::servo18].
FunctionPio0: Servo18Pio0,
/// PIO1 Function alias for pin [crate::Pins::servo18].
FunctionPio1: Servo18Pio1
}
},
/// GPIO 18 is connected to the leds of the Servo 2040 board.
Gpio18 {
name: led_data
},
/// GPIO 19 supports following functions:
///
/// | 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: int_,
aliases: {
/// UART Function alias for pin [crate::Pins::int_].
FunctionUart: Gp19Uart0Rts,
/// SPI Function alias for pin [crate::Pins::int_].
FunctionSpi: Gp19Spi0Tx,
/// I2C Function alias for pin [crate::Pins::int_].
FunctionI2C: Gp19I2C1Scl,
/// PWM Function alias for pin [crate::Pins::int_].
FunctionPwm: Gp19Pwm1B,
/// PIO0 Function alias for pin [crate::Pins::int_].
FunctionPio0: Gp19Pio0,
/// PIO1 Function alias for pin [crate::Pins::int_].
FunctionPio1: Gp19Pio1
}
},
/// GPIO 20 supports following functions:
///
/// | 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: sda,
aliases: {
/// UART Function alias for pin [crate::Pins::sda].
FunctionUart: Gp20Uart1Tx,
/// SPI Function alias for pin [crate::Pins::sda].
FunctionSpi: Gp20Spi0Rx,
/// I2C Function alias for pin [crate::Pins::sda].
FunctionI2C: Gp20I2C0Sda,
/// PWM Function alias for pin [crate::Pins::sda].
FunctionPwm: Gp20Pwm2A,
/// PIO0 Function alias for pin [crate::Pins::sda].
FunctionPio0: Gp20Pio0,
/// PIO1 Function alias for pin [crate::Pins::sda].
FunctionPio1: Gp20Pio1
}
},
/// GPIO 21 supports following functions:
///
/// | 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: scl,
aliases: {
/// UART Function alias for pin [crate::Pins::scl].
FunctionUart: Gp21Uart1Rx,
/// SPI Function alias for pin [crate::Pins::scl].
FunctionSpi: Gp21Spi0Csn,
/// I2C Function alias for pin [crate::Pins::scl].
FunctionI2C: Gp21I2C0Scl,
/// PWM Function alias for pin [crate::Pins::scl].
FunctionPwm: Gp21Pwm2B,
/// PIO0 Function alias for pin [crate::Pins::scl].
FunctionPio0: Gp21Pio0,
/// PIO1 Function alias for pin [crate::Pins::scl].
FunctionPio1: Gp21Pio1
}
},
/// GPIO 22 is connected to adc_addr_0 of the Servo 2040 board..
Gpio22 {
name: adc_addr_0,
},
/// GPIO 23 supports following functions:
///
/// | 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: user_sw,
aliases: {
/// UART Function alias for pin [crate::Pins::user_sw].
FunctionUart: Gp23Uart1Rts,
/// SPI Function alias for pin [crate::Pins::user_sw].
FunctionSpi: Gp23Spi0Tx,
/// I2C Function alias for pin [crate::Pins::user_sw].
FunctionI2C: Gp23I2C1Scl,
/// PWM Function alias for pin [crate::Pins::user_sw].
FunctionPwm: Gp23Pwm3B,
/// PIO0 Function alias for pin [crate::Pins::user_sw].
FunctionPio0: Gp23Pio0,
/// PIO1 Function alias for pin [crate::Pins::user_sw].
FunctionPio1: Gp23Pio1
}
},
/// GPIO 24 is connected to adc_addr_1 of the Servo 2040 board.
Gpio24 {
name: adc_addr_1,
},
/// GPIO 25 is connected to adc_addr_2 of the Servo 2040 board.
Gpio25 {
name: adc_addr_2,
},
/// 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: adc0,
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: adc1,
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: adc2,
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 is connected to shared adc of the Servo2040 board.
Gpio29 {
name: shared_adc,
},
);
pub const XOSC_CRYSTAL_FREQ: u32 = 12_000_000;