1 /*
2  * Copyright (c) 2019 Brett Witherspoon
3  * Copyright (c) 2020 Friedt Professional Engineering Services, Inc
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_SUBG_H_
9 #define ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_SUBG_H_
10 
11 #include <zephyr/kernel.h>
12 #include <zephyr/net/net_if.h>
13 #include <zephyr/net/ieee802154.h>
14 #include <zephyr/net/ieee802154_radio.h>
15 
16 #include <ti/drivers/rf/RF.h>
17 
18 #include <driverlib/rf_common_cmd.h>
19 #include <driverlib/rf_data_entry.h>
20 #include <driverlib/rf_ieee_cmd.h>
21 #include <driverlib/rf_prop_cmd.h>
22 #include <driverlib/rf_mailbox.h>
23 
24 #define CC13XX_CC26XX_NUM_RX_BUF \
25 	CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF
26 
27 /* Three additional bytes for length, RSSI and status values from CPE */
28 #define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 3)
29 
30 #define CC13XX_CC26XX_TX_BUF_SIZE (IEEE802154_PHY_SUN_FSK_PHR_LEN + IEEE802154_MAX_PHY_PACKET_SIZE)
31 
32 #define CC13XX_CC26XX_INVALID_RSSI INT8_MIN
33 
34 struct ieee802154_cc13xx_cc26xx_subg_data {
35 	/* protects writable data and serializes access to the API */
36 	struct k_sem lock;
37 
38 	RF_Handle rf_handle;
39 	RF_Object rf_object;
40 
41 	struct net_if *iface;
42 	uint8_t mac[8]; /* in big endian */
43 
44 	bool is_up;
45 
46 	dataQueue_t rx_queue;
47 	rfc_dataEntryPointer_t rx_entry[CC13XX_CC26XX_NUM_RX_BUF];
48 	uint8_t rx_data[CC13XX_CC26XX_NUM_RX_BUF][CC13XX_CC26XX_RX_BUF_SIZE];
49 	uint8_t tx_data[CC13XX_CC26XX_TX_BUF_SIZE];
50 
51 	/* Common Radio Commands */
52 	volatile rfc_CMD_FS_t cmd_fs;
53 
54 	/* Sub-GHz Radio Commands */
55 	volatile rfc_CMD_PROP_RX_ADV_t cmd_prop_rx_adv;
56 	volatile rfc_CMD_PROP_TX_ADV_t cmd_prop_tx_adv;
57 	volatile rfc_propRxOutput_t cmd_prop_rx_adv_output;
58 	volatile rfc_CMD_PROP_CS_t cmd_prop_cs;
59 
60 	RF_CmdHandle rx_cmd_handle;
61 };
62 
63 #endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_SUBG_H_ */
64