diff options
| author | Lofty Inclination <[email protected]> | 2025-01-01 00:56:16 +0000 |
|---|---|---|
| committer | Lofty Inclination <[email protected]> | 2025-01-01 01:35:41 +0000 |
| commit | b2cc2fda26a7ecd6d64482e1f53eaf213f2b0a54 (patch) | |
| tree | 7917014ad83e8b84b87dbc0357f9bd91acb061b5 /embassy-stm32-wpan/src/lib.rs | |
| parent | c84aef75af6c1e7b60b6c86b7dcd20293f3f5a89 (diff) | |
Add docs for the BLE bindings
These new docs explain a lot of the current implementation for the BLE
stack, with reference to AN5289 14.1. They also detail the additional
requirements around BLE startup behaviour; specifically, that certain
SYS events must be awaited, and that shci_c2_ble_init should be called.
Since the ble feature is now enabled by default for the docs, the
remaining documentation for the BLE behaviour (as implemented by the
`stm32wb-hci` crate) should be bought in automatically.
Diffstat (limited to 'embassy-stm32-wpan/src/lib.rs')
| -rw-r--r-- | embassy-stm32-wpan/src/lib.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index fb34d4ba0..1a01be200 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs | |||
| @@ -37,6 +37,7 @@ pub use crate::sub::ble::hci; | |||
| 37 | 37 | ||
| 38 | type PacketHeader = LinkedListNode; | 38 | type PacketHeader = LinkedListNode; |
| 39 | 39 | ||
| 40 | /// Transport Layer for the Mailbox interface | ||
| 40 | pub struct TlMbox<'d> { | 41 | pub struct TlMbox<'d> { |
| 41 | _ipcc: PeripheralRef<'d, IPCC>, | 42 | _ipcc: PeripheralRef<'d, IPCC>, |
| 42 | 43 | ||
| @@ -49,6 +50,33 @@ pub struct TlMbox<'d> { | |||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | impl<'d> TlMbox<'d> { | 52 | impl<'d> TlMbox<'d> { |
| 53 | /// Initialise the Transport Layer, and creates and returns a wrapper around it. | ||
| 54 | /// | ||
| 55 | /// This method performs the initialisation laid out in AN5289 annex 14.1. However, it differs | ||
| 56 | /// from the implementation documented in Figure 64, to avoid needing to reference any C | ||
| 57 | /// function pointers. | ||
| 58 | /// | ||
| 59 | /// Annex 14.1 lays out the following methods that should be called: | ||
| 60 | /// 1. tl_mbox.c/TL_Init, which initialises the reference table that is shared between CPU1 | ||
| 61 | /// and CPU2. | ||
| 62 | /// 2. shci_tl.c/shci_init(), which initialises the system transport layer, and in turn | ||
| 63 | /// calls tl_mbox.c/TL_SYS_Init, which initialises SYSTEM_EVT_QUEUE channel. | ||
| 64 | /// 3. tl_mbox.c/TL_MM_Init(), which initialises the channel used for sending memory | ||
| 65 | /// manager commands. | ||
| 66 | /// 4. tl_mbox.c/TL_Enable(), which enables the IPCC, and starts CPU2. | ||
| 67 | /// This implementation initialises all of the shared refernce tables and all IPCC channel that | ||
| 68 | /// would be initialised by this process. The developer should therefore treat this method as | ||
| 69 | /// completing all steps in Figure 64. | ||
| 70 | /// | ||
| 71 | /// Once this method has been called, no system commands may be sent until the CPU2 ready | ||
| 72 | /// signal is received, via [sys_subsystem.read]; this completes the procedure laid out in | ||
| 73 | /// Figure 65. | ||
| 74 | /// | ||
| 75 | /// If the `ble` feature is enabled, at this point, the user should call | ||
| 76 | /// [sys_subsystem.shci_c2_ble_init], before any commands are written to the [ble_subsystem] | ||
| 77 | /// ([Ble::new()] completes the process that would otherwise be handled by `TL_BLE_Init`; see | ||
| 78 | /// Figure 66). This completes the procedure laid out in Figure 66. | ||
| 79 | // TODO: document what the user should do after calling init to use the mac_802_15_4 subsystem | ||
| 52 | pub fn init( | 80 | pub fn init( |
| 53 | ipcc: impl Peripheral<P = IPCC> + 'd, | 81 | ipcc: impl Peripheral<P = IPCC> + 'd, |
| 54 | _irqs: impl interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_RX, ReceiveInterruptHandler> | 82 | _irqs: impl interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_RX, ReceiveInterruptHandler> |
| @@ -57,6 +85,9 @@ impl<'d> TlMbox<'d> { | |||
| 57 | ) -> Self { | 85 | ) -> Self { |
| 58 | into_ref!(ipcc); | 86 | into_ref!(ipcc); |
| 59 | 87 | ||
| 88 | // this is an inlined version of TL_Init from the STM32WB firmware as requested by AN5289. | ||
| 89 | // HW_IPCC_Init is not called, and its purpose is (presumably?) covered by this | ||
| 90 | // implementation | ||
| 60 | unsafe { | 91 | unsafe { |
| 61 | TL_REF_TABLE.as_mut_ptr().write_volatile(RefTable { | 92 | TL_REF_TABLE.as_mut_ptr().write_volatile(RefTable { |
| 62 | device_info_table: TL_DEVICE_INFO_TABLE.as_ptr(), | 93 | device_info_table: TL_DEVICE_INFO_TABLE.as_ptr(), |
| @@ -140,6 +171,7 @@ impl<'d> TlMbox<'d> { | |||
| 140 | 171 | ||
| 141 | compiler_fence(Ordering::SeqCst); | 172 | compiler_fence(Ordering::SeqCst); |
| 142 | 173 | ||
| 174 | // this is equivalent to `HW_IPCC_Enable`, which is called by `TL_Enable` | ||
| 143 | Ipcc::enable(config); | 175 | Ipcc::enable(config); |
| 144 | 176 | ||
| 145 | Self { | 177 | Self { |
