IEEE 802.15.4 MAC API Exported Functions

group MAC_API_Exported_Functions

MAC Exported Functions.

Functions

void mac_attribute_init(mac_attribute_t *attribute)

Initialize MAC attribute.

Parameters:

attribute -- [inout] The mac_attribute_t pointer to be initialized.

void mac_callback_register(mac_intr_callback_t intr_cb, mac_edscan_lv2dbm_callback_t lv2dbm_cb, mac_gnt_entry_callback_t gnt_entry_cb, modem_cca_comb_callback_t cca_comb_cb)

Register MAC callback functions.

Parameters:
  • intr_cb -- [in] Interrupt handler callback function.

  • lv2dbm_cb -- [in] Translate EDScan level to dbm callback function.

  • gnt_entry_cb -- [in] Set gnt entry priority callback function.

  • cca_comb_cb -- [in] Modem CCA combine callback function.

void mac_init(mac_driver_t *ptr_drv, mac_attribute_t *attribute)

Initialize mac layer with attributes.

Parameters:
  • ptr_drv -- [inout] The mac_driver_t pointer to be initialized, mac_driver_t should be defined in data section.

  • attribute -- [in] The mac_attribute_t pointer pointing to structure with default value.

void mac_init_ext(void)

Additional initialize step.

void mac_cs_enter(void)

Enter MAC layer driver critical section (disables MAC interrupts).

void mac_cs_exit(void)

Exit MAC layer driver critical section (disables MAC interrupts).

uint8_t mac_enabled_check(void)

Check if MAC clock is enabled.

Return values:
  • 1 -- MAC clock is enabled.

  • 0 -- MAC clock is disabled.

Returns:

The status of MAC clock.

void mac_enable(void)

Enable MAC clock.

void mac_disable(void)

Disable MAC clock.

void mac_btclk_get(mac_bt_clk_t *pbt_clk)

Get current BT native clock and clock counter value.

Parameters:

pbt_clk -- [out] The pointer of return BT clock data structure.

uint32_t mac_btclk_to_us(mac_bt_clk_t bt_clk)

Convert a BT clock value to a time value with unit of 1us.

Parameters:

bt_clk -- [in] The BT clock value to be converted.

Returns:

The converted time value with unit of 1us.

uint32_t mac_btus_get(void)

Get current BT native clock and clock counter value and convert it as micro-second.

Returns:

Current BT clock counter in micro-second format.

uint64_t mac_timestamp_get(void)

Get current MAC time in us, based on BT clock counter.

Returns:

Current MAC time.

void mac_btus_intr_set(uint32_t tid, uint32_t time_us)

Setup a BT clock interrupt by a time format in micro-second.

Parameters:
  • tid -- [in] The ID of BT clock timer to be set.

  • time_us -- [in] The given BT clock value in us format to trigger the interrupt.

void *mac_memcpy(void *dest, const void *src, uint32_t len)

Copy memory from source to destination.

Parameters:
  • dest -- [out] The destination memory address.

  • src -- [in] The source memory address.

  • len -- [in] The length of memory to be copied.

void mac_radio_on(void)

To request PHY grant for MAC TX/RX.

void mac_radio_off(void)

To release PHY grant, no TX/RX is allowed after releasing PHY grant.

mac_radio_state_t mac_radio_state_get(void)

To get current Radio(PHY arbitration) state.

Returns:

Current radio state.

uint8_t mac_channel_set(uint8_t ch)

This function is used to change RF channel between 11 ~ 26.

Parameters:

ch -- [in] Channel number. Value range is 11~26.

Return values:
  • MAC_STS_SUCCESS -- Set channel successfully.

  • MAC_STS_INVALID_PARAMETER -- The channel number is out of range.

Returns:

The result of changing channel.

uint8_t mac_channel_get(void)

Read current RF channel.

Returns:

RF channel, range 11-26.

uint8_t mac_freq_set(uint16_t freq)

This function is used to change RF freq between 2402 ~ 2480.

Parameters:

freq -- [in] Frequency number. Value range is 2402~2480.

Return values:
  • MAC_STS_SUCCESS -- Set freq successfully.

  • MAC_STS_INVALID_PARAMETER -- The freq value is out of range.

Returns:

The result of changing channel.

uint16_t mac_freq_get(void)

Read current RF freq.

Returns:

RF freq, range 2402-2480.

int8_t mac_SetTXPower_patch(int8_t tx_dbm)

This function is used to set the RF TX power.

Parameters:

tx_dbm -- [in] The TX power in 0.5dBm unit.

Returns:

The TX power for this TX power setting.

int8_t mac_rssi_get(uint16_t rssi_raw, uint8_t channel)

Get RSSI value from current raw data.

Parameters:
  • rssi_raw -- [in] RSSI raw data from phy layer.

  • channel -- [in] Channel number. Value range is 11~26.

Returns:

RSSI value (dbm).

void mac_panid_set(uint16_t pid)

Set IEEE 802.15.4 destination PAN id.

Parameters:

pid -- [in] 16-bit PAN identifier.

uint16_t mac_panid_get(void)

Get IEEE 802.15.4 destination PAN id.

Returns:

16-bit PAN identifier.

void mac_short_addr_set(uint16_t sadr)

Set IEEE 802.15.4 destination network(short) address.

Parameters:

sadr -- [in] 16 bits length network(short) address.

uint16_t mac_short_addr_get(void)

Get IEEE 802.15.4 destination network(short) address.

Returns:

16 bits length network(short) address.

void mac_long_addr_set(uint8_t *ladr)

Set IEEE 802.15.4 destination extended(long) address.

Parameters:

ladr -- [in] 64 bits extended(long) address pointer.

uint8_t *mac_long_addr_get(void)

Get IEEE 802.15.4 destination extended(long) address.

Returns:

64 bits extended(long) address pointer.

uint8_t mac_txn_retry_set(uint8_t max_retry)

Set the maximum retry count of the Normal FIFO transmission.

Parameters:

max_retry -- [in] The maximum retry count.

Return values:

MAC_STS_SUCCESS -- Maximum retry set OK.

Returns:

Status.

uint8_t mac_txn_retry_get(void)

Get the maximum retry count of the Normal FIFO transmission.

Returns:

The maximum retry count.

uint8_t mac_txn_retry_cnt_get(void)

Get last TxN retry times.

Returns:

Last TxN retry times 0-3.

void mac_tx_gain_set(uint8_t tx_gain)

Set RF TX power index.

Parameters:

tx_gain -- [in] The TX gain to set.

uint8_t mac_tx_gain_get(void)

Get current TX gain index setting value.

Returns:

Current TX gain control register value.

void mac_csma_max_backoffs_set(uint8_t MaxCSMABackoffs)

This function sets the maximum value of BACKOFF parameter of the TX CSMACA algorithm. The parameter affects only TX normal FIFO.

Parameters:

MaxCSMABackoffs -- [in] The max BACKOFF numbers. The value range is 0 ~ 7.

uint8_t mac_csma_max_backoffs_get(void)

Get the maximum value of BACKOFF parameter of the TX CSMACA algorithm.

Returns:

The max BACKOFF numbers. The value range is 0 ~ 7.

void mac_csma_minbe_set(uint8_t macMinBe)

Set the minimum value of Backoff Exponent parameter of the TX CSMACA algorithm.

Parameters:

macMinBe -- [in] The min BE numbers. The value range is 0 ~ 3.

uint8_t mac_csma_minbe_get(void)

Get the minimum value of Backoff Exponent parameter of the TX CSMACA algorithm.

Returns:

The min BE numbers. The value range is 0 ~ 3.

void mac_csma_maxbe_set(uint8_t macMaxBe)

Set the maximum value of Backoff Exponent parameter of the TX CSMACA algorithm.

Parameters:

macMaxBe -- [in] The max BE numbers. The value range is 0 ~ 3.

uint8_t mac_csma_maxbe_get(void)

Get the maximum value of Backoff Exponent parameter of the TX CSMACA algorithm.

Returns:

The max BE numbers. The value range is 0 ~ 3.

uint32_t mac_cca_cnt_get(void)

Get cca count.

Returns:

Total number of CCA attempts for data transmission.

uint32_t mac_txn_status_get(void)

Get latest TX error status.

Returns:

The latest TX error status:

Returns:

bit0: Normal FIFO TX status. bit1: Enh-Ack FIFO TX status. bit2: Reserved. bit3: Enh-Ack TX slot time not enough. bit4: Reserved. bit5: CCA status.

uint32_t mac_txat_status_get(void)

Get latest TX at given time error status.

Returns:

The latest TX error status: bit0: conflict with another TX process. bit1: conflict with a RX process. bit2: specified TX trigger time is past or it has no enough time to settle PHY. bit3: PHY is not granted at the specified TX trigger time. bit4: PHY is not ready (in RX state) at the specified TX trigger time.

uint32_t mac_tx_termed_status_get(void)

Get latese TX termed status.

Returns:

the latest TX error status: bit0: GTS2 FIFO TX termed. bit1: GTS1 FIFO TX termed. bit2: Normal FIFO TX termed. bit3: Beacon FIFO Tx termed.

uint8_t mac_imm_ack_fp_check(void)

Check if the immediate ACK frame pending is set.

Returns:

1 if frame pending is set, 0 otherwise.

void mac_txn_csma_set(bool enable)

Set TxN csma state.

Parameters:

enable -- [in] True: TxN csma enabled, False: TxN csma disabled.

bool mac_txn_csma_get(void)

Get TxN csma state.

Return values:
  • True -- TxN csma enabled.

  • False -- TxN csma disabled.

Returns:

The status of TxN csma.

void mac_rx_frm_filter_set(uint8_t ver, uint8_t rxftype)

Set the RX frame filter.

Parameters:
  • ver -- [in] The version of RX frame filter.

  • rxftype -- [in] The type of RX frame filter.

uint8_t mac_rx_frm_filter_get(uint8_t ver)

Get the RX frame filter.

Parameters:

ver -- [in] The version of RX frame filter.

Returns:

The type of RX frame filter.

void mac_promiscuous_set(uint8_t en)

Set promiscuous mode status.

Parameters:

en -- [in] Disable 0/Enable 1.

uint8_t mac_promiscuous_get(void)

Get promiscuous mode status.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

Promiscuous mode status.

void mac_scan_mode_set(uint8_t en)

Set scan mode status.

Parameters:

en -- [in] Disable 0/Enable 1.

uint8_t mac_scan_mode_get(void)

Get scan mode status.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

Scan mode status.

uint8_t mac_rx_frm_seq_get(void)

Get Rx frame sequence number.

Returns:

Rx frame sequence number.

uint8_t mac_rx_frm_ack_req_get(void)

Check Rx frame with ack request.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

The status of Rx frame with ack request.

uint8_t mac_rx_frm_type_get(void)

Get Rx frame type.

Return values:
  • 0x0 -- Beacon.

  • 0x1 -- Data.

  • 0x2 -- Ack.

  • 0x3 -- MAC command.

  • 0x4 -- Reserved.

  • 0x5 -- Multiple.

  • 0x6 -- Fragment.

  • 0x7 -- Extended.

Returns:

Rx frame type.

uint8_t mac_rx_frm_version_get(void)

Get Rx frame version.

Return values:
  • 0x0 -- IEEE 802.15.4-2003.

  • 0x1 -- IEEE 802.15.4-2006.

  • 0x2 -- IEEE 802.15.4-2015.

  • 0x3 -- Reserved.

Returns:

Rx frame version.

uint8_t mac_rx_frm_panid_compress_get(void)

Check Rx frame with panid compress.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

The status of Rx frame with panid compress.

uint8_t mac_rx_frm_sec_en_get(void)

Check Rx frame with security.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

The status of Rx frame with security.

uint8_t mac_rx_frm_sec_level_get(void)

Get Rx frame security level.

Return values:
  • 0x0 -- None.

  • 0x1 -- MIC-32.

  • 0x2 -- MIC-64.

  • 0x3 -- MIC-128.

  • 0x4 -- ENC.

  • 0x5 -- ENC-MIC-32.

  • 0x6 -- ENC-MIC-64.

  • 0x7 -- ENC-MIC-128.

Returns:

Rx frame security level.

uint8_t mac_rx_frm_sec_keyid_mode_get(void)

Get Rx frame security key id mode.

Return values:
  • 0x0 -- Key is determined implicitly from the originator and recipient(s) of the frame, as indicated in the frame header.

  • 0x1 -- Key is determined from the Key Index field.

  • 0x2 -- Key is determined explicitly from the 4-octet Key Source field and the Key Index field.

  • 0x3 -- Key is determined explicitly from the 8-octet Key Source field and the Key Index field.

Returns:

Rx frame security key id mode.

uint8_t mac_rx_frm_sec_keyid_get(void)

Get Rx frame security key id.

Returns:

Security key id.

uint8_t mac_rx_frm_src_addr_mode_get(void)

Get Rx frame source address mode.

Return values:
  • 0x0 -- Not present.

  • 0x1 -- Reserved.

  • 0x2 -- short address.

  • 0x3 -- extended address.

Returns:

Source address mode.

uint16_t mac_rx_frm_short_addr_get(void)

Get Rx frame short address.

Returns:

Short address.

uint64_t mac_rx_frm_long_addr_get(void)

Get Rx frame extended address.

Returns:

Extended address.

uint8_t mac_rx_frm_seq_compress_get(void)

Check Rx frame with security.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

The status of Rx frame with security.

void mac_cca_mode_set(mac_cca_mode_t cca_mode)

Select the CCA mode of CSMA-CA for frame TX.

Parameters:

cca_mode -- [in] The selected CCA mode:

  • MAC_CCA_NONE(0): Disable CCA.

  • MAC_CCA_ED(1): Energy Detection mode.

  • MAC_CCA_CS(2): Carrier Sense mode.

  • MAC_CCA_CS_ED(3): CS or ED combination mode.

  • MAC_CCA_CS_ED_AND(4): CS and ED combination mode.

uint8_t mac_cca_mode_get(void)

Get the CCA mode of CSMA-CA for frame TX.

Parameters:

cca_mode -- [in] The selected CCA mode.

Return values:
  • MAC_CCA_NONE(0) -- Disable CCA.

  • MAC_CCA_ED(1) -- Energy Detection mode.

  • MAC_CCA_CS(2) -- Carrier Sense mode.

  • MAC_CCA_CS_ED(3) -- CS or ED combination mode.

  • MAC_CCA_CS_ED_AND(4) -- CS and ED combination mode.

Returns:

The selected CCA mode.

void mac_cca_ed_threshold_set(uint8_t value)

Set CCA ED mode threshold.

Parameters:

value -- [in] CCA ED mode threshold.

int8_t mac_cca_ed_threshold_get(void)

Get CCA ED mode threshold.

Returns:

CCA ED mode threshold.

uint8_t mac_ed_scan_poll(uint32_t scan_duration, int8_t *ed_peak_lev, int8_t *ed_avrg_lev)

To do an energy detection scan for a given duration on current channel and report the maximum energy level detected during this scan.

Parameters:
  • scan_duration -- [in] The duration of this ED scan, in units of us.

  • ed_peak_lev -- [out] To return the peak energy level of this ED scan.

  • ed_avrg_lev -- [out] To return the average energy level of this ED scan.

Return values:
  • MAC_STS_SUCCESS -- ED scan successfully.

  • MAC_STS_INVALID_PARAMETER -- ED level return buffer is NULL.

  • MAC_STS_CANCELED -- ED scan is canceled by FW or FW trigger TXN.

  • MAC_STS_PHY_GRANT_FAILED -- ED scan is failed due to PHY grant failure.

  • MAC_STS_TIMEOUT -- ED scan failed due to waiting for PHY report timeout.

Returns:

The function result.

uint8_t mac_ed_scan_schedule(uint32_t scan_duration, mac_ed_scan_callback_t callback)

To start a scheduled ED scan (non-blocking ED scan) procedure.

Parameters:
  • scan_duration -- [in] The duration of this ED scan, in units of us.

  • callback -- [in] The callback function for ED scan done event.

Return values:
  • MAC_STS_SUCCESS -- Scheduled ED scan started successfully.

  • MAC_STS_INVALID_PARAMETER -- Call this function with invalid arguments.

  • MAC_STS_TEMPORARY_UNAVAILABLE -- Previous scheduled ED scan process is not finished yet.

Returns:

The function result.

void mac_ed_scan_cancel(void)

To cancel a started scheduled ED scan process.

void mac_sw_timer_init(mac_timer_handle_t *ptmr_entities, uint8_t tmr_num)

Initialize MAC driver software timer handler.

Parameters:
  • ptmr_entities -- [in] The software timer handler entities list.

  • tmr_num -- [in] Number of software timer handler in the entities list.

pmac_timer_handle_t mac_sw_timer_alloc(void)

Allocate a MAC software handler from the free timer handler pool.

Returns:

The allocated timer handler.

void mac_sw_timer_free(pmac_timer_handle_t pmac_tmr)

Free a MAC timer handler.

Parameters:

pmac_tmr -- [in] The MAC timer handler to be freed.

void mac_sw_timer_start(pmac_timer_handle_t pstart_tmr, uint32_t timeout, void *pcallback, void *arg)

Start a MAC timer with a given timestamp (BT clock) of timeout event to be triggered.

Parameters:
  • pmac_tmr -- [in] Pointer to the MAC timer handler to start.

  • timeout -- [in] Timeout timestamp (based on BT clock).

  • pcallback -- [in] Callback function to be called in timer interrupt handler.

  • arg -- [in] Argument passed to the timeout callback function.

void mac_sw_timer_stop(pmac_timer_handle_t pstop_tmr)

To stop a running MAC timer.

Parameters:

pstop_tmr -- [in] Pointer to the MAC timer handler to stop.

uint8_t mac_txn_payload_set(uint8_t HdrL, uint8_t FrmL, uint8_t *TxFIFO)

Load frame into Tx normal fifo.

1 byte

1 byte

125 bytes

HDR LEN

FRM LEN

USER DATA

Parameters:
  • HdrL -- [in] The header length of the frame.

  • FrmL -- [in] The frame length of the frame.

  • TxFIFO -- [in] The tx fifo structure which user wants to transmit.

Return values:
  • MAC_STS_SUCCESS -- The TX transmission is successful.

  • MAC_STS_DATA_LEN_ERROR -- The frame length is larger than 125 bytes.

Returns:

The process status.

uint8_t mac_txn_trig(uint8_t ackreq, uint8_t secreq)

Set if require ack, security process, then trigger Tx normal FIFO.

Parameters:
  • ackreq -- [in] Require Tx waiting an ack frame.

  • secreq -- [in] Trigger Tx outgoing security process.

Return values:

MAC_STS_SUCCESS -- TxN is triggered.

Returns:

Status.

void mac_txn_nocrc_set(uint8_t en)

Set if TxN no CRC.

Parameters:

en -- [in] 0: CRC is added to the frame, 1: CRC is not added to the frame.

uint8_t mac_txn_nocrc_get(void)

Get if TxN no CRC.

Return values:
  • 0 -- CRC is added to the frame.

  • 1 -- CRC is not added to the frame.

Returns:

0 The status of TxN on CRC.

void mac_noackrsp_set(uint8_t en)

Enable or disable automatic ACK response.

Parameters:

en -- [in] Set to 0 to enable automatic ACK response. Set to 1 to disable ACK response (no ACK sent).

uint8_t mac_noackrsp_get(void)

Get the current ACK response setting.

Return values:
  • 0 -- Automatic ACK response enabled.

  • 1 -- No ACK response (disabled).

Returns:

Current ACK response mode.

uint32_t mac_txn_timestamp_get(void)

Get the TxN timestamp.

Returns:

The TxN timestamp.

uint8_t mac_txn_trig_at_time(uint8_t ackreq, uint8_t secreq, uint8_t docca, mac_bt_clk_t txtime)

Set if require ack, then enable normal FIFO TX with a specified trigger time.

Parameters:
  • ackreq -- [in] Require Tx waiting an ack frame.

  • docca -- [in] Require to do CCA before TX.

  • txtime -- [in] The time to trigger Tx.

Return values:
  • MAC_STS_SUCCESS -- TxN is triggered.

  • MAC_STS_TRANSMISSION_TIME_NOT_ENOUGH -- The specified TXN trigger time is past.

Returns:

Status.

uint8_t mac_txn_trig_at_us(uint8_t ackreq, uint8_t secreq, uint8_t docca, uint32_t target_us)

Set if require ack, then enable normal FIFO TX with a specified trigger time.

Parameters:
  • ackreq -- [in] Require Tx waiting an ack frame.

  • docca -- [in] Require to do CCA before TX.

  • target_us -- [in] The time to trigger Tx in micro-second format.

Return values:
  • MAC_STS_SUCCESS -- TxN is triggered.

  • MAC_STS_TRANSMISSION_TIME_NOT_ENOUGH -- The specified TXN trigger time is past.

Returns:

Status.

void mac_tx_enh_ack_set_pending(uint8_t len)

Set the pending enhanced ack frame length.

Parameters:

len -- [in] Pending enhanced ack frame length.

uint8_t mac_tx_enh_ack_get_pending(void)

Get the pending enhanced ack frame length.

Returns:

Pending enhanced ack frame length.

uint8_t mac_tx_enh_ack_payload_set(uint8_t HdrL, uint8_t FrmL, uint8_t *TxFIFO)

Load frame into Tx Enh-ACK fifo.

1 byte

1 bytes

125 byte

HDR LEN

FRM LEN

USER DATA

Parameters:
  • HdrL -- [in] The header length of the frame.

  • FrmL -- [in] The frame length of the frame.

  • TxFIFO -- [in] The tx fifo structure which user wants to transmit.

Return values:
  • MAC_STS_SUCCESS -- The TX transmission is successful.

  • MAC_STS_DATA_LEN_ERROR -- The frame length is larger than 125 bytes.

Returns:

The process status.

uint8_t mac_tx_enh_ack_trig(uint8_t early, uint8_t secreq)

Set if require ack, security process, then trigger Tx normal FIFO.

Parameters:
  • early -- [in] Trigger Tx enhack in rx early interrupt.

  • secreq -- [in] Trigger Tx enhack outgoing security process.

Return values:

MAC_STS_SUCCESS -- Tx enhack is triggered.

Returns:

Status

uint8_t mac_tx_enh_ack_state_get(void)

Get the Tx enhack state.

Returns:

The Tx enhack state.

bool mac_upper_enc_trig(void)

Trigger upper layer encrypt process.

uint8_t mac_upper_cipher(uint8_t SecMode, uint8_t *SecKey, uint8_t *SecNonce)

Using TX normal FIFO to do upper cipher encryption. The data to be encrypted should be filled into the TX Normal FIFO before calling this function. It should follow the structure of the TX FIFO format. The encrypted data will be stored to the TX Normal FIFO and replace the original data.

Parameters:
  • SecMode -- [in] Security mode.

  • *SecKey -- [in] Security key pointer, security key is 16 bytes.

  • SecNonce -- [in] Security nonce, nonce is 13 bytes

Return values:
  • MAC_STS_SUCCESS -- Encryption success.

  • MAC_STS_UNSUPPORT_SECURITY_MODE --

  • MAC_STS_DATA_LEN_ERROR --

  • MAC_STS_SECURITY_FAILED --

Returns:

Process status.

void mac_upper_dec_trig(void)

Trigger upper layer decrypt process.

uint8_t mac_upper_decipher(uint8_t SecMode, uint8_t *SecKey, uint8_t *SecNonce)

Using TX normal FIFO to do upper cipher decryption. The data to be decrypted should be filled into the TX Normal FIFO before calling this function. It should follow the structure of the TX FIFO format. The decrypted data will be stored to the TX Normal FIFO and replace the origial data.

Parameters:
  • SecMode -- [in] Security mode.

  • *SecKey -- [in] Security key pointer, security key is 16 bytes.

  • SecNonce -- [in] Security nonce, nonce is 13 bytes

Return values:
  • MAC_STS_SUCCESS -- Encryption success.

  • MAC_STS_UNSUPPORT_SECURITY_MODE --

  • MAC_STS_DATA_LEN_ERROR --

  • MAC_STS_SECURITY_FAILED --

Returns:

Process status.

uint8_t mac_sec_mic_len_get(uint8_t level)

Get the length of current security level.

Parameters:

level -- [in] the security level(as the defination in IEEE802.15.4 MAC Spec.)

Returns:

the MIC length of current security level.

uint8_t mac_rx(uint8_t *rxfifo)

Read received packet from RX FIFO.

1 byte

125 bytes

1 byte

2 bytes

4/2 bytes

3 bytes

FRM LEN

USER DATA

LQI

RSSI

TimeStamp

SF Count

Parameters:

rxfifo -- [out] User data buffer pointer. The packet length will be put in the start address of buffer

Return values:
  • MAC_STS_FAILURE -- There is no received packet.

  • MAC_STS_SUCCESS -- Retrieved one packet.

Returns:

Rx status.

void mac_rx_err_pkt_set(uint8_t en)

Set Rx CRC error packet status.

Parameters:

en -- [in] Disable 0/Enable 1.

uint8_t mac_rx_err_pkt_get(void)

Get Rx CRC error packet status.

Return values:
  • 0 -- Disable.

  • 1 -- Enable.

Returns:

Rx CRC error packet status.

void mac_addr_match_mode_set(uint8_t mode)

Config the mode of auto set frame pending bit for Ack frame.

Parameters:

mode -- [in]

  • AUTO_ACK_PENDING_MODE_ZIGBEE: Set the pending bit as IEEE802.15.4 Spec.

  • AUTO_ACK_PENDING_MODE_THREAD: Set the pending bit as Thread Spec.

uint8_t mac_addr_match_mode_get(void)

Get the mode of auto set frame pending bit for Ack frame.

Return values:
  • AUTO_ACK_PENDING_MODE_ZIGBEE -- Set the pending bit as IEEE802.15.4 Spec.

  • AUTO_ACK_PENDING_MODE_THREAD -- Set the pending bit as Thread Spec.

Returns:

The mode of auto set frame pending bit for ACK frame.

uint8_t mac_addr_match_short_add(uint16_t short_addr, uint16_t panid)

To add a short address and panid pair to an entry of Source Address Match Filter.

Parameters:
  • short_addr -- [in] The short address to be added into the Source Address Match Filter.

  • panid -- [in] The panid to be added into the Source Address Match Filter.

Return values:
  • MAC_STS_SUCCESS -- Add a new short address entry successfully.

  • MAC_STS_HW_LIMIT -- No free address match entry.

Returns:

The function result.

uint8_t mac_addr_match_short_del(uint16_t short_addr, uint16_t panid)

To disable a short address match entry by a given short address and panid pair.

Parameters:
  • short_addr -- [in] The short address of the short address match entry to be disabled.

  • panid -- [in] The panidof of the short address match entry to be disabled.

Return values:
  • MAC_STS_SUCCESS -- Disable a short address entry successfully.

  • MAC_STS_FAILURE -- The short address match entry is not found.

Returns:

The function result.

void mac_addr_match_short_flush(void)

To disable all short address match entries.

uint8_t mac_addr_match_long_add(uint8_t *pext_addr)

To add an extended address match entry of Source Address Match Filter.

Parameters:

pext_addr -- [in] The extended address to be added into the Source Address Match Filter.

Return values:
  • MAC_STS_SUCCESS -- Add a new short address entry successfully.

  • MAC_STS_HW_LIMIT -- No free address match entry.

Returns:

The function result.

uint8_t mac_addr_match_long_del(uint8_t *pext_addr)

To disable an extended address match entry by a given extended address.

Parameters:

pext_addr -- [in] The extended address of the extended address match entry to be disabled.

Return values:
  • MAC_STS_SUCCESS -- Disable a short address entry successfully.

  • MAC_STS_FAILURE -- The short address match entry is not found.

Returns:

The function result.

void mac_addr_match_long_flush(void)

To disable all extended address match entries.

uint32_t mac_addr_match_entry_get(uint8_t index, bool high_bytes)

Get the source address match entry of Source Address Match Filter.

Parameters:
  • index -- [in] The index of the source address match entry.

  • high_bytes -- [in]

    • True: get the high bytes of the source address match entry.

    • False: get the low bytes of the source address match entry.

Returns:

The source address match entry.

void mac_nonce_set(uint8_t *nonce)

Load nonce into MAC.

Parameters:

nonce -- [in] The nonce structure to be loaded.

void mac_txn_key_set(uint8_t *key)

Load key into TxN key fifo.

Parameters:

key -- [in] The TxN key to be loaded.

void mac_txn_cipher_set(uint8_t level)

Config the security level of Normal FIFO cipher.

Parameters:

level -- [in] The security level(as the definition in IEEE 802.15.4 MAC Spec).

void mac_tx_enh_ack_key_set(uint8_t *key)

Load key into TxG1 key fifo.

Parameters:

key -- [in] The TxG1 key to be loaded.

void mac_tx_enh_ack_cipher_set(uint8_t level)

Config the security level of Enh-Ack FIFO cipher.

Parameters:

level -- [in] The security level(as the definition in IEEE 802.15.4 MAC Spec).