Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAL

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.

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 pwr_mode_tag pwr_mode_t
 Power modes. More...
 
typedef enum source_type_tag source_type_t
 Timer clock source type. More...
 

Enumerations

enum  ps_id_tag {
  PS_IEEE_ADDR,
  PS_XTAL_TRIM
}
 IDs for persistence storage access. 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...
 

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...
 
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...
 
static uint32_t pal_sub_time_us (uint32_t a, uint32_t b)
 Subtracts two time values. More...
 
void pal_timer_source_select (source_type_t source)
 Selects timer clock source. 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()
#define ENTER_CRITICAL_REGION ( )    {uint8_t flags = cpu_irq_save();
#define MIN_TIMEOUT   (0x80)
#define pal_timer_delay (   delay)    delay_us(delay)

Generates blocking delay.

This functions generates a blocking delay of specified time.

Parameters
delayin microseconds

Referenced by handle_ifs(), perform_cca_twice(), send_frame(), set_trx_state(), switch_pll_on(), tal_generate_rand_seed(), tfa_cca_perform(), tfa_ed_sample(), tfa_get_batmon_voltage(), transmit_frame(), trx_init(), trx_reset(), wait_for_freq_settling(), and wait_for_txprep().

#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(), 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 send_frame(), set_trx_state(), 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(), switch_pll_on(), tal_generate_rand_seed(), tal_init(), tal_reset(), and trx_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);
#define PAL_WAIT_65_NS ( )    {nop(); nop(); }

Referenced by handle_tx_end_irq(), and 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_id_tag ps_id_t

IDs for persistence storage access.

typedef enum pwr_mode_tag pwr_mode_t

Power modes.

Timer clock source type.

enum ps_id_tag

IDs for persistence storage access.

Enumerator
PS_IEEE_ADDR 
PS_XTAL_TRIM 

Power modes.

Enumerator
SYSTEM_SLEEP 

Timer clock source type.

Enumerator
TMR_CLK_SRC_DURING_TRX_SLEEP 

Identifier for timer clock source during sleep.

TMR_CLK_SRC_DURING_TRX_AWAKE 

Identifier for timer clock source while being awake.

static uint32_t pal_add_time_us ( uint32_t  a,
uint32_t  b 
)
inlinestatic

Adds two time values.

Parameters
aTime value 1
bTime value 2
Returns
Addition of a and b

Referenced by csma_backoff_calculation(), perform_cca_twice(), and send_frame_at_next_backoff_boundary().

bool pal_calibrate_rc_osc ( void  )

Calibrates the internal RC oscillator.

Returns
True if calibration is successful, false otherwise.

Referenced by mac_init().

static void pal_global_irq_disable ( void  )
inlinestatic

Disables the global interrupt.

References DISABLE_GLOBAL_IRQ.

static void pal_global_irq_enable ( void  )
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.

Returns
MAC_SUCCESS if PAL initialization is successful, FAILURE otherwise

Initialization of PAL.

Note
Init PHY layer configuration with the rest of PHY layer functions. This function will be invoked by function phy_init() and it allows the user to configure PHY layer initialization. Users can adapt the PHY layer to every hardware platform. This is an example of usage, configuring analog front end and different thresholds for load detection. ATMEL strongly recommends to consult with technical support to change any parameter in this file.

References INT_FLASH, MAC_SUCCESS, nvm_init(), PHY_ID_RX_QR_MODE_ID, PHY_ID_TX_QR_MODE_ID, phy_mac_crc_disable(), and phy_set_cfg_param().

Referenced by _prime_stack_process(), and tal_init().

static uint32_t pal_sub_time_us ( uint32_t  a,
uint32_t  b 
)
inlinestatic

Subtracts two time values.

Parameters
aTime value 1
bTime value 2
Returns
Difference between a and b

Referenced by csma_backoff_calculation(), handle_tx_end_irq(), switch_pll_on(), tal_trx_wakeup(), and trx_reset().

void pal_timer_source_select ( source_type_t  source)

Selects timer clock source.

This function selects the clock source of the timer.

Parameters
source

Referenced by mac_reset(), mac_trx_init_sleep(), mac_trx_wakeup(), tal_trx_sleep(), and tal_trx_wakeup().

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

Parameters
trx_irq_cbCallback 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

Parameters
trx_irq_cbCallback 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.

Parameters
[out]timestampin microseconds

Referenced by handle_tx_end_irq(), and trx_irq_handler_cb().