mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-24 21:21:31 +11:00
Re-export mod structs
This commit is contained in:
parent
5dafe3985f
commit
55a8b4acf9
|
@ -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,
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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;
|
Loading…
Reference in a new issue