embassy/tests/stm32/src/bin/tl_mbox.rs

72 lines
1.9 KiB
Rust
Raw Normal View History

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-05-30 00:10:36 +02:00
use common::*;
2023-05-04 00:36:31 +02:00
use embassy_executor::Spawner;
2023-06-12 15:44:30 +02:00
use embassy_stm32::bind_interrupts;
use embassy_stm32::ipcc::Config;
use embassy_stm32_wpan::ble::Ble;
2023-06-14 00:12:34 +02:00
use embassy_stm32_wpan::rc::RadioCoprocessor;
2023-06-16 04:02:10 +02:00
use embassy_stm32_wpan::sys::Sys;
2023-06-14 00:16:12 +02:00
use embassy_stm32_wpan::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-12 15:44:30 +02:00
IPCC_C1_RX => embassy_stm32_wpan::ReceiveInterruptHandler;
IPCC_C1_TX => embassy_stm32_wpan::TransmitInterruptHandler;
2023-05-26 11:03:01 +02:00
});
2023-05-04 00:36:31 +02:00
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
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
loop {
let wireless_fw_info = mbox.wireless_fw_info();
match wireless_fw_info {
2023-05-22 03:18:26 +02:00
None => {}
2023-05-04 00:36:31 +02:00
Some(fw_info) => {
let version_major = fw_info.version_major();
let version_minor = fw_info.version_minor();
let subversion = fw_info.subversion();
let sram2a_size = fw_info.sram2a_size();
let sram2b_size = fw_info.sram2b_size();
info!(
"version {}.{}.{} - SRAM2a {} - SRAM2b {}",
version_major, version_minor, subversion, sram2a_size, sram2b_size
);
break;
}
}
2023-05-22 03:18:26 +02:00
Timer::after(Duration::from_millis(50)).await;
2023-05-04 00:36:31 +02:00
}
2023-06-14 00:12:34 +02:00
let mut rc = RadioCoprocessor::new(mbox);
let response = rc.read().await;
info!("coprocessor ready {}", response);
2023-06-16 04:02:10 +02:00
Sys::shci_ble_init(Default::default());
// rc.write(&[0x01, 0x03, 0x0c, 0x00, 0x00]);
Ble::send_cmd(0x0c, &[]);
2023-06-14 00:12:34 +02:00
let response = rc.read().await;
info!("ble reset rsp {}", response);
2023-05-04 00:36:31 +02:00
info!("Test OK");
cortex_m::asm::bkpt();
}