RA Flexible Software Package Documentation
Release v5.6.0
|
|
Functions | |
fsp_err_t | R_LVD_Open (lvd_ctrl_t *const p_api_ctrl, lvd_cfg_t const *const p_cfg) |
fsp_err_t | R_LVD_StatusGet (lvd_ctrl_t *const p_api_ctrl, lvd_status_t *p_lvd_status) |
fsp_err_t | R_LVD_StatusClear (lvd_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_LVD_CallbackSet (lvd_ctrl_t *const p_api_ctrl, void(*p_callback)(lvd_callback_args_t *), void const *const p_context, lvd_callback_args_t *const p_callback_memory) |
fsp_err_t | R_LVD_Close (lvd_ctrl_t *const p_api_ctrl) |
Driver for the LVD and PVD peripherals on RA MCUs. This module implements the Low Voltage Detection Interface.
The Low Voltage Detection module configures the voltage monitors to detect when a power supply pin or a voltage detector pin voltages crosses a specified threshold.
The LVD HAL module supports the following functions:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_lvd0 | Module name. |
Monitor Number | MCU Specific Options | Select the LVD monitor. | |
Digital Filter | MCU Specific Options | Enable the digital filter and select the digital filter clock divider. | |
Voltage Threshold | MCU Specific Options | Select the low voltage detection threshold. | |
Detection Response | MCU Specific Options | Select what happens when the voltage crosses the threshold voltage. | |
Voltage Slope | MCU Specific Options | Select interrupt generation on rising voltage, falling voltage or both. | |
Negation Delay | MCU Specific Options | Negation of the monitor signal can either be delayed from the reset event or from voltage returning to normal range. | |
Monitor Interrupt Callback | Name must be a valid C symbol. | NULL | A user callback function can be provided. If this callback function is provided, it will be called from the interrupt service routine (ISR) each time the IRQ triggers. |
LVD Monitor Interrupt Priority | MCU Specific Options | Select the LVD Monitor interrupt priority. |
The LOCO clock must be enabled in order to use the digital filter.
To use LVD module, you need to switch pin funtion of EXLVDVBAT pin, VRTC pin, EXLVD pin to enable LVD function on this pin.
If VCC is below the threshold prior to configuring the voltage monitor for falling edge detection, the monitor will immediately detect the a falling edge condition. If VCC is above the threshold prior to configuring the monitor for rising edge detection, the monitor will not detect a rising edge condition until VCC falls below the threshold and then rises above it again.
The LVD HAL module only supports configuring voltage monitor 1 and voltage monitor 2. Voltage monitor 0 can be configured by setting the appropriate bits in the OFS1 register. This means that voltage monitor 0 settings cannot be changed at runtime.
Voltage monitor 0 supports the following features
This is a basic example of minimal use of the LVD in an application.
This is a basic example of using a LVD instance that is configured to generate an interrupt.
This is a basic example of using a LVD instance that is configured to reset the MCU.
Data Structures | |
struct | lvd_instance_ctrl_t |
struct lvd_instance_ctrl_t |
LVD instance control structure
fsp_err_t R_LVD_Open | ( | lvd_ctrl_t *const | p_api_ctrl, |
lvd_cfg_t const *const | p_cfg | ||
) |
Initializes a voltage monitor and detector according to the passed-in configuration structure.
[in] | p_api_ctrl | Pointer to the control structure for the driver instance |
[in] | p_cfg | Pointer to the configuration structure for the driver instance |
Example:
FSP_SUCCESS | Successful |
FSP_ERR_ASSERTION | Requested configuration was invalid |
FSP_ERR_ALREADY_OPEN | The instance was already opened |
FSP_ERR_IN_USE | Another instance is already using the desired monitor |
FSP_ERR_UNSUPPORTED | Digital filter was enabled on a device that does not support it |
fsp_err_t R_LVD_StatusGet | ( | lvd_ctrl_t *const | p_api_ctrl, |
lvd_status_t * | p_lvd_status | ||
) |
Get the current state of the monitor (threshold crossing detected, voltage currently above or below threshold).
[in] | p_api_ctrl | Pointer to the control structure for the driver instance |
[out] | p_lvd_status | Pointer to status structure |
Example:
FSP_SUCCESS | Successful |
FSP_ERR_ASSERTION | An argument was NULL |
FSP_ERR_NOT_OPEN | Driver is not open |
fsp_err_t R_LVD_StatusClear | ( | lvd_ctrl_t *const | p_api_ctrl | ) |
Clears the latched status of the monitor.
[in] | p_api_ctrl | Pointer to the control structure for the driver instance |
FSP_SUCCESS | Successful |
FSP_ERR_ASSERTION | An argument was NULL |
FSP_ERR_NOT_OPEN | Driver is not open |
fsp_err_t R_LVD_CallbackSet | ( | lvd_ctrl_t *const | p_api_ctrl, |
void(*)(lvd_callback_args_t *) | p_callback, | ||
void const *const | p_context, | ||
lvd_callback_args_t *const | p_callback_memory | ||
) |
Updates the user callback and has option of providing memory for callback structure. Implements lvd_api_t::callbackSet
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
fsp_err_t R_LVD_Close | ( | lvd_ctrl_t *const | p_api_ctrl | ) |
Disables the LVD peripheral. Closes the driver instance.
[in] | p_api_ctrl | Pointer to the control block structure for the driver instance |
FSP_SUCCESS | Successful |
FSP_ERR_ASSERTION | An argument was NULL |
FSP_ERR_NOT_OPEN | Driver is not open |