A31G11x F/W Packages  2.5.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Data Structures | Functions
A31G11x_hal_timer3n.h File Reference

Contains all macro definitions and function prototypes support for timer3n firmware library on A31G11x. More...

Go to the source code of this file.

Data Structures

struct  TIMER3n_CFG_Type
 

Functions

HAL_Status_Type HAL_TIMER3n_Init (TIMER3n_Type *TIMER3x, TIMER3n_CFG_Type *TIMER3n_Config)
 Initialize the TIMER3n peripheral with the specified parameters. More...
 
HAL_Status_Type HAL_TIMER3n_DeInit (TIMER3n_Type *TIMER3x)
 Close Timer/Counter device. More...
 
HAL_Status_Type HAL_TIMER3n_ConfigInterrupt (TIMER3n_Type *TIMER3x, uint32_t NewState, uint32_t TIMER3n_IntCfg)
 Interrupt Control Register. More...
 
HAL_Status_Type HAL_TIMER3n_MPWMCmd (TIMER3n_Type *TIMER3x, uint32_t updatedata, uint32_t intcount)
 TIMER3n PWM Mode Setting (Initial : Back to Back Mode, Internal Clock, 6channel Mode) More...
 
HAL_Status_Type HAL_TIMER3n_Start (TIMER3n_Type *TIMER3x, uint32_t NewState)
 Enable or Disable PWM start. More...
 
HAL_Status_Type HAL_TIMER3n_OutputCtrl (TIMER3n_Type *TIMER3x, uint32_t NewState, uint32_t pwmApol, uint32_t pwmBpol)
 PWM Output Port Control Register (Initial : 6channel enable, output low) More...
 
HAL_Status_Type HAL_TIMER3n_ClockPrescaler (TIMER3n_Type *TIMER3x, uint32_t prescale)
 Set Prescaler data. More...
 
HAL_Status_Type HAL_TIMER3n_SetPeriod (TIMER3n_Type *TIMER3x, uint32_t period)
 Set period data. More...
 
HAL_Status_Type HAL_TIMER3n_SetADuty (TIMER3n_Type *TIMER3x, uint32_t aduty)
 Set duty A data. More...
 
HAL_Status_Type HAL_TIMER3n_SetBDuty (TIMER3n_Type *TIMER3x, uint32_t bduty)
 Set duty B data. More...
 
HAL_Status_Type HAL_TIMER3n_SetCDuty (TIMER3n_Type *TIMER3x, uint32_t cduty)
 Set duty C data. More...
 
HAL_Status_Type HAL_TIMER3n_SetDelayTime (TIMER3n_Type *TIMER3x, uint32_t dten, uint32_t dtpos, uint32_t clkdata)
 Set dead time (delay time) More...
 
HAL_Status_Type HAL_TIMER3n_SetHizReg (TIMER3n_Type *TIMER3x, uint32_t u32T30HizSet)
 Set HIZCR Register. More...
 
HAL_Status_Type HAL_TIMER3n_SetADCTrigger (TIMER3n_Type *TIMER3x, uint32_t u32triggerpoint, uint32_t u32triggertime)
 Set ADC Tirgger Source & Timing. More...
 
HAL_Status_Type HAL_TIMER3n_ClearStatus_IT (TIMER3n_Type *TIMER3x, uint32_t TIMER3n_IntCfg)
 Interrupt Flag Clear. More...
 
uint32_t HAL_TIMER3n_GetStatus_IT (TIMER3n_Type *TIMER3x)
 Get Interrupt Flag. More...
 

Detailed Description

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

Function Documentation

◆ HAL_TIMER3n_ClearStatus_IT()

HAL_Status_Type HAL_TIMER3n_ClearStatus_IT ( TIMER3n_Type *  TIMER3x,
uint32_t  TIMER3n_IntCfg 
)

Interrupt Flag Clear.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]TIMER3n_IntCfgSelect clear interrupt
Returns
HAL_Status_Type

Definition at line 474 of file A31G11x_hal_timer3n.c.

475 {
476  /* Check TIMER3 handle */
477  if( TIMER3x == NULL )
478  {
479  return HAL_ERROR;
480  }
481 
482  TIMER3x->INTFLAG = TIMER3n_IntCfg;
483 
484  return HAL_OK;
485 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_ClockPrescaler()

HAL_Status_Type HAL_TIMER3n_ClockPrescaler ( TIMER3n_Type *  TIMER3x,
uint32_t  prescale 
)

Set Prescaler data.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]prescaleTimer30 Prescaler Value
Returns
HAL_Status_Type

Definition at line 282 of file A31G11x_hal_timer3n.c.

283 {
284  /* Check TIMER3 handle */
285  if( TIMER3x == NULL )
286  {
287  return HAL_ERROR;
288  }
289 
290  TIMER3x->PREDR = ( prescale & 0x0fff ); // period. it sould be larger than 0x10
291 
292  return HAL_OK;
293 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_ConfigInterrupt()

HAL_Status_Type HAL_TIMER3n_ConfigInterrupt ( TIMER3n_Type *  TIMER3x,
uint32_t  NewState,
uint32_t  TIMER3n_IntCfg 
)

Interrupt Control Register.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]NewStateNext State of Interrupt Operation
  • ENABLE, DISABLE
[in]TIMER3n_IntCfgInterrupt Sourtce Setting
Returns
HAL_Status_Type

Definition at line 154 of file A31G11x_hal_timer3n.c.

155 {
156  /* Check TIMER3 handle */
157  if( TIMER3x == NULL )
158  {
159  return HAL_ERROR;
160  }
161 
162  if( NewState == ENABLE )
163  {
164  TIMER3x->INTCR |= TIMER3n_IntCfg;
165  }
166  else
167  {
168  TIMER3x->INTCR &= ( ~TIMER3n_IntCfg ) & 0x7f;
169  }
170 
171  return HAL_OK;
172 }

References ENABLE, HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_DeInit()

HAL_Status_Type HAL_TIMER3n_DeInit ( TIMER3n_Type *  TIMER3x)

Close Timer/Counter device.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
Returns
HAL_Status_Type

Definition at line 112 of file A31G11x_hal_timer3n.c.

113 {
114  /* Check TIMER2 handle */
115  if( TIMER3x == NULL )
116  {
117  return HAL_ERROR;
118  }
119 
120  // Disable timer/counter
121  TIMER3x->CR_b.T3nEN = 0;
122 
123 #if 1 // supported
124  if( TIMER3x == ( TIMER3n_Type* )TIMER30 )
125  {
126  // disable peripheral clock
127  SCUCG->PPCLKEN1_b.T30CLKE = 0;
128  }
129 #endif
130 
131 #if 0 // not supported
132  if( TIMER3x == ( TIMER3n_Type* )TIMER31 )
133  {
134  // disable peripheral clock
135  SCUCG->PPCLKEN1_b.T31CLKE = 0;
136  }
137 #endif
138 
139  return HAL_OK;
140 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_GetStatus_IT()

uint32_t HAL_TIMER3n_GetStatus_IT ( TIMER3n_Type *  TIMER3x)

Get Interrupt Flag.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
Returns
Interrupt Flag

Definition at line 494 of file A31G11x_hal_timer3n.c.

495 {
496  return TIMER3x->INTFLAG;
497 }

◆ HAL_TIMER3n_Init()

HAL_Status_Type HAL_TIMER3n_Init ( TIMER3n_Type *  TIMER3x,
TIMER3n_CFG_Type TIMER3n_Config 
)

Initialize the TIMER3n peripheral with the specified parameters.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]TIMER3n_ConfigPointer to the configuration information for the specified peripheral.
Returns
HAL_Status_Type

Definition at line 56 of file A31G11x_hal_timer3n.c.

57 {
58  /* Check TIMER3 handle */
59  if( TIMER3x == NULL )
60  {
61  return HAL_ERROR;
62  }
63 
64 #if 1 // supported
65  if( TIMER3x == ( TIMER3n_Type* )TIMER30 )
66  {
67  // enable peripheral clock
68  SCUCG->PPCLKEN1_b.T30CLKE = 1;
69  }
70 #endif
71 
72 #if 0 // not supported
73  if( TIMER3x == ( TIMER3n_Type* )TIMER31 )
74  {
75  // enable peripheral clock
76  SCUCG->PPCLKEN1_b.T31CLKE = 1;
77  }
78 #endif
79 
80  // CR
81  TIMER3x->CR = 0
82  | ( TIMER3n_Config->T3nMS << TIMER3n_CR_T3nMS_Pos )
83  | ( TIMER3n_Config->T3nCLK << TIMER3n_CR_T3nCLK_Pos )
84  | ( TIMER3n_Config->T3nECE << TIMER3n_CR_T3nECE_Pos )
85  | ( TIMER3n_Config->T3nCPOL << TIMER3n_CR_T3nCPOL_Pos )
86  ;
87 
88  // PDR
89  TIMER3x->PDR = TIMER3n_Config->PDR;
90 
91  // ADR & BDR & CDR
92  TIMER3x->ADR = TIMER3n_Config->ADR;
93  TIMER3x->BDR = TIMER3n_Config->BDR;
94  TIMER3x->CDR = TIMER3n_Config->CDR;
95 
96  // PREDR
97  TIMER3x->PREDR = TIMER3n_Config->Prescaler;
98 
99  // clear counter and prescaler
100  TIMER3n_ClearCounter( TIMER3x );
101 
102  return HAL_OK;
103 }
TIMER3n_CR_T3nCPOL_Enum T3nCPOL
TIMER3n_CR_T3nMS_Enum T3nMS
TIMER3n_CR_T3nCLK_Enum T3nCLK
TIMER3n_CR_T3nECE_Enum T3nECE

References TIMER3n_CFG_Type::ADR, TIMER3n_CFG_Type::BDR, TIMER3n_CFG_Type::CDR, HAL_ERROR, HAL_OK, TIMER3n_CFG_Type::PDR, TIMER3n_CFG_Type::Prescaler, TIMER3n_CFG_Type::T3nCLK, TIMER3n_CFG_Type::T3nCPOL, TIMER3n_CFG_Type::T3nECE, and TIMER3n_CFG_Type::T3nMS.

◆ HAL_TIMER3n_MPWMCmd()

HAL_Status_Type HAL_TIMER3n_MPWMCmd ( TIMER3n_Type *  TIMER3x,
uint32_t  updatedata,
uint32_t  intcount 
)

TIMER3n PWM Mode Setting (Initial : Back to Back Mode, Internal Clock, 6channel Mode)

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]updatedataPWM Duty Update Timing
[in]intcountPeriod Match Interrupt Occurence Seletion
Returns
HAL_Status_Type

Definition at line 185 of file A31G11x_hal_timer3n.c.

186 {
187  /* Check TIMER3 handle */
188  if( TIMER3x == NULL )
189  {
190  return HAL_ERROR;
191  }
192 
193  TIMER3x->CR = 0
194  | TIMER3n_CLKINT
195  | TIMER3n_BTOB
196  | TIMER3n_6CHMOD
197  | updatedata
198  | intcount
199  | 1 // Clear TIMER3n & Precaler
200  ;
201 
202  return HAL_OK;
203 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_OutputCtrl()

HAL_Status_Type HAL_TIMER3n_OutputCtrl ( TIMER3n_Type *  TIMER3x,
uint32_t  NewState,
uint32_t  pwmApol,
uint32_t  pwmBpol 
)

PWM Output Port Control Register (Initial : 6channel enable, output low)

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]NewStateNext State of Functional Operation
  • ENABLE, DISABLE
[in]pwmApolTimer 30xA Output Polarity Selection
[in]pwmBpolTimer 30xB Output Polarity Selection
Returns
HAL_Status_Type

Definition at line 249 of file A31G11x_hal_timer3n.c.

250 {
251  uint32_t temp;
252 
253  /* Check TIMER3 handle */
254  if( TIMER3x == NULL )
255  {
256  return HAL_ERROR;
257  }
258 
259  temp = 0
260  | ( ( uint32_t )TIMER30_T30_OUTCR_WTIDKY_Value << TIMER30_OUTCR_WTIDKY_Pos )
261  | ( pwmApol | pwmBpol )
262  ;
263  if( NewState == ENABLE )
264  {
265  temp |= ( 0x3f << 8 );
266  }
267 
268  TIMER3x->OUTCR = temp;
269 
270  return HAL_OK;
271 }

References ENABLE, HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetADCTrigger()

HAL_Status_Type HAL_TIMER3n_SetADCTrigger ( TIMER3n_Type *  TIMER3x,
uint32_t  u32triggerpoint,
uint32_t  u32triggertime 
)

Set ADC Tirgger Source & Timing.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]u32triggerpointTimer 30 Output High-Impedance Setting Data
[in]u32triggertimeTimer 30 A/DC Trigger Setting Data
Returns
HAL_Status_Type

This function sets the Timer 30 HIZ/ADT Control Register

Definition at line 451 of file A31G11x_hal_timer3n.c.

452 {
453  /* Check TIMER3 handle */
454  if( TIMER3x == NULL )
455  {
456  return HAL_ERROR;
457  }
458 
459  TIMER3x->ADTCR = u32triggerpoint; //Setting Timer 30 A/DC Trigger Control Register
460  TIMER3x->ADTDR = u32triggertime;
461 
462  return HAL_OK;
463 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetADuty()

HAL_Status_Type HAL_TIMER3n_SetADuty ( TIMER3n_Type *  TIMER3x,
uint32_t  aduty 
)

Set duty A data.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]adutyTimer30 Aduty data
Returns
HAL_Status_Type

Definition at line 326 of file A31G11x_hal_timer3n.c.

327 {
328  /* Check TIMER3 handle */
329  if( TIMER3x == NULL )
330  {
331  return HAL_ERROR;
332  }
333 
334  TIMER3x->ADR = ( ( aduty ) & 0xffff ); // if using I/O control function, set period data
335 
336  return HAL_OK;
337 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetBDuty()

HAL_Status_Type HAL_TIMER3n_SetBDuty ( TIMER3n_Type *  TIMER3x,
uint32_t  bduty 
)

Set duty B data.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]bdutyTimer30 Bduty data
Returns
HAL_Status_Type

Definition at line 348 of file A31G11x_hal_timer3n.c.

349 {
350  /* Check TIMER3 handle */
351  if( TIMER3x == NULL )
352  {
353  return HAL_ERROR;
354  }
355 
356  TIMER3x->BDR = ( ( bduty ) & 0xffff ); // if using I/O control function, set period data
357 
358  return HAL_OK;
359 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetCDuty()

HAL_Status_Type HAL_TIMER3n_SetCDuty ( TIMER3n_Type *  TIMER3x,
uint32_t  cduty 
)

Set duty C data.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]cdutyTimer30 Cduty data
Returns
HAL_Status_Type

Definition at line 370 of file A31G11x_hal_timer3n.c.

371 {
372  /* Check TIMER3 handle */
373  if( TIMER3x == NULL )
374  {
375  return HAL_ERROR;
376  }
377 
378  TIMER3x->CDR = ( ( cduty ) & 0xffff ); // if using I/O control function, set period data
379 
380  return HAL_OK;
381 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetDelayTime()

HAL_Status_Type HAL_TIMER3n_SetDelayTime ( TIMER3n_Type *  TIMER3x,
uint32_t  dten,
uint32_t  dtpos,
uint32_t  clkdata 
)

Set dead time (delay time)

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]dtendead time enable
[in]dtposdead timer position (front or back)
[in]clkdatadead time
Returns
HAL_Status_Type

Definition at line 396 of file A31G11x_hal_timer3n.c.

397 {
398  uint32_t temp;
399 
400  /* Check TIMER3 handle */
401  if( TIMER3x == NULL )
402  {
403  return HAL_ERROR;
404  }
405 
406  temp = TIMER3x->CR;
407  temp &= ~( 0x03 << 8 );
408  temp |= dten | dtpos;
409  TIMER3x->CR = temp;
410 
411  TIMER3x->DLY = clkdata & 0x03ff;
412 
413  return HAL_OK;
414 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetHizReg()

HAL_Status_Type HAL_TIMER3n_SetHizReg ( TIMER3n_Type *  TIMER3x,
uint32_t  u32T30HizSet 
)

Set HIZCR Register.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]u32T30HizSetTimer 30 Output High-Impedance Setting Data
Returns
HAL_Status_Type

This function sets the Timer 30 HIZ/ADT Control Register

Definition at line 426 of file A31G11x_hal_timer3n.c.

427 {
428  /* Check TIMER3 handle */
429  if( TIMER3x == NULL )
430  {
431  return HAL_ERROR;
432  }
433 
434  TIMER3x->HIZCR = u32T30HizSet; //Setting Timer 30 High-Impedance Control Register
435 
436  return HAL_OK;
437 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_SetPeriod()

HAL_Status_Type HAL_TIMER3n_SetPeriod ( TIMER3n_Type *  TIMER3x,
uint32_t  period 
)

Set period data.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]periodMPWM period data
Returns
HAL_Status_Type

Definition at line 304 of file A31G11x_hal_timer3n.c.

305 {
306  /* Check TIMER3 handle */
307  if( TIMER3x == NULL )
308  {
309  return HAL_ERROR;
310  }
311 
312  TIMER3x->PDR = ( period & 0xffff ); // period. it sould be larger than 0x10
313 
314  return HAL_OK;
315 }

References HAL_ERROR, and HAL_OK.

◆ HAL_TIMER3n_Start()

HAL_Status_Type HAL_TIMER3n_Start ( TIMER3n_Type *  TIMER3x,
uint32_t  NewState 
)

Enable or Disable PWM start.

Parameters
[in]TIMER3xPointer to the target TIMER3
  • TIMER30
[in]NewStateNext State of Functional Operation
  • ENABLE, DISABLE
Returns
HAL_Status_Type

Definition at line 215 of file A31G11x_hal_timer3n.c.

216 {
217  /* Check TIMER3 handle */
218  if( TIMER3x == NULL )
219  {
220  return HAL_ERROR;
221  }
222 
223  if( NewState == TIMER3n_ENABLE )
224  {
225  TIMER3x->CR |= TIMER3n_ENABLE;
226  }
227  else
228  {
229  TIMER3x->CR &= ~TIMER3n_ENABLE;
230  }
231 
232  return HAL_OK;
233 }

References HAL_ERROR, and HAL_OK.