Lines Matching full:mcr20a
1 /* ieee802154_mcr20a.c - NXP MCR20A driver */
497 * RF = (LQI – 295.4) / 2.84 (MCR20A Reference Manual) in mcr20a_get_rssi()
517 struct mcr20a_context *mcr20a = dev->data; in get_mac() local
519 sys_rand_get(mcr20a->mac_addr, sizeof(mcr20a->mac_addr)); in get_mac()
521 mcr20a->mac_addr[0] = (mcr20a->mac_addr[0] & ~0x01) | 0x02; in get_mac()
523 return mcr20a->mac_addr; in get_mac()
561 struct mcr20a_context *mcr20a = dev->data; in mcr20a_rx() local
569 pkt = net_pkt_rx_alloc_with_buffer(mcr20a->iface, pkt_len, in mcr20a_rx()
582 if (ieee802154_handle_ack(mcr20a->iface, pkt) == NET_OK) { in mcr20a_rx()
595 if (net_recv_data(mcr20a->iface, pkt) < 0) { in mcr20a_rx()
600 log_stack_usage(&mcr20a->mcr20a_rx_thread); in mcr20a_rx()
617 struct mcr20a_context *mcr20a = dev->data; in irqsts1_event() local
640 atomic_set(&mcr20a->seq_retval, -EBUSY); in irqsts1_event()
647 atomic_set(&mcr20a->seq_retval, 0); in irqsts1_event()
669 atomic_set(&mcr20a->seq_retval, -EBUSY); in irqsts1_event()
678 atomic_set(&mcr20a->seq_retval, 0); in irqsts1_event()
705 struct mcr20a_context *mcr20a = dev->data; in irqsts3_event() local
714 atomic_set(&mcr20a->seq_retval, -EBUSY); in irqsts3_event()
736 struct mcr20a_context *mcr20a = dev->data; in mcr20a_thread_main() local
742 k_sem_take(&mcr20a->isr_sem, K_FOREVER); in mcr20a_thread_main()
744 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_thread_main()
800 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_thread_main()
803 k_sem_give(&mcr20a->seq_sync); in mcr20a_thread_main()
811 struct mcr20a_context *mcr20a = CONTAINER_OF(cb, in irqb_int_handler() local
814 k_sem_give(&mcr20a->isr_sem); in irqb_int_handler()
831 struct mcr20a_context *mcr20a = dev->data; in setup_gpio_callbacks() local
833 gpio_init_callback(&mcr20a->irqb_cb, in setup_gpio_callbacks()
836 gpio_add_callback(config->irq_gpio.port, &mcr20a->irqb_cb); in setup_gpio_callbacks()
864 struct mcr20a_context *mcr20a = dev->data; in mcr20a_cca() local
867 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_cca()
874 k_sem_init(&mcr20a->seq_sync, 0, 1); in mcr20a_cca()
893 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_cca()
894 retval = k_sem_take(&mcr20a->seq_sync, in mcr20a_cca()
903 return mcr20a->seq_retval; in mcr20a_cca()
906 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_cca()
912 struct mcr20a_context *mcr20a = dev->data; in mcr20a_set_channel() local
922 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_set_channel()
960 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_channel()
967 struct mcr20a_context *mcr20a = dev->data; in mcr20a_set_pan_id() local
970 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_set_pan_id()
974 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_pan_id()
978 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_pan_id()
987 struct mcr20a_context *mcr20a = dev->data; in mcr20a_set_short_addr() local
990 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_set_short_addr()
994 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_short_addr()
998 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_short_addr()
1007 struct mcr20a_context *mcr20a = dev->data; in mcr20a_set_ieee_addr() local
1009 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_set_ieee_addr()
1013 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_ieee_addr()
1017 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_ieee_addr()
1049 struct mcr20a_context *mcr20a = dev->data; in mcr20a_set_txpower() local
1052 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_set_txpower()
1065 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_txpower()
1069 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_set_txpower()
1112 struct mcr20a_context *mcr20a = dev->data; in mcr20a_tx() local
1122 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_tx()
1141 k_sem_init(&mcr20a->seq_sync, 0, 1); in mcr20a_tx()
1153 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_tx()
1154 retval = k_sem_take(&mcr20a->seq_sync, in mcr20a_tx()
1163 return mcr20a->seq_retval; in mcr20a_tx()
1166 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_tx()
1172 struct mcr20a_context *mcr20a = dev->data; in mcr20a_start() local
1176 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_start()
1180 LOG_ERR("Error starting MCR20A"); in mcr20a_start()
1218 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_start()
1224 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_start()
1230 struct mcr20a_context *mcr20a = dev->data; in mcr20a_stop() local
1233 k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER); in mcr20a_stop()
1258 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_stop()
1263 k_mutex_unlock(&mcr20a->phy_mutex); in mcr20a_stop()
1264 LOG_ERR("Error stopping MCR20A"); in mcr20a_stop()
1396 struct mcr20a_context *mcr20a = dev->data; in mcr20a_init() local
1398 k_mutex_init(&mcr20a->phy_mutex); in mcr20a_init()
1399 k_sem_init(&mcr20a->isr_sem, 0, 1); in mcr20a_init()
1401 LOG_DBG("\nInitialize MCR20A Transceiver\n"); in mcr20a_init()
1416 LOG_ERR("Configuring MCR20A failed"); in mcr20a_init()
1420 k_thread_create(&mcr20a->mcr20a_rx_thread, mcr20a->mcr20a_rx_stack, in mcr20a_init()
1424 k_thread_name_set(&mcr20a->mcr20a_rx_thread, "mcr20a_rx"); in mcr20a_init()
1432 struct mcr20a_context *mcr20a = dev->data; in mcr20a_iface_init() local
1437 mcr20a->iface = iface; in mcr20a_iface_init()