zephyr/drivers/ieee802154/ieee802154_cc13xx_cc26xx.h
Piotr Dymacz 22f6c87afc drivers: ieee802154: cc13xx_cc26xx{_subg}: fix reversed extended address
Based on the 'Technical Reference Manual' for CC13x2/CC26x2 SimpleLink
MCU family, the device contains factory pre-programmed 64-bit IEEE MAC
address for 802.15.4 radio inside two FCFG 32-bit registers:

  1. MAC_15_4_0: first 32-bit of the 64-bit IEEE MAC address
  2. MAC_15_4_1:  last 32-bit of the 64-bit IEEE MAC address

The way current version of the driver setups the address results in
incorrect bytes order (the address is reversed):

  uart:~$ ieee802154 get_ext_addr
  Extended address: AF:03:B7:25:00:4B:12:00

This fixes the problem in both drivers (also in the Sub-GHz version)
which results in use of proper EUI-64 address:

  uart:~$ ieee802154 get_ext_addr
  Extended address: 00:12:4B:00:25:B7:03:AF

IEEE MAC address was confirmed with UniFlash, nRF Sniffer for 802.15.4
and IEEE OUI database (00:12:4B is one of registered OUI for Texas
Instruments).

To prevent confusion in future, short notice about bytes order for
'mac' field in driver's data structures was also included.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-08-30 10:23:50 +02:00

89 lines
2.9 KiB
C

/*
* Copyright (c) 2019 Brett Witherspoon
*
* SPDX-License-Identifier: Apache-2.0
*
* References are to the IEEE 802.15.4-2020 standard.
*/
#ifndef ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_
#define ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_
#include <zephyr/kernel.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/ieee802154.h>
#include <zephyr/net/ieee802154_radio.h>
#include <ti/drivers/rf/RF.h>
#include <driverlib/rf_common_cmd.h>
#include <driverlib/rf_data_entry.h>
#include <driverlib/rf_ieee_cmd.h>
#include <driverlib/rf_mailbox.h>
/* For O-QPSK the physical and MAC timing symbol rates are the same, see section 12.3.3. */
#define IEEE802154_2450MHZ_OQPSK_SYMBOLS_PER_SECOND \
IEEE802154_PHY_SYMBOLS_PER_SECOND(IEEE802154_PHY_OQPSK_2450MHZ_SYMBOL_PERIOD_US)
/* PHY PIB attribute phyCcaMode - CCA Mode 3: Carrier sense with energy above threshold, see
* section 11.3, table 11-2 and section 10.2.8
*/
#define IEEE802154_PHY_CCA_MODE 3
#define IEEE802154_PHY_SHR_DURATION 10 /* in symbols, 8 preamble and 2 SFD, see section 12.1.2 */
#define IEEE802154_PHY_SYMBOLS_PER_OCTET 2 /* see section 12.2.1 */
/* ACK is 2 bytes for PHY header + 2 bytes MAC header + 2 bytes MAC footer */
#define IEEE802154_ACK_FRAME_OCTETS 6
/* IEEE 802.15.4-2006 MAC PIB attributes (7.4.2)
*
* The macAckWaitDuration attribute does not include aUnitBackoffPeriod for
* non-beacon enabled PANs (See IEEE 802.15.4-2006 7.5.6.4.2)
*/
#define IEEE802154_MAC_ACK_WAIT_DURATION \
(IEEE802154_PHY_A_TURNAROUND_TIME_DEFAULT + IEEE802154_PHY_SHR_DURATION + \
IEEE802154_ACK_FRAME_OCTETS * IEEE802154_PHY_SYMBOLS_PER_OCTET)
#define CC13XX_CC26XX_RAT_CYCLES_PER_SECOND 4000000
#define CC13XX_CC26XX_NUM_RX_BUF 2
/* Three additional bytes for length, RSSI and correlation values from CPE. */
#define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 3)
#define CC13XX_CC26XX_CPE0_IRQ (INT_RFC_CPE_0 - 16)
#define CC13XX_CC26XX_CPE1_IRQ (INT_RFC_CPE_1 - 16)
#define CC13XX_CC26XX_RECEIVER_SENSITIVITY -100
#define CC13XX_CC26XX_INVALID_RSSI INT8_MIN
struct ieee802154_cc13xx_cc26xx_data {
RF_Handle rf_handle;
RF_Object rf_object;
struct net_if *iface;
uint8_t mac[8]; /* in big endian */
struct k_mutex tx_mutex;
dataQueue_t rx_queue;
rfc_dataEntryPointer_t rx_entry[CC13XX_CC26XX_NUM_RX_BUF];
uint8_t rx_data[CC13XX_CC26XX_NUM_RX_BUF]
[CC13XX_CC26XX_RX_BUF_SIZE] __aligned(4);
volatile rfc_CMD_FS_t cmd_fs;
volatile rfc_CMD_IEEE_CCA_REQ_t cmd_ieee_cca_req;
volatile rfc_CMD_IEEE_RX_t cmd_ieee_rx;
volatile rfc_CMD_IEEE_CSMA_t cmd_ieee_csma;
volatile rfc_CMD_IEEE_TX_t cmd_ieee_tx;
volatile rfc_CMD_IEEE_RX_ACK_t cmd_ieee_rx_ack;
volatile rfc_CMD_RADIO_SETUP_t cmd_radio_setup;
volatile int16_t saved_cmdhandle;
};
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_CC13XX_CC26XX_H_ */