A31L12x F/W Packages  1.4.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Functions
A31L12x_hal_wdt.c File Reference

Contains all functions support for wdt firmware library on A31L12x. More...

Go to the source code of this file.

Functions

HAL_Status_Type HAL_WDT_Init (WDT_CFG_Type *WDT_Config)
 Initialize the WDT peripheral with the specified parameters. More...
 
HAL_Status_Type HAL_WDT_DeInit (void)
 Deinitialize WDT. More...
 
HAL_Status_Type HAL_WDT_ConfigInterrupt (WDT_INT_Type WDT_IntCfg, FunctionalState NewState)
 Configure the peripheral interrupt. More...
 
HAL_Status_Type HAL_WDT_ReloadTimeCounter (void)
 Reload WDT counter. More...
 
HAL_Status_Type HAL_WDT_Start (FunctionalState ctrl)
 Enable WDT activity. More...
 
HAL_Status_Type HAL_WDT_ClearStatus (uint32_t clrbit)
 Clear the timer status register of WDT. More...
 
uint32_t HAL_WDT_GetStatus (void)
 Get the timer status register of WDT. More...
 
uint32_t HAL_WDT_GetCurrentCount (void)
 Get the current value of WDT. More...
 

Detailed Description

Contains all functions support for wdt firmware library on A31L12x.

Version
1.00
Date
2020-05-29
Author
ABOV Application Team

Copyright(C) 2019, ABOV Semiconductor All rights reserved.

ABOV Disclaimer

IMPORTANT NOTICE ? PLEASE READ CAREFULLY ABOV Semiconductor ("ABOV") reserves the right to make changes, corrections, enhancements, modifications, and improvements to ABOV products and/or to this document at any time without notice. ABOV does not give warranties as to the accuracy or completeness of the information included herein. Purchasers should obtain the latest relevant information of ABOV products before placing orders. Purchasers are entirely responsible for the choice, selection, and use of ABOV products and ABOV assumes no liability for application assistance or the design of purchasers' products. No license, express or implied, to any intellectual property rights is granted by ABOV herein. ABOV disclaims all express and implied warranties and shall not be responsible or liable for any injuries or damages related to use of ABOV products in such unauthorized applications. ABOV and the ABOV logo are trademarks of ABOV. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces the information previously supplied in any former versions of this document. 2020 ABOV Semiconductor All rights reserved

Definition in file A31L12x_hal_wdt.c.

Function Documentation

◆ HAL_WDT_ClearStatus()

HAL_Status_Type HAL_WDT_ClearStatus ( uint32_t  clrbit)

Clear the timer status register of WDT.

Parameters
[in]clrbit
  • WDT_SR_UNFIFLAG: UNFIFLAG Interrupt flag
  • WDT_SR_WINMIFLAG: WINMIFLAG Interrupt flag
Returns
HAL_Status_Type

Definition at line 217 of file A31L12x_hal_wdt.c.

218 {
219  WDT->SR = clrbit;
220 
221  return HAL_OK;
222 }

References HAL_OK.

◆ HAL_WDT_ConfigInterrupt()

HAL_Status_Type HAL_WDT_ConfigInterrupt ( WDT_INT_Type  WDT_IntCfg,
FunctionalState  NewState 
)

Configure the peripheral interrupt.

Parameters
[in]WDT_IntCfgSpecifies the interrupt flag
  • WDT_INTCFG_UNFIEN: UNFIEN Interrupt enable
  • WDT_INTCFG_WINMIEN: WINMIEN Interrupt enable
[in]NewStateNext State of Interrupt Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 113 of file A31L12x_hal_wdt.c.

114 {
115 #if 0 // before bug fix
116  uint32_t reg_val = 0;
117  uint32_t tmp = 0;
118 
119  reg_val = ( WDT->CR & 0xFFFF );
120 
121  switch( WDT_IntCfg )
122  {
123  case WDT_INTCFG_UNFIEN:
124  tmp = WDT_CR_UNFIEN;
125  break;
126  case WDT_INTCFG_WINMIEN:
127  tmp = WDT_CR_WINMIEN;
128  break;
129  }
130 
131  if( NewState == ENABLE )
132  {
133  reg_val |= ( tmp & WDT_INTERRUPT_BITMASK );
134  }
135  else
136  {
137  reg_val &= ( ( ~tmp ) & WDT_INTERRUPT_BITMASK ); // reg_val &= ~tmp;°¡ ¿ÇÀ» µí...
138  }
139 
140  WDT->CR = ( 0x5A69 << WDT_CR_WTIDKY_Pos ) | reg_val; // Write Identification Key 0x5A69
141 #else // after bug fix
142  uint32_t reg_val = 0;
143  uint32_t mask = 0;
144 
145  switch( WDT_IntCfg )
146  {
147  case WDT_INTCFG_UNFIEN:
148  mask = WDT_CR_UNFIEN_Msk;
149  break;
150  case WDT_INTCFG_WINMIEN:
151  mask = WDT_CR_WINMIEN_Msk;
152  break;
153  }
154 
155  reg_val = WDT->CR
156  & ~( WDT_CR_WTIDKY_Msk )
157  | ( ( uint32_t )WDT_CR_WTIDKY_Value << WDT_CR_WTIDKY_Pos )
158  ;
159  if( NewState == ENABLE )
160  {
161  reg_val |= mask;
162  }
163  else
164  {
165  reg_val &= ~mask;
166  }
167 
168  WDT->CR = reg_val;
169 #endif
170 
171  return HAL_OK;
172 }

References ENABLE, HAL_OK, WDT_INTCFG_UNFIEN, and WDT_INTCFG_WINMIEN.

◆ HAL_WDT_DeInit()

HAL_Status_Type HAL_WDT_DeInit ( void  )

Deinitialize WDT.

Parameters
None
Returns
HAL_Status_Type

Definition at line 90 of file A31L12x_hal_wdt.c.

91 {
92  WDT->CR = 0
93  | ( 0x5A69 << WDT_CR_WTIDKY_Pos ) // Write Identification Key
94  | ( 0x25 << WDT_CR_RSTEN_Pos ) // Disable watch-dog timer reset
95  | ( 0x1A << WDT_CR_CNTEN_Pos ) // Disable watch-dog timer counter
96  ;
97 
98  // return
99  return HAL_OK;
100 }

References HAL_OK.

◆ HAL_WDT_GetCurrentCount()

uint32_t HAL_WDT_GetCurrentCount ( void  )

Get the current value of WDT.

Parameters
None
Returns
current value of WDT

Definition at line 239 of file A31L12x_hal_wdt.c.

240 {
241  return WDT->CNT;
242 }

◆ HAL_WDT_GetStatus()

uint32_t HAL_WDT_GetStatus ( void  )

Get the timer status register of WDT.

Parameters
None
Returns
the status register of WDT

Definition at line 229 of file A31L12x_hal_wdt.c.

230 {
231  return WDT->SR;
232 }

◆ HAL_WDT_Init()

HAL_Status_Type HAL_WDT_Init ( WDT_CFG_Type WDT_Config)

Initialize the WDT peripheral with the specified parameters.

Parameters
[in]WDT_ConfigPointer to a WDT_CFG_Type structure that contains the configuration information for the specified peripheral.
Returns
HAL_Status_Type

Definition at line 55 of file A31L12x_hal_wdt.c.

56 {
57  uint32_t reg_val = 0;
58 
59  /* Check WDT_Config */
60  if( WDT_Config == NULL )
61  {
62  return HAL_ERROR;
63  }
64 
65  // enable peripheral clock
66  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_WDTCLKE, PPxCLKE_Enable );
67 
68  WDT->DR = ( WDT_Config->wdtTmrConst & 0x00FFFFFF );
69  WDT->WINDR = ( WDT_Config->wdtWTmrConst & 0x00FFFFFF );
70  reg_val = WDT_Config->wdtClkDiv;
71  if( WDT_Config->wdtResetEn == ENABLE )
72  {
73  reg_val &= ~( 0x3f << WDT_CR_RSTEN_Pos );
74  }
75  else
76  {
77  reg_val |= ( 0x25 << WDT_CR_RSTEN_Pos );
78  }
79  WDT->CR = ( 0x5A69 << WDT_CR_WTIDKY_Pos ) | ( 0x1a << WDT_CR_CNTEN_Pos ) | reg_val; // /w Write Identification Key
80 
81  // return
82  return HAL_OK;
83 }
uint8_t wdtResetEn
void HAL_SCU_Peripheral_EnableClock2(uint32_t u32PeriClk2, uint32_t u32Ind)
Set Each Peripheral Clock.
uint16_t wdtClkDiv
uint32_t wdtTmrConst
uint32_t wdtWTmrConst

References ENABLE, HAL_ERROR, HAL_OK, HAL_SCU_Peripheral_EnableClock2(), WDT_CFG_Type::wdtClkDiv, WDT_CFG_Type::wdtResetEn, WDT_CFG_Type::wdtTmrConst, and WDT_CFG_Type::wdtWTmrConst.

Here is the call graph for this function:

◆ HAL_WDT_ReloadTimeCounter()

HAL_Status_Type HAL_WDT_ReloadTimeCounter ( void  )

Reload WDT counter.

Parameters
None
Returns
HAL_Status_Type

Definition at line 179 of file A31L12x_hal_wdt.c.

180 {
181  WDT->CNTR = 0x6a;
182 
183  return HAL_OK;
184 }

References HAL_OK.

◆ HAL_WDT_Start()

HAL_Status_Type HAL_WDT_Start ( FunctionalState  ctrl)

Enable WDT activity.

Parameters
[in]ctrl
  • DISABLE: wdt enable
  • ENABLE: wdt disable
Returns
HAL_Status_Type

Definition at line 193 of file A31L12x_hal_wdt.c.

194 {
195  uint32_t tmp_reg;
196 
197  tmp_reg = WDT->CR & 0xFFFF;
198  tmp_reg |= ( 0x1a << WDT_CR_CNTEN_Pos ); // Disable watch-dog timer counter
199 
200  if( ctrl == ENABLE )
201  {
202  tmp_reg &= ~( 0x3f << WDT_CR_CNTEN_Pos ); // Enable watch-dog timer counter,
203  }
204 
205  WDT->CR = ( 0x5A69 << WDT_CR_WTIDKY_Pos ) | tmp_reg; // Write Identification Key 0x5A69
206 
207  return HAL_OK;
208 }

References ENABLE, and HAL_OK.