| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions
Low Power Modes Functions (LPM)

## Data Structures
struct | stc_ret_cause
| Deep standby mode return cause. More...
## Defines
#define | CM0P_CORE_CSR *((volatile unsigned int*)(0xE000ED10UL))
#define | LPCM_BACKUP_REG_BASE ((volatile uint8_t*)0x40035900)
#define | WIFSR_WRTCI (1ul<<0)
#define | WIFSR_WLVDI (1ul<<1)
#define | WIFSR_WUI0 (1ul<<2)
#define | WIFSR_WUI1 (1ul<<3)
#define | WIFSR_WUI2 (1ul<<4)
#define | WIFSR_WUI3 (1ul<<5)
#define | WIFSR_WUI4 (1ul<<6)
#define | WIFSR_WUI5 (1ul<<7)
#define | WIFSR_WCEC0I (1ul<<8)
#define | WIFSR_WCEC1I (1ul<<9)
#define | WRFSR_WINITX (1ul<<0)
#define | WRFSR_WLVDH (1ul<<1)
## Typedefs
typedef enum en_lpm_mode | en_lpm_mode_t
| define standby mode type
typedef struct stc_ret_cause | stc_dstb_ret_cause_t
| Deep standby mode return cause.
typedef enum en_ret_cause_flag | en_dstb_ret_cause_t
| define deep standby mode return cause flag
typedef enum en_dstb_wkup_pin | en_dstb_wkup_pin_t
| define wkup pin index
typedef enum en_wkup_valid_level | en_wkup_valid_level_t
| Valid level of wakeup pin.
typedef enum en_dstb_bakup_reg | en_dstb_bakup_reg_t
| backup register index
## Enumerations
enum | en_lpm_mode { StbSleepMode = 0u, StbTimerMode = 1u, StbStopMode = 2u, StbRtcMode = 3u, DeepStbRtcMode = 4u, DeepStbStopMode = 5u }
| define standby mode type More...
enum | en_ret_cause_flag { DeepStbNoFlag = 0u, DeepStbInitx = 1u, DeepStbLvdReset = 2u, DeepStbRtcInt = 3u, DeepStbLvdInt = 4u, DeepStbWkupPin0 = 5u, DeepStbWkupPin1 = 6u, DeepStbWkupPin2 = 7u, DeepStbWkupPin3 = 8u, DeepStbWkupPin4 = 9u, DeepStbWkupPin5 = 10u, DeepStbCec0 = 11u, DeepStbCec1 = 12u }
| define deep standby mode return cause flag More...
enum | en_dstb_wkup_pin { WkupPin1 = 0u, WkupPin2 = 1u, WkupPin3 = 2u, WkupPin4 = 3u, WkupPin5 = 4u }
| define wkup pin index More...
enum | en_wkup_valid_level { WkupLowLevelValid = 0u, WkupHighLevelValid = 1u }
| Valid level of wakeup pin. More...
enum | en_dstb_bakup_reg { BackupReg1 = 1u, BackupReg2 = 2u, BackupReg3 = 3u, BackupReg4 = 4u, BackupReg5 = 5u, BackupReg6 = 6u, BackupReg7 = 7u, BackupReg8 = 8u, BackupReg9 = 9u, BackupReg10 = 10u, BackupReg11 = 11u, BackupReg12 = 12u, BackupReg13 = 13u, BackupReg14 = 14u, BackupReg15 = 15u, BackupReg16 = 16u }
| backup register index More...
## Functions
static uint16_t | WRFSRDummyRead (void)
| WRFSR dummy read.
static uint16_t | WIFSRDummyRead (void)
| WRFSR dummy read.
void | Lpm_GoToStandByMode (en_lpm_mode_t enMode, boolean_t bIoRemain)
| go to standby mode
en_result_t | Lpm_ConfigDeepStbRetCause (stc_dstb_ret_cause_t *pstcCause)
| Configure return cause from deep standby mode.
en_dstb_ret_cause_t | Lpm_ReadDeepStbRetCause (void)
| Read deep standby mode return cause flag.
en_result_t | Lpm_SetWkupPinLevel (en_dstb_wkup_pin_t enPinIndex, en_wkup_valid_level_t enLevel)
| Set the valid level of wkup pin.
en_result_t | Lpm_WriteBackupReg (en_dstb_bakup_reg_t enRegIndex, uint8_t u8Data)
| Write the backup register.
uint8_t | Lpm_ReadBackupReg (en_dstb_bakup_reg_t enRegIndex)
| Read the backup register.
en_result_t | Lpm_ConfigSubClk (boolean_t bSupplyCec, boolean_t bSupplyRtc)
| Configue the sub clock supply.
en_result_t | Lpm_ConfigDeepStbRAMRetention (boolean_t bRamRetain)
| Configure deep standby mode RAM retention.

## Detailed Description

Note:
  The deep standby mode may not be available for some of FM0+ product. Please refer to the hardware manual for the function availability.

Provided functions of LPM module:

- Lpm_GoToStandByMode()
- Lpm_ConfigDeepStbRetCause()
- Lpm_ReadDeepStbRetCause()
- Lpm_SetWkupPinLevel()
- Lpm_ConfigSubClk()
- Lpm_ConfigDeepStbRAMRetention()
- Lpm_WriteBackupReg()
- Lpm_ReadBackupReg()

Lpm_GoToStandByMode() enters the low power consumption selected by the parameter Lpm_GoToStandByMode::enMode. Since MCU enters into low power consumption mode after calling this funciton, this function will not return until MCU is waken up. There are also different between waken up from Standby mode and deep standby mode. When MCU is waken up from standby mode, the program of MCU will run after this function, but when MCU is waken up from deep standby mode, the program of MCU will run from the reset vector.

Lpm_ConfigDeepStbRetCause() configures the return causes of deep standby mode and Lpm_ReadDeepStbRetCause() reads the return causes after MCU is waken up. Note that Wakeup from WKUP0 pin is always enabled.

Lpm_SetWkupPinLevel() is used to set the WKUP pin active level.

Lpm_ConfigSubClk() configures whether to supply Sub clock to RTC and CEC in deep standby mode. Not all FM0P+ product has this function. Please confirm it in the hardware manual.

Lpm_ConfigDeepStbRAMRetention() configures whether to retain RAM content after entering deep standby mode. Not all FM0P+ product has this function. Plesae comfirm it in the hardware manual.

Lpm_WriteBackupReg() writes the backup registers, which can retain in the deep standby mode. and Lpm_ReadBackupReg() reads the backup regisers after waken up from deep standby mode. Up to 16 byte backup registers can be used.

## Define Documentation

#define CM0P_CORE_CSR *((volatile unsigned int*)(0xE000ED10UL))

Definition at line 90 of file lpm.c.

Referenced by Lpm_GoToStandByMode().

#define LPCM_BACKUP_REG_BASE ((volatile uint8_t*)0x40035900)

Definition at line 93 of file lpm.c.

Referenced by Lpm_ReadBackupReg(), and Lpm_WriteBackupReg().

#define WIFSR_WCEC0I (1ul<<8)

Definition at line 127 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WCEC1I (1ul<<9)

Definition at line 128 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WLVDI (1ul<<1)

Definition at line 120 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WRTCI (1ul<<0)

Definition at line 119 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI0 (1ul<<2)

Definition at line 121 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI1 (1ul<<3)

Definition at line 122 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI2 (1ul<<4)

Definition at line 123 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI3 (1ul<<5)

Definition at line 124 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI4 (1ul<<6)

Definition at line 125 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WIFSR_WUI5 (1ul<<7)

Definition at line 126 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WRFSR_WINITX (1ul<<0)

Definition at line 130 of file lpm.h.

Referenced by Lpm_ReadDeepStbRetCause().

#define WRFSR_WLVDH (1ul<<1)

Definition at line 131 of file lpm.h.

## Typedef Documentation

typedef enum en_dstb_bakup_reg en_dstb_bakup_reg_t

backup register index

typedef enum en_ret_cause_flag en_dstb_ret_cause_t

define deep standby mode return cause flag

typedef enum en_dstb_wkup_pin en_dstb_wkup_pin_t

define wkup pin index

typedef enum en_lpm_mode en_lpm_mode_t

define standby mode type

typedef enum en_wkup_valid_level en_wkup_valid_level_t

Valid level of wakeup pin.

typedef struct stc_ret_cause stc_dstb_ret_cause_t

Deep standby mode return cause.

## Enumeration Type Documentation

enum en_dstb_bakup_reg

backup register index

Enumerator:

  BackupReg1 | index of backup register 1
  BackupReg2 | index of backup register 2
  BackupReg3 | index of backup register 3
  BackupReg4 | index of backup register 4
  BackupReg5 | index of backup register 5
  BackupReg6 | index of backup register 6
  BackupReg7 | index of backup register 7
  BackupReg8 | index of backup register 8
  BackupReg9 | index of backup register 9
  BackupReg10 | index of backup register 10
  BackupReg11 | index of backup register 11
  BackupReg12 | index of backup register 12
  BackupReg13 | index of backup register 13
  BackupReg14 | index of backup register 14
  BackupReg15 | index of backup register 15
  BackupReg16 | index of backup register 16

Definition at line 223 of file lpm.h.

enum en_dstb_wkup_pin

define wkup pin index

Enumerator:

  WkupPin1 | index of wkup pin 1
  WkupPin2 | index of wkup pin 2
  WkupPin3 | index of wkup pin 3
  WkupPin4 | index of wkup pin 4
  WkupPin5 | index of wkup pin 5

Definition at line 196 of file lpm.h.

enum en_lpm_mode

define standby mode type

Enumerator:

  StbSleepMode | standby sleep mode
  StbTimerMode | standby timer mode
  StbStopMode | standby stop mode
  StbRtcMode | standby RTC mode
  DeepStbRtcMode | deep standby RTC mode
  DeepStbStopMode | deep standby stop mode

Definition at line 138 of file lpm.h.

enum en_ret_cause_flag

define deep standby mode return cause flag

Enumerator:

  DeepStbNoFlag | No flag set.
  DeepStbInitx | return from INITX input reset
  DeepStbLvdReset | return from LVD reset
  DeepStbRtcInt | return from RTC interrupt
  DeepStbLvdInt | return from LVD interrupt
  DeepStbWkupPin0 | return from Wkup pin1 detection
  DeepStbWkupPin1 | return from Wkup pin1 detection
  DeepStbWkupPin2 | return from Wkup pin2 detection
  DeepStbWkupPin3 | return from Wkup pin3 detection
  DeepStbWkupPin4 | return from Wkup pin4 detection
  DeepStbWkupPin5 | return from Wkup pin5 detection
  DeepStbCec0 | return from Wkup CEC1 reception interrupt
  DeepStbCec1 | return from Wkup CEC2 reception interrupt

Definition at line 174 of file lpm.h.

enum en_wkup_valid_level

Valid level of wakeup pin.

Enumerator:

  WkupLowLevelValid | Set low level as valid level.
  WkupHighLevelValid | Set high level as valid level.

Definition at line 211 of file lpm.h.

## Function Documentation

en_result_t Lpm_ConfigDeepStbRAMRetention | ( | boolean_t | bRamRetain | ) |

Configure deep standby mode RAM retention.

Parameters:

  bRamRetain | Whether to retain data in the RAM

Return values:

  Ok | Deep standby mode RAM retention set

Note:
  Not all FM0+ product has this function, please check it in the product manual.

Definition at line 562 of file lpm.c.

References FALSE, and Ok.

en_result_t Lpm_ConfigDeepStbRetCause | ( | stc_dstb_ret_cause_t * | pstcCause | ) |

Configure return cause from deep standby mode.

Parameters:

  pstcCause | Pointer to structure of return cause types

Return values:

  Ok | Deep standby mode is configured normally

Note:
  Wakeup from WKUP0 pin is always enabled

Definition at line 246 of file lpm.c.

References stc_ret_cause::bCec0En, stc_ret_cause::bCec1En, stc_ret_cause::bLvdEn, stc_ret_cause::bRtcEn, stc_ret_cause::bWakeup1En, stc_ret_cause::bWakeup2En, stc_ret_cause::bWakeup3En, stc_ret_cause::bWakeup4En, stc_ret_cause::bWakeup5En, and Ok.

en_result_t Lpm_ConfigSubClk | ( | boolean_t | bSupplyCec,
|  | boolean_t | bSupplyRtc
| ) |  |

Configue the sub clock supply.

Parameters:

  bSupplyCec | Whether to supply sub clock to CEC
  bSupplyRtc | Whether to supply sub clock to RTC

Return values:

  Ok | The sub clock supply is configured normally

Note:
  Not all FM0+ product has this function, please check it in the product manual.

Definition at line 526 of file lpm.c.

References Ok, and TRUE.

void Lpm_GoToStandByMode | ( | en_lpm_mode_t | enMode,
|  | boolean_t | bIoRemain
| ) |  |

go to standby mode

Parameters:

  enMode | the type of standby mode. This parameter can be one of the following values: StbSleepMode Sleep mode StbTimerMode Timer mode StbStopMode Stop mode StbRtcMode RTC mode DeepStbRtcMode deep standby RTC mode DeepStbStopMode deep standby stop mode
  bIoRemain | Set io status when enter standby mode. This parameter can be one of the following values: FALSE Set IO to Hi-z TRUE Remain IO status

Definition at line 155 of file lpm.c.

References CM0P_CORE_CSR, DeepStbRtcMode, DeepStbStopMode, StbRtcMode, StbSleepMode, StbStopMode, StbTimerMode, WIFSRDummyRead(), and WRFSRDummyRead().

Here is the call graph for this function:

uint8_t Lpm_ReadBackupReg | ( | en_dstb_bakup_reg_t | enRegIndex | ) |

Read the backup register.

Parameters:

  enRegIndex | Backup register index BackupReg1 Back up register 1 index BackupReg2 Back up register 2 index BackupReg3 Back up register 3 index BackupReg4 Back up register 4 index BackupReg5 Back up register 5 index BackupReg6 Back up register 6 index BackupReg7 Back up register 7 index BackupReg8 Back up register 8 index BackupReg9 Back up register 9 index BackupReg10 Back up register 10 index BackupReg11 Back up register 11 index BackupReg12 Back up register 12 index BackupReg13 Back up register 13 index BackupReg14 Back up register 14 index BackupReg15 Back up register 15 index BackupReg16 Back up register 16 index

Returns:
  Backup register data

Definition at line 507 of file lpm.c.

References LPCM_BACKUP_REG_BASE.

en_dstb_ret_cause_t Lpm_ReadDeepStbRetCause | ( | void |  | ) |

Read deep standby mode return cause flag.

Return values:

  DeepStbNoFlag | No flag set
  DeepStbInitx | Wakeup from deep standby mode by INITX reset
  DeepStbLvdReset | Wakeup from deep standby mode by LVD reset
  DeepStbRtcInt | Wakeup from deep standby mode by RTC interrupt
  DeepStbLvdInt | Wakeup from deep standby mode by LVD interrupt
  DeepStbWkupPin0 | Wakeup from deep standby mode by WKUP0
  DeepStbWkupPin1 | Wakeup from deep standby mode by WKUP1
  DeepStbWkupPin2 | Wakeup from deep standby mode by WKUP2
  DeepStbWkupPin3 | Wakeup from deep standby mode by WKUP3
  DeepStbWkupPin4 | Wakeup from deep standby mode by WKUP4
  DeepStbWkupPin5 | Wakeup from deep standby mode by WKUP5
  DeepStbCec0 | Wakeup from deep standby mode by CEC0 interrupt
  DeepStbCec1 | Wakeup from deep standby mode by CEC1 interrupt

Definition at line 351 of file lpm.c.

References DeepStbCec0, DeepStbCec1, DeepStbInitx, DeepStbLvdInt, DeepStbLvdReset, DeepStbNoFlag, DeepStbRtcInt, DeepStbWkupPin0, DeepStbWkupPin1, DeepStbWkupPin2, DeepStbWkupPin3, DeepStbWkupPin4, DeepStbWkupPin5, WIFSR_WCEC0I, WIFSR_WCEC1I, WIFSR_WLVDI, WIFSR_WRTCI, WIFSR_WUI0, WIFSR_WUI1, WIFSR_WUI2, WIFSR_WUI3, WIFSR_WUI4, WIFSR_WUI5, and WRFSR_WINITX.

en_result_t Lpm_SetWkupPinLevel | ( | en_dstb_wkup_pin_t | enPinIndex,
|  | en_wkup_valid_level_t | enLevel
| ) |  |

Set the valid level of wkup pin.

Parameters:

  enPinIndex | Pin index WkupPin1 WKUP1 pin index WkupPin2 WKUP2 pin index WkupPin3 WKUP3 pin index WkupPin4 WKUP4 pin index WkupPin5 WKUP5 pin index
  enLevel | Wakeup pin valid value WkupLowLevelValid Set low as active level for WKUPx WkupHighLevelValid Set high as active level for WKUPx

Return values:

  Ok | The valid level of wkup pin is set normally
  ErrorInvalidParameter | Invalid value of enPinIndex

Definition at line 429 of file lpm.c.

References ErrorInvalidParameter, Ok, and WkupPin5.

en_result_t Lpm_WriteBackupReg | ( | en_dstb_bakup_reg_t | enRegIndex,
|  | uint8_t | u8Data
| ) |  |

Write the backup register.

Parameters:

  enRegIndex | register index BackupReg1 Back up register 1 index BackupReg2 Back up register 2 index BackupReg3 Back up register 3 index BackupReg4 Back up register 4 index BackupReg5 Back up register 5 index BackupReg6 Back up register 6 index BackupReg7 Back up register 7 index BackupReg8 Back up register 8 index BackupReg9 Back up register 9 index BackupReg10 Back up register 10 index BackupReg11 Back up register 11 index BackupReg12 Back up register 12 index BackupReg13 Back up register 13 index BackupReg14 Back up register 14 index BackupReg15 Back up register 15 index BackupReg16 Back up register 16 index
  u8Data | the data written into backup register

Return values:

  Ok | The backup register written normally
  ErrorInvalidParameter | enRegIndex > BackupReg15

Definition at line 470 of file lpm.c.

References BackupReg15, ErrorInvalidParameter, LPCM_BACKUP_REG_BASE, and Ok.

static uint16_t WIFSRDummyRead | ( | void |  | ) | `[static]`

WRFSR dummy read.

Definition at line 128 of file lpm.c.

Referenced by Lpm_GoToStandByMode().

Here is the caller graph for this function:

static uint16_t WRFSRDummyRead | ( | void |  | ) | `[static]`

WRFSR dummy read.

Definition at line 116 of file lpm.c.

Referenced by Lpm_GoToStandByMode().

Here is the caller graph for this function: