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

drivers/encx24j600: introduce setup function with index

This commit is contained in:
Leandro Lanzieri 2022-03-16 15:02:25 +01:00
parent 5f7a906b95
commit a2e5934ec9
No known key found for this signature in database
GPG Key ID: F4E9A721761C7593
4 changed files with 8 additions and 3 deletions

View File

@ -81,13 +81,15 @@ static inline void unlock(encx24j600_t *dev) {
spi_release(dev->spi);
}
void encx24j600_setup(encx24j600_t *dev, const encx24j600_params_t *params)
void encx24j600_setup(encx24j600_t *dev, const encx24j600_params_t *params, uint8_t index)
{
dev->netdev.driver = &netdev_driver_encx24j600;
dev->spi = params->spi;
dev->cs = params->cs_pin;
dev->int_pin = params->int_pin;
dev->rx_next_ptr = RX_BUFFER_START;
netdev_register(&dev->netdev, NETDEV_ENCX24J600, index);
}
static void encx24j600_isr(void *arg)

View File

@ -59,8 +59,10 @@ typedef struct {
*
* @param[out] dev the 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 encx24j600_setup(encx24j600_t *dev, const encx24j600_params_t *params);
void encx24j600_setup(encx24j600_t *dev, const encx24j600_params_t *params, uint8_t index);
#ifdef __cplusplus
}

View File

@ -325,6 +325,7 @@ typedef enum {
NETDEV_SLIPDEV,
NETDEV_TAP,
NETDEV_W5100,
NETDEV_ENCX24J600,
/* add more if needed */
} netdev_type_t;
/** @} */

View File

@ -58,7 +58,7 @@ void auto_init_encx24j600(void)
LOG_DEBUG("[auto_init_netif] initializing encx24j600 #%u\n", i);
/* setup netdev device */
encx24j600_setup(&encx24j600[i], &encx24j600_params[i]);
encx24j600_setup(&encx24j600[i], &encx24j600_params[i], i);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], ENCX24J600_MAC_STACKSIZE,