lriot 2.1.0.0
|
System driver definition for LR1110. More...
#include "transceiver/lr1110_system_types.h"
#include "common/lr1110_types.h"
#include "common/lr1110_hal.h"
Go to the source code of this file.
Macros | |
#define | LR1110_SYSTEM_IMAGE_CALIBRATION_STEP_IN_MHZ 4 |
Frequency step in MHz used to compute the image calibration parameter. | |
Functions | |
err_t | lr1110_system_reset (lriot_t *ctx) |
Reset the radio. | |
err_t | lr1110_system_wakeup (lriot_t *ctx) |
Wake the radio up from sleep mode. | |
err_t | lr1110_system_get_status (lriot_t *ctx, lr1110_system_stat1_t *stat1, lr1110_system_stat2_t *stat2, lr1110_system_irq_mask_t *irq_status) |
Return stat1, stat2, and irq_status. | |
err_t | lr1110_system_clear_reset_status_info (lriot_t *ctx) |
Clear the reset status information stored in stat2. | |
err_t | lr1110_system_get_irq_status (lriot_t *ctx, lr1110_system_irq_mask_t *irq_status) |
Return irq_status. | |
err_t | lr1110_system_get_version (lriot_t *ctx, lr1110_system_version_t *version) |
Return the version of the system (hardware and software) | |
err_t | lr1110_system_get_errors (lriot_t *ctx, uint16_t *errors) |
Return the system errors. | |
err_t | lr1110_system_clear_errors (lriot_t *ctx) |
Clear all error flags pending. | |
err_t | lr1110_system_calibrate (lriot_t *ctx, uint8_t calib_param) |
lr1110_system_calibrate the requested blocks | |
err_t | lr1110_system_set_reg_mode (lriot_t *ctx, lr1110_system_reg_mode_t reg_mode) |
Configure the regulator mode to be used in specific modes. | |
err_t | lr1110_system_calibrate_image (lriot_t *ctx, uint8_t freq1, uint8_t freq2) |
Launch an image calibration valid for all frequencies inside an interval, in steps. | |
err_t | lr1110_system_calibrate_image_in_mhz (lriot_t *ctx, uint16_t freq1_in_mhz, uint16_t freq2_in_mhz) |
Launch an image calibration valid for all frequencies inside an interval, in MHz. | |
err_t | lr1110_system_set_dio_as_rf_switch (lriot_t *ctx, lr1110_system_rfswitch_cfg_t *rf_switch_cfg) |
Set the RF switch configurations for each RF setup. | |
err_t | lr1110_system_set_dio_irq_params (lriot_t *ctx, lr1110_system_irq_mask_t irqs_to_enable_dio1, lr1110_system_irq_mask_t irqs_to_enable_dio2) |
Set which interrupt signals are redirected to the dedicated DIO pin. | |
err_t | lr1110_system_clear_irq_status (lriot_t *ctx, lr1110_system_irq_mask_t irqs_to_clear) |
Clear requested bits in the internal pending interrupt register. | |
err_t | lr1110_system_get_and_clear_irq_status (lriot_t *ctx, lr1110_system_irq_mask_t *irq) |
This helper function clears any radio irq status flags that are set and returns the flags that were cleared. | |
err_t | lr1110_system_cfg_lfclk (lriot_t *ctx, lr1110_system_lfclk_cfg_t lfclock_cfg, bool wait_for_32k_ready) |
Defines which clock is used as Low Frequency (LF) clock. | |
err_t | lr1110_system_set_tcxo_mode (lriot_t *ctx, lr1110_system_tcxo_supply_voltage_t tune, uint32_t timeout) |
Enable and configure TCXO supply voltage and detection timeout. | |
err_t | lr1110_system_reboot (lriot_t *ctx, bool stay_in_bootloader) |
Software reset of the chip. | |
err_t | lr1110_system_get_vbat (lriot_t *ctx, uint8_t *vbat) |
Returns the value of Vbat. | |
err_t | lr1110_system_get_temp (lriot_t *ctx, uint16_t *temp) |
Returns the value of Temp. | |
err_t | lr1110_system_set_sleep (lriot_t *ctx, lr1110_system_sleep_cfg_t sleep_cfg, uint32_t sleep_time) |
Set the device into Sleep or Deep Sleep Mode. | |
err_t | lr1110_system_set_standby (lriot_t *ctx, lr1110_system_standby_cfg_t standby_cfg) |
Set the device into the requested Standby mode. | |
err_t | lr1110_system_set_fs (lriot_t *ctx) |
Set the device into Frequency Synthesis (FS) mode. | |
err_t | lr1110_system_erase_infopage (lriot_t *ctx, lr1110_system_infopage_id_t info_page_id) |
Erase an info page. | |
err_t | lr1110_system_write_infopage (lriot_t *ctx, lr1110_system_infopage_id_t info_page_id, uint16_t address, uint32_t *data_buf, uint8_t length) |
Write data in an info page. | |
err_t | lr1110_system_read_infopage (lriot_t *ctx, lr1110_system_infopage_id_t info_page_id, uint16_t address, uint32_t *data_buf, uint8_t length) |
Read data from an info page. | |
err_t | lr1110_system_read_uid (lriot_t *ctx, lr1110_system_uid_t unique_identifier) |
Read and return the Unique Identifier of the LR1110. | |
err_t | lr1110_system_read_join_eui (lriot_t *ctx, lr1110_system_join_eui_t join_eui) |
Read and return the Join EUI of the LR1110. | |
err_t | lr1110_system_read_pin (lriot_t *ctx, lr1110_system_pin_t pin) |
Compute and return the PIN of the LR1110 based on factory default EUIs. | |
err_t | lr1110_system_read_pin_custom_eui (lriot_t *ctx, lr1110_system_uid_t device_eui, lr1110_system_join_eui_t join_eui, uint8_t rfu, lr1110_system_pin_t pin) |
Compute and return the PIN of the LR1110 based on EUIs provided as parameters. | |
err_t | lr1110_system_get_random_number (lriot_t *ctx, uint32_t *random_number) |
Read and return a 32-bit random number. | |
err_t | lr1110_system_enable_spi_crc (lriot_t *ctx, bool enable_crc) |
Enable the CRC on SPI transactions. | |
err_t | lr1110_system_drive_dio_in_sleep_mode (lriot_t *ctx, bool enable_drive) |
Configure the GPIO drive in sleep mode. | |
System driver definition for LR1110.
The Clear BSD License Copyright Semtech Corporation 2021. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define LR1110_SYSTEM_IMAGE_CALIBRATION_STEP_IN_MHZ 4 |
Frequency step in MHz used to compute the image calibration parameter.
err_t lr1110_system_calibrate | ( | lriot_t * | ctx, |
uint8_t | calib_param ) |
lr1110_system_calibrate the requested blocks
This function can be called in any mode of the chip.
The chip will return to standby RC mode on exit. Potential calibration issues can be read out with lr1110_system_get_errors command.
[in] | ctx | Chip implementation context |
[in] | calib_param | Structure holding the reference to blocks to be calibrated |
err_t lr1110_system_calibrate_image | ( | lriot_t * | ctx, |
uint8_t | freq1, | ||
uint8_t | freq2 ) |
Launch an image calibration valid for all frequencies inside an interval, in steps.
This function can be called in any mode of the chip.
The chip will return to standby RC mode on exit. Potential calibration issues can be read out with lr1110_system_get_errors command.
The frequencies given in parameters are defined in 4MHz step (Eg. 900MHz corresponds to 0xE1). If freq1 = freq2, only one calibration is performed.
[in] | ctx | Chip implementation context |
[in] | freq1 | Image calibration interval lower bound, in steps |
[in] | freq2 | Image calibration interval upper bound, in steps |
err_t lr1110_system_calibrate_image_in_mhz | ( | lriot_t * | ctx, |
uint16_t | freq1_in_mhz, | ||
uint16_t | freq2_in_mhz ) |
Launch an image calibration valid for all frequencies inside an interval, in MHz.
[in] | ctx | Chip implementation context |
[in] | freq1_in_mhz | Image calibration interval lower bound, in MHz |
[in] | freq2_in_mhz | Image calibration interval upper bound, in MHz |
err_t lr1110_system_cfg_lfclk | ( | lriot_t * | ctx, |
lr1110_system_lfclk_cfg_t | lfclock_cfg, | ||
bool | wait_for_32k_ready ) |
Defines which clock is used as Low Frequency (LF) clock.
[in] | ctx | Chip implementation context |
[in] | lfclock_cfg | Low frequency clock configuration |
[in] | wait_for_32k_ready | Tells the radio if it has to check if 32k source is ready before driving busy low |
err_t lr1110_system_clear_errors | ( | lriot_t * | ctx | ) |
Clear all error flags pending.
This function cannot be used to clear flags individually.
[in] | ctx | Chip implementation context |
err_t lr1110_system_clear_irq_status | ( | lriot_t * | ctx, |
lr1110_system_irq_mask_t | irqs_to_clear ) |
Clear requested bits in the internal pending interrupt register.
[in] | ctx | Chip implementation context |
[in] | irqs_to_clear | Variable that holds the interrupts to be cleared |
err_t lr1110_system_clear_reset_status_info | ( | lriot_t * | ctx | ) |
Clear the reset status information stored in stat2.
[in] | ctx | Chip implementation context |
err_t lr1110_system_drive_dio_in_sleep_mode | ( | lriot_t * | ctx, |
bool | enable_drive ) |
Configure the GPIO drive in sleep mode.
[in] | ctx | Chip implementation context |
[in] | enable_drive | GPIO drive configuration (true: enabled / false: disabled) |
err_t lr1110_system_enable_spi_crc | ( | lriot_t * | ctx, |
bool | enable_crc ) |
Enable the CRC on SPI transactions.
[in] | ctx | Chip implementation context |
[in] | enable_crc | CRC |
err_t lr1110_system_erase_infopage | ( | lriot_t * | ctx, |
lr1110_system_infopage_id_t | info_page_id ) |
Erase an info page.
[in] | ctx | Chip implementation context |
[in] | info_page_id | Info page to be erased. Only LR1110_SYSTEM_INFOPAGE_1 is allowed. |
err_t lr1110_system_get_and_clear_irq_status | ( | lriot_t * | ctx, |
lr1110_system_irq_mask_t * | irq ) |
This helper function clears any radio irq status flags that are set and returns the flags that were cleared.
[in] | ctx | Chip implementation context. |
[out] | irq | Pointer to a variable for holding the system interrupt status. Can be NULL. |
err_t lr1110_system_get_errors | ( | lriot_t * | ctx, |
uint16_t * | errors ) |
Return the system errors.
Errors may be fixed following:
[in] | ctx | Chip implementation context |
[out] | errors | Pointer to a value holding error flags |
err_t lr1110_system_get_irq_status | ( | lriot_t * | ctx, |
lr1110_system_irq_mask_t * | irq_status ) |
Return irq_status.
[in] | ctx | Chip implementation context |
[out] | irq_status | irq_status status variable |
err_t lr1110_system_get_random_number | ( | lriot_t * | ctx, |
uint32_t * | random_number ) |
Read and return a 32-bit random number.
[in] | ctx | Chip implementation context |
[out] | random_number | 32-bit random number |
err_t lr1110_system_get_status | ( | lriot_t * | ctx, |
lr1110_system_stat1_t * | stat1, | ||
lr1110_system_stat2_t * | stat2, | ||
lr1110_system_irq_mask_t * | irq_status ) |
Return stat1, stat2, and irq_status.
[in] | ctx | Chip implementation context |
[out] | stat1 | Pointer to a variable for holding stat1. Can be NULL. |
[out] | stat2 | Pointer to a variable for holding stat2. Can be NULL. |
[out] | irq_status | Pointer to a variable for holding irq_status. Can be NULL. |
err_t lr1110_system_get_temp | ( | lriot_t * | ctx, |
uint16_t * | temp ) |
Returns the value of Temp.
The temperature (in °C) is a function of Vana (typ. 1.35V), Vbe25 (Vbe voltage @ 25°C, typ. 0.7295V) and VbeSlope (typ. -1.7mV/°C) using the following formula:
[in] | ctx | Chip implementation context |
[out] | temp | A pointer to the Temp value |
err_t lr1110_system_get_vbat | ( | lriot_t * | ctx, |
uint8_t * | vbat ) |
Returns the value of Vbat.
Vbat value (in V) is a function of Vana (typ. 1.35V) using the following formula:
[in] | ctx | Chip implementation context |
[out] | vbat | A pointer to the Vbat value |
err_t lr1110_system_get_version | ( | lriot_t * | ctx, |
lr1110_system_version_t * | version ) |
Return the version of the system (hardware and software)
[in] | ctx | Chip implementation context |
[out] | version | Pointer to the structure holding the system version |
err_t lr1110_system_read_infopage | ( | lriot_t * | ctx, |
lr1110_system_infopage_id_t | info_page_id, | ||
uint16_t | address, | ||
uint32_t * | data_buf, | ||
uint8_t | length ) |
Read data from an info page.
It is possible to cross from page 0 to 1 if (address + length >= 512)
[in] | ctx | Chip implementation context |
[in] | info_page_id | Info page where data are read |
[in] | address | Address within the info page (aligned on 32-bit data) |
[out] | data_buf | Pointer to the data to read (data buffer shall be - at least - length words long) |
[in] | length | Number of 32-bit data to read (maximum value is 64) |
err_t lr1110_system_read_join_eui | ( | lriot_t * | ctx, |
lr1110_system_join_eui_t | join_eui ) |
Read and return the Join EUI of the LR1110.
[in] | ctx | Chip implementation context |
[out] | join_eui | The buffer to be filled with Join EUI of the LR1110. It is up to the application to ensure join_eui is long enough to hold the join EUI |
err_t lr1110_system_read_pin | ( | lriot_t * | ctx, |
lr1110_system_pin_t | pin ) |
Compute and return the PIN of the LR1110 based on factory default EUIs.
[in] | ctx | Chip implementation context |
[out] | pin | The buffer to be filled with PIN of the LR1110. It is up to the application to ensure pin is long enough to hold the PIN |
err_t lr1110_system_read_pin_custom_eui | ( | lriot_t * | ctx, |
lr1110_system_uid_t | device_eui, | ||
lr1110_system_join_eui_t | join_eui, | ||
uint8_t | rfu, | ||
lr1110_system_pin_t | pin ) |
Compute and return the PIN of the LR1110 based on EUIs provided as parameters.
[in] | ctx | Chip implementation context |
[in] | device_eui | Custom Device EUI |
[in] | join_eui | Custom Join EUI |
[in] | rfu | Parameter RFU - shall be set to 0x00 |
[out] | pin | The buffer to be filled with PIN of the LR1110. It is up to the application to ensure pin is long enough to hold the PIN |
err_t lr1110_system_read_uid | ( | lriot_t * | ctx, |
lr1110_system_uid_t | unique_identifier ) |
Read and return the Unique Identifier of the LR1110.
[in] | ctx | Chip implementation context |
[out] | unique_identifier | The buffer to be filled with the Unique Identifier of the LR1110. It is up to the application to ensure unique_identifier is long enough to hold the unique identifier |
err_t lr1110_system_reboot | ( | lriot_t * | ctx, |
bool | stay_in_bootloader ) |
Software reset of the chip.
This function should be used to reboot the chip in a specified mode. Rebooting in flash mode presumes that the content in flash memory is not corrupted (i.e. the integrity check performed by the bootloader before executing the first instruction in flash is OK).
[in] | ctx | Chip implementation context |
[in] | stay_in_bootloader | Selector to stay in bootloader or execute flash code after reboot. If true, the bootloader will not execute the flash code but activate SPI interface to allow firmware upgrade |
err_t lr1110_system_reset | ( | lriot_t * | ctx | ) |
Reset the radio.
[in] | ctx | Chip implementation context |
err_t lr1110_system_set_dio_as_rf_switch | ( | lriot_t * | ctx, |
lr1110_system_rfswitch_cfg_t * | rf_switch_cfg ) |
Set the RF switch configurations for each RF setup.
This function shall only be called in standby RC mode.
By default, no DIO is used to control a RF switch. All DIOs are set in High-Z mode.
[in] | ctx | Chip implementation context |
[in] | rf_switch_cfg | Pointer to a structure that holds the switches configuration |
err_t lr1110_system_set_dio_irq_params | ( | lriot_t * | ctx, |
lr1110_system_irq_mask_t | irqs_to_enable_dio1, | ||
lr1110_system_irq_mask_t | irqs_to_enable_dio2 ) |
Set which interrupt signals are redirected to the dedicated DIO pin.
By default, no interrupt signal is redirected.
The dedicated DIO pin will remain asserted until all redirected interrupt signals are cleared with a call to lr1110_system_clear_irq_status.
[in] | ctx | Chip implementation context |
[in] | irqs_to_enable_dio1 | Variable that holds the interrupt mask for dio1 |
[in] | irqs_to_enable_dio2 | Variable that holds the interrupt mask for dio2 |
err_t lr1110_system_set_fs | ( | lriot_t * | ctx | ) |
Set the device into Frequency Synthesis (FS) mode.
[in] | ctx | Chip implementation context |
err_t lr1110_system_set_reg_mode | ( | lriot_t * | ctx, |
lr1110_system_reg_mode_t | reg_mode ) |
Configure the regulator mode to be used in specific modes.
This function shall only be called in standby RC mode.
The reg_mode parameter defines if the DC-DC converter is switched on in the following modes: STANDBY XOSC, FS, RX, TX and RX_CAPTURE.
[in] | ctx | Chip implementation context |
[in] | reg_mode | Regulator mode configuration |
err_t lr1110_system_set_sleep | ( | lriot_t * | ctx, |
lr1110_system_sleep_cfg_t | sleep_cfg, | ||
uint32_t | sleep_time ) |
Set the device into Sleep or Deep Sleep Mode.
The sleep_cfg parameter defines in which sleep mode the device is put and if it wakes up after a given time on the RTC event.
The sleep_time parameter is taken into account only when RtcTimeout = 1. It sets the sleep time in number of clock cycles:
[in] | ctx | Chip implementation context |
[in] | sleep_cfg | Sleep mode configuration |
[in] | sleep_time | Value of the RTC timeout (if RtcTimeout = 1) |
err_t lr1110_system_set_standby | ( | lriot_t * | ctx, |
lr1110_system_standby_cfg_t | standby_cfg ) |
Set the device into the requested Standby mode.
[in] | ctx | Chip implementation context |
[in] | standby_cfg | Stand by mode configuration (RC or XOSC) |
err_t lr1110_system_set_tcxo_mode | ( | lriot_t * | ctx, |
lr1110_system_tcxo_supply_voltage_t | tune, | ||
uint32_t | timeout ) |
Enable and configure TCXO supply voltage and detection timeout.
This function shall only be called in standby RC mode.
The timeout parameter is the maximum time the firmware waits for the TCXO to be ready. The timeout duration is given by:
The TCXO mode can be disabled by setting timeout parameter to 0.
[in] | ctx | Chip implementation context |
[in] | tune | Supply voltage value |
[in] | timeout | Gating time before which the radio starts its Rx / Tx operation |
err_t lr1110_system_wakeup | ( | lriot_t * | ctx | ) |
Wake the radio up from sleep mode.
[in] | context | Chip implementation context. |
err_t lr1110_system_write_infopage | ( | lriot_t * | ctx, |
lr1110_system_infopage_id_t | info_page_id, | ||
uint16_t | address, | ||
uint32_t * | data_buf, | ||
uint8_t | length ) |
Write data in an info page.
[in] | ctx | Chip implementation context |
[in] | info_page_id | Info page where data are written. Only LR1110_SYSTEM_INFOPAGE_1 is allowed. |
[in] | address | Address within the info page (aligned on 32-bit data) |
[in] | data_buf | Pointer to the data to write (data buffer shall be - at least - length words long) |
[in] | length | Number of 32-bit data to write (maximum value is 64) |