3 releases
0.1.2 | Oct 8, 2024 |
---|---|
0.1.1 | Oct 8, 2024 |
0.1.0 | Oct 8, 2024 |
#658 in Embedded development
394 downloads per month
12KB
201 lines
Variegated Board Cfg
Substantial credits go to James Munns for the toml-cfg crate, Adam Greig for the assign-resources crate, and Adin Ackerman for the procedural overhaul PR for assign-resources.
Example configuration
lib.rs
#[variegated_board_cfg::config_section("hid_bus")]
struct HidBus {
tx_pin: (),
rx_pin: impl embassy_rp::peripherals::Pin, // Forces a compile error if the type of rx_pin doesn't implement Pin
uart: (),
baud_rate: u32,
}
board-cfg.toml
[hid_bus]
tx_pin = "embassy_rp::peripherals::PIN_0"
rx_pin = "embassy_rp::peripherals::PIN_1"
uart = "embassy_rp::peripherals::UART0"
baud_rate = 115200
Expansion
type HidBusTxPin = embassy_rp::peripherals::PIN_0;
type HidBusRxPin = embassy_rp::peripherals::PIN_1;
type HidBusUart = embassy_rp::peripherals::UART0;
struct HidBus {
tx_pin: HidBusTxPin,
rx_pin: HidBusRxPin,
uart: HidBusUart,
baud_rate: u32,
}
impl HidBus where HidBusRxPin: embassy_rp::peripherals::Pin {
}
macro_rules! hid_bus {
($P : ident) => {
HidBus {
tx_pin: $P.PIN_0,
rx_pin: $P.PIN_1,
uart: $P.UART0,
baud_rate: 115200
}
};
}
Dependencies
~0.7–1.3MB
~29K SLoC