From 42e929d7e166c04dfae41cae07ff8e215cd6e0c0 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Sun, 21 Aug 2022 19:01:45 +0100 Subject: [PATCH] Use rp2040-hal in all example (possibly through their bsp) (#423) * Use rp2040-hal in all example (possibly through their bsp) Some of the examples were using the cortex_m_rt::entry method which misses the device specific spinlock re-initialisation. This commits makes the usage more consistent by using rp2040_hal exported macro as the only `entry` method used across examples. --- .gitignore | 1 + boards/adafruit-macropad/CHANGELOG.md | 2 +- .../examples/adafruit-macropad_blinky.rs | 7 +++++-- boards/arduino_nano_connect/CHANGELOG.md | 13 +++++++++++++ boards/arduino_nano_connect/examples/nano_blinky.rs | 9 +++------ boards/arduino_nano_connect/src/lib.rs | 4 +--- boards/pimoroni-badger2040/CHANGELOG.md | 7 ++++++- boards/pimoroni-badger2040/src/lib.rs | 7 +++---- boards/pimoroni-plasma-2040/CHANGELOG.md | 13 +++++++++++++ .../examples/pimoroni_plasma_2040_blinky.rs | 7 +++++-- .../examples/pimoroni_plasma_2040_ws2812_led.rs | 9 +++++---- boards/pimoroni-plasma-2040/src/lib.rs | 5 +---- boards/rp-pico/CHANGELOG.md | 2 +- boards/rp-pico/examples/pico_hd44780_display.rs | 9 +++++---- boards/rp-pico/examples/pico_pwm_servo.rs | 9 +++------ boards/sparkfun-thing-plus-rp2040/CHANGELOG.md | 2 +- .../examples/sparkfun_thing_plus_rainbow.rs | 5 ++--- boards/sparkfun-thing-plus-rp2040/src/lib.rs | 4 +--- rp2040-hal/CHANGELOG.md | 1 + rp2040-hal/examples/adc.rs | 9 +++------ rp2040-hal/examples/blinky.rs | 9 +++------ rp2040-hal/examples/dht11.rs | 9 +++------ rp2040-hal/examples/gpio_in_out.rs | 9 +++------ rp2040-hal/examples/gpio_irq_example.rs | 9 +++------ rp2040-hal/examples/i2c.rs | 9 +++------ rp2040-hal/examples/lcd_display.rs | 9 +++------ rp2040-hal/examples/multicore_fifo_blink.rs | 9 +++------ rp2040-hal/examples/multicore_polyblink.rs | 8 +++----- rp2040-hal/examples/pio_blink.rs | 9 +++++++-- rp2040-hal/examples/pio_proc_blink.rs | 7 +++++-- rp2040-hal/examples/pio_side_set.rs | 7 +++++-- rp2040-hal/examples/pio_synchronized.rs | 7 +++++-- rp2040-hal/examples/pwm_blink.rs | 9 +++------ rp2040-hal/examples/rom_funcs.rs | 9 +++------ rp2040-hal/examples/spi.rs | 9 +++------ rp2040-hal/examples/uart.rs | 9 +++------ rp2040-hal/examples/vector_table.rs | 9 +++------ rp2040-hal/examples/watchdog.rs | 9 +++------ 38 files changed, 138 insertions(+), 142 deletions(-) create mode 100644 boards/arduino_nano_connect/CHANGELOG.md create mode 100644 boards/pimoroni-plasma-2040/CHANGELOG.md diff --git a/.gitignore b/.gitignore index 1a5e3e1..ef0f5ea 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target Cargo.lock .vscode +*.orig diff --git a/boards/adafruit-macropad/CHANGELOG.md b/boards/adafruit-macropad/CHANGELOG.md index 8fcc166..38e08a8 100644 --- a/boards/adafruit-macropad/CHANGELOG.md +++ b/boards/adafruit-macropad/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- None +- Use `rp2040-hal`'s entry function. ## 0.3.0 - 2022-06-13 diff --git a/boards/adafruit-macropad/examples/adafruit-macropad_blinky.rs b/boards/adafruit-macropad/examples/adafruit-macropad_blinky.rs index b0c345a..81ae77c 100644 --- a/boards/adafruit-macropad/examples/adafruit-macropad_blinky.rs +++ b/boards/adafruit-macropad/examples/adafruit-macropad_blinky.rs @@ -13,12 +13,15 @@ use adafruit_macropad::{ }, Pins, XOSC_CRYSTAL_FREQ, }; -use cortex_m_rt::entry; use embedded_hal::digital::v2::OutputPin; use embedded_time::rate::*; use panic_halt as _; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap(); diff --git a/boards/arduino_nano_connect/CHANGELOG.md b/boards/arduino_nano_connect/CHANGELOG.md new file mode 100644 index 0000000..2ef2c85 --- /dev/null +++ b/boards/arduino_nano_connect/CHANGELOG.md @@ -0,0 +1,13 @@ +# 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 + +### Changed + +- Use `rp2040-hal`'s entry function. + diff --git a/boards/arduino_nano_connect/examples/nano_blinky.rs b/boards/arduino_nano_connect/examples/nano_blinky.rs index 04c1dd3..82b24ad 100644 --- a/boards/arduino_nano_connect/examples/nano_blinky.rs +++ b/boards/arduino_nano_connect/examples/nano_blinky.rs @@ -10,9 +10,6 @@ #![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::*; @@ -36,12 +33,12 @@ 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 `#[arduino_nano_connect::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then blinks the LED in an /// infinite loop. -#[entry] +#[arduino_nano_connect::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/arduino_nano_connect/src/lib.rs b/boards/arduino_nano_connect/src/lib.rs index 2309e5a..2782c23 100644 --- a/boards/arduino_nano_connect/src/lib.rs +++ b/boards/arduino_nano_connect/src/lib.rs @@ -3,9 +3,7 @@ pub extern crate rp2040_hal as hal; #[cfg(feature = "rt")] -extern crate cortex_m_rt; -#[cfg(feature = "rt")] -pub use cortex_m_rt::entry; +pub use rp2040_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. diff --git a/boards/pimoroni-badger2040/CHANGELOG.md b/boards/pimoroni-badger2040/CHANGELOG.md index 11bddf3..2ef2c85 100644 --- a/boards/pimoroni-badger2040/CHANGELOG.md +++ b/boards/pimoroni-badger2040/CHANGELOG.md @@ -5,4 +5,9 @@ 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] +## Unreleased + +### Changed + +- Use `rp2040-hal`'s entry function. + diff --git a/boards/pimoroni-badger2040/src/lib.rs b/boards/pimoroni-badger2040/src/lib.rs index cbf0cc8..dc25254 100644 --- a/boards/pimoroni-badger2040/src/lib.rs +++ b/boards/pimoroni-badger2040/src/lib.rs @@ -2,12 +2,11 @@ pub extern crate rp2040_hal as hal; -#[cfg(feature = "rt")] -extern crate cortex_m_rt; -#[cfg(feature = "rt")] -pub use cortex_m_rt::entry; pub use hal::pac; +#[cfg(feature = "rt")] +pub use rp2040_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")] diff --git a/boards/pimoroni-plasma-2040/CHANGELOG.md b/boards/pimoroni-plasma-2040/CHANGELOG.md new file mode 100644 index 0000000..2ef2c85 --- /dev/null +++ b/boards/pimoroni-plasma-2040/CHANGELOG.md @@ -0,0 +1,13 @@ +# 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 + +### Changed + +- Use `rp2040-hal`'s entry function. + diff --git a/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_blinky.rs b/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_blinky.rs index 9082f76..086ff02 100644 --- a/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_blinky.rs +++ b/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_blinky.rs @@ -2,7 +2,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use defmt::*; use defmt_rtt as _; use embedded_hal::digital::v2::OutputPin; @@ -18,7 +17,11 @@ use bsp::hal::{ watchdog::Watchdog, }; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { info!("Program start"); let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_ws2812_led.rs b/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_ws2812_led.rs index fc63880..31d8ac9 100644 --- a/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_ws2812_led.rs +++ b/boards/pimoroni-plasma-2040/examples/pimoroni_plasma_2040_ws2812_led.rs @@ -6,9 +6,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -44,7 +41,11 @@ use ws2812_pio::Ws2812; // to keep the power draw compatible with USB: const STRIP_LEN: usize = 3; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[pimoroni_plasma_2040::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[pimoroni_plasma_2040::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/pimoroni-plasma-2040/src/lib.rs b/boards/pimoroni-plasma-2040/src/lib.rs index fa7c020..9bf2412 100644 --- a/boards/pimoroni-plasma-2040/src/lib.rs +++ b/boards/pimoroni-plasma-2040/src/lib.rs @@ -3,10 +3,7 @@ pub extern crate rp2040_hal as hal; #[cfg(feature = "rt")] -extern crate cortex_m_rt; - -#[cfg(feature = "rt")] -pub use cortex_m_rt::entry; +pub use rp2040_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. diff --git a/boards/rp-pico/CHANGELOG.md b/boards/rp-pico/CHANGELOG.md index d98d693..3c21e89 100644 --- a/boards/rp-pico/CHANGELOG.md +++ b/boards/rp-pico/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- None +- Use `rp2040-hal`'s entry function. ## 0.4.0 - 2022-06-13 diff --git a/boards/rp-pico/examples/pico_hd44780_display.rs b/boards/rp-pico/examples/pico_hd44780_display.rs index 5bad14e..e6a27c5 100644 --- a/boards/rp-pico/examples/pico_hd44780_display.rs +++ b/boards/rp-pico/examples/pico_hd44780_display.rs @@ -38,9 +38,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -57,7 +54,11 @@ use embedded_time::rate::*; // For LCD display use hd44780_driver::HD44780; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp_pico::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp_pico::entry] fn main() -> ! { // Grab our singleton objects let mut pac = rp_pico::hal::pac::Peripherals::take().unwrap(); diff --git a/boards/rp-pico/examples/pico_pwm_servo.rs b/boards/rp-pico/examples/pico_pwm_servo.rs index 21b4c61..4d89600 100644 --- a/boards/rp-pico/examples/pico_pwm_servo.rs +++ b/boards/rp-pico/examples/pico_pwm_servo.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - use cortex_m::prelude::*; // GPIO traits @@ -34,12 +31,12 @@ use rp_pico::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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then fades the LED in an /// infinite loop. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/sparkfun-thing-plus-rp2040/CHANGELOG.md b/boards/sparkfun-thing-plus-rp2040/CHANGELOG.md index c62d4b1..4e9282e 100644 --- a/boards/sparkfun-thing-plus-rp2040/CHANGELOG.md +++ b/boards/sparkfun-thing-plus-rp2040/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- None +- Use `rp2040-hal`'s entry function. ## 0.2.0 - 2022-06-13 diff --git a/boards/sparkfun-thing-plus-rp2040/examples/sparkfun_thing_plus_rainbow.rs b/boards/sparkfun-thing-plus-rp2040/examples/sparkfun_thing_plus_rainbow.rs index 033cca9..eb8ef20 100644 --- a/boards/sparkfun-thing-plus-rp2040/examples/sparkfun_thing_plus_rainbow.rs +++ b/boards/sparkfun-thing-plus-rp2040/examples/sparkfun_thing_plus_rainbow.rs @@ -9,7 +9,6 @@ #![no_main] use core::iter::once; -use cortex_m_rt::entry; use embedded_hal::timer::CountDown; use embedded_time::duration::Extensions; use panic_halt as _; @@ -30,12 +29,12 @@ use ws2812_pio::Ws2812; /// Entry point to our bare-metal application. /// -/// The `#[entry]` macro ensures the Cortex-M start-up code calls this +/// The `#[sparkfun_thing_plus_rp2040::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 the LED, then runs /// the colour wheel in an infinite loop. -#[entry] +#[sparkfun_thing_plus_rp2040::entry] fn main() -> ! { // Configure the RP2040 peripherals diff --git a/boards/sparkfun-thing-plus-rp2040/src/lib.rs b/boards/sparkfun-thing-plus-rp2040/src/lib.rs index aa04d00..cd8ae76 100644 --- a/boards/sparkfun-thing-plus-rp2040/src/lib.rs +++ b/boards/sparkfun-thing-plus-rp2040/src/lib.rs @@ -2,9 +2,7 @@ pub use rp2040_hal as hal; #[cfg(feature = "rt")] -extern crate cortex_m_rt; -#[cfg(feature = "rt")] -pub use cortex_m_rt::entry; +pub use rp2040_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. diff --git a/rp2040-hal/CHANGELOG.md b/rp2040-hal/CHANGELOG.md index 0e09b66..5035eeb 100644 --- a/rp2040-hal/CHANGELOG.md +++ b/rp2040-hal/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update embedded-hal alpha support to version 1.0.0-alpha.8 - Implement `From<&SomeClock> for Hertz` instead of `From for Hertz` for the clocks in `rp2040_hal::clocks`. +- Use `rp2040-hal`'s entry function. ## [0.5.0] - 2022-06-13 diff --git a/rp2040-hal/examples/adc.rs b/rp2040-hal/examples/adc.rs index 749d276..6440282 100644 --- a/rp2040-hal/examples/adc.rs +++ b/rp2040-hal/examples/adc.rs @@ -10,9 +10,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -42,12 +39,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then prints the temperature /// in an infinite loop. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/blinky.rs b/rp2040-hal/examples/blinky.rs index 39d8225..517ca91 100644 --- a/rp2040-hal/examples/blinky.rs +++ b/rp2040-hal/examples/blinky.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -40,12 +37,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. If there is an LED connected to that pin, it will blink. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/dht11.rs b/rp2040-hal/examples/dht11.rs index 3b3028f..3d49602 100644 --- a/rp2040-hal/examples/dht11.rs +++ b/rp2040-hal/examples/dht11.rs @@ -12,9 +12,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -89,12 +86,12 @@ impl OutputPin for InOutPin { /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, assigns GPIO 28 to the /// DHT11 driver, and takes a single measurement. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/gpio_in_out.rs b/rp2040-hal/examples/gpio_in_out.rs index f01e793..812eca2 100644 --- a/rp2040-hal/examples/gpio_in_out.rs +++ b/rp2040-hal/examples/gpio_in_out.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -39,12 +36,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. If there is an LED connected to that pin, it will blink. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/gpio_irq_example.rs b/rp2040-hal/examples/gpio_irq_example.rs index 91d440f..c422f7a 100644 --- a/rp2040-hal/examples/gpio_irq_example.rs +++ b/rp2040-hal/examples/gpio_irq_example.rs @@ -22,9 +22,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -82,12 +79,12 @@ static GLOBAL_PINS: Mutex>> = Mutex::new(RefCell::n /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. If there is an LED connected to that pin, it will blink. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/i2c.rs b/rp2040-hal/examples/i2c.rs index 719ccee..e0f65cf 100644 --- a/rp2040-hal/examples/i2c.rs +++ b/rp2040-hal/examples/i2c.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -39,12 +36,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then performs a single I²C /// write to a fixed address. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/lcd_display.rs b/rp2040-hal/examples/lcd_display.rs index 99c0b19..9624875 100644 --- a/rp2040-hal/examples/lcd_display.rs +++ b/rp2040-hal/examples/lcd_display.rs @@ -12,9 +12,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -45,12 +42,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, writes to the LCD, then goes /// to sleep. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/multicore_fifo_blink.rs b/rp2040-hal/examples/multicore_fifo_blink.rs index d1f6ae6..5a6c408 100644 --- a/rp2040-hal/examples/multicore_fifo_blink.rs +++ b/rp2040-hal/examples/multicore_fifo_blink.rs @@ -12,9 +12,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - use embedded_time::fixed_point::FixedPoint; use hal::clocks::Clock; use hal::multicore::{Multicore, Stack}; @@ -83,12 +80,12 @@ fn core1_task(sys_freq: u32) -> ! { /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. If there is an LED connected to that pin, it will blink. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/multicore_polyblink.rs b/rp2040-hal/examples/multicore_polyblink.rs index 2ac5ce6..5459ee5 100644 --- a/rp2040-hal/examples/multicore_polyblink.rs +++ b/rp2040-hal/examples/multicore_polyblink.rs @@ -9,8 +9,6 @@ #![no_main] use cortex_m::delay::Delay; -// The macro for our start-up function -use cortex_m_rt::entry; use embedded_time::fixed_point::FixedPoint; use hal::clocks::Clock; @@ -64,9 +62,9 @@ static mut CORE1_STACK: Stack<4096> = Stack::new(); /// 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. -#[entry] +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/pio_blink.rs b/rp2040-hal/examples/pio_blink.rs index 06bee1d..aa762d1 100644 --- a/rp2040-hal/examples/pio_blink.rs +++ b/rp2040-hal/examples/pio_blink.rs @@ -4,7 +4,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use hal::gpio::{FunctionPio0, Pin}; use hal::pac; use hal::pio::PIOExt; @@ -16,7 +15,13 @@ use rp2040_hal as hal; #[used] pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +/// +/// The function configures the RP2040 peripherals, then blinks an LED using the PIO peripheral. +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/pio_proc_blink.rs b/rp2040-hal/examples/pio_proc_blink.rs index 117638d..0868b05 100644 --- a/rp2040-hal/examples/pio_proc_blink.rs +++ b/rp2040-hal/examples/pio_proc_blink.rs @@ -4,7 +4,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use hal::gpio::{FunctionPio0, Pin}; use hal::pac; use hal::pio::PIOExt; @@ -16,7 +15,11 @@ use rp2040_hal as hal; #[used] pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/pio_side_set.rs b/rp2040-hal/examples/pio_side_set.rs index 15ca165..f66e65d 100644 --- a/rp2040-hal/examples/pio_side_set.rs +++ b/rp2040-hal/examples/pio_side_set.rs @@ -6,7 +6,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use hal::gpio::{FunctionPio0, Pin}; use hal::pac; use hal::pio::PIOExt; @@ -18,7 +17,11 @@ use rp2040_hal as hal; #[used] pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/pio_synchronized.rs b/rp2040-hal/examples/pio_synchronized.rs index dac13c9..e161aa2 100644 --- a/rp2040-hal/examples/pio_synchronized.rs +++ b/rp2040-hal/examples/pio_synchronized.rs @@ -6,7 +6,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use hal::gpio::{FunctionPio0, Pin}; use hal::pac; use hal::pio::PIOExt; @@ -18,7 +17,11 @@ use rp2040_hal as hal; #[used] pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H; -#[entry] +/// Entry point to our bare-metal application. +/// +/// The `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. +#[rp2040_hal::entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/pwm_blink.rs b/rp2040-hal/examples/pwm_blink.rs index e96b641..a1d28b0 100644 --- a/rp2040-hal/examples/pwm_blink.rs +++ b/rp2040-hal/examples/pwm_blink.rs @@ -10,9 +10,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -47,12 +44,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then fades the LED in an /// infinite loop. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/rom_funcs.rs b/rp2040-hal/examples/rom_funcs.rs index e2008ba..fb804fb 100644 --- a/rp2040-hal/examples/rom_funcs.rs +++ b/rp2040-hal/examples/rom_funcs.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -43,12 +40,12 @@ const SYSTICK_RELOAD: u32 = 0x00FF_FFFF; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then writes to the UART in /// an infinite loop. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/spi.rs b/rp2040-hal/examples/spi.rs index e567629..4232e39 100644 --- a/rp2040-hal/examples/spi.rs +++ b/rp2040-hal/examples/spi.rs @@ -12,9 +12,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -43,12 +40,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then performs some example /// SPI transactions, then goes to sleep. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/uart.rs b/rp2040-hal/examples/uart.rs index 9e06f73..d229756 100644 --- a/rp2040-hal/examples/uart.rs +++ b/rp2040-hal/examples/uart.rs @@ -11,9 +11,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -42,12 +39,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then writes to the UART in /// an infinite loop. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/vector_table.rs b/rp2040-hal/examples/vector_table.rs index dfac446..5e14d3a 100644 --- a/rp2040-hal/examples/vector_table.rs +++ b/rp2040-hal/examples/vector_table.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic use panic_halt as _; @@ -60,12 +57,12 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. If there is an LED connected to that pin, it will blink. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap(); diff --git a/rp2040-hal/examples/watchdog.rs b/rp2040-hal/examples/watchdog.rs index 07094f4..69bed46 100644 --- a/rp2040-hal/examples/watchdog.rs +++ b/rp2040-hal/examples/watchdog.rs @@ -9,9 +9,6 @@ #![no_std] #![no_main] -// The macro for our start-up function -use cortex_m_rt::entry; - // Ensure we halt the program on panic (if we don't mention this crate it won't // be linked) use panic_halt as _; @@ -42,13 +39,13 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32; /// 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 `#[rp2040_hal::entry]` macro ensures the Cortex-M start-up code calls this function +/// as soon as all global variables and the spinlock are initialised. /// /// The function configures the RP2040 peripherals, then toggles a GPIO pin in /// an infinite loop. After a period of time, the watchdog will kick in to reset /// the CPU. -#[entry] +#[rp2040_hal::entry] fn main() -> ! { // Grab our singleton objects let mut pac = pac::Peripherals::take().unwrap();