| Microcontroller Wireless Solutions | |||||
PAL related APIs. More...
Go to the source code of this file.
Defines | |
| #define | ADD_TIME(a, b) ((a) + (b)) |
| #define | PAL_RST_HIGH() RST_HIGH() |
| #define | PAL_RST_LOW() RST_LOW() |
| #define | PAL_SLP_TR_HIGH() SLP_TR_HIGH() |
| #define | PAL_SLP_TR_LOW() SLP_TR_LOW() |
| #define | pal_trx_irq_flag_clr() CLEAR_TRX_IRQ() |
| #define | pal_trx_irq_flag_clr_awake() (CLEAR_TRX_IRQ_AWAKE()) |
| #define | pal_trx_irq_flag_clr_cca_ed() (CLEAR_TRX_IRQ_CCA_ED()) |
| #define | pal_trx_irq_flag_clr_rx_end() (CLEAR_TRX_IRQ_RX_END()) |
| #define | pal_trx_irq_flag_clr_tstamp() CLEAR_TRX_IRQ_TSTAMP() |
| #define | pal_trx_irq_flag_clr_tx_end() (CLEAR_TRX_IRQ_TX_END()) |
| #define | PAL_TRX_IRQ_HIGH() IRQ_PINGET() |
| #define | SUB_TIME(a, b) ((a) - (b)) |
| #define | U16_TO_TARGET(x) ((((x) << 8) & 0xFF00) | (((x) >> 8) & 0x00FF)) |
Typedefs | |
| typedef enum button_state_tag | button_state_t |
| typedef void(* | irq_handler_t )(void) |
| typedef enum led_action_tag | led_action_t |
| typedef enum pin_state_tag | pin_state_t |
| typedef enum ps_id_tag | ps_id_t |
| typedef enum ps_type_tag | ps_type_t |
| typedef enum pwr_mode_tag | pwr_mode_t |
| typedef enum sio_serial_tag | sio_serial_t |
| typedef enum source_type_tag | source_type_t |
| typedef enum timeout_type_tag | timeout_type_t |
Enumerations | |
| enum | button_state_tag { BUTTON_PRESSED, BUTTON_OFF } |
| enum | led_action_tag { LED_ON, LED_OFF, LED_TOGGLE } |
| enum | pin_state_tag { LOW, HIGH } |
| enum | ps_id_tag { PS_IEEE_ADDR, PS_XTAL_TRIM } |
| enum | ps_type_tag { INTERN_EEPROM, EXTERN_EEPROM } |
| enum | pwr_mode_tag { SYSTEM_SLEEP } |
| enum | sio_serial_tag { SIO_0, SIO_1, SIO_2, SIO_3, SIO_4 } |
| enum | source_type_tag { TMR_CLK_SRC_DURING_TRX_SLEEP, TMR_CLK_SRC_DURING_TRX_AWAKE } |
| enum | timeout_type_tag { TIMEOUT_RELATIVE, TIMEOUT_ABSOLUTE } |
Functions | |
| static uint32_t | pal_add_time_us (uint32_t a, uint32_t b) |
| void | pal_alert (void) |
| void | pal_button_init (void) |
| button_state_t | pal_button_read (button_id_t button_no) |
| bool | pal_calibrate_rc_osc (void) |
| uint16_t | pal_generate_rand_seed (void) |
| void | pal_get_current_time (uint32_t *current_time) |
| static void | pal_global_irq_disable (void) |
| static void | pal_global_irq_enable (void) |
| retval_t | pal_init (void) |
| bool | pal_is_timer_running (uint8_t timer_id) |
| void | pal_led (led_id_t led_no, led_action_t led_setting) |
| void | pal_led_init (void) |
| retval_t | pal_ps_get (ps_type_t ps_type, uint16_t start_addr, uint16_t length, void *value) |
| retval_t | pal_ps_set (uint16_t start_addr, uint16_t length, void *value) |
| retval_t | pal_sio_init (uint8_t sio_unit) |
| uint8_t | pal_sio_rx (uint8_t sio_unit, uint8_t *data, uint8_t max_length) |
| uint8_t | pal_sio_tx (uint8_t sio_unit, uint8_t *data, uint8_t length) |
| void | pal_sleep_mode (uint8_t sleep_mode) |
| void | pal_spi_done_cb_init (void *spi_done_cb) |
| retval_t | pal_start_high_priority_timer (uint8_t timer_id, uint16_t timer_count, FUNC_PTR timer_cb, void *param_cb) |
| retval_t | pal_stop_high_priority_timer (uint8_t timer_id) |
| static uint32_t | pal_sub_time_us (uint32_t a, uint32_t b) |
| void | pal_task (void) |
| void | pal_timer_delay (uint16_t delay) |
| void | pal_timer_source_select (source_type_t source) |
| 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) |
| retval_t | pal_timer_stop (uint8_t timer_id) |
| void | pal_trx_aes_wrrd (uint8_t addr, uint8_t *idata, uint8_t length) |
| uint8_t | pal_trx_bit_read (uint8_t addr, uint8_t mask, uint8_t pos) |
| void | pal_trx_bit_write (uint8_t reg_addr, uint8_t mask, uint8_t pos, uint8_t new_value) |
| void | pal_trx_frame_read (uint8_t *data, uint8_t length) |
| void | pal_trx_frame_write (uint8_t *data, uint8_t length) |
| void | pal_trx_irq_init_awake (FUNC_PTR trx_irq_cb) |
| void | pal_trx_irq_init_cca_ed (FUNC_PTR trx_irq_cb) |
| void | pal_trx_irq_init_rx_end (FUNC_PTR trx_irq_cb) |
| void | pal_trx_irq_init_tstamp (FUNC_PTR trx_irq_cb) |
| void | pal_trx_irq_init_tx_end (FUNC_PTR trx_irq_cb) |
| void | pal_trx_read_timestamp (uint32_t *timestamp) |
| uint8_t | pal_trx_reg_read (uint8_t addr) |
| void | pal_trx_reg_write (uint8_t addr, uint8_t data) |
| void | pal_trx_sram_read (uint8_t addr, uint8_t *data, uint8_t length) |
| void | pal_trx_sram_write (uint8_t addr, uint8_t *data, uint8_t length) |
| void | pal_wdt_enable (WDT_PER_t period) |
| void | RTC_Initialize (uint16_t period, uint16_t count, uint16_t compareValue, RTC_PRESCALER_t prescaler) |
| void | RTC_SetIntLevels (RTC_OVFINTLVL_t ovfIntLevel, RTC_COMPINTLVL_t compIntLevel) |
| void | sleeping_timer_init (void) |
| void | sleeping_timer_with_wdt (void) |
| void | sleeping_timer_without_wdt (void) |
| void | wdt_clear (void) |
| void | wdt_init (void) |
| void | wdt_parallel_timer_init (void) |
PAL related APIs.
This header file declares prototypes of PAL APIs, enumerations used by TAL and MAC.
Definition in file pal.h.
| #define ADD_TIME | ( | a, | |
| b | |||
| ) | ((a) + (b)) |
| #define PAL_RST_HIGH | ( | ) | RST_HIGH() |
| #define PAL_RST_LOW | ( | ) | RST_LOW() |
| #define PAL_SLP_TR_HIGH | ( | ) | SLP_TR_HIGH() |
| #define PAL_SLP_TR_LOW | ( | ) | SLP_TR_LOW() |
| #define PAL_TRX_IRQ_HIGH | ( | ) | IRQ_PINGET() |
| #define SUB_TIME | ( | a, | |
| b | |||
| ) | ((a) - (b)) |
| #define U16_TO_TARGET | ( | x | ) | ((((x) << 8) & 0xFF00) | (((x) >> 8) & 0x00FF)) |
| typedef enum pin_state_tag pin_state_t |
Pin State
| typedef enum sio_serial_tag sio_serial_t |
Stream I/O to serial mapping enumeration
| typedef enum source_type_tag source_type_t |
Timer clock source type
| typedef enum timeout_type_tag timeout_type_t |
Timeout type
| enum button_state_tag |
| enum led_action_tag |
| enum pin_state_tag |
| enum ps_type_tag |
| enum sio_serial_tag |
| enum source_type_tag |
| enum timeout_type_tag |
| static uint32_t pal_add_time_us | ( | uint32_t | a, |
| uint32_t | b | ||
| ) | [inline, static] |
| void pal_alert | ( | void | ) |
Alert indication.
This Function can be used by any application to indicate an error condition. The function is blocking and does never return.
Definition at line 191 of file pal.c.
References ALERT_INDICATE, ALERT_INIT, and pal_timer_delay().
| 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 |
This function returns the current time.
| [out] | current_time | Current system time |
Definition at line 697 of file pal_timer.c.
Referenced by ISR().
| retval_t pal_init | ( | void | ) |
Initialization of PAL.
This function initializes the PAL. The RC Oscillator is calibrated.
This function initializes the PAL. The RC oscillator is calibrated.
Definition at line 50 of file pal.c.
References gpio_init(), MAC_SUCCESS, mcu_init(), timer_init(), and wdt_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 |
Checks if the timer of requested timer identifier is running.
| timer_id | Timer identifier |
Definition at line 834 of file pal_timer.c.
| retval_t pal_ps_get | ( | ps_type_t | ps_type, |
| uint16_t | start_addr, | ||
| uint16_t | length, | ||
| void * | value | ||
| ) |
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 |
Definition at line 110 of file pal.c.
References EXTERN_EEPROM, extern_eeprom_get(), FAILURE, INTERN_EEPROM, MAC_INVALID_PARAMETER, and MAC_SUCCESS.
| 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 |
Definition at line 157 of file pal.c.
References FAILURE, and MAC_SUCCESS.
| retval_t pal_sio_init | ( | uint8_t | sio_unit | ) |
Initializes the requested SIO unit.
This function initializes the requested SIO unit.
| sio_unit | Specifies the SIO uint to be initialized |
| uint8_t pal_sio_rx | ( | uint8_t | sio_unit, |
| uint8_t * | data, | ||
| uint8_t | max_length | ||
| ) |
Receives data from selected SIO unit.
This function receives data from the selected SIO unit.
| sio_unit | Specifies SIO unit | |
| [out] | data | Pointer to the buffer to store received data |
| [in] | max_length | Maximum number of bytes to be received |
| uint8_t pal_sio_tx | ( | uint8_t | sio_unit, |
| uint8_t * | data, | ||
| uint8_t | length | ||
| ) |
Transmits data through selected SIO unit.
This function transmits data through the selected SIO unit.
| sio_unit | Specifies the SIO unit |
| data | Pointer to the data to be transmitted is present |
| length | Number of bytes to be transmitted |
| void pal_spi_done_cb_init | ( | void * | spi_done_cb | ) |
SPI done callback initialization.
| spi_done_cb | Pointer to SPI done callback function |
| 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 |
Definition at line 315 of file pal_timer.c.
References ENTER_CRITICAL_REGION, LEAVE_CRITICAL_REGION, MAC_INVALID_PARAMETER, MAC_SUCCESS, PAL_TMR_ALREADY_RUNNING, and PAL_TMR_INVALID_ID.
| 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 |
Definition at line 560 of file pal_timer.c.
References ENTER_CRITICAL_REGION, LEAVE_CRITICAL_REGION, MAC_SUCCESS, and PAL_TMR_NOT_RUNNING.
| static uint32_t pal_sub_time_us | ( | uint32_t | a, |
| uint32_t | b | ||
| ) | [inline, static] |
| void pal_task | ( | void | ) |
Services timer and sio handler.
This function calls sio & timer handling functions.
Definition at line 79 of file pal.c.
References timer_service().
| void pal_timer_delay | ( | uint16_t | delay | ) |
Generates blocking delay.
This functions generates a blocking delay of specified time.
| delay | in microseconds |
Generates blocking delay.
This functions performs a blocking delay of the specified time.
| delay | in microseconds |
Definition at line 730 of file pal_timer.c.
References DELAY_WITHOUT_IRQS_US.
Referenced by pal_alert(), and 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 |
|
This function selects the clock source of the timer.
Unused for the ATmega128RFA1 because the MAC symbol counter automatically switches from XTAL1 to RTC when the transceiver module is put to sleep.
| source |
|
Definition at line 682 of file pal_timer.c.
| 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 |
Start regular timer.
This function starts a regular timer and registers the corresponding callback function to handle the timeout event.
| timer_id | Timer identifier |
| timer_count | Timeout in microseconds |
| timeout_type | TIMEOUT_RELATIVE / TIMEOUT_ABSOLUTE |
| timer_cb | Callback handler invoked upon timer expiry |
| param_cb | Argument for the callback handler |
Definition at line 229 of file pal_timer.c.
References MAC_INVALID_PARAMETER, MAC_SUCCESS, MAX_TIMEOUT, MIN_TIMEOUT, PAL_TMR_ALREADY_RUNNING, PAL_TMR_INVALID_ID, PAL_TMR_INVALID_TIMEOUT, start_absolute_timer(), TIMEOUT_ABSOLUTE, and TIMEOUT_RELATIVE.
| 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 |
This function stops a running timer with the specified timer_id.
| timer_id | Timer identifier |
Definition at line 398 of file pal_timer.c.
References ENTER_CRITICAL_REGION, internal_timer_handler(), LEAVE_CRITICAL_REGION, MAC_SUCCESS, PAL_TMR_INVALID_ID, PAL_TMR_NOT_RUNNING, and prog_ocr().
| void pal_trx_aes_wrrd | ( | uint8_t | addr, |
| uint8_t * | idata, | ||
| uint8_t | length | ||
| ) |
Writes and reads data into/from SRAM of the transceiver.
This function writes data into the SRAM of the transceiver and simultaneously reads the bytes.
| addr | Start address in the SRAM for the write operation |
| idata | Pointer to the data written/read into/from SRAM |
| length | Number of bytes written/read into/from SRAM |
| uint8_t pal_trx_bit_read | ( | uint8_t | addr, |
| uint8_t | mask, | ||
| uint8_t | pos | ||
| ) |
Subregister read.
| addr | offset of the register |
| mask | bit mask of the subregister |
| pos | bit position of the subregister |
Referenced by ISR().
| void pal_trx_bit_write | ( | uint8_t | reg_addr, |
| uint8_t | mask, | ||
| uint8_t | pos, | ||
| uint8_t | new_value | ||
| ) |
Subregister write.
| [in] | reg_addr | Offset of the register |
| [in] | mask | Bit mask of the subregister |
| [in] | pos | Bit position of the subregister |
| [out] | new_value | Data, which is muxed into the register |
| void pal_trx_frame_read | ( | uint8_t * | data, |
| uint8_t | length | ||
| ) |
Reads frame buffer of the transceiver.
This function reads the frame buffer of the transceiver.
| [out] | data | Pointer to the location to store frame |
| [in] | length | Number of bytes to be read from the frame buffer. |
| void pal_trx_frame_write | ( | uint8_t * | data, |
| uint8_t | length | ||
| ) |
Writes data into frame buffer of the transceiver.
This function writes data into the frame buffer of the transceiver
| [in] | data | Pointer to data to be written into frame buffer |
| [in] | length | Number of bytes to be written into frame buffer |
| void pal_trx_irq_init_awake | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver AWAKE interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver AWAKE interrupt
| trx_irq_cb | Callback function for the transceiver AWAKE interrupt |
Definition at line 146 of file pal_irq.c.
References irq_hdl_trx_awake.
| void pal_trx_irq_init_cca_ed | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver CCA ED END interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver CCA ED END interrupt
| trx_irq_cb | Callback function for the transceiver CCA ED END interrupt |
Definition at line 114 of file pal_irq.c.
References irq_hdl_trx_cca_ed.
| void pal_trx_irq_init_rx_end | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver RX END interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver RX END interrupt
| trx_irq_cb | Callback function for the transceiver RX END interrupt |
Definition at line 100 of file pal_irq.c.
References irq_hdl_trx_rx_end.
| 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 |
Initializes the transceiver timestamp interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver timestamp interrupt (RX START interrupt)
| trx_irq_cb | Callback function for the transceiver timestamp interrupt (RX START interrupt) |
Definition at line 130 of file pal_irq.c.
References irq_hdl_trx_tstamp.
| void pal_trx_irq_init_tx_end | ( | FUNC_PTR | trx_irq_cb | ) |
Initializes the transceiver TX END interrupt.
This function sets the microcontroller specific registers responsible for handling the transceiver TX END interrupt
| trx_irq_cb | Callback function for the transceiver TX END interrupt |
Definition at line 86 of file pal_irq.c.
References irq_hdl_trx_tx_end.
| 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 |
Definition at line 716 of file pal_timer.c.
| uint8_t pal_trx_reg_read | ( | uint8_t | addr | ) |
Reads current value from a transceiver register.
This function reads the current value from a transceiver register.
| addr | Specifies the address of the trx register from which the data shall be read |
| void pal_trx_reg_write | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Writes data into a transceiver register.
This function writes a value into transceiver register.
| addr | Address of the trx register |
| data | Data to be written to trx register |
| void pal_trx_sram_read | ( | uint8_t | addr, |
| uint8_t * | data, | ||
| uint8_t | length | ||
| ) |
Reads data from SRAM of the transceiver.
This function reads from the SRAM of the transceiver
| [in] | addr | Start address in SRAM for read operation |
| [out] | data | Pointer to the location where data stored |
| [in] | length | Number of bytes to be read from SRAM |
| void pal_trx_sram_write | ( | uint8_t | addr, |
| uint8_t * | data, | ||
| uint8_t | length | ||
| ) |
Writes data into SRAM of the transceiver.
This function writes data into the SRAM of the transceiver
| addr | Start address in the SRAM for the write operation |
| data | Pointer to the data to be written into SRAM |
| length | Number of bytes to be written into SRAM |
| void pal_wdt_enable | ( | WDT_PER_t | period | ) |
Enable Watchdog and set prescaler.
This function enables the Watchdog and applies prescaler settings. The Watchdog will be reset automatically.
The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the watchdog to be synchronized to the other clock domains before proceeding
| period | Watchdog Timer timeout period |
| void RTC_Initialize | ( | uint16_t | period, |
| uint16_t | count, | ||
| uint16_t | compareValue, | ||
| RTC_PRESCALER_t | prescaler | ||
| ) |
This function initializes the RTC with period, initial count, compare value and clock prescaler.
All the synchronized registers are written at the same time to save time. The program code need to check if the RTC is busy before calling this function. The RTC_Busy() function can be used to do this.
| period | RTC period. Topvalue = Period - 1. |
| count | Initial RTC count. |
| compareValue | Compare value. |
| prescaler | Clock prescaler setting. |
| void RTC_SetIntLevels | ( | RTC_OVFINTLVL_t | ovfIntLevel, |
| RTC_COMPINTLVL_t | compIntLevel | ||
| ) |
This function sets both compare and overflow interrupt levels in one go.
| ovfIntLevel | The overflow interrupt level. |
| compIntLevel | The compare interrupt level. |
| void sleeping_timer_with_wdt | ( | void | ) |
Initialization of Sleeping timer (RTC) of the Atxmega1281 when Watchdog Timer is enabled. The period for the Sleeping timer should be given by the user in this case and the period of the sleeping timer should be less than the time-out period of the watchdog timer.