F2837xD_cputimervars.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //###########################################################################
  2. //
  3. // FILE: F2837xD_Cputimers.h
  4. //
  5. // TITLE: F2837xD Device CPUTIMERS Register Definitions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2837xD Support Library v3.05.00.00 $
  9. // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
  10. // $Copyright:
  11. // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
  12. //
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions
  15. // are met:
  16. //
  17. // Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. //
  20. // Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the
  23. // distribution.
  24. //
  25. // Neither the name of Texas Instruments Incorporated nor the names of
  26. // its contributors may be used to endorse or promote products derived
  27. // from this software without specific prior written permission.
  28. //
  29. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. // $
  41. //###########################################################################
  42. #ifndef F2837xD_CPUTIMERVARS_H
  43. #define F2837xD_CPUTIMERVARS_H
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. //
  48. // Globals
  49. //
  50. struct CPUTIMER_VARS {
  51. volatile struct CPUTIMER_REGS *RegsAddr;
  52. Uint32 InterruptCount;
  53. float CPUFreqInMHz;
  54. float PeriodInUSec;
  55. };
  56. extern struct CPUTIMER_VARS CpuTimer0;
  57. extern struct CPUTIMER_VARS CpuTimer1;
  58. extern struct CPUTIMER_VARS CpuTimer2;
  59. //
  60. // Defines
  61. //
  62. //
  63. // Start Timer:
  64. //
  65. #define StartCpuTimer0() CpuTimer0Regs.TCR.bit.TSS = 0
  66. //
  67. // Stop Timer:
  68. //
  69. #define StopCpuTimer0() CpuTimer0Regs.TCR.bit.TSS = 1
  70. //
  71. // Reload Timer With period Value:
  72. //
  73. #define ReloadCpuTimer0() CpuTimer0Regs.TCR.bit.TRB = 1
  74. //
  75. // Read 32-Bit Timer Value:
  76. //
  77. #define ReadCpuTimer0Counter() CpuTimer0Regs.TIM.all
  78. //
  79. // Read 32-Bit Period Value:
  80. //
  81. #define ReadCpuTimer0Period() CpuTimer0Regs.PRD.all
  82. //
  83. // Start Timer:
  84. //
  85. #define StartCpuTimer1() CpuTimer1Regs.TCR.bit.TSS = 0
  86. #define StartCpuTimer2() CpuTimer2Regs.TCR.bit.TSS = 0
  87. //
  88. // Stop Timer:
  89. //
  90. #define StopCpuTimer1() CpuTimer1Regs.TCR.bit.TSS = 1
  91. #define StopCpuTimer2() CpuTimer2Regs.TCR.bit.TSS = 1
  92. //
  93. // Reload Timer With period Value:
  94. //
  95. #define ReloadCpuTimer1() CpuTimer1Regs.TCR.bit.TRB = 1
  96. #define ReloadCpuTimer2() CpuTimer2Regs.TCR.bit.TRB = 1
  97. //
  98. // Read 32-Bit Timer Value:
  99. //
  100. #define ReadCpuTimer1Counter() CpuTimer1Regs.TIM.all
  101. #define ReadCpuTimer2Counter() CpuTimer2Regs.TIM.all
  102. //
  103. // Read 32-Bit Period Value:
  104. //
  105. #define ReadCpuTimer1Period() CpuTimer1Regs.PRD.all
  106. #define ReadCpuTimer2Period() CpuTimer2Regs.PRD.all
  107. //
  108. // Function Prototypes
  109. //
  110. void InitCpuTimers(void);
  111. void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period);
  112. #ifdef __cplusplus
  113. }
  114. #endif /* extern "C" */
  115. #endif // end of F2837xD_CPUTIMERVARS_H definition
  116. //
  117. // End of file
  118. //