efm32_timer.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /***************************************************************************//**
  2. * @file
  3. * @brief Timer/counter (TIMER) peripheral API for EFM32.
  4. * @author Energy Micro AS
  5. * @version 2.0.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2010 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. ******************************************************************************/
  28. #ifndef __EFM32_TIMER_H
  29. #define __EFM32_TIMER_H
  30. #include <stdbool.h>
  31. #include "efm32.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /***************************************************************************//**
  36. * @addtogroup EFM32_Library
  37. * @{
  38. ******************************************************************************/
  39. /***************************************************************************//**
  40. * @addtogroup TIMER
  41. * @{
  42. ******************************************************************************/
  43. /*******************************************************************************
  44. ******************************** ENUMS ************************************
  45. ******************************************************************************/
  46. /** Timer compare/capture mode. */
  47. typedef enum
  48. {
  49. timerCCModeOff = _TIMER_CC_CTRL_MODE_OFF, /**< Channel turned off. */
  50. timerCCModeCapture = _TIMER_CC_CTRL_MODE_INPUTCAPTURE, /**< Input capture. */
  51. timerCCModeCompare = _TIMER_CC_CTRL_MODE_OUTPUTCOMPARE, /**< Output compare. */
  52. timerCCModePWM = _TIMER_CC_CTRL_MODE_PWM /**< Pulse-Width modulation. */
  53. } TIMER_CCMode_TypeDef;
  54. /** Clock select. */
  55. typedef enum
  56. {
  57. /** Prescaled HFPER clock. */
  58. timerClkSelHFPerClk = _TIMER_CTRL_CLKSEL_PRESCHFPERCLK,
  59. /** Prescaled HFPER clock. */
  60. timerClkSelCC1 = _TIMER_CTRL_CLKSEL_CC1,
  61. /**
  62. * Cascaded, clocked by underflow (down-counting) or overflow (up-counting)
  63. * by lower numbered timer.
  64. */
  65. timerClkSelCascade = _TIMER_CTRL_CLKSEL_TIMEROUF
  66. } TIMER_ClkSel_TypeDef;
  67. /** Input capture edge select. */
  68. typedef enum
  69. {
  70. /** Rising edges detected. */
  71. timerEdgeRising = _TIMER_CC_CTRL_ICEDGE_RISING,
  72. /** Falling edges detected. */
  73. timerEdgeFalling = _TIMER_CC_CTRL_ICEDGE_FALLING,
  74. /** Both edges detected. */
  75. timerEdgeBoth = _TIMER_CC_CTRL_ICEDGE_BOTH,
  76. /** No edge detection, leave signal as is. */
  77. timerEdgeNone = _TIMER_CC_CTRL_ICEDGE_NONE
  78. } TIMER_Edge_TypeDef;
  79. /** Input capture event control. */
  80. typedef enum
  81. {
  82. /** PRS output pulse, interrupt flag and DMA request set on every capture. */
  83. timerEventEveryEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYEDGE,
  84. /** PRS output pulse, interrupt flag and DMA request set on every second capture. */
  85. timerEventEvery2ndEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYSECONDEDGE,
  86. /**
  87. * PRS output pulse, interrupt flag and DMA request set on rising edge (if
  88. * input capture edge = BOTH).
  89. */
  90. timerEventRising = _TIMER_CC_CTRL_ICEVCTRL_RISING,
  91. /**
  92. * PRS output pulse, interrupt flag and DMA request set on falling edge (if
  93. * input capture edge = BOTH).
  94. */
  95. timerEventFalling = _TIMER_CC_CTRL_ICEVCTRL_FALLING
  96. } TIMER_Event_TypeDef;
  97. /** Input edge action. */
  98. typedef enum
  99. {
  100. /** No action taken. */
  101. timerInputActionNone = _TIMER_CTRL_FALLA_NONE,
  102. /** Start counter without reload. */
  103. timerInputActionStart = _TIMER_CTRL_FALLA_START,
  104. /** Stop counter without reload. */
  105. timerInputActionStop = _TIMER_CTRL_FALLA_STOP,
  106. /** Reload and start counter. */
  107. timerInputActionReloadStart = _TIMER_CTRL_FALLA_RELOADSTART
  108. } TIMER_InputAction_TypeDef;
  109. /** Timer mode. */
  110. typedef enum
  111. {
  112. timerModeUp = _TIMER_CTRL_MODE_UP, /**< Up-counting. */
  113. timerModeDown = _TIMER_CTRL_MODE_DOWN, /**< Down-counting. */
  114. timerModeUpDown = _TIMER_CTRL_MODE_UPDOWN, /**< Up/down-counting. */
  115. timerModeQDec = _TIMER_CTRL_MODE_QDEC /**< Quadrature decoder. */
  116. } TIMER_Mode_TypeDef;
  117. /** Compare/capture output action. */
  118. typedef enum
  119. {
  120. /** No action. */
  121. timerOutputActionNone = _TIMER_CC_CTRL_CUFOA_NONE,
  122. /** Toggle on event. */
  123. timerOutputActionToggle = _TIMER_CC_CTRL_CUFOA_TOGGLE,
  124. /** Clear on event. */
  125. timerOutputActionClear = _TIMER_CC_CTRL_CUFOA_CLEAR,
  126. /** Set on event. */
  127. timerOutputActionSet = _TIMER_CC_CTRL_CUFOA_SET
  128. } TIMER_OutputAction_TypeDef;
  129. /** Prescaler. */
  130. typedef enum
  131. {
  132. timerPrescale1 = _TIMER_CTRL_PRESC_DIV1, /**< Divide by 1. */
  133. timerPrescale2 = _TIMER_CTRL_PRESC_DIV2, /**< Divide by 2. */
  134. timerPrescale4 = _TIMER_CTRL_PRESC_DIV4, /**< Divide by 4. */
  135. timerPrescale8 = _TIMER_CTRL_PRESC_DIV8, /**< Divide by 8. */
  136. timerPrescale16 = _TIMER_CTRL_PRESC_DIV16, /**< Divide by 16. */
  137. timerPrescale32 = _TIMER_CTRL_PRESC_DIV32, /**< Divide by 32. */
  138. timerPrescale64 = _TIMER_CTRL_PRESC_DIV64, /**< Divide by 64. */
  139. timerPrescale128 = _TIMER_CTRL_PRESC_DIV128, /**< Divide by 128. */
  140. timerPrescale256 = _TIMER_CTRL_PRESC_DIV256, /**< Divide by 256. */
  141. timerPrescale512 = _TIMER_CTRL_PRESC_DIV512, /**< Divide by 512. */
  142. timerPrescale1024 = _TIMER_CTRL_PRESC_DIV1024 /**< Divide by 1024. */
  143. } TIMER_Prescale_TypeDef;
  144. /** Peripheral Reflex System signal. */
  145. typedef enum
  146. {
  147. timerPRSSELCh0 = _ADC_SINGLECTRL_PRSSEL_PRSCH0, /**< PRS channel 0. */
  148. timerPRSSELCh1 = _ADC_SINGLECTRL_PRSSEL_PRSCH1, /**< PRS channel 1. */
  149. timerPRSSELCh2 = _ADC_SINGLECTRL_PRSSEL_PRSCH2, /**< PRS channel 2. */
  150. timerPRSSELCh3 = _ADC_SINGLECTRL_PRSSEL_PRSCH3, /**< PRS channel 3. */
  151. timerPRSSELCh4 = _ADC_SINGLECTRL_PRSSEL_PRSCH4, /**< PRS channel 4. */
  152. timerPRSSELCh5 = _ADC_SINGLECTRL_PRSSEL_PRSCH5, /**< PRS channel 5. */
  153. timerPRSSELCh6 = _ADC_SINGLECTRL_PRSSEL_PRSCH6, /**< PRS channel 6. */
  154. timerPRSSELCh7 = _ADC_SINGLECTRL_PRSSEL_PRSCH7 /**< PRS channel 7. */
  155. } TIMER_PRSSEL_TypeDef;
  156. /*******************************************************************************
  157. ******************************* STRUCTS ***********************************
  158. ******************************************************************************/
  159. /** TIMER initialization structure. */
  160. typedef struct
  161. {
  162. /** Start counting when init completed. */
  163. bool enable;
  164. /** Counter shall keep running during debug halt. */
  165. bool debugRun;
  166. /** Prescaling factor, if HFPER clock used. */
  167. TIMER_Prescale_TypeDef prescale;
  168. /** Clock selection. */
  169. TIMER_ClkSel_TypeDef clkSel;
  170. #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_TINY_FAMILY)
  171. /** 2x Count mode, counter increments/decrements by 2, meant for PWN mode. */
  172. bool count2x;
  173. /** ATI (Always Track Inputs) makes CCPOL always track
  174. * the polarity of the inputs. */
  175. bool ati;
  176. #endif
  177. /** Action on falling input edge. */
  178. TIMER_InputAction_TypeDef fallAction;
  179. /** Action on rising input edge. */
  180. TIMER_InputAction_TypeDef riseAction;
  181. /** Counting mode. */
  182. TIMER_Mode_TypeDef mode;
  183. /** DMA request clear on active. */
  184. bool dmaClrAct;
  185. /** Select X2 or X4 quadrature decode mode (if used). */
  186. bool quadModeX4;
  187. /** Determines if only counting up or down once. */
  188. bool oneShot;
  189. /** Timer start/stop/reload by other timers. */
  190. bool sync;
  191. } TIMER_Init_TypeDef;
  192. /** Default config for TIMER init structure. */
  193. #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_TINY_FAMILY)
  194. #define TIMER_INIT_DEFAULT \
  195. { true, /* Enable timer when init complete. */ \
  196. false, /* Stop counter during debug halt. */ \
  197. timerPrescale1, /* No prescaling. */ \
  198. timerClkSelHFPerClk, /* Select HFPER clock. */ \
  199. false, /* Not 2x count mode. */ \
  200. false, /* No ATI. */ \
  201. timerInputActionNone, /* No action on falling input edge. */ \
  202. timerInputActionNone, /* No action on rising input edge. */ \
  203. timerModeUp, /* Up-counting. */ \
  204. false, /* Do not clear DMA requests when DMA channel is active. */ \
  205. false, /* Select X2 quadrature decode mode (if used). */ \
  206. false, /* Disable one shot. */ \
  207. false /* Not started/stopped/reloaded by other timers. */ \
  208. }
  209. #else
  210. #define TIMER_INIT_DEFAULT \
  211. { true, /* Enable timer when init complete. */ \
  212. false, /* Stop counter during debug halt. */ \
  213. timerPrescale1, /* No prescaling. */ \
  214. timerClkSelHFPerClk, /* Select HFPER clock. */ \
  215. timerInputActionNone, /* No action on falling input edge. */ \
  216. timerInputActionNone, /* No action on rising input edge. */ \
  217. timerModeUp, /* Up-counting. */ \
  218. false, /* Do not clear DMA requests when DMA channel is active. */ \
  219. false, /* Select X2 quadrature decode mode (if used). */ \
  220. false, /* Disable one shot. */ \
  221. false /* Not started/stopped/reloaded by other timers. */ \
  222. }
  223. #endif
  224. /** TIMER compare/capture initialization structure. */
  225. typedef struct
  226. {
  227. /** Input capture event control. */
  228. TIMER_Event_TypeDef eventCtrl;
  229. /** Input capture edge select. */
  230. TIMER_Edge_TypeDef edge;
  231. /**
  232. * Peripheral reflex system trigger selection. Only applicable if @p prsInput
  233. * is enabled.
  234. */
  235. TIMER_PRSSEL_TypeDef prsSel;
  236. /** Counter underflow output action. */
  237. TIMER_OutputAction_TypeDef cufoa;
  238. /** Counter overflow output action. */
  239. TIMER_OutputAction_TypeDef cofoa;
  240. /** Counter match output action. */
  241. TIMER_OutputAction_TypeDef cmoa;
  242. /** Compare/capture channel mode. */
  243. TIMER_CCMode_TypeDef mode;
  244. /** Enable digital filter. */
  245. bool filter;
  246. /** Select TIMERnCCx (false) or PRS input (true). */
  247. bool prsInput;
  248. /**
  249. * Compare output initial state. Only used in Output Compare and PWM mode.
  250. * When true, the compare/PWM output is set high when the counter is
  251. * disabled. When counting resumes, this value will represent the initial
  252. * value for the compare/PWM output. If the bit is cleared, the output
  253. * will be cleared when the counter is disabled.
  254. */
  255. bool coist;
  256. /** Invert output from compare/capture channel. */
  257. bool outInvert;
  258. } TIMER_InitCC_TypeDef;
  259. /** Default config for TIMER compare/capture init structure. */
  260. #define TIMER_INITCC_DEFAULT \
  261. { timerEventEveryEdge, /* Event on every capture. */ \
  262. timerEdgeRising, /* Input capture edge on rising edge. */ \
  263. timerPRSSELCh0, /* Not used by default, select PRS channel 0. */ \
  264. timerOutputActionNone, /* No action on underflow. */ \
  265. timerOutputActionNone, /* No action on overflow. */ \
  266. timerOutputActionNone, /* No action on match. */ \
  267. timerCCModeOff, /* Disable compare/capture channel. */ \
  268. false, /* Disable filter. */ \
  269. false, /* Select TIMERnCCx input. */ \
  270. false, /* Clear output when countre disabled. */ \
  271. false /* Do not invert output. */ \
  272. }
  273. /*******************************************************************************
  274. ***************************** PROTOTYPES **********************************
  275. ******************************************************************************/
  276. /***************************************************************************//**
  277. * @brief
  278. * Get capture value for compare/capture channel when operating in capture
  279. * mode.
  280. *
  281. * @param[in] timer
  282. * Pointer to TIMER peripheral register block.
  283. *
  284. * @param[in] ch
  285. * Compare/capture channel to access.
  286. *
  287. * @return
  288. * Current capture value.
  289. ******************************************************************************/
  290. static __INLINE uint32_t TIMER_CaptureGet(TIMER_TypeDef *timer, unsigned int ch)
  291. {
  292. return(timer->CC[ch].CCV);
  293. }
  294. /***************************************************************************//**
  295. * @brief
  296. * Set compare value buffer for compare/capture channel when operating in
  297. * compare or PWM mode.
  298. *
  299. * @details
  300. * The compare value buffer holds the value which will be written to
  301. * TIMERn_CCx_CCV on an update event if the buffer has been updated since
  302. * the last event.
  303. *
  304. * @param[in] timer
  305. * Pointer to TIMER peripheral register block.
  306. *
  307. * @param[in] ch
  308. * Compare/capture channel to access.
  309. *
  310. * @param[in] val
  311. * Value to set in compare value buffer register.
  312. ******************************************************************************/
  313. static __INLINE void TIMER_CompareBufSet(TIMER_TypeDef *timer,
  314. unsigned int ch,
  315. uint32_t val)
  316. {
  317. timer->CC[ch].CCVB = val;
  318. }
  319. /***************************************************************************//**
  320. * @brief
  321. * Set compare value for compare/capture channel when operating in compare
  322. * or PWM mode.
  323. *
  324. * @param[in] timer
  325. * Pointer to TIMER peripheral register block.
  326. *
  327. * @param[in] ch
  328. * Compare/capture channel to access.
  329. *
  330. * @param[in] val
  331. * Value to set in compare value register.
  332. ******************************************************************************/
  333. static __INLINE void TIMER_CompareSet(TIMER_TypeDef *timer,
  334. unsigned int ch,
  335. uint32_t val)
  336. {
  337. timer->CC[ch].CCV = val;
  338. }
  339. /***************************************************************************//**
  340. * @brief
  341. * Get TIMER counter value.
  342. *
  343. * @param[in] timer
  344. * Pointer to TIMER peripheral register block.
  345. *
  346. * @return
  347. * Current TIMER counter value.
  348. ******************************************************************************/
  349. static __INLINE uint32_t TIMER_CounterGet(TIMER_TypeDef *timer)
  350. {
  351. return(timer->CNT);
  352. }
  353. /***************************************************************************//**
  354. * @brief
  355. * Set TIMER counter value.
  356. *
  357. * @param[in] timer
  358. * Pointer to TIMER peripheral register block.
  359. *
  360. * @param[in] val
  361. * Value to set counter to.
  362. ******************************************************************************/
  363. static __INLINE void TIMER_CounterSet(TIMER_TypeDef *timer, uint32_t val)
  364. {
  365. timer->CNT = val;
  366. }
  367. void TIMER_Enable(TIMER_TypeDef *rtc, bool enable);
  368. void TIMER_Init(TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init);
  369. void TIMER_InitCC(TIMER_TypeDef *timer,
  370. unsigned int ch,
  371. const TIMER_InitCC_TypeDef *init);
  372. /***************************************************************************//**
  373. * @brief
  374. * Clear one or more pending TIMER interrupts.
  375. *
  376. * @param[in] timer
  377. * Pointer to TIMER peripheral register block.
  378. *
  379. * @param[in] flags
  380. * Pending TIMER interrupt source(s) to clear. Use one or more valid
  381. * interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
  382. ******************************************************************************/
  383. static __INLINE void TIMER_IntClear(TIMER_TypeDef *timer, uint32_t flags)
  384. {
  385. timer->IFC = flags;
  386. }
  387. /***************************************************************************//**
  388. * @brief
  389. * Disable one or more TIMER interrupts.
  390. *
  391. * @param[in] timer
  392. * Pointer to TIMER peripheral register block.
  393. *
  394. * @param[in] flags
  395. * TIMER interrupt source(s) to disable. Use one or more valid
  396. * interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
  397. ******************************************************************************/
  398. static __INLINE void TIMER_IntDisable(TIMER_TypeDef *timer, uint32_t flags)
  399. {
  400. timer->IEN &= ~(flags);
  401. }
  402. /***************************************************************************//**
  403. * @brief
  404. * Enable one or more TIMER interrupts.
  405. *
  406. * @note
  407. * Depending on the use, a pending interrupt may already be set prior to
  408. * enabling the interrupt. Consider using TIMER_IntClear() prior to enabling
  409. * if such a pending interrupt should be ignored.
  410. *
  411. * @param[in] timer
  412. * Pointer to TIMER peripheral register block.
  413. *
  414. * @param[in] flags
  415. * TIMER interrupt source(s) to enable. Use one or more valid
  416. * interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
  417. ******************************************************************************/
  418. static __INLINE void TIMER_IntEnable(TIMER_TypeDef *timer, uint32_t flags)
  419. {
  420. timer->IEN |= flags;
  421. }
  422. /***************************************************************************//**
  423. * @brief
  424. * Get pending TIMER interrupt flags.
  425. *
  426. * @note
  427. * The event bits are not cleared by the use of this function.
  428. *
  429. * @param[in] timer
  430. * Pointer to TIMER peripheral register block.
  431. *
  432. * @return
  433. * TIMER interrupt source(s) pending. Returns one or more valid
  434. * interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
  435. ******************************************************************************/
  436. static __INLINE uint32_t TIMER_IntGet(TIMER_TypeDef *timer)
  437. {
  438. return(timer->IF);
  439. }
  440. /***************************************************************************//**
  441. * @brief
  442. * Get enabled and pending TIMER interrupt flags.
  443. * Useful for handling more interrupt sources in the same interrupt handler.
  444. *
  445. * @param[in] timer
  446. * Pointer to TIMER peripheral register block.
  447. *
  448. * @note
  449. * Interrupt flags are not cleared by the use of this function.
  450. *
  451. * @return
  452. * Pending and enabled TIMER interrupt sources.
  453. * The return value is the bitwise AND combination of
  454. * - the OR combination of enabled interrupt sources in TIMERx_IEN_nnn
  455. * register (TIMERx_IEN_nnn) and
  456. * - the OR combination of valid interrupt flags of the TIMER module
  457. * (TIMERx_IF_nnn).
  458. ******************************************************************************/
  459. static __INLINE uint32_t TIMER_IntGetEnabled(TIMER_TypeDef *timer)
  460. {
  461. uint32_t tmp;
  462. /* Store TIMER->IEN in temporary variable in order to define explicit order
  463. * of volatile accesses. */
  464. tmp = timer->IEN;
  465. /* Bitwise AND of pending and enabled interrupts */
  466. return timer->IF & tmp;
  467. }
  468. /***************************************************************************//**
  469. * @brief
  470. * Set one or more pending TIMER interrupts from SW.
  471. *
  472. * @param[in] timer
  473. * Pointer to TIMER peripheral register block.
  474. *
  475. * @param[in] flags
  476. * TIMER interrupt source(s) to set to pending. Use one or more valid
  477. * interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
  478. ******************************************************************************/
  479. static __INLINE void TIMER_IntSet(TIMER_TypeDef *timer, uint32_t flags)
  480. {
  481. timer->IFS = flags;
  482. }
  483. #ifdef TIMER_DTLOCK_LOCKKEY_LOCK
  484. void TIMER_Lock(TIMER_TypeDef *timer);
  485. #endif
  486. void TIMER_Reset(TIMER_TypeDef *timer);
  487. /***************************************************************************//**
  488. * @brief
  489. * Set top value buffer for timer.
  490. *
  491. * @details
  492. * When the top value buffer register is updated, the value is loaded into
  493. * the top value register at the next wrap around. This feature is useful
  494. * in order to update the top value safely when the timer is running.
  495. *
  496. * @param[in] timer
  497. * Pointer to TIMER peripheral register block.
  498. *
  499. * @param[in] val
  500. * Value to set in top value buffer register.
  501. ******************************************************************************/
  502. static __INLINE void TIMER_TopBufSet(TIMER_TypeDef *timer, uint32_t val)
  503. {
  504. timer->TOPB = val;
  505. }
  506. /***************************************************************************//**
  507. * @brief
  508. * Get top value setting for timer.
  509. *
  510. * @param[in] timer
  511. * Pointer to TIMER peripheral register block.
  512. *
  513. * @return
  514. * Current top value.
  515. ******************************************************************************/
  516. static __INLINE uint32_t TIMER_TopGet(TIMER_TypeDef *timer)
  517. {
  518. return(timer->TOP);
  519. }
  520. /***************************************************************************//**
  521. * @brief
  522. * Set top value for timer.
  523. *
  524. * @param[in] timer
  525. * Pointer to TIMER peripheral register block.
  526. *
  527. * @param[in] val
  528. * Value to set in top value register.
  529. ******************************************************************************/
  530. static __INLINE void TIMER_TopSet(TIMER_TypeDef *timer, uint32_t val)
  531. {
  532. timer->TOP = val;
  533. }
  534. #ifdef TIMER_DTLOCK_LOCKKEY_UNLOCK
  535. void TIMER_Unlock(TIMER_TypeDef *timer);
  536. #endif
  537. /** @} (end addtogroup TIMER) */
  538. /** @} (end addtogroup EFM32_Library) */
  539. #ifdef __cplusplus
  540. }
  541. #endif
  542. #endif /* __EFM32_TIMER_H */