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
|
|
|
|
2017-06-17 23:30:47 +08:00
|
|
|
#include <linker/sections.h>
|
2017-02-06 19:42:34 +08:00
|
|
|
#include <atomic.h>
|
|
|
|
|
|
|
|
#define NRF5_FCS_LENGTH (2)
|
|
|
|
#define NRF5_PSDU_LENGTH (125)
|
|
|
|
#define NRF5_PHR_LENGTH (1)
|
|
|
|
|
|
|
|
struct nrf5_802154_data {
|
|
|
|
/* Pointer to the network interface. */
|
|
|
|
struct net_if *iface;
|
|
|
|
/* Pointer to a received frame. */
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t *rx_psdu;
|
2017-02-06 19:42:34 +08:00
|
|
|
/* TX buffer. First byte is PHR (length), remaining bytes are
|
|
|
|
* MPDU data.
|
|
|
|
*/
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t tx_psdu[NRF5_PHR_LENGTH + NRF5_PSDU_LENGTH];
|
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];
|
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);
|
2017-05-10 03:15:00 +08:00
|
|
|
/* RX thread control block */
|
|
|
|
struct k_thread rx_thread;
|
2017-02-06 19:42:34 +08:00
|
|
|
|
|
|
|
/* CCA complete sempahore. Unlocked when CCA is complete. */
|
|
|
|
struct k_sem cca_wait;
|
|
|
|
/* RX synchronization semaphore. Unlocked when frame has been
|
|
|
|
* received.
|
|
|
|
*/
|
|
|
|
struct k_sem rx_wait;
|
|
|
|
/* TX synchronization semaphore. Unlocked when frame has been
|
|
|
|
* sent or CCA failed.
|
|
|
|
*/
|
|
|
|
struct k_sem tx_wait;
|
|
|
|
/* TX result. Set to 1 on success, 0 otherwise. */
|
|
|
|
bool tx_success;
|
|
|
|
|
|
|
|
/* CCA channel energy. Unit as per 802.15.4-2006 specification. */
|
2017-04-21 22:27:50 +08:00
|
|
|
s8_t channel_ed;
|
2017-02-06 19:42:34 +08:00
|
|
|
|
|
|
|
/* TX power, in dBm, to be used when sending a frame. */
|
2017-04-21 22:27:50 +08:00
|
|
|
s8_t txpower;
|
2017-02-06 19:42:34 +08:00
|
|
|
/* 802.15.4 channel to be used when sending a frame. */
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t channel;
|
2017-02-06 19:42:34 +08:00
|
|
|
|
|
|
|
/* Last received frame LQI value. */
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t lqi;
|
2017-02-06 19:42:34 +08:00
|
|
|
/* Last received frame RSSI value. */
|
2017-04-21 22:27:50 +08:00
|
|
|
s8_t rssi;
|
2017-02-06 19:42:34 +08:00
|
|
|
};
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_ */
|