-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1934: Initial support for Apollo3 BLE r=bradjc a=alistair23 ### Pull Request Overview This PR adds initial support for the Apollo3 BLE module. This PR can power up the module and write data to it and receive interrupts. ~~This PR applies on top of: #1917 ### Testing Strategy Try to run the `libtock-c` examples on the Apollo3. ### TODO or Help Wanted Lots of things still aren't done, if anyone is willing to help I would be very grateful. BLE still doesn't work (I can't see the device advertise itself from other devices). This PR also doesn't apply the binaries (called patches) that are required to use the BLE module. I have a branch where I call the to HAL's C code to do this. I currently just see the `ble_advertisment_driver` alarm firing and the same data being written to the BLE device over and over again. I'm not sure what else should be happening, but BLE is currently not working. ### Documentation Updated - [X] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [X] Ran `make prepush`. Co-authored-by: Alistair Francis <alistair@alistair23.me> Co-authored-by: Brad Campbell <bradjc5@gmail.com>
- Loading branch information
Showing
8 changed files
with
799 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//! Component for BLE radio on Apollo3 based platforms. | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let ble_radio = BLEComponent::new(board_kernel, &apollo3::ble::BLE, mux_alarm).finalize(); | ||
//! ``` | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules; | ||
use capsules::virtual_alarm::VirtualMuxAlarm; | ||
use kernel::capabilities; | ||
use kernel::component::Component; | ||
use kernel::hil; | ||
use kernel::{create_capability, static_init}; | ||
|
||
/// BLE component for Apollo3 BLE | ||
pub struct BLEComponent { | ||
board_kernel: &'static kernel::Kernel, | ||
radio: &'static apollo3::ble::Ble<'static>, | ||
mux_alarm: | ||
&'static capsules::virtual_alarm::MuxAlarm<'static, apollo3::stimer::STimer<'static>>, | ||
} | ||
|
||
/// BLE component for Apollo3 BLE | ||
impl BLEComponent { | ||
/// New instance | ||
pub fn new( | ||
board_kernel: &'static kernel::Kernel, | ||
radio: &'static apollo3::ble::Ble, | ||
mux_alarm: &'static capsules::virtual_alarm::MuxAlarm<'static, apollo3::stimer::STimer>, | ||
) -> BLEComponent { | ||
BLEComponent { | ||
board_kernel: board_kernel, | ||
radio: radio, | ||
mux_alarm: mux_alarm, | ||
} | ||
} | ||
} | ||
|
||
impl Component for BLEComponent { | ||
type StaticInput = (); | ||
type Output = &'static capsules::ble_advertising_driver::BLE< | ||
'static, | ||
apollo3::ble::Ble<'static>, | ||
VirtualMuxAlarm<'static, apollo3::stimer::STimer<'static>>, | ||
>; | ||
|
||
unsafe fn finalize(self, _s: Self::StaticInput) -> Self::Output { | ||
let grant_cap = create_capability!(capabilities::MemoryAllocationCapability); | ||
|
||
let ble_radio_virtual_alarm = static_init!( | ||
capsules::virtual_alarm::VirtualMuxAlarm<'static, apollo3::stimer::STimer>, | ||
capsules::virtual_alarm::VirtualMuxAlarm::new(self.mux_alarm) | ||
); | ||
|
||
let ble_radio = static_init!( | ||
capsules::ble_advertising_driver::BLE< | ||
'static, | ||
apollo3::ble::Ble, | ||
VirtualMuxAlarm<'static, apollo3::stimer::STimer>, | ||
>, | ||
capsules::ble_advertising_driver::BLE::new( | ||
self.radio, | ||
self.board_kernel.create_grant(&grant_cap), | ||
&mut capsules::ble_advertising_driver::BUF, | ||
ble_radio_virtual_alarm | ||
) | ||
); | ||
kernel::hil::ble_advertising::BleAdvertisementDriver::set_receive_client( | ||
self.radio, ble_radio, | ||
); | ||
kernel::hil::ble_advertising::BleAdvertisementDriver::set_transmit_client( | ||
self.radio, ble_radio, | ||
); | ||
hil::time::Alarm::set_client(ble_radio_virtual_alarm, ble_radio); | ||
|
||
ble_radio | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.