use a real macaddr on the nrf52

This commit is contained in:
geeksville
2020-04-23 16:55:25 -07:00
parent 2fdb75efdf
commit 8f3b33c84c
6 changed files with 84 additions and 17 deletions

View File

@@ -1,4 +1,9 @@
#include <assert.h>
#include <ble_gap.h>
#include <memory.h>
#include <nrf52840.h>
// #define USE_SOFTDEVICE
static inline void debugger_break(void)
{
@@ -10,4 +15,20 @@ static inline void debugger_break(void)
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *failedexpr)
{
debugger_break();
while (1)
;
}
void getMacAddr(uint8_t *dmac)
{
ble_gap_addr_t addr;
#ifdef USE_SOFTDEVICE
uint32_t res = sd_ble_gap_addr_get(&addr);
assert(res == NRF_SUCCESS);
memcpy(dmac, addr.addr, 6);
#else
// FIXME - byte order might be wrong and high bits might be wrong
memcpy(dmac, (const void *)NRF_FICR->DEVICEADDR, 6);
#endif
}