use nrf52840_hal::target::{FICR, RADIO, TIMER0}; use rubble::link::{AddressKind, DeviceAddress, HardwareInterface, LinkLayer, MIN_PDU_BUF}; use rubble_nrf52::{radio::BleRadio, timer::BleTimer}; struct NRF52840 {} impl HardwareInterface for NRF52840 { type Timer = BleTimer; type Tx = BleRadio; } pub fn setup(radio: RADIO, timer: TIMER0, ficr: FICR) { // make sure hfclock is started for timer0 to work at the right // resolution. let ble_timer = BleTimer::init(timer); let mut devaddr = [0u8; 6]; let devaddr_lo = ficr.deviceaddr[0].read().bits(); let devaddr_hi = ficr.deviceaddr[1].read().bits(); devaddr[..4].clone_from_slice(&devaddr_lo.to_le_bytes()); devaddr[4..].clone_from_slice(&devaddr_hi.to_le_bytes()); let addrkind = if ficr.deviceaddrtype.read().deviceaddrtype().is_public() { AddressKind::Public } else { AddressKind::Random }; let addr = DeviceAddress::new(devaddr, addrkind); let mut _ll = LinkLayer::::new(addr, ble_timer); }