| MINI51DE_BSP V3.02.003 The Board Support Package for Mini51DE Series MCU

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

## Macros
#define | SYS_CLEAR_BOD_INT_FLAG() (SYS->BODCTL |= SYS_BODCR_BOD_INTF_Msk)
| Clear Brown-out detector interrupt flag. More...
#define | SYS_CLEAR_BOD_LPM() (SYS->BODCTL &= ~SYS_BODCR_BOD_LPM_Msk)
| Set Brown-out detector function to normal mode. More...
#define | SYS_DISABLE_BOD() (SYS->BODCTL = (SYS->BODCTL &~(SYS_BODCR_BOD_VL_Msk|SYS_BODCR_BOD_VL_EXT_Msk))|SYS_BODCR_BOD_DISABLE)
| Disable Brown-out detector function. More...
#define | SYS_ENABLE_BOD() (SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_VL_3_7V)
| Enable Brown-out detector function. More...
#define | SYS_GET_BOD_INT_FLAG() (SYS->BODCTL & SYS_BODCR_BOD_INTF_Msk)
| Get Brown-out detector interrupt flag. More...
#define | SYS_GET_BOD_OUTPUT() (SYS->BODCTL & SYS_BODCR_BOD_OUT_Msk)
| Get Brown-out detector status. More...
#define | SYS_DISABLE_BOD_RST() (SYS->BODCTL &= ~SYS_BODCR_BOD_RSTEN_Msk)
| Enable Brown-out detector interrupt function. More...
#define | SYS_ENABLE_BOD_RST() (SYS->BODCTL |= SYS_BODCR_BOD_RSTEN_Msk)
| Enable Brown-out detector reset function. More...
#define | SYS_SET_BOD_LPM() (SYS->BODCTL |= SYS_BODCR_BOD_LPM_Msk)
| Set Brown-out detector function low power mode. More...
#define | SYS_SET_BOD_LEVEL(u32Level) (SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | u32Level)
| Set Brown-out detector voltage level. More...
#define | SYS_IS_BOD_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_BOD_Msk)
| Get reset source is from Brown-out detector reset. More...
#define | SYS_IS_CPU_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_CPU_Msk)
| Get reset source is from CPU reset. More...
#define | SYS_IS_POR_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_POR_Msk)
| Get reset source is from Power-on Reset. More...
#define | SYS_IS_RSTPIN_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_RESET_Msk)
| Get reset source is from reset pin reset. More...
#define | SYS_IS_SYSTEM_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_MCU_Msk)
| Get reset source is from system reset. More...
#define | SYS_IS_WDT_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_WDT_Msk)
| Get reset source is from window watch dog reset. More...
#define | SYS_DISABLE_POR() (SYS->PORCR = 0x5AA5)
| Disable Power-on Reset function. More...
#define | SYS_ENABLE_POR() (SYS->PORCR = 0)
| Enable Power-on Reset function. More...
#define | SYS_CLEAR_RST_SOURCE(u32RstSrc) (SYS->RSTSRC = u32RstSrc )
| Clear reset source flag. More...

## 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->BODCTL |= SYS_BODCR_BOD_INTF_Msk)

Clear Brown-out detector interrupt flag.

Parameters

  None |

Returns
  None

This macro clear Brown-out detector interrupt flag.

Definition at line 219 of file sys.h.

## ◆ SYS_CLEAR_BOD_LPM

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

Set Brown-out detector function to normal mode.

Parameters

  None |

Returns
  None

This macro set Brown-out detector to normal mode. The register write-protection function should be disabled before using this macro.

Definition at line 228 of file sys.h.

## ◆ SYS_CLEAR_RST_SOURCE

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

Clear reset source flag.

Parameters

  [in] | u32RstSrc | is reset source. Including : SYS_RSTSRC_RSTS_POR_Msk SYS_RSTSRC_RSTS_RESET_Msk SYS_RSTSRC_RSTS_WDT_Msk SYS_RSTSRC_RSTS_BOD_Msk SYS_RSTSRC_RSTS_MCU_Msk SYS_RSTSRC_RSTS_CPU_Msk

Returns
  None

This macro clear reset source flag.

Definition at line 391 of file sys.h.

## ◆ SYS_DISABLE_BOD

#define SYS_DISABLE_BOD | ( |  | ) | (SYS->BODCTL = (SYS->BODCTL &~(SYS_BODCR_BOD_VL_Msk|SYS_BODCR_BOD_VL_EXT_Msk))|SYS_BODCR_BOD_DISABLE)

Disable Brown-out detector function.

Parameters

  None |

Returns
  None

This macro disable Brown-out detector function. The register write-protection function should be disabled before using this macro.

Definition at line 237 of file sys.h.

## ◆ SYS_DISABLE_BOD_RST

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

Enable Brown-out detector interrupt function.

Parameters

  None |

Returns
  None

This macro enable Brown-out detector interrupt function. The register write-protection function should be disabled before using this macro.

Definition at line 274 of file sys.h.

## ◆ SYS_DISABLE_POR

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

Disable Power-on Reset function.

Parameters

  None |

Returns
  None

This macro disable Power-on Reset function. The register write-protection function should be disabled before using this macro.

Definition at line 368 of file sys.h.

## ◆ SYS_ENABLE_BOD

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

Enable Brown-out detector function.

Parameters

  None |

Returns
  None

This macro enable Brown-out detector function and set BOD_LV=3.7V The register write-protection function should be disabled before using this macro.

Definition at line 246 of file sys.h.

## ◆ SYS_ENABLE_BOD_RST

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

Enable Brown-out detector reset function.

Parameters

  None |

Returns
  None

This macro enable Brown-out detect reset function. The register write-protection function should be disabled before using this macro.

Definition at line 283 of file sys.h.

## ◆ SYS_ENABLE_POR

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

Enable Power-on Reset function.

Parameters

  None |

Returns
  None

This macro enable Power-on Reset function. The register write-protection function should be disabled before using this macro.

Definition at line 377 of file sys.h.

## ◆ SYS_GET_BOD_INT_FLAG

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

Get Brown-out detector interrupt flag.

Parameters

  None |

Return values

  0 | Brown-out detect interrupt flag is not set.
  >=1 | Brown-out detect interrupt flag is set.

This macro get Brown-out detector interrupt flag.

Definition at line 255 of file sys.h.

## ◆ SYS_GET_BOD_OUTPUT

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

Get Brown-out detector status.

Parameters

  None |

Return values

  0 | System voltage is higher than BOD threshold voltage setting or BOD function is disabled.
  >=1 | System voltage is lower than BOD threshold voltage setting.

This macro get Brown-out detector output status. If the BOD function is disabled, this function always return 0.

Definition at line 265 of file sys.h.

## ◆ SYS_IS_BOD_RST

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

Get reset source is from Brown-out detector reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from Brown-out detector reset
  >=1 | Previous reset source is from Brown-out detector reset

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

Definition at line 314 of file sys.h.

## ◆ SYS_IS_CPU_RST

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

Get reset source is from CPU reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from CPU reset
  >=1 | Previous reset source is from CPU reset

This macro get previous reset source is from CPU reset.

Definition at line 323 of file sys.h.

## ◆ SYS_IS_POR_RST

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

Get reset source is from Power-on Reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from Power-on Reset
  >=1 | Previous reset source is from Power-on Reset

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

Definition at line 332 of file sys.h.

## ◆ SYS_IS_RSTPIN_RST

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

Get reset source is from reset pin reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from reset pin reset
  >=1 | Previous reset source is from reset pin reset

This macro get previous reset source is from reset pin reset.

Definition at line 341 of file sys.h.

## ◆ SYS_IS_SYSTEM_RST

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

Get reset source is from system reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from system reset
  >=1 | Previous reset source is from system reset

This macro get previous reset source is from system reset.

Definition at line 350 of file sys.h.

## ◆ SYS_IS_WDT_RST

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

Get reset source is from window watch dog reset.

Parameters

  None |

Return values

  0 | Previous reset source is not from window watch dog reset
  >=1 | Previous reset source is from window watch dog reset

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

Definition at line 359 of file sys.h.

## ◆ SYS_SET_BOD_LEVEL

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

Set Brown-out detector voltage level.

Parameters

  [in] | u32Level | 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

This macro set Brown-out detector voltage level. The write-protection function should be disabled before using this macro.

Definition at line 305 of file sys.h.

## ◆ SYS_SET_BOD_LPM

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

Set Brown-out detector function low power mode.

Parameters

  None |

Returns
  None

This macro set Brown-out detector to low power mode. The register write-protection function should be disabled before using this macro.

Definition at line 292 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 163 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 152 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 : ADC_RST ACMP_RST PWM_RST UART_RST SPI_RST I2C_RST TMR1_RST TMR0_RST GPIO_RST

Returns
  None

Definition at line 132 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.