mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-06-03 12:58:08 +02:00
Add inline // comments to all main.rs and board.rs boilerplate across 0x01-0x08 Rust drivers
- Add // comments to mod declarations, use imports, static items, and PICOTOOL_ENTRIES in all 8 main.rs files matching rp-hal template style - Add //! file headers to all 8 board.rs files - Add // comments to all board.rs use imports and HAL alias - All 8 drivers build successfully, all 75 tests pass
This commit is contained in:
@@ -25,9 +25,14 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the UART driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -40,28 +40,36 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// UART driver module
|
||||||
mod uart;
|
mod uart;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -97,6 +105,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,14 +25,23 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the blink driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -37,29 +37,37 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// Blink driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod blink;
|
mod blink;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -96,6 +104,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,14 +25,23 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the button driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -39,30 +39,39 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// Button driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod button;
|
mod button;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Interior mutability for shared peripheral access
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -109,6 +118,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,15 +25,25 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the PWM driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// PWM duty-cycle trait for .set_duty_cycle()
|
||||||
use embedded_hal::pwm::SetDutyCycle;
|
use embedded_hal::pwm::SetDutyCycle;
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -40,30 +40,39 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// PWM driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod pwm;
|
mod pwm;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -106,6 +115,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,15 +25,25 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the servo driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// PWM duty-cycle trait for .set_duty_cycle()
|
||||||
use embedded_hal::pwm::SetDutyCycle;
|
use embedded_hal::pwm::SetDutyCycle;
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -39,30 +39,39 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// Servo driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod servo;
|
mod servo;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -105,6 +114,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,14 +25,23 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the ADC driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -39,30 +39,39 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// ADC driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod adc;
|
mod adc;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Legacy embedded-hal 0.2 ADC OneShot trait for .read()
|
||||||
use cortex_m::prelude::_embedded_hal_adc_OneShot;
|
use cortex_m::prelude::_embedded_hal_adc_OneShot;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -104,6 +113,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,15 +25,25 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the I2C driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// I2C bus trait for device probing
|
||||||
use embedded_hal::i2c::I2c;
|
use embedded_hal::i2c::I2c;
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -41,32 +41,43 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// I2C driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod i2c;
|
mod i2c;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
// GPIO traits for I2C pin reconfiguration
|
||||||
use hal::gpio::{FunctionI2C, PullUp};
|
use hal::gpio::{FunctionI2C, PullUp};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -111,6 +122,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
@@ -25,15 +25,25 @@
|
|||||||
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
//! SOFTWARE.
|
//! SOFTWARE.
|
||||||
|
|
||||||
|
//! @file board.rs
|
||||||
|
//! @brief Board-level HAL helpers for the LCD 1602 driver
|
||||||
|
//! @author Kevin Thomas
|
||||||
|
//! @date 2025
|
||||||
|
|
||||||
|
// I2C bus trait for LCD communication
|
||||||
use embedded_hal::i2c::I2c;
|
use embedded_hal::i2c::I2c;
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// GPIO pin types and function selectors
|
||||||
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
use hal::gpio::{FunctionNull, FunctionUart, Pin, PullDown, PullNone};
|
||||||
|
// UART configuration and peripheral types
|
||||||
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
use hal::uart::{DataBits, Enabled, StopBits, UartConfig, UartPeripheral};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
|||||||
@@ -41,32 +41,43 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
// Board-level helpers: constants, type aliases, and init functions
|
||||||
mod board;
|
mod board;
|
||||||
|
// LCD1602 driver module — suppress warnings for unused public API functions
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod lcd1602;
|
mod lcd1602;
|
||||||
|
|
||||||
|
// Debugging output over RTT
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
|
// Panic handler for RISC-V targets
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
// Panic handler for ARM targets
|
||||||
#[cfg(target_arch = "arm")]
|
#[cfg(target_arch = "arm")]
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Rate extension trait for .Hz() baud rate construction
|
||||||
use fugit::RateExtU32;
|
use fugit::RateExtU32;
|
||||||
|
// Clock trait for accessing system clock frequency
|
||||||
use hal::Clock;
|
use hal::Clock;
|
||||||
|
// HAL entry-point macro
|
||||||
use hal::entry;
|
use hal::entry;
|
||||||
|
// GPIO traits for I2C pin reconfiguration
|
||||||
use hal::gpio::{FunctionI2C, PullUp};
|
use hal::gpio::{FunctionI2C, PullUp};
|
||||||
|
|
||||||
|
// Alias our HAL crate
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
use rp235x_hal as hal;
|
use rp235x_hal as hal;
|
||||||
|
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
use rp2040_hal as hal;
|
use rp2040_hal as hal;
|
||||||
|
|
||||||
|
// Second-stage boot loader for RP2040
|
||||||
#[unsafe(link_section = ".boot2")]
|
#[unsafe(link_section = ".boot2")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2040)]
|
#[cfg(rp2040)]
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
||||||
|
|
||||||
|
// Boot metadata for the RP2350 Boot ROM
|
||||||
#[unsafe(link_section = ".start_block")]
|
#[unsafe(link_section = ".start_block")]
|
||||||
#[used]
|
#[used]
|
||||||
#[cfg(rp2350)]
|
#[cfg(rp2350)]
|
||||||
@@ -103,6 +114,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Picotool binary info metadata
|
||||||
#[unsafe(link_section = ".bi_entries")]
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [
|
||||||
|
|||||||
Reference in New Issue
Block a user