A31L12x F/W Packages  1.4.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Data Structures | Enumerations | Functions
A31L12x_hal_timer5n.h File Reference

Contains all macro definitions and function prototypes support for timer5n firmware library on A31L12x. More...

Go to the source code of this file.

Data Structures

struct  TIMER5n_CFG_Type
 

Enumerations

enum  TIMER5n_INT_Type { TIMER5n_CR_MATCH_INTR = 0, TIMER5n_CR_CAPTURE_INTR }
 

Functions

HAL_Status_Type HAL_TIMER5n_Init (TIMER5n_Type *TIMER5x, TIMER5n_CFG_Type *TIMER5n_Config)
 Initialize the TIMER5n peripheral with the specified parameters. More...
 
HAL_Status_Type HAL_TIMER5n_DeInit (TIMER5n_Type *TIMER5x)
 Close Timer/Counter device. More...
 
HAL_Status_Type HAL_TIMER5n_ConfigInterrupt (TIMER5n_Type *TIMER5x, TIMER5n_INT_Type TIMER5n_IntCfg, FunctionalState NewState)
 Configure the peripheral interrupt. More...
 
HAL_Status_Type HAL_TIMER5n_Cmd (TIMER5n_Type *TIMER5x, FunctionalState NewState)
 Start/Stop Timer/Counter device. More...
 
HAL_Status_Type HAL_TIMER5n_ClearCounter (TIMER5n_Type *TIMER5x)
 Clear Counter and Prescaler. More...
 
HAL_Status_Type HAL_TIMER5n_UpdateCountValue (TIMER5n_Type *TIMER5x, uint8_t CountCh, uint16_t Value)
 Update value. More...
 
HAL_Status_Type HAL_TIMER5n_ClearStatus (TIMER5n_Type *TIMER5x, uint32_t value)
 Clear Timer Status. More...
 
uint8_t HAL_TIMER5n_GetStatus (TIMER5n_Type *TIMER5x)
 Get Timer Status. More...
 
uint16_t HAL_TIMER5n_GetCaptureData (TIMER5n_Type *TIMER5x)
 Read value of capture register in timer/counter device. More...
 

Detailed Description

Contains all macro definitions and function prototypes support for timer5n 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_timer5n.h.

Enumeration Type Documentation

◆ TIMER5n_INT_Type

Enumerator
TIMER5n_CR_MATCH_INTR 

OVIE Interrupt enable

TIMER5n_CR_CAPTURE_INTR 

MBIE Interrupt enable

Definition at line 61 of file A31L12x_hal_timer5n.h.

Function Documentation

◆ HAL_TIMER5n_ClearCounter()

HAL_Status_Type HAL_TIMER5n_ClearCounter ( TIMER5n_Type *  TIMER5x)

Clear Counter and Prescaler.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
Returns
HAL_Status_Type

Definition at line 228 of file A31L12x_hal_timer5n.c.

229 {
230  /* Check TIMER5 handle */
231  if( TIMER5x == NULL )
232  {
233  return HAL_ERROR;
234  }
235 
236  TIMER5x->CR_b.T5nCLR = TIMER5n_CR_T5nCLR_Clear;
237 
238  return HAL_OK;
239 }

References HAL_ERROR, and HAL_OK.

Referenced by HAL_TIMER5n_Init().

Here is the caller graph for this function:

◆ HAL_TIMER5n_ClearStatus()

HAL_Status_Type HAL_TIMER5n_ClearStatus ( TIMER5n_Type *  TIMER5x,
uint32_t  mask 
)

Clear Timer Status.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
[in]maskclear value
Returns
HAL_Status_Type

Definition at line 283 of file A31L12x_hal_timer5n.c.

284 {
285  /* Check TIMER5 handle */
286  if( TIMER5x == NULL )
287  {
288  return HAL_ERROR;
289  }
290 
291  TIMER5x->CR = TIMER5x->CR
292  & ~TIMER5n_CR_T5nMIFLAG_Msk
293  & ~TIMER5n_CR_T5nCIFLAG_Msk
294  & ~TIMER5n_CR_T5nCLIFLAG_Msk
295  | mask
296  ;
297 
298  return HAL_OK;
299 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER5n_Cmd()

HAL_Status_Type HAL_TIMER5n_Cmd ( TIMER5n_Type *  TIMER5x,
FunctionalState  NewState 
)

Start/Stop Timer/Counter device.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
[in]NewStateNext State of Functional Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 201 of file A31L12x_hal_timer5n.c.

202 {
203  /* Check TIMER5 handle */
204  if( TIMER5x == NULL )
205  {
206  return HAL_ERROR;
207  }
208 
209  if( NewState == ENABLE )
210  {
211  TIMER5x->CR_b.T5nEN = TIMER5n_CR_T5nEN_Enable;
212  }
213  else
214  {
215  TIMER5x->CR_b.T5nEN = TIMER5n_CR_T5nEN_Disable;
216  }
217 
218  return HAL_OK;
219 }

References ENABLE, HAL_ERROR, and HAL_OK.

◆ HAL_TIMER5n_ConfigInterrupt()

HAL_Status_Type HAL_TIMER5n_ConfigInterrupt ( TIMER5n_Type *  TIMER5x,
TIMER5n_INT_Type  TIMER5n_IntCfg,
FunctionalState  NewState 
)

Configure the peripheral interrupt.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
[in]TIMER5n_IntCfgSpecifies the interrupt flag
  • TIMER5n_CR_MATCH_INTR: Match interrupt enable
  • TIMER5n_CR_CAPTURE_INTR: Capture interrupt enable
[in]NewStateNext State of Interrupt Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 156 of file A31L12x_hal_timer5n.c.

157 {
158  /* Check TIMER5 handle */
159  if( TIMER5x == NULL )
160  {
161  return HAL_ERROR;
162  }
163 
164  switch( TIMER5n_IntCfg )
165  {
167  if( NewState == ENABLE )
168  {
169  TIMER5x->CR_b.T5nMIEN = 1;
170  }
171  else if( NewState == DISABLE )
172  {
173  TIMER5x->CR_b.T5nMIEN = 0;
174  }
175  break;
177  if( NewState == ENABLE )
178  {
179  TIMER5x->CR_b.T5nCIEN = 1;
180  }
181  else if( NewState == DISABLE )
182  {
183  TIMER5x->CR_b.T5nCIEN = 0;
184  }
185  break;
186  }
187 
188  return HAL_OK;
189 }

References DISABLE, ENABLE, HAL_ERROR, HAL_OK, TIMER5n_CR_CAPTURE_INTR, and TIMER5n_CR_MATCH_INTR.

◆ HAL_TIMER5n_DeInit()

HAL_Status_Type HAL_TIMER5n_DeInit ( TIMER5n_Type *  TIMER5x)

Close Timer/Counter device.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
Returns
HAL_Status_Type

Definition at line 112 of file A31L12x_hal_timer5n.c.

113 {
114  /* Check TIMER5 handle */
115  if( TIMER5x == NULL )
116  {
117  return HAL_ERROR;
118  }
119 
120  // Disable timer/counter
121  TIMER5x->CR_b.T5nEN = 0;
122 
123 #if 1 // supported
124  if( TIMER5x == ( TIMER5n_Type* )TIMER50 )
125  {
126  // disable peripheral clock
127  SCUCG->PPCLKEN1_b.T50CLKE = 0;
128  }
129 #endif
130 
131 #if 0 // not supported
132  if( TIMER5x == ( TIMER5n_Type* )TIMER51 )
133  {
134  // disable peripheral clock
135  SCUCG->PPCLKEN1_b.T51CLKE = 0;
136  }
137 #endif
138 
139  return HAL_OK;
140 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER5n_GetCaptureData()

uint16_t HAL_TIMER5n_GetCaptureData ( TIMER5n_Type *  TIMER5x)

Read value of capture register in timer/counter device.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
Returns
Value of count register

Definition at line 320 of file A31L12x_hal_timer5n.c.

321 {
322  return TIMER5x->CAPDR;
323 }

◆ HAL_TIMER5n_GetStatus()

uint8_t HAL_TIMER5n_GetStatus ( TIMER5n_Type *  TIMER5x)

Get Timer Status.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
Returns
Value of status register

Definition at line 308 of file A31L12x_hal_timer5n.c.

309 {
310  return TIMER5x->CR;
311 }

◆ HAL_TIMER5n_Init()

HAL_Status_Type HAL_TIMER5n_Init ( TIMER5n_Type *  TIMER5x,
TIMER5n_CFG_Type TIMER5n_Config 
)

Initialize the TIMER5n peripheral with the specified parameters.

  • Set Clock frequency for Timer
  • Set initial configuration for Timer
    Parameters
    [in]TIMER5xPointer to the target TIMER5
  • TIMER50
    Parameters
    [in]TIMER5n_ConfigPointer to the configuration information for the specified peripheral.
    Returns
    HAL_Status_Type

Definition at line 58 of file A31L12x_hal_timer5n.c.

59 {
60  /* Check TIMER5 handle */
61  if( TIMER5x == NULL )
62  {
63  return HAL_ERROR;
64  }
65 
66 #if 1 // supported
67  if( TIMER5x == ( TIMER5n_Type* )TIMER50 )
68  {
69  // enable peripheral clock
70  SCUCG->PPCLKEN1_b.T50CLKE = 1;
71  }
72 #endif
73 
74 #if 0 // not supported
75  if( TIMER5x == ( TIMER5n_Type* )TIMER51 )
76  {
77  // enable peripheral clock
78  SCUCG->PPCLKEN1_b.T51CLKE = 1;
79  }
80 #endif
81 
82  // CR
83  TIMER5x->CR = 0
84  | ( TIMER5n_Config->T5nMS << TIMER5n_CR_T5nMS_Pos )
85  | ( TIMER5n_Config->T5nCLK << TIMER5n_CR_T5nCLK_Pos )
86  | ( TIMER5n_Config->T5nECE << TIMER5n_CR_T5nECE_Pos )
87  | ( TIMER5n_Config->T5nINSEL << TIMER5n_CR_T5nINSEL_Pos )
88  | ( TIMER5n_Config->T5nINPOL << TIMER5n_CR_T5nINPOL_Pos )
89  | ( TIMER5n_Config->T5nOPOL << TIMER5n_CR_T5nOPOL_Pos )
90  ;
91 
92  // ADR & BDR
93  TIMER5x->ADR = TIMER5n_Config->ADR;
94  TIMER5x->BDR = TIMER5n_Config->BDR;
95 
96  // PREDR
97  TIMER5x->PREDR_b.PRED = TIMER5n_Config->Prescaler;
98 
99  // clear counter and prescaler
100  HAL_TIMER5n_ClearCounter( TIMER5x );
101 
102  return HAL_OK;
103 }
TIMER5n_CR_T5nCLK_Enum T5nCLK
TIMER5n_CR_T5nINSEL_Enum T5nINSEL
HAL_Status_Type HAL_TIMER5n_ClearCounter(TIMER5n_Type *TIMER5x)
Clear Counter and Prescaler.
TIMER5n_CR_T5nECE_Enum T5nECE
TIMER5n_CR_T5nINPOL_Enum T5nINPOL
TIMER5n_CR_T5nMS_Enum T5nMS
TIMER5n_CR_T5nOPOL_Enum T5nOPOL

References TIMER5n_CFG_Type::ADR, TIMER5n_CFG_Type::BDR, HAL_ERROR, HAL_OK, HAL_TIMER5n_ClearCounter(), TIMER5n_CFG_Type::Prescaler, TIMER5n_CFG_Type::T5nCLK, TIMER5n_CFG_Type::T5nECE, TIMER5n_CFG_Type::T5nINPOL, TIMER5n_CFG_Type::T5nINSEL, TIMER5n_CFG_Type::T5nMS, and TIMER5n_CFG_Type::T5nOPOL.

Here is the call graph for this function:

◆ HAL_TIMER5n_UpdateCountValue()

HAL_Status_Type HAL_TIMER5n_UpdateCountValue ( TIMER5n_Type *  TIMER5x,
uint8_t  CountCh,
uint16_t  Value 
)

Update value.

Parameters
[in]TIMER5xPointer to the target TIMER5
  • TIMER50
[in]CountCh
  • 0 = GRA
  • 1 = GRB
[in]Valueupdated match value
Returns
HAL_Status_Type

Definition at line 253 of file A31L12x_hal_timer5n.c.

254 {
255  /* Check TIMER5 handle */
256  if( TIMER5x == NULL )
257  {
258  return HAL_ERROR;
259  }
260 
261  switch( CountCh )
262  {
263  case 0:
264  TIMER5x->ADR = Value;
265  break;
266  case 1:
267  TIMER5x->BDR = Value;
268  break;
269  }
270 
271  return HAL_OK;
272 }

References HAL_ERROR, and HAL_OK.