PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
Low Voltage Detection (LVD)

Defines

#define LVD_TIMEOUT   (SystemCoreClock/10)
#define LvdCtlUnlock   (0x1ACCE553)

Typedefs

typedef enum en_lvd_int_volt en_lvd_int_volt_t
 Interruption voltage settings for Low Voltage Detection.
typedef enum en_lvd_reset_volt en_lvd_reset_volt_t
 Reset voltage settings for Low Voltage Detection.
typedef enum en_lvd_func en_lvd_func_t
 LVD functions.

Enumerations

enum  en_lvd_int_volt {
  LvdIntVoltage280 = 0, LvdIntVoltage300 = 1, LvdIntVoltage320 = 2, LvdIntVoltage360 = 3,
  LvdIntVoltage370 = 4, LvdIntVoltage400 = 5, LvdIntVoltage410 = 6, LvdIntVoltage420 = 7
}
 Interruption voltage settings for Low Voltage Detection. More...
enum  en_lvd_reset_volt {
  LvdResetVoltage245 = 0, LvdResetVoltage260 = 1, LvdResetVoltage270 = 2, LvdResetVoltage280 = 3,
  LvdResetVoltage300 = 4, LvdResetVoltage320 = 5, LvdResetVoltage360 = 6, LvdResetVoltage370 = 7,
  LvdResetVoltage400 = 8, LvdResetVoltage410 = 9, LvdResetVoltage420 = 10
}
 Reset voltage settings for Low Voltage Detection. More...
enum  en_lvd_func { LvdIntFunc = 0u, LvdResetFunc = 1u }
 LVD functions. More...

Functions

void LvdIrqHandler (void)
 ISR of the LVD module.
en_result_t Lvd_ConfigInt (func_ptr_t pfnCallback)
 Configure LVD interrupt.
en_result_t Lvd_SetIntDetectVoltage (en_lvd_int_volt_t enVolt)
 Set the interrupt detect voltage of LVD.
en_result_t Lvd_SetResetDetectVoltage (en_lvd_reset_volt_t enVolt)
 Set the reset detect voltage of LVD.
en_result_t Lvd_EnableFunc (en_lvd_func_t enFunc)
 Enable LVD function.
en_result_t Lvd_DisableFunc (en_lvd_func_t enFunc)
 Disable LVD function.
boolean_t Lvd_GetIntStatus (void)
 Get the LVD interrupt status.
void Lvd_ClearIntStatus (void)
 Clear the LVD interrupt status.

Variables

static func_ptr_t pfnLvdCallback
 LVD interrupt callback function.

Detailed Description

Provided functions of LPM module:

Lvd_SetIntDetectVoltage() sets voltage threshold to generate LVD interrupt, which can be selected by the parameter Lvd_SetIntDetectVoltage::enVolt.

Lvd_SetResetDetectVoltage() sets voltage threshold to generate LVD reset, which can be selected by the parameter Lvd_SetResetDetectVoltage::enVolt.

Lvd_EnableFunc() enables the LVD interrupt or reset function and Lvd_DisableFunc() disables the LVD interrupt or reset function.

Lvd_GetIntStatus() gets the interrupt flag of LVD interrupt and Lvd_ClearIntStatus() clears the interrupt flag of LVD interrupt.

Lvd_ConfigInt() enables or disables the LVD interrupt.

LvdIrqHandler() is LVD interrupt IRQ, which is called by interrupts.c


Define Documentation

#define LVD_TIMEOUT   (SystemCoreClock/10)

Definition at line 87 of file lvd.c.

Referenced by Lvd_EnableFunc().

#define LvdCtlUnlock   (0x1ACCE553)

Typedef Documentation

typedef enum en_lvd_func en_lvd_func_t

LVD functions.

Interruption voltage settings for Low Voltage Detection.

Note:
The enumerated values do not correspond with the bit patterns of SVHI for upward compatibility reasons.

Reset voltage settings for Low Voltage Detection.

Note:
The enumerated values do not correspond with the bit patterns of SVHR for upward compatibility reasons.

Enumeration Type Documentation

LVD functions.

Enumerator:
LvdIntFunc 

Interrupt function of LVD.

LvdResetFunc 

Reset function of LVD.

Definition at line 157 of file lvd.h.

Interruption voltage settings for Low Voltage Detection.

Note:
The enumerated values do not correspond with the bit patterns of SVHI for upward compatibility reasons.
Enumerator:
LvdIntVoltage280 

Interrupt when voltage is vicinity of 2.80 volts.

LvdIntVoltage300 

Interrupt when voltage is vicinity of 3.00 volts.

LvdIntVoltage320 

Interrupt when voltage is vicinity of 3.20 volts.

LvdIntVoltage360 

Interrupt when voltage is vicinity of 3.60 volts.

LvdIntVoltage370 

Interrupt when voltage is vicinity of 3.70 volts.

LvdIntVoltage400 

Interrupt when voltage is vicinity of 4.00 volts.

LvdIntVoltage410 

Interrupt when voltage is vicinity of 4.10 volts.

LvdIntVoltage420 

Interrupt when voltage is vicinity of 4.20 volts.

Definition at line 117 of file lvd.h.

Reset voltage settings for Low Voltage Detection.

Note:
The enumerated values do not correspond with the bit patterns of SVHR for upward compatibility reasons.
Enumerator:
LvdResetVoltage245 

Reset when voltage is vicinity of 2.45 volts.

LvdResetVoltage260 

Reset when voltage is vicinity of 2.60 volts.

LvdResetVoltage270 

Reset when voltage is vicinity of 2.70 volts.

LvdResetVoltage280 

Reset when voltage is vicinity of 2.80 volts.

LvdResetVoltage300 

Reset when voltage is vicinity of 3.00 volts.

LvdResetVoltage320 

Reset when voltage is vicinity of 3.20 volts.

LvdResetVoltage360 

Reset when voltage is vicinity of 3.60 volts.

LvdResetVoltage370 

Reset when voltage is vicinity of 3.70 volts.

LvdResetVoltage400 

Reset when voltage is vicinity of 4.00 volts.

LvdResetVoltage410 

Reset when voltage is vicinity of 4.10 volts.

LvdResetVoltage420 

Reset when voltage is vicinity of 4.20 volts.

Definition at line 137 of file lvd.h.


Function Documentation

void Lvd_ClearIntStatus ( void  )

Clear the LVD interrupt status.

Definition at line 397 of file lvd.c.

Configure LVD interrupt.

Parameters:
pfnCallbackinterrupt callback function
Return values:
OkLVD interrupt configured.
Note:
  • If pfnCallback = NULL, disable the IRQ
  • if pfnCallback != NULL, set the interrupt callback function and enable IRQ

Definition at line 121 of file lvd.c.

References Ok, PDL_DEFAULT_INTERRUPT_LEVEL, PDL_IRQ_LEVEL_LVD, and pfnLvdCallback.

Disable LVD function.

Parameters:
enFuncLVD function
  • LvdIntFunc LVD interrupt detection function
  • LvdResetFunc LVD reset detection function
Return values:
OkDisable LVD function normally
ErrorInvalidParameterInvalid setting of enFunc

Definition at line 350 of file lvd.c.

References ErrorInvalidParameter, LvdCtlUnlock, LvdIntFunc, LvdResetFunc, and Ok.

Enable LVD function.

Parameters:
enFuncLVD function
  • LvdIntFunc LVD interrupt detection function
  • LvdResetFunc LVD reset detection function
Return values:
OkEnable LVD function normally
ErrorInvalidParameterInvalid setting of enFunc

Definition at line 286 of file lvd.c.

References ErrorInvalidParameter, ErrorTimeout, LVD_TIMEOUT, LvdCtlUnlock, LvdIntFunc, LvdResetFunc, and Ok.

Get the LVD interrupt status.

Return values:
FALSEA low-voltage detection is not detected.
TRUEA low-voltage detection has been detected.

Definition at line 379 of file lvd.c.

References FALSE, and TRUE.

Set the interrupt detect voltage of LVD.

Parameters:
enVoltinterrupt detect voltage of LVD
  • LvdIntVoltage280 Set interrupt detect voltage to 2.80
  • LvdIntVoltage300 Set interrupt detect voltage to 3.00
  • LvdIntVoltage320 Set interrupt detect voltage to 3.20
  • LvdIntVoltage360 Set interrupt detect voltage to 3.60
  • LvdIntVoltage370 Set interrupt detect voltage to 3.70
  • LvdIntVoltage400 Set interrupt detect voltage to 4.00
  • LvdIntVoltage410 Set interrupt detect voltage to 4.10
  • LvdIntVoltage420 Set interrupt detect voltage to 4.20
Return values:
OkThe interrupt detect voltage of LVD is set normally
ErrorInvalidParameterInvalid setting of enVolt

Definition at line 166 of file lvd.c.

References ErrorInvalidParameter, LvdCtlUnlock, LvdIntVoltage280, LvdIntVoltage300, LvdIntVoltage320, LvdIntVoltage360, LvdIntVoltage370, LvdIntVoltage400, LvdIntVoltage410, LvdIntVoltage420, and Ok.

Set the reset detect voltage of LVD.

Parameters:
enVoltinterrupt detect voltage of LVD
  • LvdResetVoltage245 Set reset detect voltage to 2.45
  • LvdResetVoltage260 Set reset detect voltage to 2.60
  • LvdResetVoltage270 Set reset detect voltage to 2.70
  • LvdResetVoltage280 Set reset detect voltage to 2.80
  • LvdResetVoltage300 Set reset detect voltage to 3.00
  • LvdResetVoltage320 Set reset detect voltage to 3.20
  • LvdResetVoltage360 Set reset detect voltage to 3.60
  • LvdResetVoltage370 Set reset detect voltage to 3.70
  • LvdResetVoltage400 Set reset detect voltage to 4.00
  • LvdResetVoltage410 Set reset detect voltage to 4.10
  • LvdResetVoltage420 Set reset detect voltage to 4.20
Return values:
OkThe reset detect voltage of LVD is set normally
ErrorInvalidParameterInvalid setting of enVolt

Definition at line 226 of file lvd.c.

References ErrorInvalidParameter, LvdCtlUnlock, LvdResetVoltage245, LvdResetVoltage260, LvdResetVoltage270, LvdResetVoltage280, LvdResetVoltage300, LvdResetVoltage320, LvdResetVoltage360, LvdResetVoltage370, LvdResetVoltage400, LvdResetVoltage410, LvdResetVoltage420, and Ok.

void LvdIrqHandler ( void  )

ISR of the LVD module.

Definition at line 98 of file lvd.c.

References pfnLvdCallback.

Referenced by LVD_IRQHandler().

Here is the caller graph for this function:


Variable Documentation

LVD interrupt callback function.

Definition at line 81 of file lvd.c.

Referenced by Lvd_ConfigInt(), and LvdIrqHandler().