mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sx126x: avoid explicit cast to netdev
This commit is contained in:
parent
af5622cd78
commit
c9ee5fb76a
@ -72,7 +72,7 @@ const sx126x_pa_cfg_params_t sx1261_pa_cfg = {
|
||||
|
||||
void sx126x_setup(sx126x_t *dev, const sx126x_params_t *params, uint8_t index)
|
||||
{
|
||||
netdev_t *netdev = (netdev_t *)dev;
|
||||
netdev_t *netdev = &dev->netdev;
|
||||
|
||||
netdev->driver = &sx126x_driver;
|
||||
dev->params = (sx126x_params_t *)params;
|
||||
@ -136,7 +136,7 @@ static void sx126x_init_default_config(sx126x_t *dev)
|
||||
|
||||
static void _dio1_isr(void *arg)
|
||||
{
|
||||
netdev_trigger_event_isr((netdev_t *)arg);
|
||||
netdev_trigger_event_isr(arg);
|
||||
}
|
||||
|
||||
int sx126x_init(sx126x_t *dev)
|
||||
|
@ -39,7 +39,7 @@ const uint8_t sx126x_max_sf = LORA_SF12;
|
||||
|
||||
static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
{
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
|
||||
netopt_state_t state;
|
||||
|
||||
@ -78,10 +78,10 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
{
|
||||
DEBUG("[sx126x] netdev: read received data.\n");
|
||||
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
uint8_t size = 0;
|
||||
|
||||
netdev_lora_rx_info_t *packet_info = (netdev_lora_rx_info_t *)info;
|
||||
netdev_lora_rx_info_t *packet_info = info;
|
||||
|
||||
if (packet_info) {
|
||||
sx126x_pkt_status_lora_t pkt_status;
|
||||
@ -111,7 +111,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
|
||||
static int _init(netdev_t *netdev)
|
||||
{
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
|
||||
/* Launch initialization of driver and device */
|
||||
DEBUG("[sx126x] netdev: initializing driver...\n");
|
||||
@ -126,7 +126,7 @@ static int _init(netdev_t *netdev)
|
||||
|
||||
static void _isr(netdev_t *netdev)
|
||||
{
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
|
||||
sx126x_irq_mask_t irq_mask;
|
||||
|
||||
@ -205,7 +205,7 @@ static int _get_state(sx126x_t *dev, void *val)
|
||||
static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
|
||||
{
|
||||
(void)max_len; /* unused when compiled without debug, assert empty */
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -316,7 +316,7 @@ static int _set_state(sx126x_t *dev, netopt_state_t state)
|
||||
static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
|
||||
{
|
||||
(void)len; /* unused when compiled without debug, assert empty */
|
||||
sx126x_t *dev = (sx126x_t *)netdev;
|
||||
sx126x_t *dev = container_of(netdev, sx126x_t, netdev);
|
||||
int res = -ENOTSUP;
|
||||
|
||||
if (dev == NULL) {
|
||||
|
@ -95,7 +95,7 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
|
||||
void *_recv_thread(void *arg)
|
||||
{
|
||||
netdev_t *netdev = (netdev_t *)arg;
|
||||
netdev_t *netdev = arg;
|
||||
|
||||
static msg_t _msg_queue[SX126X_MSG_QUEUE];
|
||||
|
||||
@ -295,7 +295,7 @@ int sx126x_cmd(int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
netdev_t *netdev = (netdev_t *)&sx126x;
|
||||
netdev_t *netdev = &sx126x.netdev;
|
||||
|
||||
if (!strcmp("get", argv[1])) {
|
||||
return sx126x_get_cmd(netdev, argc, argv);
|
||||
@ -321,7 +321,7 @@ static const shell_command_t shell_commands[] = {
|
||||
int main(void)
|
||||
{
|
||||
sx126x_setup(&sx126x, &sx126x_params[0], 0);
|
||||
netdev_t *netdev = (netdev_t *)&sx126x;
|
||||
netdev_t *netdev = &sx126x.netdev;
|
||||
|
||||
netdev->driver = &sx126x_driver;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user