1
0
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:
Leandro Lanzieri 2022-03-10 12:03:26 +01:00 committed by MrKevinWeiss
parent e3ec242ecf
commit 4a3231f763
No known key found for this signature in database
GPG Key ID: 4B69974722CBEEAE
4 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -328,6 +328,7 @@ typedef enum {
NETDEV_W5100,
NETDEV_ENCX24J600,
NETDEV_ATWINC15X0,
NETDEV_KW2XRF,
/* add more if needed */
} netdev_type_t;
/** @} */

View File

@ -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)

View File

@ -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);