Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions boards/seeed_studio_lora_e5_mini/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2025.
// Copyright Tock Contributors 2026.

//! Board file for STM32WLE5JC Seeed Studio LoRa E5 HF mini development board.
//!
Expand Down Expand Up @@ -104,6 +104,10 @@ struct SeeedStudioLoraE5Mini {
'static,
stm32wle5jc::i2c::I2C<'static>,
>,
date_time: &'static capsules_extra::date_time::DateTimeCapsule<
'static,
stm32wle5jc::rtc::Rtc<'static>,
>,
}

/// Mapping of integer syscalls to objects that implement syscalls.
Expand All @@ -119,6 +123,7 @@ impl SyscallDriverLookup for SeeedStudioLoraE5Mini {
LORA_SPI_DRIVER_NUM => f(Some(self.lora_spi_controller)),
LORA_GPIO_DRIVER_NUM => f(Some(self.lora_gpio)),
capsules_core::i2c_master::DRIVER_NUM => f(Some(self.i2c_master)),
capsules_extra::date_time::DRIVER_NUM => f(Some(self.date_time)),
_ => f(None),
}
}
Expand Down Expand Up @@ -178,6 +183,10 @@ unsafe fn setup_peripherals(tim2: &stm32wle5jc::tim2::Tim2, subghz_spi: &stm32wl

cortexm4::nvic::Nvic::new(stm32wle5jc::nvic::I2C2_EV).enable();
cortexm4::nvic::Nvic::new(stm32wle5jc::nvic::I2C2_ER).enable();

// RTC interrupts
cortexm4::nvic::Nvic::new(stm32wle5jc::nvic::RTC_WKUP).enable();
cortexm4::nvic::Nvic::new(stm32wle5jc::nvic::RTC_Alarm).enable();
}

/// Statically initialize the core peripherals for the chip.
Expand Down Expand Up @@ -205,9 +214,11 @@ unsafe fn create_peripherals() -> &'static mut Stm32wle5jcDefaultPeripherals<'st
stm32wle5jc::exti::Exti::new(syscfg)
);

let pwr = static_init!(stm32wle5jc::pwr::Pwr, stm32wle5jc::pwr::Pwr::new());

let peripherals = static_init!(
Stm32wle5jcDefaultPeripherals,
Stm32wle5jcDefaultPeripherals::new(clocks, exti, syscfg)
Stm32wle5jcDefaultPeripherals::new(clocks, exti, syscfg, pwr)
);

peripherals
Expand Down Expand Up @@ -333,7 +344,7 @@ pub unsafe fn main() {
gpio_ports.get_pin(stm32wle5jc::gpio::PinId::PB08).unwrap(),
);

base_peripherals.subghz_spi.set_nss(&base_peripherals.pwr);
base_peripherals.subghz_spi.set_nss(base_peripherals.pwr);

let lora_spi_mux = components::spi::SpiMuxComponent::new(&base_peripherals.subghz_spi)
.finalize(components::spi_mux_component_static!(
Expand Down Expand Up @@ -365,7 +376,7 @@ pub unsafe fn main() {

let lora_busy_base = static_init!(
stm32wle5jc::subghz_radio::SubGhzRadioBusy,
stm32wle5jc::subghz_radio::SubGhzRadioBusy::new(&base_peripherals.pwr)
stm32wle5jc::subghz_radio::SubGhzRadioBusy::new(base_peripherals.pwr)
);
let lora_busy_pin = static_init!(
stm32wle5jc::subghz_radio::SubGhzRadioVirtualGpio,
Expand Down Expand Up @@ -421,7 +432,29 @@ pub unsafe fn main() {
});

// Uncomment to run I2C scan test
//test::i2c_dummy::i2c_scan_slaves(&base_peripherals.i2c2);
// test::i2c_dummy::i2c_scan_slaves(&base_peripherals.i2c2);

//--------------------------------------------------------------------
// RTC
//--------------------------------------------------------------------
if let Err(e) = base_peripherals.rtc.rtc_init() {
panic!("RTC init failed: {:?}", e);
}

let rtc = &base_peripherals.rtc;

let date_time = components::date_time::DateTimeComponent::new(
board_kernel,
capsules_extra::date_time::DRIVER_NUM,
rtc,
)
.finalize(components::date_time_component_static!(
stm32wle5jc::rtc::Rtc<'static>
));

// Note: this replaces date_time as the RTC client — comment out the `DateTimeComponent``
// block above when testing. Uncomment to run RTC test sequence.
// test::rtc_dummy::run_complete_rtc_test(rtc);

//--------------------------------------------------------------------
// PROCESS CONSOLE
Expand Down Expand Up @@ -452,6 +485,7 @@ pub unsafe fn main() {
lora_spi_controller,
lora_gpio,
i2c_master,
date_time,
};

assert!(base_peripherals.subghz_spi.is_enabled_clock());
Expand Down
249 changes: 249 additions & 0 deletions boards/seeed_studio_lora_e5_mini/src/test/RTC_QUICK_REFERENCE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions boards/seeed_studio_lora_e5_mini/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
// Copyright Tock Contributors 2022.

pub(crate) mod i2c_dummy;
pub(crate) mod rtc_dummy;
Loading
Loading