1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 23:41:18 +01:00

Merge pull request #15537 from fabian18/sx127x_netdev_register

drivers/sx127x: use netdev_register()
This commit is contained in:
Marian Buschsieweke 2020-12-01 21:38:38 +01:00 committed by GitHub
commit 5c70345aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

View File

@ -292,6 +292,7 @@ typedef enum {
NETDEV_NRF802154,
NETDEV_STM32_ETH,
NETDEV_CC110X,
NETDEV_SX127X,
/* add more if needed */
} netdev_type_t;
/** @} */

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