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