This file implements ED scan.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#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) |
Handles ED scan end interrupt. 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... | |
void | stop_ed_scan (trx_id_t trx_id) |
Stops ED Scan. More... | |
retval_t | tal_ed_start (trx_id_t trx_id, uint8_t scan_duration) |
Starts ED Scan. More... | |
Variables | |
static int8_t | max_ed_level [NUM_TRX] |
The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration. More... | |
static uint32_t | sampler_counter [NUM_TRX] |
#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 | ) |
Handles ED scan end interrupt.
This function handles an ED done interrupt from the transceiver.
trx_id | Transceiver identifier |
References cca_done_handling(), max_ed_level, RF_BASE_ADDR_OFFSET, RF_EDAUTO, RF_RX, RF_TRXOFF, RG_RF09_CMD, RG_RF09_EDV, sampler_counter, 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 stop_ed_scan(), and 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.
ed | RF215 register value EDV. |
References LOWER_ED_LIMIT, 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.
trx_id | Transceiver identifier |
sample_duration_us | Sample duration in us |
References RF_BASE_ADDR_OFFSET, RG_RF09_EDD, and trx_reg_write().
Referenced by config_phy(), handle_ed_end_irq(), tal_ed_start(), and tal_pib_set().
void stop_ed_scan | ( | trx_id_t | trx_id | ) |
Stops ED Scan.
This function stops an ED Scan and completes it by calling tal_ed_end_cb().
trx_id | Transceiver identifier |
References handle_ed_end_irq(), RF_BASE_ADDR_OFFSET, RF_EDAUTO, RF_IRQ_EDC, sampler_counter, SR_RF09_EDC_EDM, TAL_RF_IRQ_CLR, and trx_bit_write().
Referenced by handle_trxerr().
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().
trx_id | Transceiver identifier |
scan_duration | Specifies the ED scan duration in superframe duration |
References aBaseSuperframeDuration, Assert, ED_SAMPLE_DURATION_SYM, MAC_SUCCESS, max_ed_level, NUM_TRX, pal_timer_delay, RF_BASE_ADDR_OFFSET, RF_EDCONT, RF_RX, RF_TXPREP, RG_RF09_CMD, sampler_counter, scan_duration, set_ed_sample_duration(), SR_BBC0_PC_BBEN, SR_RF09_AGCC_FRZC, SR_RF09_EDC_EDM, SR_RF09_IRQM_EDC, switch_to_txprep(), TAL_BUSY, TAL_ED_SCAN, TAL_IDLE, tal_pib, TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, trx_bit_write(), trx_default_state, trx_reg_write(), and trx_state.
Referenced by per_mode_initiator_ed_end_cb(), and start_ed_scan().
|
static |
The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration.
Referenced by handle_ed_end_irq(), and tal_ed_start().
|
static |
Referenced by handle_ed_end_irq(), stop_ed_scan(), and tal_ed_start().