Microchip® Advanced Software Framework

at86rf215/src/tal_ed.c File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "pal.h"
#include "return_val.h"
#include "tal.h"
#include "ieee_const.h"
#include "tal_config.h"
#include "tal_internal.h"
#include "mac_build_config.h"

Macros

#define LOWER_ED_LIMIT   -100
 
#define UPPER_ED_LIMIT   -30
 Values used for ED scaling in dBm. More...
 

Functions

void handle_ed_end_irq (trx_id_t trx_id)
 The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration. More...
 
uint8_t scale_ed_value (int8_t ed)
 Scale ED value. More...
 
void set_ed_sample_duration (trx_id_t trx_id, uint16_t sample_duration_us)
 Sets the energy measurement duration. More...
 

#define LOWER_ED_LIMIT   -100

Referenced by scale_ed_value().

#define UPPER_ED_LIMIT   -30

Values used for ED scaling in dBm.

Referenced by scale_ed_value().

void handle_ed_end_irq ( trx_id_t  trx_id)

The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration.

Starts ED Scan

This function starts an ED Scan for the scan duration specified by the MAC layer. The result is returned from the TAL by calling tal_ed_end_cb().

Parameters
trx_idTransceiver identifier
scan_durationSpecifies the ED scan duration in superframe duration
Returns
MAC_SUCCESS - ED scan duration timer started successfully TAL_BUSY - TAL is busy servicing the previous request from MAC TAL_TRX_ASLEEP - Transceiver is currently sleeping FAILURE otherwise Handles ED scan end interrupt

This function handles an ED done interrupt from the transceiver.

Parameters
trx_idTransceiver identifier

References cca_done_handling(), RF_BASE_ADDR_OFFSET, RF_EDAUTO, RF_RX, RF_TRXOFF, RG_RF09_CMD, RG_RF09_EDV, set_ed_sample_duration(), SR_BBC0_PC_BBEN, SR_RF09_EDC_EDM, SR_RF09_IRQM_EDC, switch_to_rx(), tal_current_ed_val, tal_ed_end_cb(), TAL_ED_SCAN, TAL_IDLE, tal_pib, tal_state, trx_bit_write(), trx_default_state, trx_reg_read(), trx_reg_write(), and tx_state.

Referenced by tal_task().

uint8_t scale_ed_value ( int8_t  ed)

Scale ED value.

This function scales the trx ED value to the range 0x00 - 0xFF.

Parameters
edRF215 register value EDV.
Returns
Scaled ED value

References LOWER_ED_LIMIT, temp, and UPPER_ED_LIMIT.

Referenced by process_incoming_frame().

void set_ed_sample_duration ( trx_id_t  trx_id,
uint16_t  sample_duration_us 
)

Sets the energy measurement duration.

Parameters
trx_idTransceiver identifier
sample_duration_usSample duration in us

References RF_BASE_ADDR_OFFSET, RG_RF09_EDD, and trx_reg_write().

Referenced by config_phy(), handle_ed_end_irq(), and tal_pib_set().