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

sx127x: make use of netdev_register()

Call netdev_register() in sx127x_setup()
and pass the index in auto_init_sx127x()
and semtech_loramac_init()
This commit is contained in:
Fabian Hüßler 2020-12-01 11:38:17 +01:00
parent 8ca2e09d95
commit c526a34770
4 changed files with 7 additions and 4 deletions

View File

@ -256,8 +256,10 @@ typedef void (sx127x_dio_irq_handler_t)(sx127x_t *dev);
*
* @param[in] 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 sx127x_setup(sx127x_t *dev, const sx127x_params_t *params);
void sx127x_setup(sx127x_t *dev, const sx127x_params_t *params, uint8_t index);
/**
* @brief Resets the SX127X

View File

@ -73,11 +73,12 @@ static void sx127x_on_dio1_isr(void *arg);
static void sx127x_on_dio2_isr(void *arg);
static void sx127x_on_dio3_isr(void *arg);
void sx127x_setup(sx127x_t *dev, const sx127x_params_t *params)
void sx127x_setup(sx127x_t *dev, const sx127x_params_t *params, uint8_t index)
{
netdev_t *netdev = (netdev_t*) dev;
netdev->driver = &sx127x_driver;
dev->params = *params;
netdev_register(&dev->netdev, NETDEV_SX127X, index);
}
int sx127x_reset(const sx127x_t *dev)

View File

@ -830,7 +830,7 @@ void *_semtech_loramac_event_loop(void *arg)
int semtech_loramac_init(semtech_loramac_t *mac)
{
sx127x_setup(&sx127x, &sx127x_params[0]);
sx127x_setup(&sx127x, &sx127x_params[0], 0);
sx127x.netdev.driver = &sx127x_driver;
sx127x.netdev.event_callback = _semtech_loramac_event_cb;

View File

@ -57,7 +57,7 @@ void auto_init_sx127x(void)
LOG_DEBUG("[auto_init_netif] initializing sx1276 #%u\n", i);
#endif
sx127x_setup(&sx127x_devs[i], &sx127x_params[i]);
sx127x_setup(&sx127x_devs[i], &sx127x_params[i], i);
if (IS_USED(MODULE_GNRC_NETIF_LORAWAN)) {
/* Currently only one lora device is supported */
assert(SX127X_NUMOF == 1);