csl_tmrAux.h 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. /**
  2. * @file csl_tmrAux.h
  3. *
  4. * @brief
  5. * This is the TIMER Auxilary Header File which exposes the various
  6. * CSL Functional Layer API's to configure the TIMER Module.
  7. *
  8. * \par
  9. * ============================================================================
  10. * @n (C) Copyright 2002-2011, Texas Instruments, Inc.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * Neither the name of Texas Instruments Incorporated nor the names of
  25. * its contributors may be used to endorse or promote products derived
  26. * from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. */
  41. #ifndef CSL_TMRAUX_H
  42. #define CSL_TMRAUX_H
  43. #include <ti/csl/csl_tmr.h>
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /** @addtogroup CSL_TIMER_FUNCTION
  48. @{ */
  49. /** ============================================================================
  50. * @n@b CSL_tmrGetTimHiCount
  51. *
  52. * @b Description
  53. * @n This function gets the value of the CNTHI counter
  54. *
  55. * @b Arguments
  56. * @verbatim
  57. hTmr Pointer to the object that holds reference to the
  58. instance of TIMER requested after the call
  59. countHi Output parameter to get the CNTHI value
  60. @endverbatim
  61. *
  62. * <b> Return Value </b>
  63. * @n The argument countHi is populated with the contents of the CNTHI register
  64. *
  65. * <b> Pre Condition </b>
  66. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  67. *
  68. * <b> Post Condition </b>
  69. * @n None
  70. *
  71. * @b Reads
  72. * @n TMR_CNTHI_CNT
  73. *
  74. * @b Example
  75. * @verbatim
  76. CSL_TmrHandle hTmr;
  77. Unit32* countHi;
  78. ...
  79. CSL_tmrGetTimHiCount(hTmr, &countHi);
  80. ...
  81. @endverbatim
  82. * ============================================================================
  83. */
  84. /* for misra warnings*/
  85. static inline void CSL_tmrGetTimHiCount (CSL_TmrHandle hTmr,Uint32 *countHi);
  86. static inline void CSL_tmrGetTimHiCount (CSL_TmrHandle hTmr,Uint32 *countHi)
  87. {
  88. *countHi = CSL_FEXT (hTmr->regs->CNTHI, TMR_CNTHI_CNT);
  89. }
  90. /** ===========================================================================
  91. * @n@b CSL_tmrGetTimLoCount
  92. *
  93. * @b Description
  94. * @n This function gets the value of the CNTLO counter
  95. *
  96. * @b Arguments
  97. * @verbatim
  98. hTmr Pointer to the object that holds reference to the
  99. instance of TIMER requested after the call
  100. countLo Output parameter to get the CNTLO value
  101. @endverbatim
  102. *
  103. * <b> Return Value </b>
  104. * None
  105. *
  106. * <b> Pre Condition </b>
  107. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  108. *
  109. * <b> Post Condition </b>
  110. * @n The argument countLo is populated with the contents of the CNTLO register
  111. *
  112. * @b Reads
  113. * @n TMR_CNTLO_CNT
  114. *
  115. * @b Example
  116. * @verbatim
  117. CSL_TmrHandle hTmr;
  118. Unit32 *countLo;
  119. ...
  120. CSL_tmrGetTimLoCount(hTmr, &countLo);
  121. ...
  122. @endverbatim
  123. * ============================================================================
  124. */
  125. /* for misra warnings*/
  126. static inline void CSL_tmrGetTimLoCount (CSL_TmrHandle hTmr,Uint32* countLo);
  127. static inline void CSL_tmrGetTimLoCount (CSL_TmrHandle hTmr,Uint32* countLo)
  128. {
  129. *countLo = CSL_FEXT (hTmr->regs->CNTLO, TMR_CNTLO_CNT);
  130. }
  131. /** ===========================================================================
  132. * @n@b CSL_tmrGetTstatLoStatus
  133. *
  134. * @b Description
  135. * @n This function gets the status of the TINTLO
  136. *
  137. * @b Arguments
  138. * @verbatim
  139. hTmr Pointer to the object that holds reference to the
  140. instance of TIMER requested after the call
  141. @endverbatim
  142. *
  143. * <b> Return Value </b>
  144. * @n CSL_TmrTstatLo - TINTLO status value
  145. * @li CSL_TMR_TSTAT_LO_LOW - Data low
  146. * @li CSL_TMR_TSTAT_LO_HIGH - Data High
  147. *
  148. * <b> Pre Condition </b>
  149. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  150. *
  151. * <b> Post Condition </b>
  152. * @n None
  153. *
  154. * @b Reads
  155. * @n TMR_TCR_TSTAT_LO
  156. *
  157. * @b Example
  158. * @verbatim
  159. CSL_TmrHandle hTmr;
  160. CSL_TmrTstatLo statusLo;
  161. ...
  162. statusLo = CSL_tmrGetTstatLoStatus(hTmr);
  163. ...
  164. @endverbatim
  165. * ===========================================================================
  166. */
  167. /* for misra warnings*/
  168. static inline CSL_TmrTstat CSL_tmrGetTstatLoStatus (CSL_TmrHandle hTmr);
  169. static inline CSL_TmrTstat CSL_tmrGetTstatLoStatus (CSL_TmrHandle hTmr)
  170. {
  171. return (CSL_TmrTstat)CSL_FEXT(hTmr->regs->TCR, TMR_TCR_TSTAT_LO);
  172. }
  173. /** ===========================================================================
  174. * @n@b CSL_tmrGetTstatHiStatus
  175. *
  176. * @b Description
  177. * @n This function gets the status of the TINTHI
  178. *
  179. * @b Arguments
  180. * @verbatim
  181. hTmr Pointer to the object that holds reference to the
  182. instance of TIMER requested after the call
  183. @endverbatim
  184. *
  185. * <b> Return Value </b>
  186. * @n CSL_TmrTstatHi - TINTHI status value
  187. * @li CSL_TMR_TSTATHI_LOW - Data low
  188. * @li CSL_TMR_TSTATHI_HIGH - Data High
  189. *
  190. * <b> Pre Condition </b>
  191. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  192. *
  193. * <b> Post Condition </b>
  194. * @n None
  195. *
  196. * @b Reads
  197. * @n TMR_TCR_TSTAT_HI
  198. *
  199. * @b Example
  200. * @verbatim
  201. CSL_TmrHandle hTmr;
  202. CSL_TmrTstatHi statusHi;
  203. ...
  204. statusHi = CSL_tmrGetTstatHiStatus(hTmr);
  205. ...
  206. @endverbatim
  207. * ============================================================================
  208. */
  209. /* for misra warnings*/
  210. static inline CSL_TmrTstat CSL_tmrGetTstatHiStatus (CSL_TmrHandle hTmr);
  211. static inline CSL_TmrTstat CSL_tmrGetTstatHiStatus (CSL_TmrHandle hTmr)
  212. {
  213. return (CSL_TmrTstat)CSL_FEXT(hTmr->regs->TCR, TMR_TCR_TSTAT_HI);
  214. }
  215. /** ===========================================================================
  216. * @n@b CSL_tmrGetWdflagStatus
  217. *
  218. * @b Description
  219. * @n This function gets the status of the WDFLAG
  220. *
  221. * @b Arguments
  222. * @verbatim
  223. hTmr Pointer to the object that holds reference to the
  224. instance of TIMER requested after the call
  225. @endverbatim
  226. *
  227. * <b> Return Value </b>
  228. * @n CSL_TmrFlagBitStatus - WDFLAG status value
  229. * @li CSL_TMR_WDFLAG_NOTIMEOUT - no watchdog timeout occurred
  230. * @li CSL_TMR_WDFLAG_TIMEOUT - watchdog timeout occurred
  231. *
  232. * <b> Pre Condition </b>
  233. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called and the
  234. * Timer should be set in WATCHDOG mode
  235. *
  236. * <b> Post Condition </b>
  237. * @n None
  238. *
  239. * @b Reads
  240. * @n TMR_WDTCR_WDFLAG
  241. *
  242. * @b Example
  243. * @verbatim
  244. CSL_TmrHandle hTmr;
  245. CSL_TmrWdflagBitStatus status;
  246. ...
  247. status = CSL_tmrGetWdflagStatus(hTmr);
  248. ...
  249. @endverbatim
  250. * ===========================================================================
  251. */
  252. /* for misra warnings*/
  253. static inline CSL_TmrWdflagBitStatus CSL_tmrGetWdflagStatus (CSL_TmrHandle hTmr);
  254. static inline CSL_TmrWdflagBitStatus CSL_tmrGetWdflagStatus (CSL_TmrHandle hTmr)
  255. {
  256. return (CSL_TmrWdflagBitStatus)CSL_FEXT(hTmr->regs->WDTCR, TMR_WDTCR_WDFLAG);
  257. }
  258. /** ============================================================================
  259. * @n@b CSL_TmrLoadPrdLo
  260. *
  261. * @b Description
  262. * Loads the General purpose timer LOW period register.
  263. *
  264. * @b Arguments
  265. * @verbatim
  266. hTmr Handle to the Gptimer instance
  267. loadVal Value to be loaded to the Gptimer period register Low
  268. @endverbatim
  269. *
  270. * <b> Return Value </b>
  271. * @n None
  272. *
  273. * <b> Pre Condition </b>
  274. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  275. *
  276. * <b> Post Condition </b>
  277. * @n Period register is loaded with the given value.
  278. *
  279. * @b Writes
  280. * @n TMR_PRDLO_PRDLO
  281. *
  282. * @b Example
  283. * @verbatim
  284. CSL_TmrHandle hTmr;
  285. Uint32 loadVal;
  286. loadVal = 10;
  287. CSL_TmrLoadPrdLo(hWdt, &loadVal);
  288. ...
  289. @endverbatim
  290. * ===========================================================================
  291. */
  292. /* for misra warnings*/
  293. static inline void CSL_TmrLoadPrdLo (CSL_TmrHandle hTmr,const Uint32* loadVal);
  294. static inline void CSL_TmrLoadPrdLo (CSL_TmrHandle hTmr,const Uint32* loadVal)
  295. {
  296. CSL_FINS (hTmr->regs->PRDLO, TMR_PRDLO_PRDLO, *loadVal);
  297. }
  298. /** ============================================================================
  299. * @n@b CSL_TmrLoadPrdHi
  300. *
  301. * @b Description
  302. * Loads the General purpose timer HIGH period register
  303. *
  304. * @b Arguments
  305. * @verbatim
  306. hTmr Handle to the GPtimer instance
  307. loadVal Value to be loaded to the Gptimer period register High
  308. @endverbatim
  309. *
  310. * <b> Return Value </b>
  311. * None
  312. *
  313. * <b> Pre Condition </b>
  314. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  315. *
  316. * <b> Post Condition </b>
  317. * @n Period register is loaded with the given value.
  318. *
  319. * @b Writes
  320. * @n TMR_PRDHI_PRDHI
  321. *
  322. * @b Example
  323. * @verbatim
  324. CSL_TmrHandle hTmr;
  325. Uint32 loadVal;
  326. ...
  327. loadVal = 10;
  328. CSL_TmrLoadPrdHi(hWdt, &loadVal);
  329. ...
  330. @endverbatim
  331. * ===========================================================================
  332. */
  333. /* for misra warnings*/
  334. static inline void CSL_TmrLoadPrdHi (CSL_TmrHandle hTmr,const Uint32* loadVal);
  335. static inline void CSL_TmrLoadPrdHi (CSL_TmrHandle hTmr,const Uint32* loadVal)
  336. {
  337. CSL_FINS (hTmr->regs->PRDHI, TMR_PRDHI_PRDHI, *loadVal);
  338. }
  339. /** ============================================================================
  340. * @n@b CSL_TmrLoadRelLo
  341. *
  342. * @b Description
  343. * Loads the General purpose timer LOW reload register.
  344. *
  345. * @b Arguments
  346. * @verbatim
  347. hTmr Handle to the Gptimer instance
  348. loadVal Value to be loaded to the Gptimer reload register Low
  349. @endverbatim
  350. *
  351. * <b> Return Value </b>
  352. * @n None
  353. *
  354. * <b> Pre Condition </b>
  355. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  356. *
  357. * <b> Post Condition </b>
  358. * @n Reload register is loaded with the given value.
  359. *
  360. * @b Writes
  361. * @n TMR_RELLO_RELLO
  362. *
  363. * @b Example
  364. * @verbatim
  365. CSL_TmrHandle hTmr;
  366. Uint32 loadVal;
  367. loadVal = 10;
  368. CSL_TmrLoadRelLo(hWdt, &loadVal);
  369. ...
  370. @endverbatim
  371. * ===========================================================================
  372. */
  373. /* for misra warnings*/
  374. static inline void CSL_TmrLoadRelLo (CSL_TmrHandle hTmr,const Uint32* loadVal);
  375. static inline void CSL_TmrLoadRelLo (CSL_TmrHandle hTmr,const Uint32* loadVal)
  376. {
  377. CSL_FINS (hTmr->regs->RELLO, TMR_RELLO_RELLO, *loadVal);
  378. }
  379. /** ============================================================================
  380. * @n@b CSL_TmrLoadRelHi
  381. *
  382. * @b Description
  383. * Loads the General purpose timer HIGH reload register
  384. *
  385. * @b Arguments
  386. * @verbatim
  387. hTmr Handle to the GPtimer instance
  388. loadVal Value to be loaded to the Gptimer reload register High
  389. @endverbatim
  390. *
  391. * <b> Return Value </b>
  392. * None
  393. *
  394. * <b> Pre Condition </b>
  395. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  396. *
  397. * <b> Post Condition </b>
  398. * @n Reload register is loaded with the given value.
  399. *
  400. * @b Writes
  401. * @n TMR_RELHI_RELHI
  402. *
  403. * @b Example
  404. * @verbatim
  405. CSL_TmrHandle hTmr;
  406. Uint32 loadVal;
  407. ...
  408. loadVal = 10;
  409. CSL_TmrLoadRelHi(hWdt, &loadVal);
  410. ...
  411. @endverbatim
  412. * ===========================================================================
  413. */
  414. /* for misra warnings*/
  415. static inline void CSL_TmrLoadRelHi (CSL_TmrHandle hTmr,const Uint32* loadVal);
  416. static inline void CSL_TmrLoadRelHi (CSL_TmrHandle hTmr,const Uint32* loadVal)
  417. {
  418. CSL_FINS (hTmr->regs->RELHI, TMR_RELHI_RELHI, *loadVal);
  419. }
  420. /** ============================================================================
  421. * @n@b CSL_TmrLoadPrescalarHi
  422. *
  423. * @b Description
  424. * Configures the prescalar values for the HIGH Timer.
  425. *
  426. * @b Arguments
  427. * @verbatim
  428. hTmr Handle to the Timer Instance
  429. loadVal Value to be loaded to the PRESCALAR bits in the TGCR register
  430. @endverbatim
  431. *
  432. * <b> Return Value </b>
  433. * @n None
  434. *
  435. * <b> Pre Condition </b>
  436. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  437. *
  438. * <b> Post Condition </b>
  439. * @n Gptimer pre scalar register is loaded with the given value.
  440. *
  441. * @b Writes
  442. * @n TMR_TGCR_PSCHI
  443. *
  444. * @b Example
  445. * @verbatim
  446. CSL_TmrHandle hTmr;
  447. Uint8 *loadVal;
  448. ...
  449. CSL_TmrLoadPrescalarHi(hWdt, &loadVal);
  450. ...
  451. @endverbatim
  452. * ===========================================================================
  453. */
  454. /* for misra warnings*/
  455. static inline void CSL_TmrLoadPrescalarHi (CSL_TmrHandle hTmr, const Uint8* loadVal);
  456. static inline void CSL_TmrLoadPrescalarHi (CSL_TmrHandle hTmr, const Uint8* loadVal)
  457. {
  458. CSL_FINS(hTmr->regs->TGCR, TMR_TGCR_PSCHI, ((Uint32)(*loadVal)));
  459. }
  460. /** ============================================================================
  461. * @n@b CSL_TmrStartHi
  462. *
  463. * @b Description
  464. * The functions starts the HIGH timer.
  465. *
  466. * @b Arguments
  467. * @verbatim
  468. hTmr Handle to the Timer instance
  469. countMode Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)
  470. @endverbatim
  471. *
  472. * <b> Return Value </b>
  473. * None
  474. *
  475. * <b> Pre Condition </b>
  476. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  477. *
  478. * <b> Post Condition </b>
  479. * @n The HIGH timer is brought out of reset and is activated in the
  480. * provided counting mode.
  481. *
  482. * @b Writes
  483. * @n TMR_TGCR_TIMHIRS=1,TMR_TCR_ENAMODE_HI
  484. *
  485. * @b Example
  486. * @verbatim
  487. CSL_TmrHandle hTmr;
  488. ...
  489. CSL_TmrStartHi(hTmr, CSL_TMR_ENAMODE_ENABLE);
  490. ...
  491. @endverbatim
  492. * ===========================================================================
  493. */
  494. /* for misra warnings*/
  495. static inline void CSL_TmrStartHi (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode);
  496. static inline void CSL_TmrStartHi (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
  497. {
  498. /* Bring the HIGH Timer out of reset. */
  499. CSL_FINST(hTmr->regs->TGCR, TMR_TGCR_TIMHIRS, RESET_OFF);
  500. /* Configure the HIGH TIMER with the appropriate counting mode. */
  501. CSL_FINS(hTmr->regs->TCR, TMR_TCR_ENAMODE_HI, countMode);
  502. return;
  503. }
  504. /** ============================================================================
  505. * @n@b CSL_TmrStartLo
  506. *
  507. * @b Description
  508. * The function starts the LOW Timer.
  509. *
  510. * @b Arguments
  511. * @verbatim
  512. hTmr Handle to the Gptimer instance
  513. countMode Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)
  514. @endverbatim
  515. *
  516. * <b> Return Value </b>
  517. * None
  518. *
  519. * <b> Pre Condition </b>
  520. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  521. *
  522. * <b> Post Condition </b>
  523. * @n The LOW timer is brought out of reset and is activated in the
  524. * provided counting mode.
  525. *
  526. * @b Writes
  527. * @n TMR_TGCR_TIMLORS=1,TMR_TCR_ENAMODE_LO
  528. *
  529. * @b Example
  530. * @verbatim
  531. CSL_TmrHandle hTmr;
  532. ...
  533. CSL_TmrStartLo(hTmr, CSL_TMR_ENAMODE_ENABLE);
  534. ...
  535. @endverbatim
  536. * ===========================================================================
  537. */
  538. /* for misra warnings*/
  539. static inline void CSL_TmrStartLo (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode);
  540. static inline void CSL_TmrStartLo (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
  541. {
  542. /* Bring the LOW Timer out of reset. */
  543. CSL_FINST(hTmr->regs->TGCR, TMR_TGCR_TIMLORS, RESET_OFF);
  544. /* Configure the LOW TIMER with the appropriate counting mode. */
  545. CSL_FINS(hTmr->regs->TCR, TMR_TCR_ENAMODE_LO, countMode);
  546. }
  547. /** ===========================================================================
  548. * @n@b CSL_TmrStart64
  549. *
  550. * @b Description
  551. * The function starts the 64bit Timer by bringing both the LOW and HIGH
  552. * timer out of reset.
  553. *
  554. * @b Arguments
  555. * @verbatim
  556. hTmr Handle to the Gptimer instance
  557. countMode Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)
  558. @endverbatim
  559. *
  560. * <b> Return Value </b>
  561. * None
  562. *
  563. * <b> Pre Condition </b>
  564. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  565. *
  566. * <b> Post Condition </b>
  567. * @n Set the GP OR chained timer counting mode and
  568. * timer Low and High reset register.
  569. *
  570. * @b Writes
  571. * @n TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1,
  572. * @n TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI
  573. *
  574. * @b Example
  575. * @verbatim
  576. CSL_TmrHandle hTmr;
  577. ...
  578. CSL_TmrStart64(hTmr, CSL_TMR_ENAMODE_ENABLE);
  579. ...
  580. @endverbatim
  581. * ===========================================================================
  582. */
  583. /* for misra warnings*/
  584. static inline void CSL_TmrStart64 (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode);
  585. static inline void CSL_TmrStart64 (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
  586. {
  587. Uint32 tmpReg;
  588. /* Bring the LOW and HIGH Timer outs of reset. */
  589. tmpReg = hTmr->regs->TGCR;
  590. CSL_FINST(tmpReg, TMR_TGCR_TIMLORS, RESET_OFF);
  591. CSL_FINST(tmpReg, TMR_TGCR_TIMHIRS, RESET_OFF);
  592. hTmr->regs->TGCR = tmpReg;
  593. /* Configure the counting mode for both the LOW and HIGH Timers. */
  594. tmpReg = hTmr->regs->TCR;
  595. CSL_FINS(tmpReg, TMR_TCR_ENAMODE_LO, countMode);
  596. CSL_FINS(tmpReg, TMR_TCR_ENAMODE_HI, countMode);
  597. hTmr->regs->TCR = tmpReg;
  598. }
  599. /** ===========================================================================
  600. * @n@b CSL_TmrStopLo
  601. *
  602. * @b Description
  603. * The function stops the LOW Timer
  604. *
  605. * @b Arguments
  606. * @verbatim
  607. hTmr Handle to the Timer instance
  608. @endverbatim
  609. *
  610. * <b> Return Value </b>
  611. * @n None
  612. *
  613. * <b> Pre Condition </b>
  614. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  615. *
  616. * <b> Post Condition </b>
  617. * @n Low Timer is disabled.
  618. *
  619. * @b Writes
  620. * @n TMR_TCR_ENAMODE_LO=0
  621. *
  622. * @b Example
  623. * @verbatim
  624. CSL_TmrHandle hTmr;
  625. ...
  626. CSL_TmrStopLo(hTmr);
  627. ...
  628. @endverbatim
  629. * ===========================================================================
  630. */
  631. /* for misra warnings*/
  632. static inline void CSL_TmrStopLo (CSL_TmrHandle hTmr);
  633. static inline void CSL_TmrStopLo (CSL_TmrHandle hTmr)
  634. {
  635. CSL_FINST(hTmr->regs->TCR, TMR_TCR_ENAMODE_LO, DISABLE);
  636. }
  637. /** ===========================================================================
  638. * @n@b CSL_TmrStopHi
  639. *
  640. * @b Description
  641. * The function stops the HIGH Timer
  642. *
  643. * @b Arguments
  644. * @verbatim
  645. hTmr Handle to the Timer instance
  646. @endverbatim
  647. *
  648. * <b> Return Value </b>
  649. * @n None
  650. *
  651. * <b> Pre Condition </b>
  652. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  653. *
  654. * <b> Post Condition </b>
  655. * @n High Timer is disabled.
  656. *
  657. * @b Writes
  658. * @n TMR_TCR_ENAMODE_HI=0
  659. *
  660. * @b Example
  661. * @verbatim
  662. CSL_TmrHandle hTmr;
  663. ...
  664. CSL_TmrStopHi(hTmr);
  665. ...
  666. @endverbatim
  667. * ===========================================================================
  668. */
  669. /* for misra warnings*/
  670. static inline void CSL_TmrStopHi (CSL_TmrHandle hTmr);
  671. static inline void CSL_TmrStopHi (CSL_TmrHandle hTmr)
  672. {
  673. CSL_FINST(hTmr->regs->TCR, TMR_TCR_ENAMODE_HI, DISABLE);
  674. }
  675. /** ===========================================================================
  676. * @n@b CSL_TmrStop64
  677. *
  678. * @b Description
  679. * The function stops the 64bit timer.
  680. *
  681. * @b Arguments
  682. * @verbatim
  683. hTmr Handle to the Timer instance
  684. @endverbatim
  685. *
  686. * <b> Return Value </b>
  687. * @n None
  688. *
  689. * <b> Pre Condition </b>
  690. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  691. *
  692. * <b> Post Condition </b>
  693. * @n The 64bit timer is stopped
  694. *
  695. * @b Writes
  696. * @n TMR_TCR_ENAMODE_LO=0,TMR_TCR_ENAMODE_HI=0
  697. *
  698. * @b Example
  699. * @verbatim
  700. CSL_TmrHandle hTmr;
  701. ...
  702. CSL_TmrStop64(hWdt);
  703. ...
  704. @endverbatim
  705. * ===========================================================================
  706. */
  707. /* for misra warnings*/
  708. static inline void CSL_TmrStop64 (CSL_TmrHandle hTmr);
  709. static inline void CSL_TmrStop64 (CSL_TmrHandle hTmr)
  710. {
  711. Uint32 tmpReg;
  712. /* Disable the LOW and HIGH Timers. */
  713. tmpReg = hTmr->regs->TCR;
  714. CSL_FINST(tmpReg, TMR_TCR_ENAMODE_LO, DISABLE);
  715. CSL_FINST(tmpReg, TMR_TCR_ENAMODE_HI, DISABLE);
  716. hTmr->regs->TCR = tmpReg;
  717. }
  718. /** ===========================================================================
  719. * @n@b CSL_TmrResetHi
  720. *
  721. * @b Description
  722. * The HIGH timer is moved to RESET state.
  723. *
  724. * @b Arguments
  725. * @verbatim
  726. hTmr Handle to the HIGH timer instance
  727. @endverbatim
  728. *
  729. * <b> Return Value </b>
  730. * @n None
  731. *
  732. * <b> Pre Condition </b>
  733. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  734. *
  735. * <b> Post Condition </b>
  736. * @n High timer is reset.
  737. *
  738. * @b Writes
  739. * @n TMR_TGCR_TIMHIRS=0
  740. *
  741. * @b Example
  742. * @verbatim
  743. CSL_TmrHandle hTmr;
  744. ...
  745. CSL_TmrResetHi(hTmr);
  746. ...
  747. @endverbatim
  748. * ===========================================================================
  749. */
  750. /* for misra warnings*/
  751. static inline void CSL_TmrResetHi (CSL_TmrHandle hTmr);
  752. static inline void CSL_TmrResetHi (CSL_TmrHandle hTmr)
  753. {
  754. CSL_FINST(hTmr->regs->TGCR, TMR_TGCR_TIMHIRS, RESET_ON);
  755. }
  756. /** ===========================================================================
  757. * @n@b CSL_TmrResetLo
  758. *
  759. * @b Description
  760. * The LOW timer is moved to RESET state.
  761. *
  762. * @b Arguments
  763. * @verbatim
  764. hTmr Handle to the Gptimer instance
  765. @endverbatim
  766. *
  767. * <b> Return Value </b>
  768. * @n None
  769. *
  770. * <b> Pre Condition </b>
  771. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  772. *
  773. * <b> Post Condition </b>
  774. * @n Low Timer is Reset
  775. *
  776. * @b Writes
  777. * @n TMR_TGCR_TIMLORS=0
  778. *
  779. * @b Example
  780. * @verbatim
  781. CSL_TmrHandle hTmr;
  782. ...
  783. CSL_TmrResetLo(hWdt);
  784. ...
  785. @endverbatim
  786. * ===========================================================================
  787. */
  788. /* for misra warnings*/
  789. static inline void CSL_TmrResetLo (CSL_TmrHandle hTmr);
  790. static inline void CSL_TmrResetLo (CSL_TmrHandle hTmr)
  791. {
  792. CSL_FINST(hTmr->regs->TGCR, TMR_TGCR_TIMLORS, RESET_ON);
  793. }
  794. /** ===========================================================================
  795. * @n@b CSL_TmrReset64
  796. *
  797. * @b Description
  798. * The function resets the 64bit timer.
  799. *
  800. * @b Arguments
  801. * @verbatim
  802. hTmr Handle to the Timer instance
  803. @endverbatim
  804. *
  805. * <b> Return Value </b>
  806. * @n None
  807. *
  808. * <b> Pre Condition </b>
  809. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  810. *
  811. * <b> Post Condition </b>
  812. * @n 64bit Timer is reset.
  813. *
  814. * @b Writes
  815. * @n TMR_TGCR_TIMLORS=0,TMR_TGCR_TIMHIRS=0
  816. *
  817. * @b Example
  818. * @verbatim
  819. CSL_TmrHandle hTmr;
  820. ...
  821. CSL_TmrReset64(hTmr);
  822. ...
  823. @endverbatim
  824. * ===========================================================================
  825. */
  826. /* for misra warnings*/
  827. static inline void CSL_TmrReset64 (CSL_TmrHandle hTmr);
  828. static inline void CSL_TmrReset64 (CSL_TmrHandle hTmr)
  829. {
  830. Uint32 tmpReg = hTmr->regs->TGCR;
  831. /* Move both the Low and High Timers into reset. */
  832. CSL_FINST(tmpReg, TMR_TGCR_TIMLORS, RESET_ON);
  833. CSL_FINST(tmpReg, TMR_TGCR_TIMHIRS, RESET_ON);
  834. hTmr->regs->TGCR = tmpReg;
  835. }
  836. /** ===========================================================================
  837. * @n@b CSL_TmrStartWdt
  838. *
  839. * @b Description
  840. * The function starts the timer in Watch Dog Mode.
  841. *
  842. * @b Arguments
  843. * @verbatim
  844. hTmr Handle to the Timer instance
  845. countMode Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)
  846. @endverbatim
  847. *
  848. * <b> Return Value </b>
  849. * None
  850. *
  851. * <b> Pre Condition </b>
  852. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  853. *
  854. * <b> Post Condition </b>
  855. * @n Timer has been started in WATCH Dog Mode.
  856. *
  857. * @b Writes
  858. * @n TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1,TMR_WDTCR_WDEN=1,TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI;
  859. *
  860. * @b Example
  861. * @verbatim
  862. CSL_TmrHandle hWdt;
  863. ...
  864. CSL_TmrStartWdt(hWdt, CSL_TMR_ENAMODE_CONT);
  865. ...
  866. @endverbatim
  867. * ===========================================================================
  868. */
  869. /* for misra warnings*/
  870. static inline void CSL_TmrStartWdt (CSL_TmrHandle hTmr,CSL_TmrEnamode countMode);
  871. static inline void CSL_TmrStartWdt (CSL_TmrHandle hTmr,CSL_TmrEnamode countMode)
  872. {
  873. Uint32 tmpReg = hTmr->regs->TGCR;
  874. /* Bring the LOW and HIGH Timers out of reset. */
  875. CSL_FINST(tmpReg, TMR_TGCR_TIMLORS, RESET_OFF);
  876. CSL_FINST(tmpReg, TMR_TGCR_TIMHIRS, RESET_OFF);
  877. hTmr->regs->TGCR = tmpReg;
  878. /* Enable the Watch Dog Timer */
  879. CSL_FINST(hTmr->regs->WDTCR, TMR_WDTCR_WDEN, ENABLE);
  880. /* Enable the LOW and HIGH Timers to operate */
  881. tmpReg = hTmr->regs->TCR;
  882. CSL_FINS(tmpReg, TMR_TCR_ENAMODE_LO, countMode);
  883. CSL_FINS(tmpReg, TMR_TCR_ENAMODE_HI, countMode);
  884. hTmr->regs->TCR = tmpReg;
  885. }
  886. /** ===========================================================================
  887. * @n@b CSL_TmrLoadtWdkey
  888. *
  889. * @b Description
  890. * The function loads the watch dog timer with the appropriate key.
  891. *
  892. * @b Arguments
  893. * @verbatim
  894. hTmr Handle to the Gptimer instance
  895. cmd Specifies the WATCHDOG Key. This can only be either of
  896. the following:-
  897. - CSL_TMR_WDTCR_WDKEY_CMD1
  898. - CSL_TMR_WDTCR_WDKEY_CMD2
  899. @endverbatim
  900. *
  901. * <b> Return Value </b>
  902. * None
  903. *
  904. * <b> Pre Condition </b>
  905. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  906. *
  907. * <b> Post Condition </b>
  908. * @n Loads the WDKEY in WDTCR register.
  909. *
  910. * @b Writes
  911. * @n TMR_WDTCR_WDKEY
  912. *
  913. * @b Example
  914. * @verbatim
  915. CSL_TmrHandle hWdt;
  916. ...
  917. CSL_TmrLoadWdkey(hWdt, CSL_TMR_WDTCR_WDKEY_CMD1);
  918. ...
  919. @endverbatim
  920. * ===========================================================================
  921. */
  922. /* for misra warnings*/
  923. static inline void CSL_TmrLoadWdkey (CSL_TmrHandle hTmr, Uint16 cmd);
  924. static inline void CSL_TmrLoadWdkey (CSL_TmrHandle hTmr, Uint16 cmd)
  925. {
  926. CSL_FINS(hTmr->regs->WDTCR, TMR_WDTCR_WDKEY, (Uint32)cmd);
  927. }
  928. /** ===========================================================================
  929. * @n@b CSL_TmrDisableWdt
  930. *
  931. * @b Description
  932. * The function disables the Watch Dog Timer.
  933. *
  934. * @b Arguments
  935. * @verbatim
  936. hTmr Handle to the Timer instance
  937. @endverbatim
  938. *
  939. * <b> Return Value </b>
  940. * None
  941. *
  942. * <b> Pre Condition </b>
  943. * @n Both @a CSL_tmrInit() and @a CSL_tmrOpen() must be called.
  944. *
  945. * <b> Post Condition </b>
  946. * @n The Watch Dog timer is disabled.
  947. *
  948. * @b Writes
  949. * @n TMR_WDTCR_WDEN=0
  950. *
  951. * @b Example
  952. * @verbatim
  953. CSL_TmrHandle hWdt;
  954. ...
  955. CSL_TmrDisableWdt(hWdt);
  956. ...
  957. @endverbatim
  958. * ===========================================================================
  959. */
  960. /* for misra warnings*/
  961. static inline void CSL_TmrDisableWdt (CSL_TmrHandle hTmr);
  962. static inline void CSL_TmrDisableWdt (CSL_TmrHandle hTmr)
  963. {
  964. CSL_FINST(hTmr->regs->WDTCR, TMR_WDTCR_WDEN, DISABLE);
  965. }
  966. /**
  967. @}
  968. */
  969. #ifdef __cplusplus
  970. }
  971. #endif
  972. #endif /* CSL_TMRAUX_H_ */