2023-05-30 00:10:36 +02:00
|
|
|
// required-features: ble
|
|
|
|
|
2023-05-04 00:36:31 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
2023-05-30 00:10:36 +02:00
|
|
|
#[path = "../common.rs"]
|
|
|
|
mod common;
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-17 21:38:36 +02:00
|
|
|
use core::mem;
|
|
|
|
|
2023-05-30 00:10:36 +02:00
|
|
|
use common::*;
|
2023-05-04 00:36:31 +02:00
|
|
|
use embassy_executor::Spawner;
|
2023-06-17 19:00:33 +02:00
|
|
|
use embassy_futures::poll_once;
|
2023-06-12 15:44:30 +02:00
|
|
|
use embassy_stm32::bind_interrupts;
|
2023-06-17 19:00:33 +02:00
|
|
|
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
|
|
|
use embassy_stm32_wpan::{mm, TlMbox};
|
2023-05-04 00:36:31 +02:00
|
|
|
use embassy_time::{Duration, Timer};
|
|
|
|
|
2023-05-26 11:03:01 +02:00
|
|
|
bind_interrupts!(struct Irqs{
|
2023-06-17 19:00:33 +02:00
|
|
|
IPCC_C1_RX => ReceiveInterruptHandler;
|
|
|
|
IPCC_C1_TX => TransmitInterruptHandler;
|
2023-05-26 11:03:01 +02:00
|
|
|
});
|
|
|
|
|
2023-06-17 19:00:33 +02:00
|
|
|
#[embassy_executor::task]
|
2023-06-17 22:37:34 +02:00
|
|
|
async fn run_mm_queue(memory_manager: mm::MemoryManager) {
|
|
|
|
memory_manager.run_queue().await;
|
2023-06-17 19:00:33 +02:00
|
|
|
}
|
|
|
|
|
2023-05-04 00:36:31 +02:00
|
|
|
#[embassy_executor::main]
|
2023-06-17 19:00:33 +02:00
|
|
|
async fn main(spawner: Spawner) {
|
2023-05-27 22:05:50 +02:00
|
|
|
let p = embassy_stm32::init(config());
|
2023-05-04 00:36:31 +02:00
|
|
|
info!("Hello World!");
|
|
|
|
|
|
|
|
let config = Config::default();
|
2023-06-12 15:44:30 +02:00
|
|
|
let mbox = TlMbox::init(p.IPCC, Irqs, config);
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-17 22:37:34 +02:00
|
|
|
spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
|
|
|
|
|
|
|
|
let ready_event = mbox.sys_subsystem.read().await;
|
|
|
|
let _ = poll_once(mbox.sys_subsystem.read()); // clear rx not
|
2023-06-17 19:00:33 +02:00
|
|
|
|
2023-06-18 15:37:26 +02:00
|
|
|
info!("sys event {:x} : {:x}", ready_event.stub().kind, ready_event.payload());
|
2023-06-17 21:38:36 +02:00
|
|
|
|
|
|
|
// test memory manager
|
|
|
|
mem::drop(ready_event);
|
2023-06-17 19:00:33 +02:00
|
|
|
|
2023-06-17 22:37:34 +02:00
|
|
|
let fw_info = mbox.sys_subsystem.wireless_fw_info().unwrap();
|
|
|
|
let version_major = fw_info.version_major();
|
|
|
|
let version_minor = fw_info.version_minor();
|
|
|
|
let subversion = fw_info.subversion();
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-17 22:37:34 +02:00
|
|
|
let sram2a_size = fw_info.sram2a_size();
|
|
|
|
let sram2b_size = fw_info.sram2b_size();
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-17 22:37:34 +02:00
|
|
|
info!(
|
|
|
|
"version {}.{}.{} - SRAM2a {} - SRAM2b {}",
|
|
|
|
version_major, version_minor, subversion, sram2a_size, sram2b_size
|
|
|
|
);
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-17 22:37:34 +02:00
|
|
|
Timer::after(Duration::from_millis(50)).await;
|
2023-05-04 00:36:31 +02:00
|
|
|
|
2023-06-18 15:37:26 +02:00
|
|
|
let result = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await;
|
|
|
|
info!("subsystem initialization: {}", result);
|
2023-06-14 00:12:34 +02:00
|
|
|
|
2023-06-17 19:00:33 +02:00
|
|
|
info!("starting ble...");
|
2023-06-17 22:37:34 +02:00
|
|
|
mbox.ble_subsystem.write(0x0c, &[]).await;
|
2023-06-16 04:02:10 +02:00
|
|
|
|
2023-06-17 19:00:33 +02:00
|
|
|
info!("waiting for ble...");
|
2023-06-17 22:37:34 +02:00
|
|
|
let ble_event = mbox.ble_subsystem.read().await;
|
2023-06-17 03:15:03 +02:00
|
|
|
|
2023-06-18 15:37:26 +02:00
|
|
|
info!("ble event {:x} : {:x}", ble_event.stub().kind, ble_event.payload());
|
2023-06-13 04:23:42 +02:00
|
|
|
|
2023-05-04 00:36:31 +02:00
|
|
|
info!("Test OK");
|
|
|
|
cortex_m::asm::bkpt();
|
|
|
|
}
|