diff options
| author | goueslati <[email protected]> | 2023-07-13 16:29:29 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-07-13 16:29:29 +0100 |
| commit | f90b170dad91848d5a0ff746d873bd8a4ce7e91f (patch) | |
| tree | dcad430269b866f795376cb7f9859ac160e57fe9 | |
| parent | 68792bb9188b69c1e7629425a0d39110c602b9b2 (diff) | |
cleanup
| -rw-r--r-- | embassy-stm32-wpan/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/responses.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs | 8 | ||||
| -rw-r--r-- | examples/stm32wb/.cargo/config.toml | 4 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/mac_ffd.rs | 10 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/mac_rfd.rs | 2 |
7 files changed, 15 insertions, 15 deletions
diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 1325faed9..91540321f 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml | |||
| @@ -29,7 +29,7 @@ stm32wb-hci = { version = "0.1.2", features = ["version-5-0"], optional = true } | |||
| 29 | bitflags = { version = "2.3.3", optional = true } | 29 | bitflags = { version = "2.3.3", optional = true } |
| 30 | 30 | ||
| 31 | [features] | 31 | [features] |
| 32 | default = ["stm32wb55rg", "mac", "ble", "defmt"] | 32 | default = [] |
| 33 | defmt = ["dep:defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt"] | 33 | defmt = ["dep:defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt"] |
| 34 | 34 | ||
| 35 | ble = ["dep:stm32wb-hci"] | 35 | ble = ["dep:stm32wb-hci"] |
diff --git a/embassy-stm32-wpan/src/sub/mac/mod.rs b/embassy-stm32-wpan/src/sub/mac/mod.rs index 26358bf81..ab39f89c2 100644 --- a/embassy-stm32-wpan/src/sub/mac/mod.rs +++ b/embassy-stm32-wpan/src/sub/mac/mod.rs | |||
| @@ -98,8 +98,6 @@ impl Mac { | |||
| 98 | let mut payload = [0u8; MAX_PACKET_SIZE]; | 98 | let mut payload = [0u8; MAX_PACKET_SIZE]; |
| 99 | cmd.copy_into_slice(&mut payload); | 99 | cmd.copy_into_slice(&mut payload); |
| 100 | 100 | ||
| 101 | debug!("sending {}", &payload[..T::SIZE]); | ||
| 102 | |||
| 103 | let response = self | 101 | let response = self |
| 104 | .tl_write_and_get_response(T::OPCODE as u16, &payload[..T::SIZE]) | 102 | .tl_write_and_get_response(T::OPCODE as u16, &payload[..T::SIZE]) |
| 105 | .await; | 103 | .await; |
diff --git a/embassy-stm32-wpan/src/sub/mac/responses.rs b/embassy-stm32-wpan/src/sub/mac/responses.rs index 0d3c09869..2f6f5bf58 100644 --- a/embassy-stm32-wpan/src/sub/mac/responses.rs +++ b/embassy-stm32-wpan/src/sub/mac/responses.rs | |||
| @@ -28,8 +28,6 @@ impl ParseableMacEvent for AssociateConfirm { | |||
| 28 | const SIZE: usize = 16; | 28 | const SIZE: usize = 16; |
| 29 | 29 | ||
| 30 | fn try_parse(buf: &[u8]) -> Result<Self, ()> { | 30 | fn try_parse(buf: &[u8]) -> Result<Self, ()> { |
| 31 | debug!("{}", buf); | ||
| 32 | |||
| 33 | Self::validate(buf)?; | 31 | Self::validate(buf)?; |
| 34 | 32 | ||
| 35 | Ok(Self { | 33 | Ok(Self { |
diff --git a/embassy-stm32-wpan/src/sub/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index caa4845f2..c17fd531d 100644 --- a/embassy-stm32-wpan/src/sub/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
| @@ -50,7 +50,7 @@ impl Sys { | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | /// `HW_IPCC_SYS_CmdEvtNot` | 52 | /// `HW_IPCC_SYS_CmdEvtNot` |
| 53 | pub async fn write_and_get_response(&self, opcode: ShciOpcode, payload: &[u8]) -> SchiCommandStatus { | 53 | pub async fn write_and_get_response(&self, opcode: ShciOpcode, payload: &[u8]) -> Result<SchiCommandStatus, ()> { |
| 54 | self.write(opcode, payload).await; | 54 | self.write(opcode, payload).await; |
| 55 | Ipcc::flush(channels::cpu1::IPCC_SYSTEM_CMD_RSP_CHANNEL).await; | 55 | Ipcc::flush(channels::cpu1::IPCC_SYSTEM_CMD_RSP_CHANNEL).await; |
| 56 | 56 | ||
| @@ -59,12 +59,12 @@ impl Sys { | |||
| 59 | let p_command_event = &((*p_event_packet).evt_serial.evt.payload) as *const _ as *const CcEvt; | 59 | let p_command_event = &((*p_event_packet).evt_serial.evt.payload) as *const _ as *const CcEvt; |
| 60 | let p_payload = &((*p_command_event).payload) as *const u8; | 60 | let p_payload = &((*p_command_event).payload) as *const u8; |
| 61 | 61 | ||
| 62 | ptr::read_volatile(p_payload).try_into().unwrap() | 62 | ptr::read_volatile(p_payload).try_into() |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | #[cfg(feature = "mac")] | 66 | #[cfg(feature = "mac")] |
| 67 | pub async fn shci_c2_mac_802_15_4_init(&self) -> SchiCommandStatus { | 67 | pub async fn shci_c2_mac_802_15_4_init(&self) -> Result<SchiCommandStatus, ()> { |
| 68 | use crate::tables::{ | 68 | use crate::tables::{ |
| 69 | Mac802_15_4Table, TracesTable, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, | 69 | Mac802_15_4Table, TracesTable, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, |
| 70 | TL_MAC_802_15_4_TABLE, TL_TRACES_TABLE, TRACES_EVT_QUEUE, | 70 | TL_MAC_802_15_4_TABLE, TL_TRACES_TABLE, TRACES_EVT_QUEUE, |
| @@ -88,7 +88,7 @@ impl Sys { | |||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | #[cfg(feature = "ble")] | 90 | #[cfg(feature = "ble")] |
| 91 | pub async fn shci_c2_ble_init(&self, param: ShciBleInitCmdParam) -> SchiCommandStatus { | 91 | pub async fn shci_c2_ble_init(&self, param: ShciBleInitCmdParam) -> Result<SchiCommandStatus, ()> { |
| 92 | self.write_and_get_response(ShciOpcode::BleInit, param.payload()).await | 92 | self.write_and_get_response(ShciOpcode::BleInit, param.payload()).await |
| 93 | } | 93 | } |
| 94 | 94 | ||
diff --git a/examples/stm32wb/.cargo/config.toml b/examples/stm32wb/.cargo/config.toml index cf62a10a0..51c499ee7 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-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/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs index 37d36fcdd..689a28353 100644 --- a/examples/stm32wb/src/bin/mac_ffd.rs +++ b/examples/stm32wb/src/bin/mac_ffd.rs | |||
| @@ -168,9 +168,13 @@ async fn main(spawner: Spawner) { | |||
| 168 | .unwrap(), | 168 | .unwrap(), |
| 169 | MacEvent::McpsDataInd(data_ind) => { | 169 | MacEvent::McpsDataInd(data_ind) => { |
| 170 | let data_addr = data_ind.msdu_ptr; | 170 | let data_addr = data_ind.msdu_ptr; |
| 171 | let mut a = [0u8; 256]; | 171 | let mut data = [0u8; 256]; |
| 172 | unsafe { data_addr.copy_to(&mut a as *mut _, data_ind.msdu_length as usize) } | 172 | unsafe { data_addr.copy_to(&mut data as *mut _, data_ind.msdu_length as usize) } |
| 173 | info!("{}", a[..data_ind.msdu_length as usize]) | 173 | info!("{}", data[..data_ind.msdu_length as usize]); |
| 174 | |||
| 175 | if &data[..data_ind.msdu_length as usize] == b"Hello from embassy!" { | ||
| 176 | info!("success"); | ||
| 177 | } | ||
| 174 | } | 178 | } |
| 175 | _ => {} | 179 | _ => {} |
| 176 | } | 180 | } |
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs index 756709132..ea349f9a8 100644 --- a/examples/stm32wb/src/bin/mac_rfd.rs +++ b/examples/stm32wb/src/bin/mac_rfd.rs | |||
| @@ -148,7 +148,7 @@ async fn main(spawner: Spawner) { | |||
| 148 | .send_command(&DataRequest { | 148 | .send_command(&DataRequest { |
| 149 | src_addr_mode: AddressMode::Short, | 149 | src_addr_mode: AddressMode::Short, |
| 150 | dst_addr_mode: AddressMode::Short, | 150 | dst_addr_mode: AddressMode::Short, |
| 151 | dst_pan_id: PanId::BROADCAST, | 151 | dst_pan_id: PanId([0x1A, 0xAA]), |
| 152 | dst_address: MacAddress::BROADCAST, | 152 | dst_address: MacAddress::BROADCAST, |
| 153 | msdu_handle: 0x02, | 153 | msdu_handle: 0x02, |
| 154 | ack_tx: 0x00, | 154 | ack_tx: 0x00, |
