Fixing typos spotted in the review.

This commit is contained in:
Jonathan Pallant 2021-12-26 19:29:14 +00:00
parent d3bd232885
commit 7da16a726f
18 changed files with 46 additions and 47 deletions

View file

@ -7,8 +7,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -7,8 +7,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -28,7 +28,7 @@ use adafruit_kb2040::{
use smart_leds::{brightness, SmartLedsWrite, RGB8}; use smart_leds::{brightness, SmartLedsWrite, RGB8};
use ws2812_pio::Ws2812; use ws2812_pio::Ws2812;
//// The linker will place this boot block at the start of our program image. /// 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. /// We need this to help the ROM bootloader get our code up and running.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]

View file

@ -9,8 +9,8 @@ pub use cortex_m_rt::entry;
// Adafruit macropad uses W25Q64JVxQ flash chip. Should work with BOOT_LOADER_W25Q080 (untested) // Adafruit macropad uses W25Q64JVxQ flash chip. Should work with BOOT_LOADER_W25Q080 (untested)
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -7,8 +7,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -8,8 +8,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -7,8 +7,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -91,7 +91,7 @@ fn main() -> ! {
let uart_pins = ( let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0) // UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into_mode::<hal::gpio::FunctionUart>(), pins.gpio0.into_mode::<hal::gpio::FunctionUart>(),
// UART RX (characters reveived by RP2040) on pin 2 (GPIO1) // UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into_mode::<hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<hal::gpio::FunctionUart>(),
); );

View file

@ -1,4 +1,4 @@
//! # UART IRQ TX BUffer Example //! # UART IRQ TX Buffer Example
//! //!
//! This application demonstrates how to use the UART Driver to talk to a //! This application demonstrates how to use the UART Driver to talk to a
//! serial connection. In this example, the IRQ owns the UART and you cannot //! serial connection. In this example, the IRQ owns the UART and you cannot
@ -6,8 +6,7 @@
//! static queue, and have the queue contents transferred to the UART under //! static queue, and have the queue contents transferred to the UART under
//! interrupt. //! interrupt.
//! //!
//! It may need to be adapted to your particular board layout and/or pin //! The pinouts are:
//! assignment. The pinouts assume you have a Raspberry Pi Pico or compatible:
//! //!
//! * GPIO 0 - UART TX (out of the RP2040) //! * GPIO 0 - UART TX (out of the RP2040)
//! * GPIO 1 - UART RX (in to the RP2040) //! * GPIO 1 - UART RX (in to the RP2040)
@ -72,7 +71,7 @@ struct UartQueue {
} }
/// 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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
@ -97,7 +96,7 @@ static UART_TX_QUEUE: UartQueue = UartQueue {
/// as soon as all global variables are initialised. /// as soon as all global variables are initialised.
/// ///
/// The function configures the RP2040 peripherals, then writes to the UART in /// The function configures the RP2040 peripherals, then writes to the UART in
/// an inifinite loop. /// an infinite loop.
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// Grab our singleton objects // Grab our singleton objects
@ -127,7 +126,7 @@ fn main() -> ! {
let sio = hal::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 = rp_pico::Pins::new(
pac.IO_BANK0, pac.IO_BANK0,
pac.PADS_BANK0, pac.PADS_BANK0,
sio.gpio_bank0, sio.gpio_bank0,
@ -137,7 +136,7 @@ fn main() -> ! {
let uart_pins = ( let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0) // UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into_mode::<hal::gpio::FunctionUart>(), pins.gpio0.into_mode::<hal::gpio::FunctionUart>(),
// UART RX (characters reveived by RP2040) on pin 2 (GPIO1) // UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into_mode::<hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<hal::gpio::FunctionUart>(),
); );
@ -160,11 +159,11 @@ fn main() -> ! {
}); });
// But we can blink an LED. // But we can blink an LED.
let mut led_pin = pins.gpio25.into_push_pull_output(); let mut led_pin = pins.led.into_push_pull_output();
loop { loop {
// Light the LED whilst the main thread is in the transmit routine. It // Light the LED whilst the main thread is in the transmit routine. It
// shouldn't be on very long, but it will be on whilst we get enough // shouldn't be on very long, but it will be on until we get enough
// data /out/ of the queue and over the UART for this remainder of // data /out/ of the queue and over the UART for this remainder of
// this string to fit. // this string to fit.
led_pin.set_high().unwrap(); led_pin.set_high().unwrap();
@ -178,7 +177,8 @@ fn main() -> ! {
) )
.unwrap(); .unwrap();
led_pin.set_low().unwrap(); led_pin.set_low().unwrap();
// Wait for a second - the UART TX IRQ will transmit the remainder of our queue contents in the background. // Wait for a second - the UART TX IRQ will transmit the remainder of
// our queue contents in the background.
delay.delay_ms(1000); delay.delay_ms(1000);
} }
} }

View file

@ -4,8 +4,7 @@
//! connection. In this example, the IRQ owns the UART and you cannot do any UART //! connection. In this example, the IRQ owns the UART and you cannot do any UART
//! access from the main thread. //! access from the main thread.
//! //!
//! It may need to be adapted to your particular board layout and/or pin //! The pinouts are:
//! assignment. The pinouts assume you have a Raspberry Pi Pico or compatible:
//! //!
//! * GPIO 0 - UART TX (out of the RP2040) //! * GPIO 0 - UART TX (out of the RP2040)
//! * GPIO 1 - UART RX (in to the RP2040) //! * GPIO 1 - UART RX (in to the RP2040)
@ -63,7 +62,7 @@ type UartPins = (
type Uart = hal::uart::UartPeripheral<hal::uart::Enabled, pac::UART0, UartPins>; type Uart = hal::uart::UartPeripheral<hal::uart::Enabled, pac::UART0, UartPins>;
/// 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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
@ -81,7 +80,7 @@ static GLOBAL_UART: Mutex<RefCell<Option<Uart>>> = Mutex::new(RefCell::new(None)
/// as soon as all global variables are initialised. /// as soon as all global variables are initialised.
/// ///
/// The function configures the RP2040 peripherals, then writes to the UART in /// The function configures the RP2040 peripherals, then writes to the UART in
/// an inifinite loop. /// an infinite loop.
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// Grab our singleton objects // Grab our singleton objects
@ -111,7 +110,7 @@ fn main() -> ! {
let sio = hal::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 = rp_pico::Pins::new(
pac.IO_BANK0, pac.IO_BANK0,
pac.PADS_BANK0, pac.PADS_BANK0,
sio.gpio_bank0, sio.gpio_bank0,
@ -121,7 +120,7 @@ fn main() -> ! {
let uart_pins = ( let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0) // UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into_mode::<hal::gpio::FunctionUart>(), pins.gpio0.into_mode::<hal::gpio::FunctionUart>(),
// UART RX (characters reveived by RP2040) on pin 2 (GPIO1) // UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into_mode::<hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<hal::gpio::FunctionUart>(),
); );
@ -154,7 +153,7 @@ fn main() -> ! {
}); });
// But we can blink an LED. // But we can blink an LED.
let mut led_pin = pins.gpio25.into_push_pull_output(); let mut led_pin = pins.led.into_push_pull_output();
loop { loop {
// The normal *Wait For Interrupts* (WFI) has a race-hazard - the // The normal *Wait For Interrupts* (WFI) has a race-hazard - the

View file

@ -7,8 +7,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -6,8 +6,8 @@ extern crate cortex_m_rt;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
pub use cortex_m_rt::entry; pub use cortex_m_rt::entry;
//// 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.
#[cfg(feature = "boot2")] #[cfg(feature = "boot2")]
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[no_mangle] #[no_mangle]

View file

@ -29,7 +29,7 @@ use embedded_time::fixed_point::FixedPoint;
use rp2040_hal::clocks::Clock; use rp2040_hal::clocks::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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;

View file

@ -34,7 +34,7 @@ use hal::pac;
use embedded_hal::digital::v2::ToggleableOutputPin; use embedded_hal::digital::v2::ToggleableOutputPin;
/// 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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;

View file

@ -29,8 +29,8 @@ use rp2040_hal::clocks::Clock;
// register access // register access
use hal::pac; use hal::pac;
//// 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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;

View file

@ -27,7 +27,7 @@ use hal::pac;
use core::fmt::Write; use core::fmt::Write;
/// 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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
@ -46,7 +46,7 @@ const SYSTICK_RELOAD: u32 = 0x00FF_FFFF;
/// as soon as all global variables are initialised. /// as soon as all global variables are initialised.
/// ///
/// The function configures the RP2040 peripherals, then writes to the UART in /// The function configures the RP2040 peripherals, then writes to the UART in
/// an inifinite loop. /// an infinite loop.
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// Grab our singleton objects // Grab our singleton objects
@ -83,7 +83,7 @@ fn main() -> ! {
let uart_pins = ( let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0) // UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into_mode::<hal::gpio::FunctionUart>(), pins.gpio0.into_mode::<hal::gpio::FunctionUart>(),
// UART RX (characters reveived by RP2040) on pin 2 (GPIO1) // UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into_mode::<hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<hal::gpio::FunctionUart>(),
); );
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS) let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
@ -177,7 +177,7 @@ fn main() -> ! {
/// ``` /// ```
/// assert_eq!(1, calc_delta(SYSTICK_RELOAD, SYSTICK_RELOAD - 1)); /// assert_eq!(1, calc_delta(SYSTICK_RELOAD, SYSTICK_RELOAD - 1));
/// assert_eq!(2, calc_delta(0, SYSTICK_RELOAD - 1)); /// assert_eq!(2, calc_delta(0, SYSTICK_RELOAD - 1));
//// ``` /// ```
fn calc_delta(start: u32, end: u32) -> u32 { fn calc_delta(start: u32, end: u32) -> u32 {
if start < end { if start < end {
(start.wrapping_sub(end)) & SYSTICK_RELOAD (start.wrapping_sub(end)) & SYSTICK_RELOAD

View file

@ -31,7 +31,7 @@ use embedded_time::fixed_point::FixedPoint;
use rp2040_hal::clocks::Clock; use rp2040_hal::clocks::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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
@ -46,7 +46,7 @@ const XTAL_FREQ_HZ: u32 = 12_000_000u32;
/// as soon as all global variables are initialised. /// as soon as all global variables are initialised.
/// ///
/// The function configures the RP2040 peripherals, then writes to the UART in /// The function configures the RP2040 peripherals, then writes to the UART in
/// an inifinite loop. /// an infinite loop.
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// Grab our singleton objects // Grab our singleton objects
@ -85,7 +85,7 @@ fn main() -> ! {
let uart_pins = ( let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0) // UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into_mode::<hal::gpio::FunctionUart>(), pins.gpio0.into_mode::<hal::gpio::FunctionUart>(),
// UART RX (characters reveived by RP2040) on pin 2 (GPIO1) // UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into_mode::<hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<hal::gpio::FunctionUart>(),
); );
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS) let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)

View file

@ -31,7 +31,7 @@ use embedded_time::fixed_point::FixedPoint;
use rp2040_hal::clocks::Clock; use rp2040_hal::clocks::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.
#[link_section = ".boot2"] #[link_section = ".boot2"]
#[used] #[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;