This module acts as a wrapper layer between the Wireless stack and the ASF drivers All hardwar level acess to the ASF drivers from the stack happens through this module.
Modules | |
Common SW Timer | |
Implements the software Algorithm for Timer Handling in the Stack. | |
Macros | |
#define | DISABLE_GLOBAL_IRQ() Disable_global_interrupt() |
#define | ENABLE_GLOBAL_IRQ() Enable_global_interrupt() |
#define | ENTER_CRITICAL_REGION() {uint8_t flags = cpu_irq_save(); |
#define | LEAVE_CRITICAL_REGION() cpu_irq_restore(flags); } |
#define | MIN_TIMEOUT (0x80) |
#define | pal_timer_delay(delay) delay_us(delay) |
Generates blocking delay. More... | |
#define | pal_trx_irq_dis() DISABLE_TRX_IRQ() |
Disables the transceiver main interrupt. More... | |
#define | pal_trx_irq_dis_tstamp() DISABLE_TRX_IRQ_TSTAMP() |
Disables the transceiver timestamp interrupt. More... | |
#define | pal_trx_irq_en() ENABLE_TRX_IRQ() |
Enables the transceiver main interrupt. More... | |
#define | pal_trx_irq_en_tstamp() ENABLE_TRX_IRQ_TSTAMP() |
Enables the transceiver timestamp interrupt. More... | |
#define | pal_trx_irq_flag_clr() CLEAR_TRX_IRQ() |
Clears the transceiver main interrupt. More... | |
#define | pal_trx_irq_flag_clr_tstamp() CLEAR_TRX_IRQ_TSTAMP() |
Clears the transceiver timestamp interrupt. More... | |
#define | PAL_WAIT_1_US() delay_us(1); |
#define | PAL_WAIT_65_NS() {nop(); nop(); } |
#define | STACK_FLASH_SIZE (1024) |
#define | TIMER_SRC_DURING_TRX_AWAKE() |
Timer clock source while radio is awake. More... | |
#define | TIMER_SRC_DURING_TRX_SLEEP() |
Timer clock source while radio is sleeping. More... | |
#define | U16_TO_TARGET(x) (x) |
This macro is used for handling endianness among the different CPUs. More... | |
Typedefs | |
typedef enum ps_id_tag | ps_id_t |
IDs for persistence storage access. More... | |
typedef enum ps_type_tag | ps_type_t |
IDs for persistence storage type. More... | |
typedef enum pwr_mode_tag | pwr_mode_t |
Power modes. More... | |
typedef enum source_type_tag | source_type_t |
Timer clock source type. More... | |
typedef enum timeout_type_tag | timeout_type_t |
Timeout type. More... | |
Enumerations | |
enum | ps_id_tag { PS_IEEE_ADDR, PS_XTAL_TRIM } |
IDs for persistence storage access. More... | |
enum | ps_type_tag { INTERN_EEPROM, EXTERN_EEPROM } |
IDs for persistence storage type. More... | |
enum | pwr_mode_tag { SYSTEM_SLEEP } |
Power modes. More... | |
enum | source_type_tag { TMR_CLK_SRC_DURING_TRX_SLEEP, TMR_CLK_SRC_DURING_TRX_AWAKE } |
Timer clock source type. More... | |
enum | timeout_type_tag { TIMEOUT_RELATIVE, TIMEOUT_ABSOLUTE } |
Timeout type. More... | |
Functions | |
static uint32_t | pal_add_time_us (uint32_t a, uint32_t b) |
Adds two time values. More... | |
bool | pal_calibrate_rc_osc (void) |
Calibrates the internal RC oscillator. More... | |
uint16_t | pal_generate_rand_seed (void) |
Generation of random seed for function srand() in case this is not supported by the transceiver (e.g. More... | |
void | pal_get_current_time (uint32_t *current_time) |
Gets current time. More... | |
static void | pal_global_irq_disable (void) |
Disables the global interrupt. More... | |
static void | pal_global_irq_enable (void) |
Enables the global interrupt. More... | |
retval_t | pal_init (void) |
Initialization of PAL. More... | |
bool | pal_is_timer_running (uint8_t timer_id) |
Checks if the timer of requested timer identifier is running. More... | |
retval_t | pal_ps_get (ps_type_t ps_type, uint16_t start_addr, uint16_t length, void *value) |
Get data from persistence storage. More... | |
retval_t | pal_ps_set (uint16_t start_addr, uint16_t length, void *value) |
Write data to persistence storage. More... | |
retval_t | pal_start_high_priority_timer (uint8_t timer_id, uint16_t timer_count, FUNC_PTR timer_cb, void *param_cb) |
Starts high priority timer. More... | |
retval_t | pal_stop_high_priority_timer (uint8_t timer_id) |
Stops a high priority timer. More... | |
static uint32_t | pal_sub_time_us (uint32_t a, uint32_t b) |
Subtracts two time values. More... | |
void | pal_task (void) |
Services timer and sio handler. More... | |
retval_t | pal_timer_get_id (uint8_t *timer_id) |
void | pal_timer_source_select (source_type_t source) |
Selects timer clock source. More... | |
retval_t | pal_timer_start (uint8_t timer_id, uint32_t timer_count, timeout_type_t timeout_type, FUNC_PTR timer_cb, void *param_cb) |
Start regular timer. More... | |
retval_t | pal_timer_stop (uint8_t timer_id) |
Stops a running timer. More... | |
void | pal_trx_irq_init (FUNC_PTR trx_irq_cb) |
Initializes the transceiver main interrupt. More... | |
void | pal_trx_irq_init_tstamp (FUNC_PTR trx_irq_cb) |
Initializes the transceiver timestamp interrupt. More... | |
void | pal_trx_read_timestamp (uint32_t *timestamp) |
Provides timestamp of the last received frame. More... | |
#define DISABLE_GLOBAL_IRQ | ( | ) | Disable_global_interrupt() |
Referenced by pal_global_irq_disable().
#define ENABLE_GLOBAL_IRQ | ( | ) | Enable_global_interrupt() |
Referenced by pal_global_irq_enable(), and set_trx_state().
#define ENTER_CRITICAL_REGION | ( | ) | {uint8_t flags = cpu_irq_save(); |
Referenced by qmm_queue_append(), queue_read_or_remove(), set_trx_state(), and tal_reset().
#define LEAVE_CRITICAL_REGION | ( | ) | cpu_irq_restore(flags); } |
Referenced by qmm_queue_append(), queue_read_or_remove(), set_trx_state(), and tal_reset().
#define MIN_TIMEOUT (0x80) |
Referenced by sw_timer_start().
#define pal_timer_delay | ( | delay | ) | delay_us(delay) |
Generates blocking delay.
This functions generates a blocking delay of specified time.
delay | in microseconds |
Referenced by send_frame(), set_trx_state(), switch_pll_on(), tfa_cca_perform(), tfa_ed_sample(), tfa_get_batmon_voltage(), trx_init(), and trx_reset().
#define pal_trx_irq_dis | ( | ) | DISABLE_TRX_IRQ() |
Disables the transceiver main interrupt.
This macro is only available for non-single chip transceivers, since in single chip transceivers there is no separation between disabling transceiver interrupts at the transceiver, and clearing the IRQ mask at the MCU. Therefore the transceiver interrupts in single chips are disabled by clearing the MCU IRQ mask.
Referenced by send_frame(), tal_ed_start(), and tfa_get_batmon_voltage().
#define pal_trx_irq_dis_tstamp | ( | ) | DISABLE_TRX_IRQ_TSTAMP() |
Disables the transceiver timestamp interrupt.
This macro is only available for non-single chip transceivers, since in single chip transceivers there is no separation between disabling transceiver interrupts at the transceiver, and clearing the IRQ mask at the MCU. Therefore the transceiver interrupts in single chips are disabled by clearing the MCU IRQ mask.
#define pal_trx_irq_en | ( | ) | ENABLE_TRX_IRQ() |
Enables the transceiver main interrupt.
This macro is only available for non-single chip transceivers, since in single chip transceivers there is no separation between enabling transceiver interrupts at the transceiver, and setting the IRQ mask at the MCU. Therefore the transceiver interrupts in single chips are enabled by setting the MCU IRQ mask.
Referenced by ed_scan_done(), send_frame(), set_trx_state(), tal_ed_start(), tal_init(), tal_reset(), and tfa_get_batmon_voltage().
#define pal_trx_irq_en_tstamp | ( | ) | ENABLE_TRX_IRQ_TSTAMP() |
Enables the transceiver timestamp interrupt.
This macro is only available for non-single chip transceivers, since in single chip transceivers there is no separation between enabling transceiver interrupts at the transceiver, and setting the IRQ mask at the MCU. Therefore the transceiver interrupts in single chips are enabled by setting the MCU IRQ mask.
Referenced by tal_init().
#define pal_trx_irq_flag_clr | ( | ) | CLEAR_TRX_IRQ() |
Clears the transceiver main interrupt.
Referenced by set_trx_state(), tal_generate_rand_seed(), and tal_reset().
#define pal_trx_irq_flag_clr_tstamp | ( | ) | CLEAR_TRX_IRQ_TSTAMP() |
Clears the transceiver timestamp interrupt.
#define PAL_WAIT_1_US | ( | ) | delay_us(1); |
Referenced by set_trx_state(), and tal_generate_rand_seed().
Referenced by send_frame().
#define STACK_FLASH_SIZE (1024) |
#define TIMER_SRC_DURING_TRX_AWAKE | ( | ) |
Timer clock source while radio is awake.
T0 & T1 of PORTC clk source is event channel 2 triggered by transceiver clock (CLKM, 1MHz)
#define TIMER_SRC_DURING_TRX_SLEEP | ( | ) |
Timer clock source while radio is sleeping.
T0 & T1 of PORTC clk source is event channel 0 triggered by system clock with corresponding event system prescaler (see function event_system_init()).
#define U16_TO_TARGET | ( | x | ) | (x) |
This macro is used for handling endianness among the different CPUs.
typedef enum ps_type_tag ps_type_t |
IDs for persistence storage type.
typedef enum pwr_mode_tag pwr_mode_t |
Power modes.
typedef enum source_type_tag source_type_t |
Timer clock source type.
typedef enum timeout_type_tag timeout_type_t |
Timeout type.
enum ps_id_tag |
enum ps_type_tag |
enum pwr_mode_tag |
enum source_type_tag |
enum timeout_type_tag |
|
inlinestatic |
Adds two time values.
a | Time value 1 |
b | Time value 2 |
References ADD_TIME.
bool pal_calibrate_rc_osc | ( | void | ) |
Calibrates the internal RC oscillator.
uint16_t pal_generate_rand_seed | ( | void | ) |
Generation of random seed for function srand() in case this is not supported by the transceiver (e.g.
AT86RF230)
void pal_get_current_time | ( | uint32_t * | current_time | ) |
Gets current time.
This function returns the current time.
[out] | current_time | Returns current system time |
References MEMCPY_ENDIAN, and sw_timer_get_time().
Referenced by tal_tx_frame().
|
inlinestatic |
Disables the global interrupt.
References DISABLE_GLOBAL_IRQ.
|
inlinestatic |
Enables the global interrupt.
References ENABLE_GLOBAL_IRQ.
retval_t pal_init | ( | void | ) |
Initialization of PAL.
This function initializes the PAL. The RC Oscillator is calibrated.
References MAC_SUCCESS, and trx_spi_init().
Referenced by tal_init().
bool pal_is_timer_running | ( | uint8_t | timer_id | ) |
Checks if the timer of requested timer identifier is running.
This function checks if the timer of requested timer identifier is running.
timer_id | Timer identifier |
References sw_timer_is_running().
Get data from persistence storage.
[in] | ps_type | Persistence storage type |
[in] | start_addr | Start offset within EEPROM |
[in] | length | Number of bytes to read from EEPROM |
[out] | value | Data from persistence storage |
Referenced by tal_init().
retval_t pal_ps_set | ( | uint16_t | start_addr, |
uint16_t | length, | ||
void * | value | ||
) |
Write data to persistence storage.
[in] | start_addr | Start address offset within EEPROM |
[in] | length | Number of bytes to be written to EEPROM |
[in] | value | Data to persistence storage |
Referenced by tal_init().
retval_t pal_start_high_priority_timer | ( | uint8_t | timer_id, |
uint16_t | timer_count, | ||
FUNC_PTR | timer_cb, | ||
void * | param_cb | ||
) |
Starts high priority timer.
This function starts a high priority timer for the specified timeout.
timer_id | Timer identifier |
timer_count | Timeout in microseconds |
timer_cb | Callback handler invoked upon timer expiry |
param_cb | Argument for the callback handler |
retval_t pal_stop_high_priority_timer | ( | uint8_t | timer_id | ) |
Stops a high priority timer.
This function stops a high priority timer.
timer_id | Timer identifier |
|
inlinestatic |
Subtracts two time values.
a | Time value 1 |
b | Time value 2 |
References SUB_TIME.
void pal_task | ( | void | ) |
Services timer and sio handler.
This function calls sio & timer handling functions.
References sw_timer_service().
Referenced by performance_analyzer_task().
retval_t pal_timer_get_id | ( | uint8_t * | timer_id | ) |
References MAC_SUCCESS, PAL_TMR_INVALID_ID, STATUS_OK, and sw_timer_get_id().
Referenced by tal_timer_init().
void pal_timer_source_select | ( | source_type_t | source | ) |
Selects timer clock source.
This function selects the clock source of the timer.
source |
|
Referenced by tal_trx_sleep(), and tal_trx_wakeup().
retval_t pal_timer_start | ( | uint8_t | timer_id, |
uint32_t | timer_count, | ||
timeout_type_t | timeout_type, | ||
FUNC_PTR | timer_cb, | ||
void * | param_cb | ||
) |
Start regular timer.
This function starts a regular timer and installs the corresponding callback function handle the timeout event.
timer_id | Timer identifier |
timer_count | Timeout in microseconds |
timeout_type | TIMEOUT_RELATIVE or TIMEOUT_ABSOLUTE |
timer_cb | Callback handler invoked upon timer expiry |
param_cb | Argument for the callback handler |
References ERR_TIMER_ALREADY_RUNNING, MAC_INVALID_PARAMETER, MAC_SUCCESS, PAL_TMR_ALREADY_RUNNING, STATUS_OK, and sw_timer_start().
Referenced by tal_reset(), and tal_trx_wakeup().
retval_t pal_timer_stop | ( | uint8_t | timer_id | ) |
Stops a running timer.
This function stops a running timer with specified timer_id
timer_id | Timer identifier |
References ERR_TIMER_NOT_RUNNING, MAC_SUCCESS, PAL_TMR_INVALID_ID, PAL_TMR_NOT_RUNNING, STATUS_OK, and sw_timer_stop().
Referenced by tal_timers_stop(), tal_trx_sleep(), and trx_irq_handler_cb().
void pal_trx_irq_init | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver main interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver main interrupt
trx_irq_cb | Callback function for the transceiver main interrupt |
void pal_trx_irq_init_tstamp | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver timestamp interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver timestamp interrupt
trx_irq_cb | Callback function for the transceiver timestamp interrupt |
Referenced by tal_init().
void pal_trx_read_timestamp | ( | uint32_t * | timestamp | ) |
Provides timestamp of the last received frame.
This function provides the timestamp (in microseconds) of the last received frame.
[out] | timestamp | in microseconds |
References sw_timer_get_time().
Referenced by handle_tx_end_irq(), and trx_irq_handler_cb().