diff options
| author | goueslati <[email protected]> | 2023-07-10 16:54:48 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-07-10 16:54:48 +0100 |
| commit | 4aca7c8811b70e420280893784cdad2acbe326f9 (patch) | |
| tree | 7d7b1d989b2533d536725b2b7a6d0e63b9c4c2ae /examples | |
| parent | 8a811cfcf75b25fe81168134bf0cf8a8d387c391 (diff) | |
wip
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wb/.cargo/config.toml | 4 | ||||
| -rw-r--r-- | examples/stm32wb/Cargo.toml | 6 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox_mac_2.rs | 117 |
3 files changed, 124 insertions, 3 deletions
diff --git a/examples/stm32wb/.cargo/config.toml b/examples/stm32wb/.cargo/config.toml index 8b6d6d754..cf62a10a0 100644 --- a/examples/stm32wb/.cargo/config.toml +++ b/examples/stm32wb/.cargo/config.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | # replace STM32WB55CCUx with your chip as listed in `probe-rs chip list` | 2 | # replace STM32WB55CCUx with your chip as listed in `probe-rs chip list` |
| 3 | # runner = "probe-rs run --chip STM32WB55RGVx --speed 1000 --connect-under-reset" | 3 | runner = "probe-run --chip STM32WB55RGVx --speed 1000 --connect-under-reset" |
| 4 | runner = "teleprobe local run --chip STM32WB55RG --elf" | 4 | # runner = "teleprobe local run --chip STM32WB55RG --elf" |
| 5 | 5 | ||
| 6 | [build] | 6 | [build] |
| 7 | target = "thumbv7em-none-eabihf" | 7 | target = "thumbv7em-none-eabihf" |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 203ca1486..109734546 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -23,7 +23,7 @@ heapless = { version = "0.7.5", default-features = false } | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | [features] | 25 | [features] |
| 26 | default = ["ble"] | 26 | default = ["ble", "mac"] |
| 27 | mac = ["embassy-stm32-wpan/mac"] | 27 | mac = ["embassy-stm32-wpan/mac"] |
| 28 | ble = ["embassy-stm32-wpan/ble"] | 28 | ble = ["embassy-stm32-wpan/ble"] |
| 29 | 29 | ||
| @@ -36,6 +36,10 @@ name = "tl_mbox_mac" | |||
| 36 | required-features = ["mac"] | 36 | required-features = ["mac"] |
| 37 | 37 | ||
| 38 | [[bin]] | 38 | [[bin]] |
| 39 | name = "tl_mbox_mac_2" | ||
| 40 | required-features = ["mac"] | ||
| 41 | |||
| 42 | [[bin]] | ||
| 39 | name = "eddystone_beacon" | 43 | name = "eddystone_beacon" |
| 40 | required-features = ["ble"] | 44 | required-features = ["ble"] |
| 41 | 45 | ||
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac_2.rs b/examples/stm32wb/src/bin/tl_mbox_mac_2.rs new file mode 100644 index 000000000..e069adf87 --- /dev/null +++ b/examples/stm32wb/src/bin/tl_mbox_mac_2.rs | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::bind_interrupts; | ||
| 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | ||
| 9 | use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, MacAddress, ResetRequest, SetRequest}; | ||
| 10 | use embassy_stm32_wpan::sub::mm; | ||
| 11 | use embassy_stm32_wpan::TlMbox; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | |||
| 14 | bind_interrupts!(struct Irqs{ | ||
| 15 | IPCC_C1_RX => ReceiveInterruptHandler; | ||
| 16 | IPCC_C1_TX => TransmitInterruptHandler; | ||
| 17 | }); | ||
| 18 | |||
| 19 | #[embassy_executor::task] | ||
| 20 | async fn run_mm_queue(memory_manager: mm::MemoryManager) { | ||
| 21 | memory_manager.run_queue().await; | ||
| 22 | } | ||
| 23 | |||
| 24 | #[embassy_executor::main] | ||
| 25 | async fn main(spawner: Spawner) { | ||
| 26 | /* | ||
| 27 | How to make this work: | ||
| 28 | |||
| 29 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. | ||
| 30 | - Download and Install STM32CubeProgrammer. | ||
| 31 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from | ||
| 32 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x | ||
| 33 | - Open STM32CubeProgrammer | ||
| 34 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. | ||
| 35 | - Once complete, click connect to connect to the device. | ||
| 36 | - On the left hand pane, click the RSS signal icon to open "Firmware Upgrade Services". | ||
| 37 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file | ||
| 38 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | ||
| 39 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the | ||
| 40 | stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. | ||
| 41 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | ||
| 42 | - Select "Start Wireless Stack". | ||
| 43 | - Disconnect from the device. | ||
| 44 | - In the examples folder for stm32wb, modify the memory.x file to match your target device. | ||
| 45 | - Run this example. | ||
| 46 | |||
| 47 | Note: extended stack versions are not supported at this time. Do not attempt to install a stack with "extended" in the name. | ||
| 48 | */ | ||
| 49 | |||
| 50 | let p = embassy_stm32::init(Default::default()); | ||
| 51 | info!("Hello World!"); | ||
| 52 | |||
| 53 | let config = Config::default(); | ||
| 54 | let mbox = TlMbox::init(p.IPCC, Irqs, config); | ||
| 55 | |||
| 56 | spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); | ||
| 57 | |||
| 58 | let sys_event = mbox.sys_subsystem.read().await; | ||
| 59 | info!("sys event: {}", sys_event.payload()); | ||
| 60 | |||
| 61 | core::mem::drop(sys_event); | ||
| 62 | |||
| 63 | let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; | ||
| 64 | info!("initialized mac: {}", result); | ||
| 65 | |||
| 66 | info!("resetting"); | ||
| 67 | let response = mbox | ||
| 68 | .mac_subsystem | ||
| 69 | .send_command(ResetRequest { set_default_pib: true }) | ||
| 70 | .await; | ||
| 71 | info!("{}", response); | ||
| 72 | |||
| 73 | info!("setting extended address"); | ||
| 74 | let extended_address: u64 = 0xACDE480000000001; | ||
| 75 | defmt::debug!("{}", &extended_address as *const _ as *const u8); | ||
| 76 | let response = mbox | ||
| 77 | .mac_subsystem | ||
| 78 | .send_command(SetRequest { | ||
| 79 | pib_attribute_ptr: &extended_address as *const _ as *const u8, | ||
| 80 | pib_attribute: 0x6F, | ||
| 81 | stuffing: [0; 3], | ||
| 82 | }) | ||
| 83 | .await; | ||
| 84 | info!("{}", response); | ||
| 85 | |||
| 86 | // info!("association request"); | ||
| 87 | // mbox.mac_subsystem | ||
| 88 | // .send_command(AssociateRequest { | ||
| 89 | // channel_number: 16, | ||
| 90 | // channel_page: 0, | ||
| 91 | // coord_addr_mode: 2, | ||
| 92 | // coord_address: MacAddress { short: [0x22, 0x11] }, | ||
| 93 | // capability_information: 0x80, | ||
| 94 | // coord_pan_id: [0xAA, 0x1A], | ||
| 95 | // security_level: 0, | ||
| 96 | |||
| 97 | // key_id_mode: 0, | ||
| 98 | // key_index: 0, | ||
| 99 | // key_source: [0; 8], | ||
| 100 | // }) | ||
| 101 | // .await; | ||
| 102 | // info!("reading"); | ||
| 103 | // let result = mbox.mac_subsystem.read().await; | ||
| 104 | // info!("{}", result.payload()); | ||
| 105 | |||
| 106 | // | ||
| 107 | // info!("starting ble..."); | ||
| 108 | // mbox.ble_subsystem.t_write(0x0c, &[]).await; | ||
| 109 | // | ||
| 110 | // info!("waiting for ble..."); | ||
| 111 | // let ble_event = mbox.ble_subsystem.tl_read().await; | ||
| 112 | // | ||
| 113 | // info!("ble event: {}", ble_event.payload()); | ||
| 114 | |||
| 115 | info!("Test OK"); | ||
| 116 | cortex_m::asm::bkpt(); | ||
| 117 | } | ||
