Merge pull request #16296 from fabian18/nrf24l01p_ng_eui_get
drivers/nrf24l01p_ng: add hook nrf24l01p_ng_eui_get()
This commit is contained in:
commit
855a6fa36a
@ -424,6 +424,17 @@ int nrf24l01p_ng_set_state(nrf24l01p_ng_t *dev, nrf24l01p_ng_state_t state);
|
|||||||
*/
|
*/
|
||||||
nrf24l01p_ng_state_t nrf24l01p_ng_get_state(const nrf24l01p_ng_t *dev);
|
nrf24l01p_ng_state_t nrf24l01p_ng_get_state(const nrf24l01p_ng_t *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieve a unique layer-2 address for an nrf24l01p_ng instance
|
||||||
|
*
|
||||||
|
* @note This function has __attribute__((weak)) so you can override this, e.g.
|
||||||
|
* to construct an address. By default @ref luid_get_lb is used.
|
||||||
|
*
|
||||||
|
* @param[in] dev The device descriptor of the transceiver
|
||||||
|
* @param[out] eui Destination to write the address to
|
||||||
|
*/
|
||||||
|
void nrf24l01p_ng_eui_get(const netdev_t *dev, uint8_t *eui);
|
||||||
|
|
||||||
#if IS_USED(MODULE_NRF24L01P_NG_DIAGNOSTICS)
|
#if IS_USED(MODULE_NRF24L01P_NG_DIAGNOSTICS)
|
||||||
/**
|
/**
|
||||||
* @brief Get state variable as a string
|
* @brief Get state variable as a string
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "net/gnrc.h"
|
#include "net/gnrc.h"
|
||||||
|
#include "luid.h"
|
||||||
#include "gnrc_netif_nrf24l01p_ng.h"
|
#include "gnrc_netif_nrf24l01p_ng.h"
|
||||||
#include "nrf24l01p_ng.h"
|
#include "nrf24l01p_ng.h"
|
||||||
|
|
||||||
@ -234,3 +235,13 @@ int gnrc_netif_nrf24l01p_ng_create(gnrc_netif_t *netif, char *stack,
|
|||||||
return gnrc_netif_create(netif, stack, stacksize, priority, name,
|
return gnrc_netif_create(netif, stack, stacksize, priority, name,
|
||||||
dev, &nrf24l01p_ng_netif_ops);
|
dev, &nrf24l01p_ng_netif_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __attribute__((weak)) nrf24l01p_ng_eui_get(const netdev_t *netdev, uint8_t *eui)
|
||||||
|
{
|
||||||
|
(void)netdev;
|
||||||
|
do {
|
||||||
|
luid_get_lb(eui, NRF24L01P_NG_ADDR_WIDTH);
|
||||||
|
}
|
||||||
|
while (eui[NRF24L01P_NG_ADDR_WIDTH - 1] ==
|
||||||
|
((uint8_t[])NRF24L01P_NG_BROADCAST_ADDR)[NRF24L01P_NG_ADDR_WIDTH - 1]);
|
||||||
|
}
|
||||||
|
|||||||
@ -26,9 +26,6 @@
|
|||||||
#include "kernel_defines.h"
|
#include "kernel_defines.h"
|
||||||
#include "iolist.h"
|
#include "iolist.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "luid.h"
|
|
||||||
#include "mutex.h"
|
|
||||||
#include "net/eui64.h"
|
|
||||||
#include "net/netdev.h"
|
#include "net/netdev.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
|
|
||||||
@ -196,12 +193,10 @@ static int _init(netdev_t *netdev)
|
|||||||
/* assign to pipe 0 the broadcast address*/
|
/* assign to pipe 0 the broadcast address*/
|
||||||
nrf24l01p_ng_write_reg(dev, NRF24L01P_NG_REG_RX_ADDR_P0,
|
nrf24l01p_ng_write_reg(dev, NRF24L01P_NG_REG_RX_ADDR_P0,
|
||||||
NRF24L01P_NG_ADDR_P0(dev), aw);
|
NRF24L01P_NG_ADDR_P0(dev), aw);
|
||||||
luid_get_lb(NRF24L01P_NG_ADDR_P1(dev), aw);
|
|
||||||
/* "The LSByte must be unique for all six pipes" [datasheet p.38] */
|
/* "The LSByte must be unique for all six pipes" [datasheet p.38] */
|
||||||
if (NRF24L01P_NG_ADDR_P1(dev)[aw - 1] == bc[aw - 1]) {
|
nrf24l01p_ng_eui_get(&dev->netdev, NRF24L01P_NG_ADDR_P1(dev));
|
||||||
luid_get_lb(NRF24L01P_NG_ADDR_P1(dev), aw);
|
assert(NRF24L01P_NG_ADDR_P1(dev)[aw - 1] != NRF24L01P_NG_ADDR_P0(dev)[aw - 1]);
|
||||||
}
|
/* assign to pipe 1 the "main" listening address */
|
||||||
/* assign to pipe 0 the "main" listening address */
|
|
||||||
nrf24l01p_ng_write_reg(dev, NRF24L01P_NG_REG_RX_ADDR_P1,
|
nrf24l01p_ng_write_reg(dev, NRF24L01P_NG_REG_RX_ADDR_P1,
|
||||||
NRF24L01P_NG_ADDR_P1(dev), aw);
|
NRF24L01P_NG_ADDR_P1(dev), aw);
|
||||||
/* set the address width */
|
/* set the address width */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user