device.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //#############################################################################
  2. //
  3. // FILE: device.h
  4. //
  5. // TITLE: Device setup for examples.
  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. //
  43. // Included Files
  44. //
  45. #include "driverlib.h"
  46. #if (!defined(CPU1) && !defined(CPU2))
  47. #error "You must define CPU1 or CPU2 in your project properties. Otherwise, \
  48. the offsets in your header files will be inaccurate."
  49. #endif
  50. #if (defined(CPU1) && defined(CPU2))
  51. #error "You have defined both CPU1 and CPU2 in your project properties. Only \
  52. a single CPU should be defined."
  53. #endif
  54. //*****************************************************************************
  55. //
  56. // Defines for pin numbers and other GPIO configuration
  57. //
  58. //*****************************************************************************
  59. //
  60. // LEDs
  61. //
  62. #define DEVICE_GPIO_PIN_LED1 31U // GPIO number for LD2
  63. #define DEVICE_GPIO_PIN_LED2 34U // GPIO number for LD3
  64. #define DEVICE_GPIO_CFG_LED1 GPIO_31_GPIO31 // "pinConfig" for LD2
  65. #define DEVICE_GPIO_CFG_LED2 GPIO_34_GPIO34 // "pinConfig" for LD3
  66. //
  67. // SCI for USB-to-UART adapter on FTDI chip
  68. //
  69. #define DEVICE_GPIO_PIN_SCIRXDA 28U // GPIO number for SCI RX
  70. #define DEVICE_GPIO_PIN_SCITXDA 29U // GPIO number for SCI TX
  71. #define DEVICE_GPIO_CFG_SCIRXDA GPIO_28_SCIRXDA // "pinConfig" for SCI RX
  72. #define DEVICE_GPIO_CFG_SCITXDA GPIO_29_SCITXDA // "pinConfig" for SCI TX
  73. //
  74. // CANA
  75. //
  76. #define DEVICE_GPIO_PIN_CANTXA 31U // GPIO number for CANTXA
  77. #define DEVICE_GPIO_PIN_CANRXA 30U // GPIO number for CANRXA
  78. //
  79. // CAN External Loopback
  80. //
  81. #define DEVICE_GPIO_CFG_CANRXA GPIO_30_CANRXA // "pinConfig" for CANA RX
  82. #define DEVICE_GPIO_CFG_CANTXA GPIO_31_CANTXA // "pinConfig" for CANA TX
  83. #define DEVICE_GPIO_CFG_CANRXB GPIO_10_CANRXB // "pinConfig" for CANB RX
  84. #define DEVICE_GPIO_CFG_CANTXB GPIO_8_CANTXB // "pinConfig" for CANB TX
  85. //*****************************************************************************
  86. //
  87. // Defines related to clock configuration
  88. //
  89. //*****************************************************************************
  90. //
  91. // Launchpad Configuration
  92. //
  93. #ifdef _LAUNCHXL_F28379D
  94. //
  95. // 10MHz XTAL on LaunchPad. For use with SysCtl_getClock().
  96. //
  97. #define DEVICE_OSCSRC_FREQ 10000000U
  98. //
  99. // Define to pass to SysCtl_setClock(). Will configure the clock as follows:
  100. // PLLSYSCLK = 10MHz (XTAL_OSC) * 40 (IMULT) * 1 (FMULT) / 2 (PLLCLK_BY_2)
  101. //
  102. #define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(40) | \
  103. SYSCTL_FMULT_NONE | SYSCTL_SYSDIV(2) | \
  104. SYSCTL_PLL_ENABLE)
  105. //
  106. // 200MHz SYSCLK frequency based on the above DEVICE_SETCLOCK_CFG. Update the
  107. // code below if a different clock configuration is used!
  108. //
  109. #define DEVICE_SYSCLK_FREQ ((DEVICE_OSCSRC_FREQ * 40 * 1) / 2)
  110. //
  111. // ControlCARD Configuration
  112. //
  113. #else
  114. //
  115. // 20MHz XTAL on controlCARD. For use with SysCtl_getClock().
  116. //
  117. #define DEVICE_OSCSRC_FREQ 20000000U
  118. //
  119. // Define to pass to SysCtl_setClock(). Will configure the clock as follows:
  120. // PLLSYSCLK = 20MHz (XTAL_OSC) * 20 (IMULT) * 1 (FMULT) / 2 (PLLCLK_BY_2)
  121. //
  122. #define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(20) | \
  123. SYSCTL_FMULT_NONE | SYSCTL_SYSDIV(2) | \
  124. SYSCTL_PLL_ENABLE)
  125. //
  126. // 200MHz SYSCLK frequency based on the above DEVICE_SETCLOCK_CFG. Update the
  127. // code below if a different clock configuration is used!
  128. //
  129. #define DEVICE_SYSCLK_FREQ ((DEVICE_OSCSRC_FREQ * 20 * 1) / 2)
  130. #endif
  131. //
  132. // 50MHz LSPCLK frequency based on the above DEVICE_SYSCLK_FREQ and a default
  133. // low speed peripheral clock divider of 4. Update the code below if a
  134. // different LSPCLK divider is used!
  135. //
  136. #define DEVICE_LSPCLK_FREQ (DEVICE_SYSCLK_FREQ / 4)
  137. //*****************************************************************************
  138. //
  139. // Macro to call SysCtl_delay() to achieve a delay in microseconds. The macro
  140. // will convert the desired delay in microseconds to the count value expected
  141. // by the function. \b x is the number of microseconds to delay.
  142. //
  143. //*****************************************************************************
  144. #define DEVICE_DELAY_US(x) SysCtl_delay(((((long double)(x)) / (1000000.0L / \
  145. (long double)DEVICE_SYSCLK_FREQ)) - 9.0L) / 5.0L)
  146. //*****************************************************************************
  147. //
  148. // Defines, Globals, and Header Includes related to Flash Support
  149. //
  150. //*****************************************************************************
  151. #ifdef _FLASH
  152. #include <stddef.h>
  153. extern uint16_t RamfuncsLoadStart;
  154. extern uint16_t RamfuncsLoadEnd;
  155. extern uint16_t RamfuncsLoadSize;
  156. extern uint16_t RamfuncsRunStart;
  157. extern uint16_t RamfuncsRunEnd;
  158. extern uint16_t RamfuncsRunSize;
  159. #define DEVICE_FLASH_WAITSTATES 3
  160. #endif
  161. //*****************************************************************************
  162. //
  163. // Function Prototypes
  164. //
  165. //*****************************************************************************
  166. extern void Device_init(void);
  167. extern void Device_enableAllPeripherals(void);
  168. extern void Device_initGPIO(void);
  169. extern void Device_enableUnbondedGPIOPullupsFor176Pin(void);
  170. extern void Device_enableUnbondedGPIOPullupsFor100Pin(void);
  171. extern void Device_enableUnbondedGPIOPullups(void);
  172. extern void __error__(char *filename, uint32_t line);
  173. //
  174. // End of file
  175. //