| NUC029FAE_BSP V3.02.000 The Board Support Package for NUC029FAE MCU

Macros | Functions
SYS Exported Functions
NUC029FAE Device Driver » SYS Driver » SYS Exported Constants
Collaboration diagram for SYS Exported Functions:

## Macros
#define | SYS_CLEAR_BOD_INT_FLAG() (SYS->BODCR |= SYS_BODCR_BOD_INTF_Msk)
#define | SYS_CLEAR_BOD_LPM() (SYS->BODCR &= ~SYS_BODCR_BOD_LPM_Msk)
#define | SYS_DISABLE_BOD() (SYS->BODCR |= SYS_BODCR_BOD_DISABLE)
#define | SYS_ENABLE_BOD() (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_VL_3_7V)
#define | SYS_GET_BOD_INT_FLAG() (SYS->BODCR & SYS_BODCR_BOD_INTF_Msk)
#define | SYS_GET_BOD_OUTPUT() (SYS->BODCR & SYS_BODCR_BOD_OUT_Msk)
#define | SYS_DISABLE_BOD_RST() (SYS->BODCR &= ~SYS_BODCR_BOD_RSTEN_Msk)
#define | SYS_ENABLE_BOD_RST() (SYS->BODCR |= SYS_BODCR_BOD_RSTEN_Msk)
#define | SYS_SET_BOD_LPM() (SYS->BODCR |= SYS_BODCR_BOD_LPM_Msk)
#define | SYS_SET_BOD_LEVEL(u32Level) (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | u32Level)
#define | SYS_IS_BOD_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_BOD_Msk)
#define | SYS_IS_CPU_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_CPU_Msk)
#define | SYS_IS_POR_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_POR_Msk)
#define | SYS_IS_RSTPIN_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_RESET_Msk)
#define | SYS_IS_SYSTEM_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_MCU_Msk)
#define | SYS_IS_WDT_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_WDT_Msk)
#define | SYS_DISABLE_POR() (SYS->PORCR = 0x5AA5)
#define | SYS_ENABLE_POR() (SYS->PORCR = 0)
#define | SYS_CLEAR_RST_SOURCE(u32RstSrc) (SYS->RSTSRC | u32RstSrc )

## Functions
void | SYS_ClearResetSrc (uint32_t u32Src)
| This function clear the selected system reset source. More...
uint32_t | SYS_GetBODStatus (void)
| This function get Brown-out detector output status. More...
uint32_t | SYS_GetResetSrc (void)
| This function get the system reset source register value. More...
uint32_t | SYS_IsRegLocked (void)
| This function check register write-protection bit setting. More...
void | SYS_LockReg (void)
| This function enable register write-protection function. More...
void | SYS_UnlockReg (void)
| This function disable register write-protection function. More...
uint32_t | SYS_ReadPDID (void)
| This function get product ID. More...
void | SYS_ResetChip (void)
| This function reset chip. More...
void | SYS_ResetCPU (void)
| This function reset CPU. More...
void | SYS_ResetModule (uint32_t u32ModuleIndex)
| This function reset selected modules. More...
void | SYS_EnableBOD (int32_t i32Mode, uint32_t u32BODLevel)
| This function configure BOD function. Configure BOD reset or interrupt mode and set Brown-out voltage level. Enable Brown-out function. More...
void | SYS_DisableBOD (void)
| This function disable BOD function. More...

## Detailed Description

## Macro Definition Documentation

## ◆ SYS_CLEAR_BOD_INT_FLAG

#define SYS_CLEAR_BOD_INT_FLAG | ( |  | ) | (SYS->BODCR |= SYS_BODCR_BOD_INTF_Msk)

This macro clear Brown-out interrupt flag

Definition at line 214 of file sys.h.

## ◆ SYS_CLEAR_BOD_LPM

#define SYS_CLEAR_BOD_LPM | ( |  | ) | (SYS->BODCR &= ~SYS_BODCR_BOD_LPM_Msk)

This macro set Brown-out detect to normal mode

Definition at line 215 of file sys.h.

## ◆ SYS_CLEAR_RST_SOURCE

#define SYS_CLEAR_RST_SOURCE | ( |  | u32RstSrc | ) | (SYS->RSTSRC | u32RstSrc )

This macro clear reset source flag

Definition at line 233 of file sys.h.

## ◆ SYS_DISABLE_BOD

#define SYS_DISABLE_BOD | ( |  | ) | (SYS->BODCR |= SYS_BODCR_BOD_DISABLE)

This macro disable Brown-out detect function

Definition at line 216 of file sys.h.

## ◆ SYS_DISABLE_BOD_RST

#define SYS_DISABLE_BOD_RST | ( |  | ) | (SYS->BODCR &= ~SYS_BODCR_BOD_RSTEN_Msk)

This macro enable Brown-out detect interrupt function

Definition at line 220 of file sys.h.

## ◆ SYS_DISABLE_POR

#define SYS_DISABLE_POR | ( |  | ) | (SYS->PORCR = 0x5AA5)

This macro disable Power-on Reset function

Definition at line 231 of file sys.h.

## ◆ SYS_ENABLE_BOD

#define SYS_ENABLE_BOD | ( |  | ) | (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_VL_3_7V)

This macro enable Brown-out detect function and set BOD_LV=3.7V

Definition at line 217 of file sys.h.

## ◆ SYS_ENABLE_BOD_RST

#define SYS_ENABLE_BOD_RST | ( |  | ) | (SYS->BODCR |= SYS_BODCR_BOD_RSTEN_Msk)

This macro enable Brown-out detect reset function

Definition at line 221 of file sys.h.

## ◆ SYS_ENABLE_POR

#define SYS_ENABLE_POR | ( |  | ) | (SYS->PORCR = 0)

This macro enable Power-on Reset function

Definition at line 232 of file sys.h.

## ◆ SYS_GET_BOD_INT_FLAG

#define SYS_GET_BOD_INT_FLAG | ( |  | ) | (SYS->BODCR & SYS_BODCR_BOD_INTF_Msk)

This macro get Brown-out detect interrupt flag

Definition at line 218 of file sys.h.

## ◆ SYS_GET_BOD_OUTPUT

#define SYS_GET_BOD_OUTPUT | ( |  | ) | (SYS->BODCR & SYS_BODCR_BOD_OUT_Msk)

This macro get Brown-out detector output status

Definition at line 219 of file sys.h.

## ◆ SYS_IS_BOD_RST

#define SYS_IS_BOD_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_BOD_Msk)

This macro get previous reset source is from Brown-out detect reset

Definition at line 224 of file sys.h.

## ◆ SYS_IS_CPU_RST

#define SYS_IS_CPU_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_CPU_Msk)

This macro get previous reset source is from Low-Voltage-Reset

Definition at line 225 of file sys.h.

## ◆ SYS_IS_POR_RST

#define SYS_IS_POR_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_POR_Msk)

This macro get previous reset source is from Power-on Reset

Definition at line 227 of file sys.h.

## ◆ SYS_IS_RSTPIN_RST

#define SYS_IS_RSTPIN_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_RESET_Msk)

This macro get previous reset source is from reset pin reset

Definition at line 228 of file sys.h.

## ◆ SYS_IS_SYSTEM_RST

#define SYS_IS_SYSTEM_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_MCU_Msk)

This macro get previous reset source is from system reset

Definition at line 229 of file sys.h.

## ◆ SYS_IS_WDT_RST

#define SYS_IS_WDT_RST | ( |  | ) | (SYS->RSTSRC & SYS_RSTSRC_RSTS_WDT_Msk)

This macro get previous reset source is from window watch dog reset

Definition at line 230 of file sys.h.

## ◆ SYS_SET_BOD_LEVEL

#define SYS_SET_BOD_LEVEL | ( |  | u32Level | ) | (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | u32Level)

This macro set Brown-out detect voltage level.u32Level=0~3

Definition at line 223 of file sys.h.

## ◆ SYS_SET_BOD_LPM

#define SYS_SET_BOD_LPM | ( |  | ) | (SYS->BODCR |= SYS_BODCR_BOD_LPM_Msk)

This macro set Brown-out detect to low power mode

Definition at line 222 of file sys.h.

## Function Documentation

## ◆ SYS_ClearResetSrc()

void SYS_ClearResetSrc | ( | uint32_t | u32Src | ) |

This function clear the selected system reset source.

Parameters

  u32Src | is system reset source

Returns
  None

Definition at line 31 of file sys.c.

## ◆ SYS_DisableBOD()

void SYS_DisableBOD | ( | void |  | ) |

This function disable BOD function.

Returns
  None

Definition at line 165 of file sys.c.

## ◆ SYS_EnableBOD()

void SYS_EnableBOD | ( | int32_t | i32Mode,
|  | uint32_t | u32BODLevel
| ) |  |

This function configure BOD function. Configure BOD reset or interrupt mode and set Brown-out voltage level. Enable Brown-out function.

Parameters

  i32Mode | is reset or interrupt mode. Including : SYS_BODCR_BOD_RST_EN SYS_BODCR_BOD_INTERRUPT_EN
  u32BODLevel | is Brown-out voltage level. Including : SYS_BODCR_BOD_VL_4_4V SYS_BODCR_BOD_VL_3_7V SYS_BODCR_BOD_VL_2_7V SYS_BODCR_BOD_VL_2_2V

Returns
  None

Definition at line 154 of file sys.c.

## ◆ SYS_GetBODStatus()

uint32_t SYS_GetBODStatus | ( | void |  | ) |

This function get Brown-out detector output status.

Returns
  0: System voltage is higher than BOD_VL setting or BOD_EN is 0. 1: System voltage is lower than BOD_VL setting. Note : If the BOD_EN is 0, this function always return 0.

Definition at line 42 of file sys.c.

## ◆ SYS_GetResetSrc()

uint32_t SYS_GetResetSrc | ( | void |  | ) |

This function get the system reset source register value.

Returns
  Reset source

Definition at line 51 of file sys.c.

## ◆ SYS_IsRegLocked()

uint32_t SYS_IsRegLocked | ( | void |  | ) |

This function check register write-protection bit setting.

Returns
  0: Write-protection function is disabled. 1: Write-protection function is enabled.

Definition at line 61 of file sys.c.

## ◆ SYS_LockReg()

void SYS_LockReg | ( | void |  | ) |

This function enable register write-protection function.

Returns
  None

To lock the protected register to forbid write access

Definition at line 71 of file sys.c.

## ◆ SYS_ReadPDID()

uint32_t SYS_ReadPDID | ( | void |  | ) |

This function get product ID.

Returns
  Product ID

Definition at line 95 of file sys.c.

## ◆ SYS_ResetChip()

void SYS_ResetChip | ( | void |  | ) |

This function reset chip.

Returns
  None

Definition at line 104 of file sys.c.

## ◆ SYS_ResetCPU()

void SYS_ResetCPU | ( | void |  | ) |

This function reset CPU.

Returns
  None

Definition at line 113 of file sys.c.

## ◆ SYS_ResetModule()

void SYS_ResetModule | ( | uint32_t | u32ModuleIndex | ) |

This function reset selected modules.

Parameters

  u32ModuleIndex | is module index. Including : CHIP_RST CPU_RST ADC_RST ACMP_RST PWM_RST UART_RST SPI_RST I2C_RST TMR1_RST TMR0_RST GPIO_RST

Returns
  None

Definition at line 134 of file sys.c.

## ◆ SYS_UnlockReg()

void SYS_UnlockReg | ( | void |  | ) |

This function disable register write-protection function.

Returns
  None

To unlock the protected register to allow write access

Definition at line 81 of file sys.c.