S32 SDK
lptmr_driver.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
18 
52 #include <stddef.h>
53 #include "lptmr_driver.h"
54 #include "lptmr_hal.h"
55 #include "clock_manager.h"
56 
57 /* Takes into consideration that LPTMR compare events take place
58  * when "the CNR equals the value of the CMR and increments". */
59 #define LPTMR_MAX_CMR_NTICKS (LPTMR_CMR_COMPARE_MASK + 1u)
60 #define LPTMR_MAX_PRESCALER (1u << LPTMR_PSR_PRESCALE_WIDTH)
61 
62 /*******************************************************************************
63  * Variables
64  ******************************************************************************/
65 
68 /* Table of base addresses for LPTMR instances. */
69 static LPTMR_Type* const g_lptmrBase[LPTMR_INSTANCE_COUNT] = LPTMR_BASE_PTRS;
70 
71 /*******************************************************************************
72  * Private Functions
73  ******************************************************************************/
74 static inline uint8_t lptmr_cfg2p(
75  const lptmr_prescaler_t prescval,
76  const bool bypass
77  );
78 
79 static inline uint64_t lptmr_us2nn(
80  const uint32_t clkfreq,
81  const uint32_t us
82  );
83 
84 static inline uint64_t lptmr_compute_nticks(
85  uint64_t nn,
86  uint8_t p
87  );
88 
89 static inline bool nticks2compare_ticks(
90  uint64_t nticks,
91  uint16_t* ticks
92  );
93 
94 static uint32_t lptmr_GetClkFreq(
95  const lptmr_clocksource_t clkSrc,
96  const uint32_t instance
97  );
98 
99 static bool lptmr_Ticks2Us(
100  const uint32_t clkfreq,
101  const lptmr_prescaler_t pval,
102  const bool bypass,
103  const uint16_t ticks,
104  uint32_t* const us
105  );
106 
107 static bool lptmr_Us2Ticks(
108  const uint32_t clkfreq,
109  const lptmr_prescaler_t prescval,
110  const bool bypass,
111  const uint32_t us,
112  uint16_t* const ticks
113  );
114 
115 static bool lptmr_ChooseClkConfig(
116  const uint32_t clkfreq,
117  const uint32_t us,
118  lptmr_prescaler_t* const prescval,
119  bool* const bypass,
120  uint16_t* const ticks
121  );
122 
123 /*TIMER MODE CONFIGURATION******************************************************
124  *
125  * Timer Mode - Prescaler settings calculations
126  * --------------------------------------------
127  *
128  * Timer Mode configuration takes a period (timeout) value expressed in
129  * micro-seconds. To convert this to LPTMR prescaler (and compare value)
130  * settings, the closest match must be found.
131  * For best precision, the lowest prescaler that allows the corresponding
132  * compare value to fit in the 16-bit register will be chosen.
133  *
134  * Algorithm for choosing prescaler and compare values:
135  * =============================================================================
136  * In: tper_us (period in microseconds), fclk (input clock frequency in Hertz)
137  * Out: nticks (timer ticks), p (prescaler coefficient, 2^p = prescaler value)
138  * ---
139  * 1) Compute nn = tper_us * fclk / 1000000
140  * 2) for p = 0..16
141  * 2.1) nticks = nn / 2^p
142  * 2.2) if nticks < 0x10000
143  * 2.2.1) STOP, found nticks and p
144  * 3) nticks = 0xFFFF, p = 16
145  * =============================================================================
146  *
147  * A few names used throughout the static functions affecting Timer mode:
148  * nn - total number of timer ticks (undivided, unprescaled) that is necessary
149  * for a particular timeout.
150  * nn = (tper_us * fclk) / 1000000 = nticks * npresc
151  *
152  * tper_us - a period (or timeout) expressed in microsecond units. In most
153  * functions will be denoted as 'us' for microseconds.
154  *
155  * nticks - number of timer ticks that is necessary for a particular timeout,
156  * after prescaling
157  *
158  * npresc - prescaler value (1, 2, 4 ... 65536)
159  *
160  * p - prescaler coefficient, 2^p = npresc
161  *
162  * fclk - input clock frequency, in Hertz. In most function will be denoted as
163  * 'clkfreq'.
164  *END**************************************************************************/
165 
166 /*FUNCTION**********************************************************************
167  *
168  * Function Name : lptmr_cfg2p
169  * Description : Transform prescaler settings (bypass on/off, prescaler value)
170  * to prescaler coefficient value (2's power), p.
171  * Return: the value of p.
172  *END**************************************************************************/
173 static inline uint8_t lptmr_cfg2p(
174  const lptmr_prescaler_t prescval,
175  const bool bypass
176  )
177 {
178  uint8_t p = 0u;
179 
180  if (!bypass)
181  {
182  p = (uint8_t)(((uint8_t)prescval) + 1u);
183  }
184 
185  return p;
186 }
187 
188 /*FUNCTION**********************************************************************
189  *
190  * Function Name : lptmr_us2nn
191  * Description : Transform microseconds to undivided (unprescaled) timer units,
192  * nn.
193  * Return: the value of nn.
194  *END**************************************************************************/
195 static inline uint64_t lptmr_us2nn(
196  const uint32_t clkfreq,
197  const uint32_t us
198  )
199 {
200  /* Approximate the timeout in undivided (unprescaled) timer ticks.
201  - us is the timeout in microseconds (1/10^6 seconds)
202  - clkfreq is the frequency in Hertz
203  Operation:
204  nn = (us/1000000) * clkfreq
205  In C:
206  For better precision, first to the multiplication (us * clkfreq)
207  To overcome the truncation of the div operator in C, add half of the
208  denominator before the division. Hence:
209  nn = (us * clkfreq + 500000) / 1000000
210  */
211  /* There is no risk of overflow since us is 32-bit wide and clkfreq can be
212  a theoretical maximum of ~100 MHz (platform maximum), which is over the
213  maximum input of the LPTMR anyway
214  */
215  uint64_t nn = (uint64_t)( (uint64_t)us * (uint64_t)clkfreq );
216  nn = (nn + 500000u) / 1000000u;
217  return nn;
218 }
219 
220 /*FUNCTION**********************************************************************
221  *
222  * Function Name : lptmr_compute_nticks
223  * Description : Compute total number of divided (prescaled) timer ticks,
224  * nticks.
225  * Return: the value of nticks.
226  *END**************************************************************************/
227 static inline uint64_t lptmr_compute_nticks(
228  uint64_t nn,
229  uint8_t p
230  )
231 {
232  uint64_t npresc = (uint64_t) 1u << p;
233  DEV_ASSERT(npresc != 0u);
234 
235  /* integer division */
236  uint64_t nticks = ((nn + (npresc >> 1u)) / npresc);
237 
238  return nticks;
239 }
240 
241 /*FUNCTION**********************************************************************
242  *
243  * Function Name : nticks2compare_ticks
244  * Description : Transform the value of divided (prescaled) timer ticks, nticks
245  * to a 16-bit value to be written to the hardware register. Cap or underflow
246  * cause an error.
247  * Return: the success state.
248  * - true: no underflow or overflow detected
249  * - false: value written was capped, underflow or overflow detected
250  *
251  *END**************************************************************************/
252 static inline bool nticks2compare_ticks(
253  uint64_t nticks,
254  uint16_t* ticks
255  )
256 {
257  bool success = true;
258 
259  /* if nticks fits, write the value to ticks */
260  if (nticks <= LPTMR_MAX_CMR_NTICKS)
261  {
262  if (nticks == 0u)
263  {
264  /* timeout period (us) too low for prescaler settings */
265  *ticks = 0u;
266  success = false;
267  }
268  else{
269  /* According to RM, the LPTMR compare events take place when "the CNR equals the value of the CMR and increments".
270  * The additional increment is compensated here by decrementing the calculated compare value with 1, before being written to CMR. */
271  *ticks = (uint16_t)(nticks - 1u);
272  }
273  }
274  else {
275  /* timeout period (us) too high for prescaler settings */
276  *ticks = LPTMR_CMR_COMPARE_MASK;
277  success = false;
278  }
279 
280  return success;
281 }
282 
283 /*FUNCTION**********************************************************************
284  *
285  * Function Name : lptmr_GetClkFreq
286  * Description : Get the clock frequency for the selected clock source. If the
287  * selected clock source is not enabled, a frequency of 0 is returned.
288  * Return values:
289  * - the clock frequency or 0 if the clock is invalid.
290  *
291  *END**************************************************************************/
292 static uint32_t lptmr_GetClkFreq(const lptmr_clocksource_t clkSrc,
293  const uint32_t instance)
294 {
295  /* LPTMR PCC clock source names, for getting the input clock frequency */
296  static const clock_names_t lptmrPccClockName[LPTMR_INSTANCE_COUNT] = {PCC_LPTMR0_CLOCK};
297  clock_names_t inputClockName = SIRC_CLOCK;
298  uint32_t clkFreq;
299  status_t clkStatus;
300 
301  /* Get input clock name */
302  switch(clkSrc)
303  {
305  inputClockName = SIRC_CLOCK;
306  break;
308  inputClockName = SIM_LPO_1K_CLOCK;
309  break;
311  inputClockName = SIM_RTCCLK_CLOCK;
312  break;
314  inputClockName = lptmrPccClockName[instance];
315  break;
316  default:
317  /* Invalid clock source */
318  DEV_ASSERT(false);
319  break;
320  }
321 
322  /* Get input clock frequency */
323  if (inputClockName == SIRC_CLOCK)
324  {
326  }
327  else
328  {
329  clkStatus = CLOCK_SYS_GetFreq(inputClockName, &clkFreq);
330  DEV_ASSERT(clkStatus == STATUS_SUCCESS);
331  (void) clkStatus;
332  DEV_ASSERT(clkFreq != 0u); /* If the GetFreq functions fails, clkfreq will be 0 */
333  }
334 
335  return clkFreq;
336 }
337 
338 /*FUNCTION**********************************************************************
339  *
340  * Function Name : lptmr_Ticks2Us
341  * Description : Transform timer ticks to microseconds using the given
342  * prescaler settings. Clock frequency must be valid ( different from 0).
343  * Possible return values:
344  * - true: conversion success
345  * - false: conversion failed, result did not fit in 32-bit.
346  *
347  *END**************************************************************************/
348 static bool lptmr_Ticks2Us(
349  const uint32_t clkfreq,
350  const lptmr_prescaler_t pval,
351  const bool bypass,
352  const uint16_t ticks,
353  uint32_t* const us
354  )
355 {
356  bool success = true;
357  uint8_t p = lptmr_cfg2p(pval, bypass);
358  uint64_t nn = ( (uint64_t)ticks + 1u ) << p;
359  uint64_t us_real = (nn * 1000000u) / (clkfreq);
360  uint32_t us_local;
361 
362  if ( us_real <= (0xFFFFFFFFu) )
363  {
364  us_local = (uint32_t)us_real;
365  }
366  else
367  {
368  us_local = 0xFFFFFFFFu;
369  success = false;
370  }
371 
372  *us = us_local;
373  return success;
374 }
375 
376 /*FUNCTION**********************************************************************
377  *
378  * Function Name : lptmr_Us2Ticks
379  * Description : Transform microseconds to timer ticks using the given
380  * prescaler settings. Input clock frequency, clkfreq, must be greater than 0.
381  * Possible return values:
382  * - true: conversion completed successfully
383  * - false: conversion failed, value did not fit in 16-bit.
384  *
385  *END**************************************************************************/
386 static bool lptmr_Us2Ticks(
387  const uint32_t clkfreq,
388  const lptmr_prescaler_t prescval,
389  const bool bypass,
390  const uint32_t us,
391  uint16_t* const ticks
392  )
393 {
394  bool success = true;
395  /* Transform prescaler configuration to prescaler coefficient p */
396  uint8_t p = lptmr_cfg2p(prescval, bypass);
397  /* Compute nn, the number of ticks necessary for the period in microseconds
398  without any prescaler */
399  uint64_t nn = lptmr_us2nn(clkfreq, us);
400  /* Compute nticks, total number of ticks with prescaler */
401  uint64_t nticks = lptmr_compute_nticks(nn, p);
402  /* Transform nticks to value to be written to register */
403  success = nticks2compare_ticks(nticks, ticks);
404  return success;
405 }
406 
407 /*FUNCTION**********************************************************************
408  *
409  * Function Name : lptmr_ChooseClkConfig
410  * Description : Choose clocking configuration (prescaler value, timer ticks)
411  * for the desired timeout period, given in microseconds. Input clock frequency,
412  * clkfreq, must be greater than 0.
413  * Possible return values:
414  * - true: configuration found
415  * - false: configuration mismatch, desired timeout period is too small or too
416  * big for the clock settings.
417  *
418  *END**************************************************************************/
419 static bool lptmr_ChooseClkConfig(
420  const uint32_t clkfreq,
421  const uint32_t us,
422  lptmr_prescaler_t* const prescval,
423  bool* const bypass,
424  uint16_t* const ticks
425  )
426 {
427  uint8_t p;
428  uint64_t nticks;
429  bool success;
430 
431  uint64_t nn = lptmr_us2nn(clkfreq, us);
432 
433  /* Find the lowest prescaler value that allows the compare value in 16-bits */
434  for (p = 0u; p <= LPTMR_MAX_PRESCALER; p++)
435  {
436  nticks = lptmr_compute_nticks(nn, p);
437 
438  if (nticks <= LPTMR_MAX_CMR_NTICKS)
439  {
440  /* Search finished, value will fit in the 16-bit register */
441  break;
442  }
443  }
444 
445  success = nticks2compare_ticks(nticks, ticks);
446 
447  /* Convert p to prescaler configuration */
448  if (p == 0u)
449  {
450  /* Prescaler value of 1 */
451  *bypass = true;
452  *prescval = LPTMR_PRESCALE_2;
453  }
454  else{
455  *bypass = false;
456  p--; /* Decrement to match lptmr_prescaler_t. */
457  *prescval = (lptmr_prescaler_t) p;
458  }
459 
460  return success;
461 }
462 
463 
464 /*******************************************************************************
465  * Public Functions
466  ******************************************************************************/
467 
468 
469 /*FUNCTION**********************************************************************
470  *
471  * Function Name : LPTMR_DRV_InitConfigStruct
472  * Description : Initialize a configuration structure with default values.
473  *
474  * Implements : LPTMR_DRV_InitConfigStruct_Activity
475  *END**************************************************************************/
476 void LPTMR_DRV_InitConfigStruct(lptmr_config_t * const config)
477 {
478  DEV_ASSERT(config != NULL);
479 
480  /* General parameters */
481  config->dmaRequest = false;
482  config->interruptEnable = false;
483  config->freeRun = false;
484  config->workMode = LPTMR_WORKMODE_TIMER;
485 
486  /* Counter parameters */
488  config->prescaler = LPTMR_PRESCALE_2;
489  config->bypassPrescaler = false;
490  config->compareValue = 0u;
492 
493  /* Pulse Counter specific parameters */
496 }
497 
498 /*FUNCTION**********************************************************************
499  *
500  * Function Name : LPTMR_DRV_Init
501  * Description : Initialize a LPTMR instance based on the input configuration
502  * structure.
503  *
504  * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS) the function will
505  * automatically configure the timer for the input compareValue in microseconds.
506  * The input params for 'prescaler' and 'bypassPrescaler' will be ignored
507  * - their values will be adapted by the function, to best fit the input compareValue
508  * (in microseconds) for the operating clock frequency.
509  *
510  * LPTMR_COUNTER_UNITS_MICROSECONDS may only be used for LPTMR_WORKMODE_TIMER mode.
511  * Otherwise the function shall not convert 'compareValue' in ticks
512  * and this is likely to cause erroneous behavior.
513  *
514  * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS) the function will use the
515  * 'prescaler' and 'bypassPrescaler' provided in the input config structure.
516  *
517  * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS), 'compareValue' must be lower
518  * than 0xFFFFu. Only the least significant 16bits of 'compareValue' will be used.
519  * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS), 'compareValue'
520  * may take any 32bit unsigned value.
521  *
522  * Implements : LPTMR_DRV_Init_Activity
523  *END**************************************************************************/
524 void LPTMR_DRV_Init(const uint32_t instance,
525  const lptmr_config_t * const config,
526  const bool startCounter)
527 {
528  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
529  DEV_ASSERT(config != NULL);
530 
531  LPTMR_Type* const base = g_lptmrBase[instance];
532 
533  LPTMR_DRV_SetConfig(instance, config);
534 
535  /* Start the counter if requested */
536  if (startCounter)
537  {
538  LPTMR_HAL_Enable(base);
539  }
540 }
541 
542 /*FUNCTION**********************************************************************
543  *
544  * Function Name : LPTMR_DRV_SetConfig
545  * Description : Configure a LPTMR instance based on the input configuration
546  * structure.
547  *
548  * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS) the function will
549  * automatically configure the timer for the input compareValue in microseconds.
550  * The input params for 'prescaler' and 'bypassPrescaler' will be ignored
551  * - their values will be adapted by the function, to best fit the input compareValue
552  * (in microseconds) for the operating clock frequency.
553  *
554  * LPTMR_COUNTER_UNITS_MICROSECONDS may only be used for LPTMR_WORKMODE_TIMER mode.
555  * Otherwise the function shall not convert 'compareValue' in ticks
556  * and this is likely to cause erroneous behavior.
557  *
558  * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS) the function will use the
559  * 'prescaler' and 'bypassPrescaler' provided in the input config structure.
560  *
561  * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS), 'compareValue' must be lower
562  * than 0xFFFFu. Only the least significant 16bits of 'compareValue' will be used.
563  * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS), 'compareValue'
564  * may take any 32bit unsigned value.
565  *
566  * Implements : LPTMR_DRV_SetConfig_Activity
567  *END**************************************************************************/
568 void LPTMR_DRV_SetConfig(const uint32_t instance,
569  const lptmr_config_t * const config)
570 {
571  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
572  DEV_ASSERT(config != NULL);
573 
574  LPTMR_Type* const base = g_lptmrBase[instance];
575  uint32_t configCmpValue = config->compareValue;
576  lptmr_workmode_t configWorkMode = config->workMode;
577  uint16_t cmpValueTicks = 0U;
578  lptmr_prescaler_t prescVal = config->prescaler;
579  bool prescBypass = config->bypassPrescaler;
580  lptmr_counter_units_t configCounterUnits = config->counterUnits;
581 
582  /* The LPTMR instance cannot be reconfigured, unless it is disabled. */
583  DEV_ASSERT(LPTMR_HAL_GetEnable(base) == false);
584 
585  if(configWorkMode == LPTMR_WORKMODE_TIMER)
586  {
587  /* A valid clock must be selected when used in Timer Mode. */
588  uint32_t clkFreq;
589  clkFreq = lptmr_GetClkFreq(config->clockSelect, instance);
590  DEV_ASSERT(clkFreq != 0U); /* Clock frequency equal to '0', signals invalid value. */
591 
592  if(configCounterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS)
593  {
594  bool chooseClkConfigStatus;
595 
596  /* When workmode is set to Timer Mode and compare value is provided in microseconds,
597  * then the input params for prescale value and prescaleBypass are ignored.
598  * The prescaleValue, prescaleBypass and cmpValue in ticks, are calculated to best fit
599  * the input configCmpValue (in us) for the current operating clk frequency. */
600  chooseClkConfigStatus = lptmr_ChooseClkConfig(clkFreq, configCmpValue, &prescVal, &prescBypass, &cmpValueTicks);
601  DEV_ASSERT(chooseClkConfigStatus == true);
602  (void) chooseClkConfigStatus;
603  }
604  else
605  {
606  DEV_ASSERT(configCounterUnits == LPTMR_COUNTER_UNITS_TICKS);
607  DEV_ASSERT(configCmpValue <= LPTMR_CMR_COMPARE_MASK); /* Compare Value in Tick Units must fit in CMR. */
608 
609  cmpValueTicks = (uint16_t)(configCmpValue & LPTMR_CMR_COMPARE_MASK);
610  }
611  }
612  else
613  {
614  /* If configWorkMode is not LPTMR_WORKMODE_TIMER, then it must be LPTMR_WORKMODE_PULSECOUNTER. */
615  DEV_ASSERT(configWorkMode == LPTMR_WORKMODE_PULSECOUNTER);
616 
617  /* Only LPTMR_COUNTER_UNITS_TICKS can be used when LPTMR is configured as Pulse Counter. */
619  /* A valid clock must be selected when glitch filter is enabled (prescaler not bypassed). */
620  DEV_ASSERT((lptmr_GetClkFreq(config->clockSelect, instance) != 0u) || prescBypass);
621  /* Glitch filter does not support LPTMR_PRESCALE_2. */
622  DEV_ASSERT(prescBypass || (prescVal != LPTMR_PRESCALE_2));
623 
624  DEV_ASSERT(configCmpValue <= LPTMR_CMR_COMPARE_MASK); /* Compare Value in Tick Units must fit in CMR. */
625 
626  cmpValueTicks = (uint16_t)(configCmpValue & LPTMR_CMR_COMPARE_MASK);
627  }
628 
629  /* Initialize and write configuration parameters. */
630  LPTMR_HAL_Init(base);
631 
632  LPTMR_HAL_SetDmaRequest (base, config->dmaRequest);
633  LPTMR_HAL_SetInterrupt (base, config->interruptEnable);
634  LPTMR_HAL_SetFreeRunning (base, config->freeRun);
635  LPTMR_HAL_SetWorkMode (base, configWorkMode);
636  LPTMR_HAL_SetPrescaler (base, prescVal);
637  LPTMR_HAL_SetBypass (base, prescBypass);
638  LPTMR_HAL_SetClockSelect (base, config->clockSelect);
639  LPTMR_HAL_SetCompareValue (base, cmpValueTicks);
640  LPTMR_HAL_SetPinSelect (base, config->pinSelect);
641  LPTMR_HAL_SetPinPolarity (base, config->pinPolarity);
642 }
643 
644 /*FUNCTION**********************************************************************
645  *
646  * Function Name : LPTMR_DRV_GetConfig
647  * Description : Get the current configuration of the LPTMR instance.
648  * Always returns compareValue in LPTMR_COUNTER_UNITS_TICKS.
649  *
650  * Implements : LPTMR_DRV_GetConfig_Activity
651  *END**************************************************************************/
652 void LPTMR_DRV_GetConfig(const uint32_t instance,
653  lptmr_config_t * const config)
654 {
655  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
656  DEV_ASSERT(config != NULL);
657 
658  const LPTMR_Type* const base = g_lptmrBase[instance];
659 
660  /* Read current configuration */
661  config->dmaRequest = LPTMR_HAL_GetDmaRequest(base);
663  config->freeRun = LPTMR_HAL_GetFreeRunning(base);
664  config->workMode = LPTMR_HAL_GetWorkMode(base);
665  config->prescaler = LPTMR_HAL_GetPrescaler(base);
666  config->bypassPrescaler = LPTMR_HAL_GetBypass(base);
667  config->clockSelect = LPTMR_HAL_GetClockSelect(base);
668  config->compareValue = LPTMR_HAL_GetCompareValue(base);
670  config->pinSelect = LPTMR_HAL_GetPinSelect(base);
671  config->pinPolarity = LPTMR_HAL_GetPinPolarity(base);
672 }
673 
674 
675 /*FUNCTION**********************************************************************
676  *
677  * Function Name : LPTMR_DRV_Deinit
678  * Description : De-initialize the LPTMR (stop the counter and reset config values to default).
679  *
680  * Implements : LPTMR_DRV_Deinit_Activity
681  *END**************************************************************************/
682 void LPTMR_DRV_Deinit(const uint32_t instance)
683 {
684  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
685 
686  LPTMR_Type* const base = g_lptmrBase[instance];
687  LPTMR_HAL_Disable(base);
688 
689  LPTMR_HAL_Init(base);
690 }
691 
692 
693 /*FUNCTION**********************************************************************
694  *
695  * Function Name : LPTMR_DRV_SetCompareValueByCount
696  * Description : Set the compare value in counter tick units, for a LPTMR instance.
697  * Possible return values:
698  * - STATUS_SUCCESS: completed successfully
699  * - STATUS_ERROR: cannot reconfigure compare value (TCF not set)
700  * - STATUS_TIMEOUT: compare value greater then current counter value
701  *
702  * Implements : LPTMR_DRV_SetCompareValueByCount_Activity
703  *END**************************************************************************/
704 status_t LPTMR_DRV_SetCompareValueByCount(const uint32_t instance,
705  const uint16_t compareValueByCount)
706 {
707  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
708 
709  LPTMR_Type* const base = g_lptmrBase[instance];
710  status_t statusCode = STATUS_SUCCESS;
711 
712  bool timerEnabled = LPTMR_HAL_GetEnable(base);
713  bool compareFlag = LPTMR_HAL_GetCompareFlag(base);
714 
715  uint16_t counterVal;
716 
717  /* Check if a valid clock is selected for the timer/glitch filter */
718 #if (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT))
719  bool bypass = LPTMR_HAL_GetBypass(base);
720  lptmr_workmode_t workMode = LPTMR_HAL_GetWorkMode(base);
721  (void) bypass;
722  (void) workMode;
723 #endif /* (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT)) */
724  DEV_ASSERT((lptmr_GetClkFreq(LPTMR_HAL_GetClockSelect(base), instance) != 0u) || \
725  (bypass && (workMode == LPTMR_WORKMODE_PULSECOUNTER)));
726 
727 
728  /* The compare value can only be written if counter is disabled or the compare flag is set. */
729  if (timerEnabled && !compareFlag)
730  {
731  statusCode = STATUS_ERROR;
732  }
733  else
734  {
735  /* Check if new value is below the current counter value */
736  LPTMR_HAL_SetCompareValue(base, compareValueByCount);
737  counterVal = LPTMR_HAL_GetCounterValue(base);
738  if (counterVal >= compareValueByCount)
739  {
740  statusCode = STATUS_TIMEOUT;
741  }
742  }
743 
744  return statusCode;
745 }
746 
747 
748 /*FUNCTION**********************************************************************
749  *
750  * Function Name : LPTMR_DRV_GetCompareValueByCount
751  * Description : Get the compare value in timer ticks units.
752  *
753  * Implements : LPTMR_DRV_GetCompareValueByCount_Activity
754  *END**************************************************************************/
755 void LPTMR_DRV_GetCompareValueByCount(const uint32_t instance,
756  uint16_t * const compareValueByCount)
757 {
758  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
759 
760  const LPTMR_Type* const base = g_lptmrBase[instance];
761 
762  *compareValueByCount = LPTMR_HAL_GetCompareValue(base);
763 }
764 
765 
766 /*FUNCTION**********************************************************************
767  *
768  * Function Name : LPTMR_DRV_SetCompareValueUs
769  * Description : Set the compare value for Timer Mode in microseconds,
770  * for a LPTMR instance.
771  * Can be used only in Timer Mode.
772  * Possible return values:
773  * - STATUS_SUCCESS: completed successfully
774  * - STATUS_ERROR: cannot reconfigure compare value
775  * - STATUS_TIMEOUT: compare value greater then current counter value
776  *
777  * Implements : LPTMR_DRV_SetCompareValueByUs_Activity
778  *END**************************************************************************/
779 status_t LPTMR_DRV_SetCompareValueByUs(const uint32_t instance,
780  const uint32_t compareValueUs)
781 {
782  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
783 
784  status_t returnCode = STATUS_SUCCESS;
785  LPTMR_Type* const base = g_lptmrBase[instance];
786  bool timerEnabled, compareFlag;
787 
788  lptmr_clocksource_t clkSrc;
789  uint32_t clkFreq;
790  uint16_t cmpValTicks, currentCounterVal;
791  lptmr_prescaler_t prescVal;
792  bool prescBypass, conversionStatus;
793 
794  /* This function can only be used if LPTMR is configured in Timer Mode. */
796 
797  timerEnabled = LPTMR_HAL_GetEnable(base);
798  compareFlag = LPTMR_HAL_GetCompareFlag(base);
799  /* The compare value can only be written if counter is disabled or the compare flag is set. */
800  if (timerEnabled && !compareFlag)
801  {
802  returnCode = STATUS_ERROR;
803  }
804  else
805  {
806  clkSrc = LPTMR_HAL_GetClockSelect(base);
807  clkFreq = lptmr_GetClkFreq(clkSrc, instance);
808  DEV_ASSERT(clkFreq != 0U); /* Check the calculated clock frequency: '0' - invalid*/
809 
810  /* Get prescaler value and prescaler bypass state.*/
811  prescVal = LPTMR_HAL_GetPrescaler(base);
812  prescBypass = LPTMR_HAL_GetBypass(base);
813  /* Convert new compare value from microseconds to ticks. */
814  conversionStatus = lptmr_Us2Ticks(clkFreq, prescVal, prescBypass, compareValueUs, &cmpValTicks);
815  DEV_ASSERT(conversionStatus == true); /* Check the conversion status: compareValueUs doesn't fit for current prescaller. */
816  (void) conversionStatus;
817 
818  /* Write value and check if written successfully */
819  LPTMR_HAL_SetCompareValue(base, cmpValTicks);
820  currentCounterVal = LPTMR_HAL_GetCounterValue(base);
821 
822  if (currentCounterVal >= cmpValTicks)
823  {
824  returnCode = STATUS_TIMEOUT;
825  }
826  }
827 
828  return returnCode;
829 }
830 
831 /*FUNCTION**********************************************************************
832  *
833  * Function Name : LPTMR_DRV_GetCompareValueByUs
834  * Description : Get the compare value in microseconds representation.
835  * Can be used only in Timer Mode.
836  *
837  * Implements : LPTMR_DRV_GetCompareValueByUs_Activity
838  *END**************************************************************************/
839 void LPTMR_DRV_GetCompareValueByUs(const uint32_t instance,
840  uint32_t * const compareValueUs)
841 {
842  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
843  DEV_ASSERT(compareValueUs != NULL);
844 
845  const LPTMR_Type* const base = g_lptmrBase[instance];
846  lptmr_clocksource_t clkSrc;
847  uint32_t clkFreq;
848  uint16_t cmpValTicks;
849  lptmr_prescaler_t prescVal;
850  bool prescBypass, conversionStatus;
851 
852  /* This function can only be used if LPTMR is configured in Timer Mode. */
854 
855  clkSrc = LPTMR_HAL_GetClockSelect(base);
856  clkFreq = lptmr_GetClkFreq(clkSrc, instance);
857  /* The clock frequency must be valid. */
858  DEV_ASSERT(clkFreq != 0U);
859 
860  /* Get prescaler value and prescaler bypass state.*/
861  prescVal = LPTMR_HAL_GetPrescaler(base);
862  prescBypass = LPTMR_HAL_GetBypass(base);
863  cmpValTicks = LPTMR_HAL_GetCompareValue(base);
864 
865  /* Convert current compare value from ticks to microseconds. */
866  conversionStatus = lptmr_Ticks2Us(clkFreq, prescVal, prescBypass, cmpValTicks, compareValueUs);
867  DEV_ASSERT(conversionStatus == true); /* Check the conversion status. */
868  (void) conversionStatus;
869 }
870 
871 
872 /*FUNCTION**********************************************************************
873  *
874  * Function Name : LPTMR_DRV_GetCompareFlag
875  * Description : Get the current state of the Compare Flag of a LPTMR instance
876  *
877  * Implements : LPTMR_DRV_GetCompareFlag_Activity
878  *END**************************************************************************/
879 bool LPTMR_DRV_GetCompareFlag(const uint32_t instance)
880 {
881  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
882 
883  const LPTMR_Type* const base = g_lptmrBase[instance];
884  bool compareFlag = LPTMR_HAL_GetCompareFlag(base);
885 
886  return compareFlag;
887 }
888 
889 
890 /*FUNCTION**********************************************************************
891  *
892  * Function Name : LPTMR_DRV_ClearCompareFlag
893  * Description : Clear the Compare Flag.
894  *
895  * Implements : LPTMR_DRV_ClearCompareFlag_Activity
896  *END**************************************************************************/
897 void LPTMR_DRV_ClearCompareFlag(const uint32_t instance)
898 {
899  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
900 
901  LPTMR_Type* const base = g_lptmrBase[instance];
902 
904 }
905 
906 
907 /*FUNCTION**********************************************************************
908  *
909  * Function Name : LPTMR_DRV_IsRunning
910  * Description : Get the running state of a LPTMR instance.
911  * Possible return values:
912  * - true: Timer/Counter started
913  * - false: Timer/Counter stopped
914  *
915  * Implements : LPTMR_DRV_IsRunning_Activity
916  *END**************************************************************************/
917 bool LPTMR_DRV_IsRunning(const uint32_t instance)
918 {
919  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
920 
921  const LPTMR_Type* const base = g_lptmrBase[instance];
922 
923  bool runningState = LPTMR_HAL_GetEnable(base);
924 
925  return runningState;
926 }
927 
928 
929 /*FUNCTION**********************************************************************
930  *
931  * Function Name : LPTMR_DRV_SetInterrupt
932  * Description : Enable/disable the LPTMR interrupt.
933  *
934  * Implements : LPTMR_DRV_SetInterrupt_Activity
935  *END**************************************************************************/
936 void LPTMR_DRV_SetInterrupt(const uint32_t instance,
937  const bool enableInterrupt)
938 {
939  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
940 
941  LPTMR_Type* const base = g_lptmrBase[instance];
942 
943  /* The interrupt enable flag can only be changed, if the LPTMR instance is disabled. */
944  DEV_ASSERT(LPTMR_HAL_GetEnable(base) == false);
945 
946  LPTMR_HAL_SetInterrupt(base, enableInterrupt);
947 }
948 
949 
950 /*FUNCTION**********************************************************************
951  *
952  * Function Name : LPTMR_DRV_GetCounterValueTicks
953  * Description : Get the current Counter Value in timer ticks representation.
954  * Return:
955  * - the counter value.
956  *
957  * Implements : LPTMR_DRV_GetCounterValueByCount_Activity
958  *END**************************************************************************/
959 uint16_t LPTMR_DRV_GetCounterValueByCount(const uint32_t instance)
960 {
961  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
962 
963  LPTMR_Type* const base = g_lptmrBase[instance];
964 
965  uint16_t counterVal = LPTMR_HAL_GetCounterValue(base);
966 
967  return counterVal;
968 }
969 
970 
971 /*FUNCTION**********************************************************************
972  *
973  * Function Name : LPTMR_DRV_StartCounter
974  * Description : Enable (start) the counter.
975  *
976  * Implements : LPTMR_DRV_StartCounter_Activity
977  *END**************************************************************************/
978 void LPTMR_DRV_StartCounter(const uint32_t instance)
979 {
980  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
981 
982  LPTMR_Type* const base = g_lptmrBase[instance];
983 
984  /* Check if a valid clock is selected for the timer/glitch filter */
985 #if (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT))
986  bool bypass = LPTMR_HAL_GetBypass(base);
987  lptmr_workmode_t workMode = LPTMR_HAL_GetWorkMode(base);
988  (void) bypass;
989  (void) workMode;
990 #endif /* (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT)) */
991  DEV_ASSERT((lptmr_GetClkFreq(LPTMR_HAL_GetClockSelect(base), instance) != 0u) || \
992  (bypass && (workMode == LPTMR_WORKMODE_PULSECOUNTER)));
993 
994  LPTMR_HAL_Enable(base);
995 }
996 
997 
998 /*FUNCTION**********************************************************************
999  *
1000  * Function Name : LPTMR_DRV_StopCounter
1001  * Description : Disable (stop) the counter.
1002  *
1003  * Implements : LPTMR_DRV_StopCounter_Activity
1004  *END**************************************************************************/
1005 void LPTMR_DRV_StopCounter(const uint32_t instance)
1006 {
1007  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
1008 
1009  LPTMR_Type* const base = g_lptmrBase[instance];
1010 
1011  LPTMR_HAL_Disable(base);
1012 }
1013 
1014 
1015 /*FUNCTION**********************************************************************
1016  *
1017  * Function Name : LPTMR_DRV_SetPinConfiguration
1018  * Description : Set the Input Pin configuration for Pulse Counter mode.
1019  *
1020  * Implements : LPTMR_DRV_SetPinConfiguration_Activity
1021  *END**************************************************************************/
1022 void LPTMR_DRV_SetPinConfiguration(const uint32_t instance,
1023  const lptmr_pinselect_t pinSelect,
1024  const lptmr_pinpolarity_t pinPolarity)
1025 {
1026  DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
1027 
1028  LPTMR_Type* const base = g_lptmrBase[instance];
1029 
1030  LPTMR_HAL_SetPinSelect(base, pinSelect);
1031  LPTMR_HAL_SetPinPolarity(base, pinPolarity);
1032 }
1033 
1034 /*******************************************************************************
1035  * EOF
1036  ******************************************************************************/
void LPTMR_DRV_InitConfigStruct(lptmr_config_t *const config)
Initialize a configuration structure with default values.
lptmr_workmode_t workMode
Definition: lptmr_driver.h:62
void LPTMR_DRV_Init(const uint32_t instance, const lptmr_config_t *const config, const bool startCounter)
Initialize a LPTMR instance with values from an input configuration structure.
void LPTMR_HAL_Init(LPTMR_Type *const base)
Initialize the LPTMR instance to reset values.
Definition: lptmr_hal.c:43
bool bypassPrescaler
Definition: lptmr_driver.h:66
lptmr_pinselect_t
Pulse Counter Input selection Implements : lptmr_pinselect_t_Class.
Definition: lptmr_hal.h:53
void LPTMR_DRV_SetInterrupt(const uint32_t instance, const bool enableInterrupt)
Enable/disable the LPTMR interrupt.
lptmr_pinpolarity_t pinPolarity
Definition: lptmr_driver.h:71
static void LPTMR_HAL_SetPinSelect(LPTMR_Type *const base, const lptmr_pinselect_t pinsel)
Configure the Pin selection for Pulse Counter Mode.
Definition: lptmr_hal.h:322
void LPTMR_DRV_StopCounter(const uint32_t instance)
Disable the LPTMR / Stop the counter.
#define LPTMR_MAX_CMR_NTICKS
Definition: lptmr_driver.c:59
lptmr_clocksource_t clockSelect
Definition: lptmr_driver.h:64
Defines the configuration structure for LPTMR.
Definition: lptmr_driver.h:56
void LPTMR_DRV_ClearCompareFlag(const uint32_t instance)
Clear the Compare Flag of a LPTMR instance.
lptmr_prescaler_t prescaler
Definition: lptmr_driver.h:65
static lptmr_pinselect_t LPTMR_HAL_GetPinSelect(const LPTMR_Type *const base)
Get the Pin select for Counter Mode.
Definition: lptmr_hal.h:297
bool LPTMR_DRV_IsRunning(const uint32_t instance)
Get the run state of a LPTMR instance.
static lptmr_prescaler_t LPTMR_HAL_GetPrescaler(const LPTMR_Type *const base)
Get Prescaler/Glitch Filter divider value.
Definition: lptmr_hal.h:578
#define LPTMR_CMR_COMPARE_MASK
Definition: S32K144.h:6634
lptmr_counter_units_t counterUnits
Definition: lptmr_driver.h:68
static bool LPTMR_HAL_GetEnable(const LPTMR_Type *const base)
Get the Enable state.
Definition: lptmr_hal.h:497
static lptmr_pinpolarity_t LPTMR_HAL_GetPinPolarity(const LPTMR_Type *const base)
Get Pin Polarity for Pulse Counter Mode.
Definition: lptmr_hal.h:348
void LPTMR_DRV_GetCompareValueByUs(const uint32_t instance, uint32_t *const compareValueUs)
Get the compare value in microseconds, of a LPTMR instance.
lptmr_counter_units_t
Defines the LPTMR counter units available for configuring or reading the timer compare value...
Definition: lptmr_driver.h:44
lptmr_pinselect_t pinSelect
Definition: lptmr_driver.h:70
lptmr_clocksource_t
Clock Source selection Implements : lptmr_clocksource_t_Class.
Definition: lptmr_hal.h:101
#define LPTMR_INSTANCE_COUNT
Definition: S32K144.h:6559
static void LPTMR_HAL_SetBypass(LPTMR_Type *const base, const bool enable)
Configure the Prescaler/Glitch Filter Bypass enable state.
Definition: lptmr_hal.h:663
#define DEV_ASSERT(x)
Definition: devassert.h:78
uint32_t compareValue
Definition: lptmr_driver.h:67
void LPTMR_DRV_GetCompareValueByCount(const uint32_t instance, uint16_t *const compareValueByCount)
Get the compare value in counter tick units, of a LPTMR instance.
static void LPTMR_HAL_SetPinPolarity(LPTMR_Type *const base, const lptmr_pinpolarity_t pol)
Configure Pin Polarity for Pulse Counter Mode.
Definition: lptmr_hal.h:372
static void LPTMR_HAL_ClearCompareFlag(LPTMR_Type *const base)
Clear the Compare Flag.
Definition: lptmr_hal.h:219
lptmr_pinpolarity_t
Pulse Counter input polarity Implements : lptmr_pinpolarity_t_Class.
Definition: lptmr_hal.h:63
static bool LPTMR_HAL_GetDmaRequest(const LPTMR_Type *const base)
Get the DMA Request Enable Flag.
Definition: lptmr_hal.h:146
status_t CLOCK_SYS_GetFreq(clock_names_t clockName, uint32_t *frequency)
Gets the clock frequency for a specific clock name.
void LPTMR_DRV_Deinit(const uint32_t instance)
De-initialize a LPTMR instance.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
Definition: status.h:31
static void LPTMR_HAL_SetWorkMode(LPTMR_Type *const base, const lptmr_workmode_t mode)
Configure the Work Mode.
Definition: lptmr_hal.h:472
static void LPTMR_HAL_SetDmaRequest(LPTMR_Type *const base, bool enable)
Configure the DMA Request Enable Flag state.
Definition: lptmr_hal.h:173
static uint16_t LPTMR_HAL_GetCounterValue(LPTMR_Type *const base)
Get the current Counter Value.
Definition: lptmr_hal.h:779
uint16_t LPTMR_DRV_GetCounterValueByCount(const uint32_t instance)
Get the current counter value in counter tick units.
void LPTMR_DRV_StartCounter(const uint32_t instance)
Enable the LPTMR / Start the counter.
clock_names_t
Clock names.
static void LPTMR_HAL_Disable(LPTMR_Type *const base)
Disable the LPTMR.
Definition: lptmr_hal.h:539
static void LPTMR_HAL_Enable(LPTMR_Type *const base)
Enable the LPTMR.
Definition: lptmr_hal.h:518
void LPTMR_DRV_SetConfig(const uint32_t instance, const lptmr_config_t *const config)
Configure a LPTMR instance.
lptmr_workmode_t
Work Mode Implements : lptmr_workmode_t_Class.
Definition: lptmr_hal.h:71
void LPTMR_DRV_GetConfig(const uint32_t instance, lptmr_config_t *const config)
Get the current configuration of a LPTMR instance.
#define SCG
Definition: S32K144.h:10398
#define LPTMR_MAX_PRESCALER
Definition: lptmr_driver.c:60
static void LPTMR_HAL_SetCompareValue(LPTMR_Type *const base, const uint16_t compval)
Configure the Compare Value.
Definition: lptmr_hal.h:757
uint32_t SCG_HAL_GetSircAsyncFreq(const SCG_Type *base, scg_async_clock_type_t type)
Get SCG asynchronous clock frequency from SIRC.
static void LPTMR_HAL_SetFreeRunning(LPTMR_Type *const base, const bool enable)
Configure the Free Running state.
Definition: lptmr_hal.h:422
static bool LPTMR_HAL_GetBypass(const LPTMR_Type *const base)
Get the Prescaler/Glitch Filter Bypass enable state.
Definition: lptmr_hal.h:639
static void LPTMR_HAL_SetClockSelect(LPTMR_Type *const base, const lptmr_clocksource_t clocksel)
Configure the LPTMR input Clock selection.
Definition: lptmr_hal.h:713
static bool LPTMR_HAL_GetCompareFlag(const LPTMR_Type *const base)
Get the Compare Flag state.
Definition: lptmr_hal.h:199
static lptmr_clocksource_t LPTMR_HAL_GetClockSelect(const LPTMR_Type *const base)
Get the LPTMR input Clock selection.
Definition: lptmr_hal.h:688
static void LPTMR_HAL_SetPrescaler(LPTMR_Type *const base, const lptmr_prescaler_t presc)
Configure the Prescaler/Glitch Filter divider value.
Definition: lptmr_hal.h:615
#define LPTMR_BASE_PTRS
Definition: S32K144.h:6570
lptmr_prescaler_t
Prescaler Selection Implements : lptmr_prescaler_t_Class.
Definition: lptmr_hal.h:79
bool interruptEnable
Definition: lptmr_driver.h:60
void LPTMR_DRV_SetPinConfiguration(const uint32_t instance, const lptmr_pinselect_t pinSelect, const lptmr_pinpolarity_t pinPolarity)
Set the Input Pin configuration for Pulse Counter mode.
static bool LPTMR_HAL_GetFreeRunning(const LPTMR_Type *const base)
Get the Free Running state.
Definition: lptmr_hal.h:398
static void LPTMR_HAL_SetInterrupt(LPTMR_Type *const base, bool enable)
Configure the Interrupt Enable state.
Definition: lptmr_hal.h:270
status_t LPTMR_DRV_SetCompareValueByCount(const uint32_t instance, const uint16_t compareValueByCount)
Set the compare value in counter tick units, for a LPTMR instance.
status_t LPTMR_DRV_SetCompareValueByUs(const uint32_t instance, const uint32_t compareValueUs)
Set the compare value for Timer Mode in microseconds, for a LPTMR instance.
static uint16_t LPTMR_HAL_GetCompareValue(const LPTMR_Type *const base)
Get the Compare Value.
Definition: lptmr_hal.h:735
bool LPTMR_DRV_GetCompareFlag(const uint32_t instance)
Get the current state of the Compare Flag of a LPTMR instance.
static lptmr_workmode_t LPTMR_HAL_GetWorkMode(const LPTMR_Type *const base)
Get current Work Mode.
Definition: lptmr_hal.h:448
static bool LPTMR_HAL_GetInterruptEnable(const LPTMR_Type *const base)
Get the Interrupt Enable state.
Definition: lptmr_hal.h:246