RA Flexible Software Package Documentation  Release v5.6.0

 
Low Voltage Detection Interface

Detailed Description

Interface for Low Voltage Detection.

Summary

The LVD driver provides functions for configuring the LVD voltage monitors and detectors.

Data Structures

struct  lvd_status_t
 
struct  lvd_callback_args_t
 
struct  lvd_cfg_t
 
struct  lvd_api_t
 
struct  lvd_instance_t
 

Typedefs

typedef void lvd_ctrl_t
 

Enumerations

enum  lvd_threshold_t
 
enum  lvd_response_t
 
enum  lvd_voltage_slope_t
 
enum  lvd_sample_clock_t
 
enum  lvd_negation_delay_t
 
enum  lvd_threshold_crossing_t
 
enum  lvd_current_state_t
 

Data Structure Documentation

◆ lvd_status_t

struct lvd_status_t

Current state of a voltage monitor.

Data Fields
lvd_threshold_crossing_t crossing_detected

Threshold crossing detection (latched)

lvd_current_state_t current_state

Instantaneous status of monitored voltage (above or below threshold)

◆ lvd_callback_args_t

struct lvd_callback_args_t

LVD callback parameter definition

Data Fields
uint32_t monitor_number Monitor number.
lvd_current_state_t current_state Current state of the voltage monitor.
void const * p_context Placeholder for user data.

◆ lvd_cfg_t

struct lvd_cfg_t

LVD configuration structure

Data Fields

uint32_t monitor_number
 
lvd_threshold_t voltage_threshold
 
lvd_response_t detection_response
 
lvd_voltage_slope_t voltage_slope
 
lvd_negation_delay_t negation_delay
 
lvd_sample_clock_t sample_clock_divisor
 
IRQn_Type irq
 
uint8_t monitor_ipl
 
void(* p_callback )(lvd_callback_args_t *p_args)
 
void const * p_context
 
void const * p_extend
 

Field Documentation

◆ monitor_number

uint32_t lvd_cfg_t::monitor_number

Monitor number, 1, 2, ...

◆ voltage_threshold

lvd_threshold_t lvd_cfg_t::voltage_threshold

Threshold for out of range voltage detection

◆ detection_response

lvd_response_t lvd_cfg_t::detection_response

Response on detecting a threshold crossing

◆ voltage_slope

lvd_voltage_slope_t lvd_cfg_t::voltage_slope

Direction of voltage crossing that will trigger a detection (Rising Edge, Falling Edge, Both).

◆ negation_delay

lvd_negation_delay_t lvd_cfg_t::negation_delay

Negation of LVD signal follows reset or voltage in range

◆ sample_clock_divisor

lvd_sample_clock_t lvd_cfg_t::sample_clock_divisor

Sample clock divider, use LVD_SAMPLE_CLOCK_DISABLED to disable digital filtering

◆ irq

IRQn_Type lvd_cfg_t::irq

Interrupt number.

◆ monitor_ipl

uint8_t lvd_cfg_t::monitor_ipl

Interrupt priority level.

◆ p_callback

void(* lvd_cfg_t::p_callback) (lvd_callback_args_t *p_args)

User function to be called from interrupt

◆ p_context

void const* lvd_cfg_t::p_context

Placeholder for user data. Passed to the user callback in

◆ p_extend

void const* lvd_cfg_t::p_extend

Extension parameter for hardware specific settings

◆ lvd_api_t

struct lvd_api_t

LVD driver API structure. LVD driver functions implemented at the HAL layer will adhere to this API.

Data Fields

fsp_err_t(* open )(lvd_ctrl_t *const p_ctrl, lvd_cfg_t const *const p_cfg)
 
fsp_err_t(* statusGet )(lvd_ctrl_t *const p_ctrl, lvd_status_t *p_lvd_status)
 
fsp_err_t(* statusClear )(lvd_ctrl_t *const p_ctrl)
 
fsp_err_t(* callbackSet )(lvd_ctrl_t *const p_ctrl, void(*p_callback)(lvd_callback_args_t *), void const *const p_context, lvd_callback_args_t *const p_callback_memory)
 
fsp_err_t(* close )(lvd_ctrl_t *const p_ctrl)
 

Field Documentation

◆ open

fsp_err_t(* lvd_api_t::open) (lvd_ctrl_t *const p_ctrl, lvd_cfg_t const *const p_cfg)

Initializes a low voltage detection driver according to the passed-in configuration structure.

Parameters
[in]p_ctrlPointer to control structure for the driver instance
[in]p_cfgPointer to the configuration structure for the driver instance

◆ statusGet

fsp_err_t(* lvd_api_t::statusGet) (lvd_ctrl_t *const p_ctrl, lvd_status_t *p_lvd_status)

Get the current state of the monitor, (threshold crossing detected, voltage currently above or below threshold). Must be used if the peripheral was initialized with lvd_response_t set to LVD_RESPONSE_NONE.

Parameters
[in]p_ctrlPointer to the control structure for the driver instance
[in,out]p_lvd_statusPointer to a lvd_status_t structure

◆ statusClear

fsp_err_t(* lvd_api_t::statusClear) (lvd_ctrl_t *const p_ctrl)

Clears the latched status of the monitor. Must be used if the peripheral was initialized with lvd_response_t set to LVD_RESPONSE_NONE.

Parameters
[in]p_ctrlPointer to the control structure for the driver instance

◆ callbackSet

fsp_err_t(* lvd_api_t::callbackSet) (lvd_ctrl_t *const p_ctrl, void(*p_callback)(lvd_callback_args_t *), void const *const p_context, lvd_callback_args_t *const p_callback_memory)

Specify callback function and optional context pointer and working memory pointer.

Parameters
[in]p_ctrlPointer to the LVD control block.
[in]p_callbackCallback function
[in]p_contextPointer to send to callback function
[in]p_working_memoryPointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback.

◆ close

fsp_err_t(* lvd_api_t::close) (lvd_ctrl_t *const p_ctrl)

Disables the LVD peripheral. Closes the driver instance.

Parameters
[in]p_ctrlPointer to the control structure for the driver instance

◆ lvd_instance_t

struct lvd_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
lvd_ctrl_t * p_ctrl Pointer to the control structure for this instance.
lvd_cfg_t const * p_cfg Pointer to the configuration structure for this interface instance.
lvd_api_t const * p_api Pointer to the API structure for this interface instance.

Typedef Documentation

◆ lvd_ctrl_t

typedef void lvd_ctrl_t

LVD control block. Allocate an instance specific control block to pass into the LVD API calls.

Enumeration Type Documentation

◆ lvd_threshold_t

enum lvd_threshold_t

Register definitions, common services, and error codes. Voltage detection level The thresholds supported by each MCU are in the MCU User's Manual as well as in the r_lvd module description on the stack tab of the RA project.

Enumerator
LVD_THRESHOLD_MONITOR_1_LEVEL_4_08V 

4.08V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_88V 

3.88V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_67V 

3.67V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_47V 

3.47V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_27V 

3.27V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_06V 

3.06V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_91V 

2.91V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_76V 

2.76V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_60V 

2.60V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_45V 

2.45V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_35V 

2.35V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_25V 

2.25V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_15V 

2.15V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_04V 

2.04V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_94V 

1.94V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_84V 

1.84V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_74V 

1.74V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_63V 

1.63V

LVD_THRESHOLD_MONITOR_1_LEVEL_4_29V 

4.29V

LVD_THRESHOLD_MONITOR_1_LEVEL_4_16V 

4.16V

LVD_THRESHOLD_MONITOR_1_LEVEL_4_14V 

4.14V

LVD_THRESHOLD_MONITOR_1_LEVEL_4_03V 

4.03V

LVD_THRESHOLD_MONITOR_1_LEVEL_4_02V 

4.02V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_86V 

3.86V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_84V 

3.84V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_10V 

3.10V

LVD_THRESHOLD_MONITOR_1_LEVEL_3_00V 

3.00V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_90V 

2.90V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_79V 

2.79V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_68V 

2.68V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_58V 

2.58V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_48V 

2.48V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_20V 

2.20V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_96V 

1.96V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_86V 

1.86V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_75V 

1.75V

LVD_THRESHOLD_MONITOR_1_LEVEL_1_65V 

1.65V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_99V 

2.99V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_92V 

2.92V

LVD_THRESHOLD_MONITOR_1_LEVEL_2_85V 

2.85V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_31V 

4.31V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_29V 

4.29V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_17V 

4.17V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_14V 

4.14V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_03V 

4.03V

LVD_THRESHOLD_MONITOR_2_LEVEL_4_02V 

4.02V

LVD_THRESHOLD_MONITOR_2_LEVEL_3_84V 

3.84V

LVD_THRESHOLD_MONITOR_2_LEVEL_2_99V 

2.99V

LVD_THRESHOLD_MONITOR_2_LEVEL_2_92V 

2.92V

LVD_THRESHOLD_MONITOR_2_LEVEL_2_85V 

2.85V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_3_1V 

3.1V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_9V 

2.9V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_8V 

2.8V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_7V 

2.7V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_6V 

2.6V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_4V 

2.4V

LVD_THRESHOLD_EXLVDVBAT_LEVEL_2_2V 

2.2V

LVD_THRESHOLD_LVDVRTC_LEVEL_2_8V 

2.8V

LVD_THRESHOLD_LVDVRTC_LEVEL_2_6V 

2.6V

LVD_THRESHOLD_LVDVRTC_LEVEL_2_4V 

2.4V

LVD_THRESHOLD_LVDVRTC_LEVEL_2_2V 

2.2V

◆ lvd_response_t

Response types for handling threshold crossing event.

Enumerator
LVD_RESPONSE_NMI 

Non-maskable interrupt.

LVD_RESPONSE_INTERRUPT 

Maskable interrupt.

LVD_RESPONSE_RESET 

Reset on VCC-fall.

LVD_RESPONSE_RESET_ON_RISING 

Reset on VCC-rise.

LVD_RESPONSE_NONE 

No response, status must be requested via statusGet function.

◆ lvd_voltage_slope_t

The direction from which VCC must cross the threshold to trigger a detection (rising, falling, or both).

Enumerator
LVD_VOLTAGE_SLOPE_RISING 

When VCC >= Vdet2 (rise) is detected.

LVD_VOLTAGE_SLOPE_FALLING 

When VCC < Vdet2 (drop) is detected.

LVD_VOLTAGE_SLOPE_BOTH 

When drop and rise are detected.

◆ lvd_sample_clock_t

Sample clock divider, use LVD_SAMPLE_CLOCK_DISABLED to disable digital filtering

Enumerator
LVD_SAMPLE_CLOCK_LOCO_DIV_2 

Digital filter sample clock is LOCO divided by 2.

LVD_SAMPLE_CLOCK_LOCO_DIV_4 

Digital filter sample clock is LOCO divided by 4.

LVD_SAMPLE_CLOCK_LOCO_DIV_8 

Digital filter sample clock is LOCO divided by 8.

LVD_SAMPLE_CLOCK_LOCO_DIV_16 

Digital filter sample clock is LOCO divided by 16.

LVD_SAMPLE_CLOCK_DISABLED 

Digital filter is disabled.

◆ lvd_negation_delay_t

Negation delay of LVD reset signal follows reset or voltage in range

Enumerator
LVD_NEGATION_DELAY_FROM_VOLTAGE 

Negation follows a stabilization time (tLVDn) after VCC > Vdet1 is detected. If a transition to software standby or deep software standby is to be made, the only possible value for the RN bit is LVD_NEGATION_DELAY_FROM_VOLTAGE

LVD_NEGATION_DELAY_FROM_RESET 

Negation follows a stabilization time (tLVDn) after assertion of the LVDn reset. If a transition to software standby or deep software standby is to be made, the only possible value for the RN bit is LVD_NEGATION_DELAY_FROM_VOLTAGE

◆ lvd_threshold_crossing_t

Threshold crossing detection (latched)

Enumerator
LVD_THRESHOLD_CROSSING_NOT_DETECTED 

Threshold crossing has not been detected.

LVD_THRESHOLD_CROSSING_DETECTED 

Threshold crossing has been detected.

◆ lvd_current_state_t

Instantaneous status of VCC (above or below threshold)

Enumerator
LVD_CURRENT_STATE_BELOW_THRESHOLD 

VCC < threshold.

LVD_CURRENT_STATE_ABOVE_THRESHOLD 

VCC >= threshold or monitor is disabled.