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

drivers/w5100: introduce setup with index

This commit is contained in:
Leandro Lanzieri 2022-03-16 16:53:37 +01:00
parent 530e699de1
commit 5f7a906b95
No known key found for this signature in database
GPG Key ID: F4E9A721761C7593
4 changed files with 14 additions and 3 deletions

View File

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

View File

@ -74,8 +74,13 @@ typedef struct {
*
* This function pre-initializes the netdev structure, saves the configuration
* parameters and finally initializes the SPI bus and the used GPIO pins.
*
* @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 w5100_setup(w5100_t *dev, const w5100_params_t *params);
void w5100_setup(w5100_t *dev, const w5100_params_t *params, uint8_t index);
#ifdef __cplusplus
}

View File

@ -110,8 +110,11 @@ static void extint(void *arg)
netdev_trigger_event_isr(&dev->nd);
}
void w5100_setup(w5100_t *dev, const w5100_params_t *params)
void w5100_setup(w5100_t *dev, const w5100_params_t *params, uint8_t index)
{
assert(dev);
assert(params);
/* initialize netdev structure */
dev->nd.driver = &netdev_driver_w5100;
dev->nd.event_callback = NULL;
@ -123,6 +126,8 @@ void w5100_setup(w5100_t *dev, const w5100_params_t *params)
/* initialize the chip select pin and the external interrupt pin */
spi_init_cs(dev->p.spi, dev->p.cs);
gpio_init_int(dev->p.evt, GPIO_IN, GPIO_FALLING, extint, dev);
netdev_register(&dev->nd, NETDEV_W5100, index);
}
static int init(netdev_t *netdev)

View File

@ -55,7 +55,7 @@ void auto_init_w5100(void)
LOG_DEBUG("[auto_init_netif] initializing w5100 #%u\n", i);
/* setup netdev device */
w5100_setup(&dev[i], &w5100_params[i]);
w5100_setup(&dev[i], &w5100_params[i], i);
/* initialize netdev <-> gnrc adapter state */
gnrc_netif_ethernet_create(&_netif[i], stack[i], MAC_STACKSIZE, MAC_PRIO, "w5100",
&dev[i].nd);