Re-export mod structs

This commit is contained in:
9names 2021-12-04 00:04:45 +11:00
parent 5dafe3985f
commit 55a8b4acf9
13 changed files with 33 additions and 24 deletions

View file

@ -11,7 +11,7 @@ use feather_rp2040::{
hal::{ hal::{
clocks::{init_clocks_and_plls, Clock}, clocks::{init_clocks_and_plls, Clock},
pac, pac,
sio::Sio, Sio,
watchdog::Watchdog, watchdog::Watchdog,
}, },
Pins, XOSC_CRYSTAL_FREQ, Pins, XOSC_CRYSTAL_FREQ,

View file

@ -26,7 +26,7 @@ use hal::pac;
// Some traits we need // Some traits we need
use embedded_hal::digital::v2::OutputPin; use embedded_hal::digital::v2::OutputPin;
use embedded_time::fixed_point::FixedPoint; use embedded_time::fixed_point::FixedPoint;
use rp2040_hal::clocks::Clock; use rp2040_hal::Clock;
/// The linker will place this boot block at the start of our program image. We /// 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. // need this to help the ROM bootloader get our code up and running.

View file

@ -24,7 +24,7 @@ use rp2040_hal as hal;
use core::fmt::Write; use core::fmt::Write;
use embedded_hal::adc::OneShot; use embedded_hal::adc::OneShot;
use embedded_time::fixed_point::FixedPoint; use embedded_time::fixed_point::FixedPoint;
use rp2040_hal::clocks::Clock; use rp2040_hal::Clock;
// A shorter alias for the Peripheral Access Crate, which provides low-level // A shorter alias for the Peripheral Access Crate, which provides low-level
// register access // register access
@ -54,7 +54,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -74,7 +74,7 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); 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 // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(
@ -101,7 +101,7 @@ fn main() -> ! {
uart.write_full_blocking(b"ADC example\r\n"); uart.write_full_blocking(b"ADC example\r\n");
// Enable ADC // Enable ADC
let mut adc = hal::adc::Adc::new(pac.ADC, &mut pac.RESETS); let mut adc = hal::Adc::new(pac.ADC, &mut pac.RESETS);
// Enable the temperature sense channel // Enable the temperature sense channel
let mut temperature_sensor = adc.enable_temp_sensor(); let mut temperature_sensor = adc.enable_temp_sensor();

View file

@ -52,7 +52,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -70,7 +70,7 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); 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 // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -50,7 +50,7 @@ fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap(); let mut pac = pac::Peripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let _clocks = hal::clocks::init_clocks_and_plls( let _clocks = hal::clocks::init_clocks_and_plls(
@ -66,7 +66,7 @@ fn main() -> ! {
.unwrap(); .unwrap();
// The single-cycle I/O block controls our GPIO pins // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -49,7 +49,7 @@ fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap(); let mut pac = pac::Peripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -83,7 +83,7 @@ fn main() -> ! {
// Create the I²C drive, using the two pre-configured pins. This will fail // Create the I²C drive, using the two pre-configured pins. This will fail
// at compile time if the pins are in the wrong mode, or if this I²C // at compile time if the pins are in the wrong mode, or if this I²C
// peripheral isn't available on these pins! // peripheral isn't available on these pins!
let mut i2c = hal::i2c::I2C::i2c1( let mut i2c = hal::I2C::i2c1(
pac.I2C1, pac.I2C1,
sda_pin, sda_pin,
scl_pin, // Try `not_an_scl_pin` here scl_pin, // Try `not_an_scl_pin` here

View file

@ -57,7 +57,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -77,7 +77,7 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); 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 // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -59,7 +59,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
// //
@ -77,7 +77,7 @@ fn main() -> ! {
.unwrap(); .unwrap();
// The single-cycle I/O block controls our GPIO pins // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins up according to their function on this particular board // Set the pins up according to their function on this particular board
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -54,7 +54,7 @@ fn main() -> ! {
let mut core = pac::CorePeripherals::take().unwrap(); let mut core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -70,7 +70,7 @@ fn main() -> ! {
.unwrap(); .unwrap();
// The single-cycle I/O block controls our GPIO pins // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -54,7 +54,7 @@ fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap(); let mut pac = pac::Peripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -70,7 +70,7 @@ fn main() -> ! {
.unwrap(); .unwrap();
// The single-cycle I/O block controls our GPIO pins // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(
@ -84,7 +84,7 @@ fn main() -> ! {
let _spi_sclk = pins.gpio6.into_mode::<hal::gpio::FunctionSpi>(); let _spi_sclk = pins.gpio6.into_mode::<hal::gpio::FunctionSpi>();
let _spi_mosi = pins.gpio7.into_mode::<hal::gpio::FunctionSpi>(); let _spi_mosi = pins.gpio7.into_mode::<hal::gpio::FunctionSpi>();
let _spi_miso = pins.gpio4.into_mode::<hal::gpio::FunctionSpi>(); let _spi_miso = pins.gpio4.into_mode::<hal::gpio::FunctionSpi>();
let spi = hal::spi::Spi::<_, _, 8>::new(pac.SPI0); let spi = hal::Spi::<_, _, 8>::new(pac.SPI0);
// Exchange the uninitialised SPI driver for an initialised one // Exchange the uninitialised SPI driver for an initialised one
let mut spi = spi.init( let mut spi = spi.init(

View file

@ -54,7 +54,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(
@ -72,7 +72,7 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); 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 // The single-cycle I/O block controls our GPIO pins
let sio = hal::sio::Sio::new(pac.SIO); let sio = hal::Sio::new(pac.SIO);
// Set the pins to their default state // Set the pins to their default state
let pins = hal::gpio::Pins::new( let pins = hal::gpio::Pins::new(

View file

@ -55,7 +55,7 @@ fn main() -> ! {
let core = pac::CorePeripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap();
// Set up the watchdog driver - needed by the clock setup code // Set up the watchdog driver - needed by the clock setup code
let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
// Configure the clocks // Configure the clocks
let clocks = hal::clocks::init_clocks_and_plls( let clocks = hal::clocks::init_clocks_and_plls(

View file

@ -40,3 +40,12 @@ pub mod uart;
pub mod usb; pub mod usb;
pub mod watchdog; pub mod watchdog;
pub mod xosc; pub mod xosc;
// Provide access to common datastructures to avoid repeating ourselves
pub use adc::Adc;
pub use clocks::Clock;
pub use i2c::I2C;
pub use sio::Sio;
pub use spi::Spi;
pub use timer::Timer;
pub use watchdog::Watchdog;