1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/dose: register driver with netdev

This commit is contained in:
Benjamin Valentin 2020-07-07 20:51:43 +02:00 committed by Benjamin Valentin
parent 4f19b54b7b
commit decadc41a0
4 changed files with 8 additions and 4 deletions

View File

@ -49,7 +49,6 @@ static int _send(netdev_t *dev, const iolist_t *iolist);
static int _get(netdev_t *dev, netopt_t opt, void *value, size_t max_len);
static int _set(netdev_t *dev, netopt_t opt, const void *value, size_t len);
static int _init(netdev_t *dev);
void dose_setup(dose_t *ctx, const dose_params_t *params);
static uint16_t crc16_update(uint16_t crc, uint8_t octet)
{
@ -540,7 +539,7 @@ static const netdev_driver_t netdev_driver_dose = {
.set = _set
};
void dose_setup(dose_t *ctx, const dose_params_t *params)
void dose_setup(dose_t *ctx, const dose_params_t *params, uint8_t index)
{
static const xtimer_ticks32_t min_timeout = {.ticks32 = XTIMER_BACKOFF};
@ -557,6 +556,8 @@ void dose_setup(dose_t *ctx, const dose_params_t *params)
gpio_irq_disable(ctx->sense_pin);
}
netdev_register(&ctx->netdev, NETDEV_DOSE, index);
assert(sizeof(ctx->mac_addr.uint8) == ETHERNET_ADDR_LEN);
luid_get_eui48(&ctx->mac_addr);
DEBUG("dose dose_setup(): mac addr %02x:%02x:%02x:%02x:%02x:%02x\n",

View File

@ -175,8 +175,10 @@ typedef struct {
* @brief Setup a DOSE based device state
* @param[out] dev Handle of the device to initialize
* @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 dose_setup(dose_t *dev, const dose_params_t *params);
void dose_setup(dose_t *dev, const dose_params_t *params, uint8_t index);
#ifdef __cplusplus
}

View File

@ -280,6 +280,7 @@ typedef enum {
NETDEV_ANY = 0, /**< Will match any device type */
NETDEV_AT86RF215,
NETDEV_AT86RF2XX,
NETDEV_DOSE,
/* add more if needed */
} netdev_type_t;
/** @} */

View File

@ -44,7 +44,7 @@ void auto_init_dose(void)
for (unsigned i = 0; i < DOSE_NUM; i++) {
LOG_DEBUG("[auto_init_netif] initializing dose #%d.\n", i);
dose_setup(&dose[i], &dose_params[i]);
dose_setup(&dose[i], &dose_params[i], i);
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], DOSE_MAC_STACKSIZE,
DOSE_MAC_PRIO, "dose", (netdev_t *)&dose[i]);
}