1 /* 2 * Copyright (c) 2019 Brett Witherspoon 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * References are to the IEEE 802.15.4-2020 standard. 7 */ 8 9 #ifndef ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_ 10 #define ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_ 11 12 #include <zephyr/kernel.h> 13 #include <zephyr/net/net_if.h> 14 #include <zephyr/net/ieee802154.h> 15 #include <zephyr/net/ieee802154_radio.h> 16 17 #include <ti/drivers/rf/RF.h> 18 19 #include <driverlib/rf_common_cmd.h> 20 #include <driverlib/rf_data_entry.h> 21 #include <driverlib/rf_ieee_cmd.h> 22 #include <driverlib/rf_mailbox.h> 23 24 /* For O-QPSK the physical and MAC timing symbol rates are the same, see section 12.3.3. */ 25 #define IEEE802154_2450MHZ_OQPSK_SYMBOLS_PER_SECOND \ 26 IEEE802154_PHY_SYMBOLS_PER_SECOND(IEEE802154_PHY_OQPSK_780_TO_2450MHZ_SYMBOL_PERIOD_NS) 27 28 /* PHY PIB attribute phyCcaMode - CCA Mode 3: Carrier sense with energy above threshold, see 29 * section 11.3, table 11-2 and section 10.2.8 30 */ 31 #define IEEE802154_PHY_CCA_MODE 3 32 33 #define IEEE802154_PHY_SHR_DURATION 10 /* in symbols, 8 preamble and 2 SFD, see section 12.1.2 */ 34 35 #define IEEE802154_PHY_SYMBOLS_PER_OCTET 2 /* see section 12.2.1 */ 36 37 /* ACK is 2 bytes for PHY header + 2 bytes MAC header + 2 bytes MAC footer */ 38 #define IEEE802154_ACK_FRAME_OCTETS 6 39 40 /* IEEE 802.15.4-2006 MAC PIB attributes (7.4.2) 41 * 42 * The macAckWaitDuration attribute does not include aUnitBackoffPeriod for 43 * non-beacon enabled PANs (See IEEE 802.15.4-2006 7.5.6.4.2) 44 */ 45 #define IEEE802154_MAC_ACK_WAIT_DURATION \ 46 (IEEE802154_PHY_A_TURNAROUND_TIME_DEFAULT + IEEE802154_PHY_SHR_DURATION + \ 47 IEEE802154_ACK_FRAME_OCTETS * IEEE802154_PHY_SYMBOLS_PER_OCTET) 48 49 #define CC13XX_CC26XX_RAT_CYCLES_PER_SECOND 4000000 50 51 #define CC13XX_CC26XX_NUM_RX_BUF 2 52 53 /* Three additional bytes for length, RSSI and correlation values from CPE. */ 54 #define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 3) 55 56 #define CC13XX_CC26XX_CPE0_IRQ (INT_RFC_CPE_0 - 16) 57 #define CC13XX_CC26XX_CPE1_IRQ (INT_RFC_CPE_1 - 16) 58 59 #define CC13XX_CC26XX_RECEIVER_SENSITIVITY -100 60 #define CC13XX_CC26XX_INVALID_RSSI INT8_MIN 61 62 struct ieee802154_cc13xx_cc26xx_data { 63 RF_Handle rf_handle; 64 RF_Object rf_object; 65 66 struct net_if *iface; 67 68 uint8_t mac[8]; /* in big endian */ 69 70 struct k_mutex tx_mutex; 71 72 dataQueue_t rx_queue; 73 rfc_dataEntryPointer_t rx_entry[CC13XX_CC26XX_NUM_RX_BUF]; 74 uint8_t rx_data[CC13XX_CC26XX_NUM_RX_BUF] 75 [CC13XX_CC26XX_RX_BUF_SIZE] __aligned(4); 76 77 volatile rfc_CMD_FS_t cmd_fs; 78 volatile rfc_CMD_IEEE_CCA_REQ_t cmd_ieee_cca_req; 79 volatile rfc_CMD_IEEE_RX_t cmd_ieee_rx; 80 volatile rfc_CMD_IEEE_CSMA_t cmd_ieee_csma; 81 volatile rfc_CMD_IEEE_TX_t cmd_ieee_tx; 82 volatile rfc_CMD_IEEE_RX_ACK_t cmd_ieee_rx_ack; 83 volatile rfc_CMD_RADIO_SETUP_t cmd_radio_setup; 84 85 volatile int16_t saved_cmdhandle; 86 }; 87 88 #endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_ */ 89