2023-05-15 11:25:02 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use defmt::*;
|
|
|
|
use embassy_executor::Spawner;
|
2023-06-12 13:27:51 +02:00
|
|
|
use embassy_stm32::bind_interrupts;
|
2023-06-17 19:13:51 +02:00
|
|
|
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
2023-07-30 17:46:33 +02:00
|
|
|
use embassy_stm32::rcc::WPAN_DEFAULT;
|
2023-07-09 23:01:13 +02:00
|
|
|
use embassy_stm32_wpan::sub::mm;
|
2023-06-12 13:27:51 +02:00
|
|
|
use embassy_stm32_wpan::TlMbox;
|
2023-05-15 11:25:02 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
2023-05-25 00:29:56 +02:00
|
|
|
bind_interrupts!(struct Irqs{
|
2023-06-17 19:13:51 +02:00
|
|
|
IPCC_C1_RX => ReceiveInterruptHandler;
|
|
|
|
IPCC_C1_TX => TransmitInterruptHandler;
|
2023-05-25 00:29:56 +02:00
|
|
|
});
|
|
|
|
|
2023-07-09 23:01:13 +02:00
|
|
|
#[embassy_executor::task]
|
|
|
|
async fn run_mm_queue(memory_manager: mm::MemoryManager) {
|
|
|
|
memory_manager.run_queue().await;
|
|
|
|
}
|
|
|
|
|
2023-05-15 11:25:02 +02:00
|
|
|
#[embassy_executor::main]
|
2023-07-09 23:01:13 +02:00
|
|
|
async fn main(spawner: Spawner) {
|
2023-05-15 11:25:02 +02:00
|
|
|
/*
|
|
|
|
How to make this work:
|
|
|
|
|
|
|
|
- Obtain a NUCLEO-STM32WB55 from your preferred supplier.
|
|
|
|
- Download and Install STM32CubeProgrammer.
|
2023-07-30 17:46:33 +02:00
|
|
|
- Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Mac_802_15_4_fw.bin, and Release_Notes.html from
|
2023-05-15 11:25:02 +02:00
|
|
|
gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x
|
|
|
|
- Open STM32CubeProgrammer
|
|
|
|
- On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware.
|
|
|
|
- Once complete, click connect to connect to the device.
|
|
|
|
- On the left hand pane, click the RSS signal icon to open "Firmware Upgrade Services".
|
|
|
|
- In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file
|
|
|
|
- Select that file, the memory address, "verify download", and then "Firmware Upgrade".
|
|
|
|
- Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the
|
2023-07-30 17:46:33 +02:00
|
|
|
stm32wb5x_BLE_Mac_802_15_4_fw.bin file. It should not be the same memory address.
|
2023-05-15 11:25:02 +02:00
|
|
|
- Select that file, the memory address, "verify download", and then "Firmware Upgrade".
|
2023-05-22 01:39:13 +02:00
|
|
|
- Select "Start Wireless Stack".
|
2023-05-15 11:25:02 +02:00
|
|
|
- Disconnect from the device.
|
|
|
|
- In the examples folder for stm32wb, modify the memory.x file to match your target device.
|
|
|
|
- Run this example.
|
|
|
|
|
|
|
|
Note: extended stack versions are not supported at this time. Do not attempt to install a stack with "extended" in the name.
|
|
|
|
*/
|
|
|
|
|
2023-07-30 17:46:33 +02:00
|
|
|
let mut config = embassy_stm32::Config::default();
|
|
|
|
config.rcc = WPAN_DEFAULT;
|
|
|
|
let p = embassy_stm32::init(config);
|
2023-05-15 11:25:02 +02:00
|
|
|
info!("Hello World!");
|
|
|
|
|
|
|
|
let config = Config::default();
|
2023-06-17 22:37:34 +02:00
|
|
|
let mbox = TlMbox::init(p.IPCC, Irqs, config);
|
2023-05-15 11:25:02 +02:00
|
|
|
|
2023-07-09 23:01:13 +02:00
|
|
|
spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
|
|
|
|
|
2023-06-23 04:05:51 +02:00
|
|
|
let sys_event = mbox.sys_subsystem.read().await;
|
2023-06-17 22:37:34 +02:00
|
|
|
info!("sys event: {}", sys_event.payload());
|
|
|
|
|
2023-07-09 23:01:13 +02:00
|
|
|
core::mem::drop(sys_event);
|
|
|
|
|
2023-06-25 18:38:48 +02:00
|
|
|
let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
|
|
|
|
info!("initialized mac: {}", result);
|
|
|
|
|
2023-06-19 01:56:53 +02:00
|
|
|
//
|
|
|
|
// info!("starting ble...");
|
2023-06-22 16:31:45 +02:00
|
|
|
// mbox.ble_subsystem.t_write(0x0c, &[]).await;
|
2023-06-19 01:56:53 +02:00
|
|
|
//
|
|
|
|
// info!("waiting for ble...");
|
2023-06-22 16:31:45 +02:00
|
|
|
// let ble_event = mbox.ble_subsystem.tl_read().await;
|
2023-06-19 01:56:53 +02:00
|
|
|
//
|
|
|
|
// info!("ble event: {}", ble_event.payload());
|
2023-05-15 11:25:02 +02:00
|
|
|
|
2023-05-27 22:05:50 +02:00
|
|
|
info!("Test OK");
|
|
|
|
cortex_m::asm::bkpt();
|
2023-05-15 11:25:02 +02:00
|
|
|
}
|