2017-02-06 19:42:34 +08:00
|
|
|
/* ieee802154_nrf5.h - nRF5 802.15.4 driver */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_
|
|
|
|
#define ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_
|
2017-02-06 19:42:34 +08:00
|
|
|
|
2019-01-17 21:12:27 +08:00
|
|
|
#include "nrf_802154_config.h"
|
2017-02-06 19:42:34 +08:00
|
|
|
|
|
|
|
#define NRF5_FCS_LENGTH (2)
|
|
|
|
#define NRF5_PSDU_LENGTH (125)
|
|
|
|
#define NRF5_PHR_LENGTH (1)
|
|
|
|
|
2019-01-17 21:12:27 +08:00
|
|
|
struct nrf5_802154_rx_frame {
|
|
|
|
void *fifo_reserved; /* 1st word reserved for use by fifo. */
|
|
|
|
u8_t *psdu; /* Pointer to a received frame. */
|
|
|
|
u8_t lqi; /* Last received frame LQI value. */
|
|
|
|
s8_t rssi; /* Last received frame RSSI value. */
|
|
|
|
};
|
|
|
|
|
2017-02-06 19:42:34 +08:00
|
|
|
struct nrf5_802154_data {
|
|
|
|
/* Pointer to the network interface. */
|
|
|
|
struct net_if *iface;
|
2019-01-17 21:12:27 +08:00
|
|
|
|
2017-02-06 19:42:34 +08:00
|
|
|
/* 802.15.4 HW address. */
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t mac[8];
|
2019-01-17 21:12:27 +08:00
|
|
|
|
2017-02-06 19:42:34 +08:00
|
|
|
/* RX thread stack. */
|
2017-06-03 05:08:45 +08:00
|
|
|
K_THREAD_STACK_MEMBER(rx_stack, CONFIG_IEEE802154_NRF5_RX_STACK_SIZE);
|
2019-01-17 21:12:27 +08:00
|
|
|
|
|
|
|
/* RX thread control block. */
|
2017-05-10 03:15:00 +08:00
|
|
|
struct k_thread rx_thread;
|
2017-02-06 19:42:34 +08:00
|
|
|
|
2019-01-17 21:12:27 +08:00
|
|
|
/* RX fifo queue. */
|
|
|
|
struct k_fifo rx_fifo;
|
|
|
|
|
|
|
|
/* Buffers for passing received frame pointers and data to the
|
|
|
|
* RX thread via rx_fifo object.
|
|
|
|
*/
|
|
|
|
struct nrf5_802154_rx_frame rx_frames[NRF_802154_RX_BUFFERS];
|
|
|
|
|
2017-02-06 19:42:34 +08:00
|
|
|
/* CCA complete sempahore. Unlocked when CCA is complete. */
|
|
|
|
struct k_sem cca_wait;
|
2019-01-17 21:12:27 +08:00
|
|
|
|
|
|
|
/* CCA result. Holds information whether channel is free or not. */
|
|
|
|
bool channel_free;
|
|
|
|
|
2017-02-06 19:42:34 +08:00
|
|
|
/* TX synchronization semaphore. Unlocked when frame has been
|
2019-01-17 21:12:27 +08:00
|
|
|
* sent or send procedure failed.
|
2017-02-06 19:42:34 +08:00
|
|
|
*/
|
|
|
|
struct k_sem tx_wait;
|
|
|
|
|
2019-01-17 21:12:27 +08:00
|
|
|
/* TX buffer. First byte is PHR (length), remaining bytes are
|
|
|
|
* MPDU data.
|
|
|
|
*/
|
|
|
|
u8_t tx_psdu[NRF5_PHR_LENGTH + NRF5_PSDU_LENGTH + NRF5_FCS_LENGTH];
|
2017-02-06 19:42:34 +08:00
|
|
|
|
2019-01-17 21:12:27 +08:00
|
|
|
/* TX result, updated in radio transmit callbacks. */
|
|
|
|
u8_t tx_result;
|
2017-02-06 19:42:34 +08:00
|
|
|
|
2019-04-11 19:29:25 +08:00
|
|
|
/* A buffer for the received ACK frame. psdu pointer be NULL if no
|
|
|
|
* ACK was requested/received.
|
2019-01-17 21:12:27 +08:00
|
|
|
*/
|
2019-04-11 19:29:25 +08:00
|
|
|
struct nrf5_802154_rx_frame ack_frame;
|
2017-02-06 19:42:34 +08:00
|
|
|
};
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_ */
|