mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/kw2xrf: add setup function with global index
This index is used to register the network device.
This commit is contained in:
parent
e3ec242ecf
commit
4a3231f763
@ -138,8 +138,10 @@ typedef struct {
|
||||
*
|
||||
* @param[out] dev device descriptor
|
||||
* @param[in] params parameters for device initialization
|
||||
* @param[in] index index of @p params in a global parameter struct array.
|
||||
* If initialized manually, pass a unique identifier instead.
|
||||
*/
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params);
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params, uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Initialize the given KW2XRF device
|
||||
|
@ -328,6 +328,7 @@ typedef enum {
|
||||
NETDEV_W5100,
|
||||
NETDEV_ENCX24J600,
|
||||
NETDEV_ATWINC15X0,
|
||||
NETDEV_KW2XRF,
|
||||
/* add more if needed */
|
||||
} netdev_type_t;
|
||||
/** @} */
|
||||
|
@ -54,7 +54,7 @@ static void kw2xrf_set_address(kw2xrf_t *dev)
|
||||
kw2xrf_set_addr_short(dev, ntohs(addr_long.uint16[0].u16));
|
||||
}
|
||||
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params)
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params, uint8_t index)
|
||||
{
|
||||
netdev_t *netdev = &dev->netdev.netdev;
|
||||
|
||||
@ -71,6 +71,9 @@ void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params)
|
||||
kw2xrf_clear_dreg_bit(dev, MKW2XDM_PHY_CTRL2, MKW2XDM_PHY_CTRL2_RXMSK);
|
||||
kw2xrf_clear_dreg_bit(dev, MKW2XDM_PHY_CTRL2, MKW2XDM_PHY_CTRL2_TXMSK);
|
||||
DEBUG("[kw2xrf] setup finished\n");
|
||||
|
||||
/* register with netdev */
|
||||
netdev_register(netdev, NETDEV_KW2XRF, index);
|
||||
}
|
||||
|
||||
int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb)
|
||||
|
@ -51,7 +51,7 @@ void auto_init_kw2xrf(void)
|
||||
const kw2xrf_params_t *p = &kw2xrf_params[i];
|
||||
|
||||
LOG_DEBUG("[auto_init_netif] initializing kw2xrf #%u\n", i);
|
||||
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p);
|
||||
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p, i);
|
||||
gnrc_netif_ieee802154_create(&_netif[i], _kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
|
||||
KW2XRF_MAC_PRIO, "kw2xrf",
|
||||
&kw2xrf_devs[i].netdev.netdev);
|
||||
|
Loading…
Reference in New Issue
Block a user