A31G11x F/W Packages  2.5.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Functions
A31G11x_hal_wt.c File Reference

Contains all functions support for wt firmware library on A31G11x. More...

Go to the source code of this file.

Functions

HAL_Status_Type HAL_WT_Init (WT_CFG_Type *WT_Config)
 Initialize the WT peripheral with the specified parameters. More...
 
HAL_Status_Type HAL_WT_DeInit (void)
 deinit for Watch Timer function More...
 
HAL_Status_Type HAL_WT_ConfigInterrupt (FunctionalState NewState)
 Configure the peripheral interrupt. More...
 
HAL_Status_Type HAL_WT_Start (FunctionalState ctrl)
 Enable WT activity. More...
 
HAL_Status_Type HAL_WT_SetRegister (uint32_t u32WTSet)
 Set WT CR Register. More...
 
HAL_Status_Type HAL_WT_ClearStatus (void)
 Clear the timer status register of WT. More...
 
uint32_t HAL_WT_GetStatus (void)
 Get the timer status register of WT. More...
 
uint32_t HAL_WT_GetCurrentCount (void)
 Get the current value of WT. More...
 

Detailed Description

Contains all functions support for wt firmware library on A31G11x.

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 A31G11x_hal_wt.c.

Function Documentation

◆ HAL_WT_ClearStatus()

HAL_Status_Type HAL_WT_ClearStatus ( void  )

Clear the timer status register of WT.

Parameters
None
Returns
HAL_Status_Type

Definition at line 162 of file A31G11x_hal_wt.c.

163 {
164  WT->CR |= WT_CR_WTIFLAG; // (1<<1): clear for WTIFLAG
165 
166  return HAL_OK;
167 }

References HAL_OK.

◆ HAL_WT_ConfigInterrupt()

HAL_Status_Type HAL_WT_ConfigInterrupt ( FunctionalState  NewState)

Configure the peripheral interrupt.

Parameters
[in]NewStateNext State of Interrupt Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 96 of file A31G11x_hal_wt.c.

97 {
98  uint32_t reg_val = 0;
99 
100  reg_val = ( WT->CR & 0xFF );
101 
102  if( NewState == ENABLE )
103  {
104  reg_val |= WT_CR_WTIEN; // WTIEN bit
105  }
106  else
107  {
108  reg_val &= ~WT_CR_WTIEN;
109  }
110 
111  WT->CR = reg_val | WT_CR_WTIFLAG; // (1<<1): clear for WTIFLAG
112 
113  return HAL_OK;
114 }

References ENABLE, and HAL_OK.

◆ HAL_WT_DeInit()

HAL_Status_Type HAL_WT_DeInit ( void  )

deinit for Watch Timer function

Parameters
None
Returns
HAL_Status_Type

Definition at line 81 of file A31G11x_hal_wt.c.

82 {
83  WT->CR = 0;
84 
85  // return
86  return HAL_OK;
87 }

References HAL_OK.

◆ HAL_WT_GetCurrentCount()

uint32_t HAL_WT_GetCurrentCount ( void  )

Get the current value of WT.

Parameters
None
Returns
current value of WT

Definition at line 184 of file A31G11x_hal_wt.c.

185 {
186  return ( WT->CNT & 0xFFF );
187 }

◆ HAL_WT_GetStatus()

uint32_t HAL_WT_GetStatus ( void  )

Get the timer status register of WT.

Parameters
None
Returns
the status register of WT

Definition at line 174 of file A31G11x_hal_wt.c.

175 {
176  return ( WT->CR & WT_STATUS_BITMASK );
177 }

◆ HAL_WT_Init()

HAL_Status_Type HAL_WT_Init ( WT_CFG_Type WT_Config)

Initialize the WT peripheral with the specified parameters.

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

Definition at line 55 of file A31G11x_hal_wt.c.

56 {
57  /* Check WT_Config */
58  if( WT_Config == NULL )
59  {
60  return HAL_ERROR;
61  }
62 
63  // enable peripheral clock
64  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_WTCLKE, PPxCLKE_Enable );
65 
66  WT->CR = 0
67  | ( ( WT_Config->wtClkDiv & 0x03 ) << 4 ) // WTINTV[1:0]
68  | WT_CR_WTCLR
69  ;
70  WT->DR = ( WT_Config->wtTmrConst & 0xFFF );
71 
72  // return
73  return HAL_OK;
74 }
void HAL_SCU_Peripheral_EnableClock2(uint32_t u32PeriClk2, uint32_t u32Ind)
Set Each Peripheral Clock.
uint32_t wtTmrConst
uint32_t wtClkDiv

References HAL_ERROR, HAL_OK, HAL_SCU_Peripheral_EnableClock2(), WT_CFG_Type::wtClkDiv, and WT_CFG_Type::wtTmrConst.

Here is the call graph for this function:

◆ HAL_WT_SetRegister()

HAL_Status_Type HAL_WT_SetRegister ( uint32_t  u32WTSet)

Set WT CR Register.

Parameters
[in]u32WTSetWatch Timer Control Register Setting Data
Returns
HAL_Status_Type

This function sets the mode, external clock edge, Timer out polarity, Capture Polarity and Timer match/capture interrupt.

Definition at line 150 of file A31G11x_hal_wt.c.

151 {
152  WT->CR = u32WTSet; // Setting Timer 1n Control Register
153 
154  return HAL_OK;
155 }

References HAL_OK.

◆ HAL_WT_Start()

HAL_Status_Type HAL_WT_Start ( FunctionalState  ctrl)

Enable WT activity.

Parameters
[in]ctrlNext State of Functional Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 123 of file A31G11x_hal_wt.c.

124 {
125  uint32_t tmp_reg;
126 
127  tmp_reg = WT->CR & 0xFF;
128  tmp_reg &= ~( 0x1 << 7 ); // Disable watch-dog timer counter
129 
130  if( ctrl == ENABLE )
131  {
132  tmp_reg |= ( 0x1 << 7 ); // Enable watch timer counter
133  }
134 
135  tmp_reg |= WT_CR_WTCLR; // clear the counter and divider
136 
137  WT->CR = tmp_reg;
138 
139  return HAL_OK;
140 }

References ENABLE, and HAL_OK.