A31R71x F/W Packages  1.5.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Functions
A31R71x_hal_timer1n.c File Reference

Contains all functions support for timer1n firmware library on A31R71x. More...

Go to the source code of this file.

Functions

HAL_Status_Type HAL_TIMER1n_Init (TIMER1n_Type *TIMER1x, TIMER1n_MODE_OPT TimerCounterMode, void *TIMER1n_Config)
 Initialize the TIMER1n peripheral with the specified parameters. More...
 
HAL_Status_Type HAL_TIMER1n_DeInit (TIMER1n_Type *TIMER1x)
 Close Timer/Counter device. More...
 
HAL_Status_Type HAL_TIMER1n_ConfigInterrupt (TIMER1n_Type *TIMER1x, TIMER1n_INT_Type TIMER1n_IntCfg, FunctionalState NewState)
 Configure the peripheral interrupt. More...
 
HAL_Status_Type HAL_TIMER1n_Cmd (TIMER1n_Type *TIMER1x, FunctionalState NewState)
 Start/Stop Timer/Counter device. More...
 
HAL_Status_Type HAL_TIMER1n_SetRegister (TIMER1n_Type *TIMER1x, uint32_t u32T1nSet, uint32_t u32T1nClk)
 Set TIMER1n CR/PREDR Registers. More...
 

Detailed Description

Contains all functions support for timer1n firmware library on A31R71x.

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

Function Documentation

◆ HAL_TIMER1n_Cmd()

HAL_Status_Type HAL_TIMER1n_Cmd ( TIMER1n_Type *  TIMER1x,
FunctionalState  NewState 
)

Start/Stop Timer/Counter device.

Parameters
[in]TIMER1xPointer to the target TIMER1
  • TIMER10 ~ TIMER15
[in]NewStateNext State of Functional Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 314 of file A31R71x_hal_timer1n.c.

315 {
316  /* Check TIMER1 handle */
317  if( TIMER1x == NULL )
318  {
319  return HAL_ERROR;
320  }
321 
322  if( NewState == ENABLE )
323  {
324  TIMER1x->CR |= TIMER1n_ENABLE;
325  }
326  else
327  {
328  TIMER1x->CR &= ~TIMER1n_ENABLE;
329  }
330 
331  return HAL_OK;
332 }

References ENABLE, HAL_ERROR, and HAL_OK.

◆ HAL_TIMER1n_ConfigInterrupt()

HAL_Status_Type HAL_TIMER1n_ConfigInterrupt ( TIMER1n_Type *  TIMER1x,
TIMER1n_INT_Type  TIMER1n_IntCfg,
FunctionalState  NewState 
)

Configure the peripheral interrupt.

Parameters
[in]TIMER1xPointer to the target TIMER1
  • TIMER10 ~ TIMER15
[in]TIMER1n_IntCfgSpecifies the interrupt flag
  • TIMER1n_INTCFG_MIE: OVIE Interrupt enable
  • TIMER1n_INTCFG_CIE: MBIE Interrupt enable
[in]NewStateNext State of Interrupt Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 272 of file A31R71x_hal_timer1n.c.

273 {
274  uint8_t tmp;
275 
276  /* Check TIMER1 handle */
277  if( TIMER1x == NULL )
278  {
279  return HAL_ERROR;
280  }
281 
282  switch( TIMER1n_IntCfg )
283  {
284  case TIMER1n_INTCFG_MIE:
285  tmp = TIMER1n_MATINTEN;
286  break;
287  case TIMER1n_INTCFG_CIE:
288  tmp = TIMER1n_CAPINTEN;
289  break;
290  }
291 
292  if( NewState == ENABLE )
293  {
294  TIMER1x->CR |= tmp;
295  }
296  else
297  {
298  TIMER1x->CR &= ( ~tmp );
299  }
300 
301  return HAL_OK;
302 }

References ENABLE, HAL_ERROR, HAL_OK, TIMER1n_INTCFG_CIE, and TIMER1n_INTCFG_MIE.

◆ HAL_TIMER1n_DeInit()

HAL_Status_Type HAL_TIMER1n_DeInit ( TIMER1n_Type *  TIMER1x)

Close Timer/Counter device.

Parameters
[in]TIMER1xPointer to the target TIMER1
  • TIMER10 ~ TIMER15
Returns
HAL_Status_Type

Definition at line 195 of file A31R71x_hal_timer1n.c.

196 {
197  /* Check TIMER1 handle */
198  if( TIMER1x == NULL )
199  {
200  return HAL_ERROR;
201  }
202 
203  // Disable timer/counter
204  TIMER1x->CR = 0x00;
205 
206 #if 1 // supported
207  if( TIMER1x == ( TIMER1n_Type* )TIMER10 )
208  {
209  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T10CLKE, PPxCLKE_Disable );
210  }
211 #endif
212 
213 #if 1 // supported
214  if( TIMER1x == ( TIMER1n_Type* )TIMER11 )
215  {
216  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T11CLKE, PPxCLKE_Disable );
217  }
218 #endif
219 
220 #if 1 // supported
221  if( TIMER1x == ( TIMER1n_Type* )TIMER12 )
222  {
223  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T12CLKE, PPxCLKE_Disable );
224  }
225 #endif
226 
227 #if 1 // supported
228  if( TIMER1x == ( TIMER1n_Type* )TIMER13 )
229  {
230  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T13CLKE, PPxCLKE_Disable );
231  }
232 #endif
233 
234 #if 1 // supported
235  if( TIMER1x == ( TIMER1n_Type* )TIMER14 )
236  {
237  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T14CLKE, PPxCLKE_Disable );
238  }
239 #endif
240 
241 #if 1 // supported
242  if( TIMER1x == ( TIMER1n_Type* )TIMER15 )
243  {
244  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T15CLKE, PPxCLKE_Disable );
245  }
246 #endif
247 
248 #if 0 // not supported
249  if( TIMER1x == ( TIMER1n_Type* )TIMER16 )
250  {
251  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T16CLKE, PPxCLKE_Disable );
252  }
253 #endif
254 
255  return HAL_OK;
256 }
void HAL_SCU_Peripheral_EnableClock1(uint32_t u32PeriClk1, uint32_t Ind)
Set Each Peripheral Clock.

References HAL_ERROR, HAL_OK, and HAL_SCU_Peripheral_EnableClock1().

Here is the call graph for this function:

◆ HAL_TIMER1n_Init()

HAL_Status_Type HAL_TIMER1n_Init ( TIMER1n_Type *  TIMER1x,
TIMER1n_MODE_OPT  TimerCounterMode,
void *  TIMER1n_Config 
)

Initialize the TIMER1n peripheral with the specified parameters.

  • Set Clock frequency for Timer
  • Set initial configuration for Timer
    Parameters
    [in]TIMER1xPointer to the target TIMER1
  • TIMER10 ~ TIMER15
    Parameters
    [in]TimerCounterModeTimer Counter Mode
  • TIMER1n_PERIODIC_MODE
  • TIMER1n_CAPTURE_MODE
  • TIMER1n_ONESHOT_MODE
  • TIMER1n_PWM_MODE
    Parameters
    [in]TIMER1n_ConfigPointer to the configuration information for the specified peripheral.
    Returns
    HAL_Status_Type
    Note
    There are no T13OUT and T14OUT pins of 16-bit Timer 1n modules.

Definition at line 66 of file A31R71x_hal_timer1n.c.

67 {
68  TIMER1n_PERIODICCFG_Type* pTimeCfg;
69  TIMER1n_PWMCFG_Type* pPwmOneshotCfg;
70  TIMER1n_CAPTURECFG_Type* pCaptureCfg;
71  uint16_t reg_val16;
72 
73  /* Check TIMER1 handle */
74  if( TIMER1x == NULL )
75  {
76  return HAL_ERROR;
77  }
78 
79 #if 1 // supported
80  if( TIMER1x == ( TIMER1n_Type* )TIMER10 )
81  {
82  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T10CLKE, PPxCLKE_Enable );
83  }
84 #endif
85 
86 #if 1 // supported
87  if( TIMER1x == ( TIMER1n_Type* )TIMER11 )
88  {
89  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T11CLKE, PPxCLKE_Enable );
90  }
91 #endif
92 
93 #if 1 // supported
94  if( TIMER1x == ( TIMER1n_Type* )TIMER12 )
95  {
96  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T12CLKE, PPxCLKE_Enable );
97  }
98 #endif
99 
100 #if 1 // supported
101  if( TIMER1x == ( TIMER1n_Type* )TIMER13 )
102  {
103  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T13CLKE, PPxCLKE_Enable );
104  }
105 #endif
106 
107 #if 1 // supported
108  if( TIMER1x == ( TIMER1n_Type* )TIMER14 )
109  {
110  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T14CLKE, PPxCLKE_Enable );
111  }
112 #endif
113 
114 #if 1 // supported
115  if( TIMER1x == ( TIMER1n_Type* )TIMER15 )
116  {
117  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T15CLKE, PPxCLKE_Enable );
118  }
119 #endif
120 
121 #if 0 // not supported
122  if( TIMER1x == ( TIMER1n_Type* )TIMER16 )
123  {
124  HAL_SCU_Peripheral_EnableClock1( PPCLKEN1_T16CLKE, PPxCLKE_Enable );
125  }
126 #endif
127 
128  if( TimerCounterMode == TIMER1n_PERIODIC_MODE )
129  {
130  pTimeCfg = ( TIMER1n_PERIODICCFG_Type* )TIMER1n_Config;
131 
132  reg_val16 = 0
133  | TIMER1n_CR_CKSEL_SET( pTimeCfg->CkSel )
134  | TIMER1n_CR_MODE_SET( TimerCounterMode )
135  | TIMER1n_CR_STARTLVL_SET( pTimeCfg->StartLevel )
136  ;
137  if( pTimeCfg->CkSel == 1 )
138  {
139  reg_val16 = reg_val16 | TIMER1n_CR_ECE_SET( pTimeCfg->ECE );
140  }
141  TIMER1x->CR = reg_val16;
142 
143  TIMER1x->PREDR = ( ( pTimeCfg->Prescaler - 1 ) & TIMER1n_PRS_MASK );
144  TIMER1x->ADR = pTimeCfg->ADR;
145  }
146  else if( ( TimerCounterMode == TIMER1n_PWM_MODE ) || ( TimerCounterMode == TIMER1n_ONESHOT_MODE ) )
147  {
148  pPwmOneshotCfg = ( TIMER1n_PWMCFG_Type* )TIMER1n_Config;
149 
150  reg_val16 = 0
151  | TIMER1n_CR_CKSEL_SET( pPwmOneshotCfg->CkSel )
152  | TIMER1n_CR_MODE_SET( TimerCounterMode )
153  | TIMER1n_CR_STARTLVL_SET( pPwmOneshotCfg->StartLevel )
154  ;
155  if( pPwmOneshotCfg->CkSel == 1 )
156  {
157  reg_val16 = reg_val16 | TIMER1n_CR_ECE_SET( pPwmOneshotCfg->ECE );
158  }
159  TIMER1x->CR = reg_val16;
160 
161  TIMER1x->PREDR = ( ( pPwmOneshotCfg->Prescaler - 1 ) & TIMER1n_PRS_MASK );
162  TIMER1x->ADR = pPwmOneshotCfg->ADR;
163  TIMER1x->BDR = pPwmOneshotCfg->BDR;
164  }
165  else if( TimerCounterMode == TIMER1n_CAPTURE_MODE )
166  {
167  pCaptureCfg = ( TIMER1n_CAPTURECFG_Type* )TIMER1n_Config;
168 
169  reg_val16 = 0
170  | TIMER1n_CR_CKSEL_SET( pCaptureCfg->CkSel )
171  | TIMER1n_CR_MODE_SET( TimerCounterMode )
172  | TIMER1n_CR_CPOL_SET( pCaptureCfg->ClrMode )
173  ;
174  if( pCaptureCfg->CkSel == 1 )
175  {
176  reg_val16 = reg_val16 | TIMER1n_CR_ECE_SET( pCaptureCfg->ECE );
177  }
178  TIMER1x->CR = reg_val16;
179 
180  TIMER1x->PREDR = ( ( pCaptureCfg->Prescaler - 1 ) & TIMER1n_PRS_MASK );
181  TIMER1x->ADR = pCaptureCfg->ADR;
182  }
183  TIMER1x->CR |= 0x1; // timer counter clear
184 
185  return HAL_OK;
186 }
void HAL_SCU_Peripheral_EnableClock1(uint32_t u32PeriClk1, uint32_t Ind)
Set Each Peripheral Clock.

References TIMER1n_PERIODICCFG_Type::ADR, TIMER1n_PWMCFG_Type::ADR, TIMER1n_CAPTURECFG_Type::ADR, TIMER1n_PWMCFG_Type::BDR, TIMER1n_PERIODICCFG_Type::CkSel, TIMER1n_PWMCFG_Type::CkSel, TIMER1n_CAPTURECFG_Type::CkSel, TIMER1n_CAPTURECFG_Type::ClrMode, TIMER1n_PERIODICCFG_Type::ECE, TIMER1n_PWMCFG_Type::ECE, TIMER1n_CAPTURECFG_Type::ECE, HAL_ERROR, HAL_OK, HAL_SCU_Peripheral_EnableClock1(), TIMER1n_PERIODICCFG_Type::Prescaler, TIMER1n_PWMCFG_Type::Prescaler, TIMER1n_CAPTURECFG_Type::Prescaler, TIMER1n_PERIODICCFG_Type::StartLevel, TIMER1n_PWMCFG_Type::StartLevel, TIMER1n_CAPTURE_MODE, TIMER1n_ONESHOT_MODE, TIMER1n_PERIODIC_MODE, and TIMER1n_PWM_MODE.

Here is the call graph for this function:

◆ HAL_TIMER1n_SetRegister()

HAL_Status_Type HAL_TIMER1n_SetRegister ( TIMER1n_Type *  TIMER1x,
uint32_t  u32T1nSet,
uint32_t  u32T1nClk 
)

Set TIMER1n CR/PREDR Registers.

Parameters
[in]TIMER1xPointer to the target TIMER1
  • TIMER10 ~ TIMER15
[in]u32T1nSetTIMER1n Control Register Setting Data
[in]u32T1nClkTIMER1n Prescaler 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 347 of file A31R71x_hal_timer1n.c.

348 {
349  /* Check TIMER1 handle */
350  if( TIMER1x == NULL )
351  {
352  return HAL_ERROR;
353  }
354 
355  TIMER1x->CR = u32T1nSet; // Setting TIMER1n Control Register
356 
357  TIMER1x->PREDR = u32T1nClk; // Setting TIMER1n Prescaler data
358 
359  return HAL_OK;
360 }

References HAL_ERROR, and HAL_OK.