Lines Matching refs:nrf5_radio
152 struct nrf5_802154_data *nrf5_radio = (struct nrf5_802154_data *)arg1; in nrf5_rx_thread() local
167 rx_frame = k_fifo_get(&nrf5_radio->rx_fifo, K_FOREVER); in nrf5_rx_thread()
193 pkt = net_pkt_rx_alloc_with_buffer(nrf5_radio->iface, pkt_len, in nrf5_rx_thread()
215 if (net_recv_data(nrf5_radio->iface, pkt) < 0) { in nrf5_rx_thread()
225 log_stack_usage(&nrf5_radio->rx_thread); in nrf5_rx_thread()
277 struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); in nrf5_cca() local
287 k_sem_take(&nrf5_radio->cca_wait, K_FOREVER); in nrf5_cca()
289 LOG_DBG("Channel free? %d", nrf5_radio->channel_free); in nrf5_cca()
291 return nrf5_radio->channel_free ? 0 : -EBUSY; in nrf5_cca()
405 static int handle_ack(struct nrf5_802154_data *nrf5_radio) in handle_ack() argument
412 if (nrf5_radio->ack_frame.time == NRF_802154_NO_TIMESTAMP) { in handle_ack()
423 ack_len = nrf5_radio->ack_frame.psdu[0]; in handle_ack()
425 ack_len = nrf5_radio->ack_frame.psdu[0] - IEEE802154_FCS_LENGTH; in handle_ack()
428 ack_pkt = net_pkt_rx_alloc_with_buffer(nrf5_radio->iface, ack_len, in handle_ack()
439 if (net_pkt_write(ack_pkt, nrf5_radio->ack_frame.psdu + 1, in handle_ack()
446 net_pkt_set_ieee802154_lqi(ack_pkt, nrf5_radio->ack_frame.lqi); in handle_ack()
447 net_pkt_set_ieee802154_rssi_dbm(ack_pkt, nrf5_radio->ack_frame.rssi); in handle_ack()
450 net_pkt_set_timestamp_ns(ack_pkt, nrf5_radio->ack_frame.time * NSEC_PER_USEC); in handle_ack()
455 if (ieee802154_handle_ack(nrf5_radio->iface, ack_pkt) != NET_OK) { in handle_ack()
463 nrf_802154_buffer_free_raw(nrf5_radio->ack_frame.psdu); in handle_ack()
464 nrf5_radio->ack_frame.psdu = NULL; in handle_ack()
517 static bool nrf5_tx_at(struct nrf5_802154_data *nrf5_radio, struct net_pkt *pkt, in nrf5_tx_at() argument
578 struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); in nrf5_tx() local
590 nrf5_radio->tx_psdu[0] = payload_len + IEEE802154_FCS_LENGTH; in nrf5_tx()
591 memcpy(nrf5_radio->tx_psdu + 1, payload, payload_len); in nrf5_tx()
594 k_sem_reset(&nrf5_radio->tx_wait); in nrf5_tx()
599 ret = nrf5_tx_immediate(pkt, nrf5_radio->tx_psdu, in nrf5_tx()
604 ret = nrf5_tx_csma_ca(pkt, nrf5_radio->tx_psdu); in nrf5_tx()
614 ret = nrf5_tx_at(nrf5_radio, pkt, nrf5_radio->tx_psdu, mode); in nrf5_tx()
633 k_sem_take(&nrf5_radio->tx_wait, K_FOREVER); in nrf5_tx()
648 memcpy(payload, nrf5_radio->tx_psdu + 1, payload_len); in nrf5_tx()
650 net_pkt_set_ieee802154_frame_secured(pkt, nrf5_radio->tx_frame_is_secured); in nrf5_tx()
651 net_pkt_set_ieee802154_mac_hdr_rdy(pkt, nrf5_radio->tx_frame_mac_hdr_rdy); in nrf5_tx()
653 switch (nrf5_radio->tx_result) { in nrf5_tx()
655 if (nrf5_radio->ack_frame.psdu == NULL) { in nrf5_tx()
660 return handle_ack(nrf5_radio); in nrf5_tx()
791 struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); in nrf5_init() local
796 k_fifo_init(&nrf5_radio->rx_fifo); in nrf5_init()
797 k_sem_init(&nrf5_radio->tx_wait, 0, 1); in nrf5_init()
798 k_sem_init(&nrf5_radio->cca_wait, 0, 1); in nrf5_init()
804 nrf5_radio->rx_on_when_idle = true; in nrf5_init()
807 k_thread_create(&nrf5_radio->rx_thread, nrf5_radio->rx_stack, in nrf5_init()
809 nrf5_rx_thread, nrf5_radio, NULL, NULL, in nrf5_init()
812 k_thread_name_set(&nrf5_radio->rx_thread, "nrf5_rx"); in nrf5_init()
822 struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); in nrf5_iface_init() local
824 nrf5_get_eui64(nrf5_radio->mac); in nrf5_iface_init()
825 net_if_set_link_addr(iface, nrf5_radio->mac, sizeof(nrf5_radio->mac), in nrf5_iface_init()
828 nrf5_radio->iface = iface; in nrf5_iface_init()