sysctl.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. //###########################################################################
  2. //
  3. // FILE: sysctl.h
  4. //
  5. // TITLE: Stellaris style wrapper driver for F2837x system control.
  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 __SYSCTL_H__
  43. #define __SYSCTL_H__
  44. //*****************************************************************************
  45. //
  46. // If building with a C++ compiler, make all of the definitions in this header
  47. // have a C binding.
  48. //
  49. //*****************************************************************************
  50. #ifdef __cplusplus
  51. extern "C"
  52. {
  53. #endif
  54. //*****************************************************************************
  55. //
  56. //! \addtogroup sysctl_api
  57. //! @{
  58. //
  59. //*****************************************************************************
  60. #include "inc/hw_types.h"
  61. //*****************************************************************************
  62. //
  63. //! Defined system clock oscillator source speed. Adjust this to reflect your
  64. //! actual clock speed.
  65. //
  66. //*****************************************************************************
  67. #if defined(_LAUNCHXL_F28379D) || defined(_LAUNCHXL_F28377S)
  68. #define SYSTEM_CLOCK_SPEED 10000000
  69. #else
  70. #define SYSTEM_CLOCK_SPEED 20000000
  71. #endif
  72. //*****************************************************************************
  73. //
  74. // The following are values that can be passed to the SysCtlClockSet() API as
  75. // the ui32Config parameter.
  76. //
  77. //*****************************************************************************
  78. #define SYSCTL_SYSDIV_M 0x00001F80
  79. #define SYSCTL_SYSDIV_S 0x00000007
  80. // Only 1 or even values up to 126 are allowed
  81. #define SYSCTL_SYSDIV(x) ((((x == 1) ? 0 : (x / 2)) << SYSCTL_SYSDIV_S) & SYSCTL_SYSDIV_M)
  82. #define SYSCTL_IMULT_M 0x0000007F
  83. #define SYSCTL_IMULT_S 0x00000000
  84. #define SYSCTL_IMULT(x) (((x) << SYSCTL_IMULT_S) & SYSCTL_IMULT_M)
  85. #define SYSCTL_FMULT_M 0x00006000
  86. #define SYSCTL_FMULT_S 0x0000000D
  87. #define SYSCTL_FMULT_0 0x00000000
  88. #define SYSCTL_FMULT_1_4 0x00002000
  89. #define SYSCTL_FMULT_1_2 0x00004000
  90. #define SYSCTL_FMULT_3_4 0x00006000
  91. #define SYSCTL_OSCSRC_M 0x00030000
  92. #define SYSCTL_OSCSRC_S 0x00000010
  93. #define SYSCTL_OSCSRC_OSC2 0x00000000
  94. #define SYSCTL_OSCSRC_XTAL 0x00010000
  95. #define SYSCTL_OSCSRC_OSC1 0x00020000
  96. #define SYSCTL_LSDIV_M 0x00700000
  97. #define SYSCTL_LSDIV_S 0x00000014
  98. // Only 1 or even values up to 14 are allowed
  99. #define SYSCTL_LSDIV(x) (((x == 1) ? 0 : (x / 2)) << SYSCTL_LSDIV_S) & SYSCTL_LSDIV_M)
  100. #define SYSCTL_PLL_ENABLE 0x80000000
  101. #define SYSCTL_PLL_DISABLE 0x00000000
  102. //*****************************************************************************
  103. //
  104. // The following are values that can be passed to the
  105. // SysCtlPeripheralPresent(), SysCtlPeripheralEnable(),
  106. // SysCtlPeripheralDisable(), and SysCtlPeripheralReset() APIs as the
  107. // ui32Peripheral parameter. The peripherals in the fourth group (upper nibble
  108. // is 3) can only be used with the SysCtlPeripheralPresent() API.
  109. //
  110. //*****************************************************************************
  111. #define SYSCTL_PERIPH_REG_M 0x0000001F
  112. #define SYSCTL_PERIPH_REG_S 0x00000000
  113. #define SYSCTL_PERIPH_BIT_M 0x003F0000
  114. #define SYSCTL_PERIPH_BIT_S 0x00000010
  115. //PCLKCR0
  116. #define SYSCTL_PERIPH_CLA1 0x00000000
  117. #define SYSCTL_PERIPH_DMA 0x00020000
  118. #define SYSCTL_PERIPH_TIMER0 0x00030000
  119. #define SYSCTL_PERIPH_TIMER1 0x00040000
  120. #define SYSCTL_PERIPH_TIMER2 0x00050000
  121. #define SYSCTL_PERIPH_HRPWM 0x00100000
  122. #define SYSCTL_PERIPH_TBCLKSYNC 0x00120000
  123. #define SYSCTL_PERIPH_GTBCLKSYNC 0x00130000
  124. //PCLKCR1
  125. #define SYSCTL_PERIPH_EMIF1 0x00000001
  126. #define SYSCTL_PERIPH_EMIF2 0x00010001
  127. //PCLKCR2
  128. #define SYSCTL_PERIPH_EPWM1 0x00000002
  129. #define SYSCTL_PERIPH_EPWM2 0x00010002
  130. #define SYSCTL_PERIPH_EPWM3 0x00020002
  131. #define SYSCTL_PERIPH_EPWM4 0x00030002
  132. #define SYSCTL_PERIPH_EPWM5 0x00040002
  133. #define SYSCTL_PERIPH_EPWM6 0x00050002
  134. #define SYSCTL_PERIPH_EPWM7 0x00060002
  135. #define SYSCTL_PERIPH_EPWM8 0x00070002
  136. #define SYSCTL_PERIPH_EPWM9 0x00080002
  137. #define SYSCTL_PERIPH_EPWM10 0x00090002
  138. #define SYSCTL_PERIPH_EPWM11 0x000A0002
  139. #define SYSCTL_PERIPH_EPWM12 0x000B0002
  140. //PCLKCR3
  141. #define SYSCTL_PERIPH_ECAP1 0x00000003
  142. #define SYSCTL_PERIPH_ECAP2 0x00010003
  143. #define SYSCTL_PERIPH_ECAP3 0x00020003
  144. #define SYSCTL_PERIPH_ECAP4 0x00030003
  145. #define SYSCTL_PERIPH_ECAP5 0x00040003
  146. #define SYSCTL_PERIPH_ECAP6 0x00050003
  147. //PCLKCR4
  148. #define SYSCTL_PERIPH_EQEP1 0x00000004
  149. #define SYSCTL_PERIPH_EQEP2 0x00010004
  150. #define SYSCTL_PERIPH_EQEP3 0x00020004
  151. //PCLKCR5
  152. //Reserved
  153. //PCLKCR6
  154. #define SYSCTL_PERIPH_SD1 0x00000006
  155. #define SYSCTL_PERIPH_SD2 0x00010006
  156. //PCLKCR7
  157. #define SYSCTL_PERIPH_SCI1 0x00000007
  158. #define SYSCTL_PERIPH_SCI2 0x00010007
  159. #define SYSCTL_PERIPH_SCI3 0x00020007
  160. #define SYSCTL_PERIPH_SCI4 0x00030007
  161. //PCLKCR8
  162. #define SYSCTL_PERIPH_SPI1 0x00000008
  163. #define SYSCTL_PERIPH_SPI2 0x00010008
  164. #define SYSCTL_PERIPH_SPI3 0x00020008
  165. //PCLKCR9
  166. #define SYSCTL_PERIPH_I2C1 0x00000009
  167. #define SYSCTL_PERIPH_I2C2 0x00010009
  168. //PCLKCR10
  169. #define SYSCTL_PERIPH_CAN1 0x0000000A
  170. #define SYSCTL_PERIPH_CAN2 0x0001000A
  171. //PCLKCR11
  172. #define SYSCTL_PERIPH_MCBSP1 0x0000000B
  173. #define SYSCTL_PERIPH_MCBSP2 0x0001000B
  174. #define SYSCTL_PERIPH_USB0 0x0010000B
  175. //PCLKCR12
  176. #define SYSCTL_PERIPH_UPP1 0x0000000C
  177. //PCLKCR13
  178. #define SYSCTL_PERIPH_ADC1 0x0000000D
  179. #define SYSCTL_PERIPH_ADC2 0x0001000D
  180. #define SYSCTL_PERIPH_ADC3 0x0002000D
  181. #define SYSCTL_PERIPH_ADC4 0x0003000D
  182. //PCLKCR14
  183. #define SYSCTL_PERIPH_CMPSS1 0x0000000E
  184. #define SYSCTL_PERIPH_CMPSS2 0x0001000E
  185. #define SYSCTL_PERIPH_CMPSS3 0x0002000E
  186. #define SYSCTL_PERIPH_CMPSS4 0x0003000E
  187. #define SYSCTL_PERIPH_CMPSS5 0x0004000E
  188. #define SYSCTL_PERIPH_CMPSS6 0x0005000E
  189. #define SYSCTL_PERIPH_CMPSS7 0x0006000E
  190. #define SYSCTL_PERIPH_CMPSS8 0x0007000E
  191. //PCLKCR15
  192. //Reserved
  193. //PCLKCR16
  194. #define SYSCTL_PERIPH_BUFFDAC1 0x00000010
  195. #define SYSCTL_PERIPH_BUFFDAC2 0x00010010
  196. #define SYSCTL_PERIPH_BUFFDAC3 0x00020010
  197. //old
  198. //#define SYSCTL_PERIPH_UART_A 0x1 // SCI A
  199. //#define SYSCTL_PERIPH_UART_B 0x2 // SCI B
  200. //#define SYSCTL_PERIPH_UART_C 0x3 // SCI C
  201. //#define SYSCTL_PERIPH_UART_D 0x4 // SCI D
  202. //
  203. //#define SYSCTL_PERIPH_SPI_A 0x5 // SPI A
  204. //#define SYSCTL_PERIPH_SPI_B 0x6 // SPI B
  205. //#define SYSCTL_PERIPH_SPI_C 0x7 // SPI C
  206. //
  207. //#define SYSCTL_PERIPH_MCBSP_A 0x8 // McBSP A
  208. //#define SYSCTL_PERIPH_MCBSP_B 0x9 // McBSP B
  209. //
  210. //#define SYSCTL_PERIPH_DMA 0xA // DMA
  211. //
  212. //#define SYSCTL_PERIPH_USB0 0xB // USBA
  213. //*****************************************************************************
  214. //
  215. // Prototypes for the APIs.
  216. //
  217. //*****************************************************************************
  218. extern uint32_t SysCtlSRAMSizeGet(void);
  219. extern uint32_t SysCtlFlashSizeGet(void);
  220. extern void SysCtlPeripheralReset(uint32_t ui32Peripheral);
  221. extern void SysCtlPeripheralEnable(uint32_t ui32Peripheral);
  222. extern void SysCtlPeripheralDisable(uint32_t ui32Peripheral);
  223. extern bool SysCtlPeripheralPresent(uint32_t ui32Peripheral);
  224. extern void SysCtlDelay(uint32_t ulCount);
  225. extern uint32_t SysCtlClockGet(uint32_t u32ClockIn);
  226. extern void SysCtlClockSet(uint32_t ui32Config);
  227. extern void SysCtlAuxClockSet(uint32_t ui32Config);
  228. extern uint32_t SysCtlLowSpeedClockGet(uint32_t u32ClockIn);
  229. extern void SysCtlUSBPLLEnable(void);
  230. extern void SysCtlUSBPLLDisable(void);
  231. //*****************************************************************************
  232. //
  233. // Close the Doxygen group.
  234. //! @}
  235. //
  236. //****************************************************************************
  237. //*****************************************************************************
  238. //
  239. // Mark the end of the C bindings section for C++ compilers.
  240. //
  241. //*****************************************************************************
  242. #ifdef __cplusplus
  243. }
  244. #endif
  245. #endif // __SYSCTL_H__