collab/mm20
git clone https://git.julia.blue/collab/mm20
b47fcc8
firmware
1/* 2* Copyright (c) 2015, Texas Instruments Incorporated 3* All rights reserved. 4* 5* Redistribution and use in source and binary forms, with or without 6* modification, are permitted provided that the following conditions 7* are met: 8* 9* * Redistributions of source code must retain the above copyright 10* notice, this list of conditions and the following disclaimer. 11* 12* * Redistributions in binary form must reproduce the above copyright 13* notice, this list of conditions and the following disclaimer in the 14* documentation and/or other materials provided with the distribution. 15* 16* * Neither the name of Texas Instruments Incorporated nor the names of 17* its contributors may be used to endorse or promote products derived 18* from this software without specific prior written permission. 19* 20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*/ 32 33/* 34* ======== EK_TM4C123GXL.c ======== 35* This file is responsible for setting up the board specific items for the 36* EK_TM4C123GXL board. 37*/ 38 39#include <stdint.h> 40#include <stdbool.h> 41 42#include <xdc/std.h> 43#include <xdc/runtime/Error.h> 44#include <xdc/runtime/System.h> 45#include <ti/sysbios/family/arm/m3/Hwi.h> 46 47#include <inc/hw_ints.h> 48#include <inc/hw_memmap.h> 49#include <inc/hw_types.h> 50#include <inc/hw_gpio.h> 51 52#include <driverlib/gpio.h> 53#include <driverlib/i2c.h> 54#include <driverlib/pin_map.h> 55#include <driverlib/pwm.h> 56#include <driverlib/ssi.h> 57#include <driverlib/sysctl.h> 58#include <driverlib/uart.h> 59#include <driverlib/udma.h> 60 61#include "EK_TM4C123GXL.h" 62 63#ifndef TI_DRIVERS_UART_DMA 64#define TI_DRIVERS_UART_DMA 0 65#endif 66 67/* 68* =============================== DMA =============================== 69*/ 70#if defined(__TI_COMPILER_VERSION__ ) 71#pragma DATA_ALIGN(dmaControlTable, 1024) 72#elif defined(__IAR_SYSTEMS_ICC__ ) 73#pragma data_alignment=1024 74#elif defined(__GNUC__ ) 75__attribute__ ((aligned (1024 ))) 76#endif 77static tDMAControlTable dmaControlTable [32 ]; 78static bool dmaInitialized = false; 79 80/* Hwi_Struct used in the initDMA Hwi_construct call */ 81static Hwi_Struct dmaHwiStruct ; 82 83/* 84* ======== dmaErrorHwi ======== 85*/ 86static Void dmaErrorHwi (UArg arg ) 87{ 88System_printf ("DMA error code: %d\n" ,uDMAErrorStatusGet ()); 89uDMAErrorStatusClear (); 90System_abort ("DMA error!!" ); 91} 92 93/* 94* ======== EK_TM4C123GXL_initDMA ======== 95*/ 96void EK_TM4C123GXL_initDMA (void ) 97{ 98Error_Block eb ; 99Hwi_Params hwiParams ; 100 101if (!dmaInitialized ) { 102Error_init (& eb ); 103Hwi_Params_init (& hwiParams ); 104Hwi_construct (& (dmaHwiStruct ),INT_UDMAERR ,dmaErrorHwi , 105& hwiParams ,& eb ); 106if (Error_check (& eb )) { 107System_abort ("Couldn't construct DMA error hwi" ); 108 } 109 110SysCtlPeripheralEnable (SYSCTL_PERIPH_UDMA ); 111uDMAEnable (); 112uDMAControlBaseSet (dmaControlTable ); 113 114dmaInitialized = true; 115 } 116} 117 118/* 119* =============================== General =============================== 120*/ 121/* 122* ======== EK_TM4C123GXL_initGeneral ======== 123*/ 124void EK_TM4C123GXL_initGeneral (void ) 125{ 126SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA ); 127SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOB ); 128SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOC ); 129SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOD ); 130SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOE ); 131SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF ); 132} 133 134/* 135* =============================== GPIO =============================== 136*/ 137/* Place into subsections to allow the TI linker to remove items properly */ 138#if defined(__TI_COMPILER_VERSION__ ) 139#pragma DATA_SECTION(GPIOTiva_config, ".const:GPIOTiva_config") 140#endif 141 142#include <ti/drivers/GPIO.h> 143#include <ti/drivers/gpio/GPIOTiva.h> 144 145/* 146* Array of Pin configurations 147* NOTE: The order of the pin configurations must coincide with what was 148* defined in EK_TM4C123GXL.h 149* NOTE: Pins not used for interrupts should be placed at the end of the 150* array. Callback entries can be omitted from callbacks array to 151* reduce memory usage. 152*/ 153GPIO_PinConfig gpioPinConfigs []= { 154/* Input pins */ 155/* EK_TM4C123GXL_GPIO_SW1 */ 156GPIOTiva_PF_4 |GPIO_CFG_IN_PU |GPIO_CFG_IN_INT_RISING , 157/* EK_TM4C123GXL_GPIO_SW2 */ 158GPIOTiva_PF_0 |GPIO_CFG_IN_PU |GPIO_CFG_IN_INT_RISING , 159 160/* Output pins */ 161/* EK_TM4C123GXL_LED_RED */ 162GPIOTiva_PF_1 |GPIO_CFG_OUT_STD |GPIO_CFG_OUT_STR_HIGH |GPIO_CFG_OUT_LOW , 163/* EK_TM4C123GXL_LED_BLUE */ 164GPIOTiva_PF_2 |GPIO_CFG_OUT_STD |GPIO_CFG_OUT_STR_HIGH |GPIO_CFG_OUT_LOW , 165/* EK_TM4C123GXL_LED_GREEN */ 166GPIOTiva_PF_3 |GPIO_CFG_OUT_STD |GPIO_CFG_OUT_STR_HIGH |GPIO_CFG_OUT_LOW 167}; 168 169/* 170* Array of callback function pointers 171* NOTE: The order of the pin configurations must coincide with what was 172* defined in EK_TM4C123GXL.h 173* NOTE: Pins not used for interrupts can be omitted from callbacks array to 174* reduce memory usage (if placed at end of gpioPinConfigs array). 175*/ 176GPIO_CallbackFxn gpioCallbackFunctions []= { 177NULL ,/* EK_TM4C123GXL_GPIO_SW1 */ 178NULL /* EK_TM4C123GXL_GPIO_SW2 */ 179}; 180 181/* The device-specific GPIO_config structure */ 182const GPIOTiva_Config GPIOTiva_config = { 183 .pinConfigs = (GPIO_PinConfig * )gpioPinConfigs , 184 .callbacks = (GPIO_CallbackFxn * )gpioCallbackFunctions , 185 .numberOfPinConfigs = sizeof (gpioPinConfigs )/sizeof (GPIO_PinConfig ), 186 .numberOfCallbacks = sizeof (gpioCallbackFunctions )/sizeof (GPIO_CallbackFxn ), 187 .intPriority = (~0 ) 188}; 189 190/* 191* ======== EK_TM4C123GXL_initGPIO ======== 192*/ 193void EK_TM4C123GXL_initGPIO (void ) 194{ 195/* EK_TM4C123GXL_GPIO_SW2 - PF0 requires unlocking before configuration */ 196HWREG (GPIO_PORTF_BASE + GPIO_O_LOCK )= GPIO_LOCK_KEY ; 197HWREG (GPIO_PORTF_BASE + GPIO_O_CR ) |=GPIO_PIN_0 ; 198GPIOPinTypeGPIOInput (GPIO_PORTF_BASE ,GPIO_PIN_0 ); 199 200/* Initialize peripheral and pins */ 201GPIO_init (); 202} 203 204/* 205* =============================== I2C =============================== 206*/ 207/* Place into subsections to allow the TI linker to remove items properly */ 208#if defined(__TI_COMPILER_VERSION__ ) 209#pragma DATA_SECTION(I2C_config, ".const:I2C_config") 210#pragma DATA_SECTION(i2cTivaHWAttrs, ".const:i2cTivaHWAttrs") 211#endif 212 213#include <ti/drivers/I2C.h> 214#include <ti/drivers/i2c/I2CTiva.h> 215 216I2CTiva_Object i2cTivaObjects [EK_TM4C123GXL_I2CCOUNT ]; 217 218const I2CTiva_HWAttrs i2cTivaHWAttrs [EK_TM4C123GXL_I2CCOUNT ]= { 219 { 220 .baseAddr = I2C1_BASE , 221 .intNum = INT_I2C1 , 222 .intPriority = (~0 ) 223 }, 224 { 225 .baseAddr = I2C3_BASE , 226 .intNum = INT_I2C3 , 227 .intPriority = (~0 ) 228 }, 229}; 230 231const I2C_Config I2C_config []= { 232 { 233 .fxnTablePtr = & I2CTiva_fxnTable , 234 .object = & i2cTivaObjects [0 ], 235 .hwAttrs = & i2cTivaHWAttrs [0 ] 236 }, 237 { 238 .fxnTablePtr = & I2CTiva_fxnTable , 239 .object = & i2cTivaObjects [1 ], 240 .hwAttrs = & i2cTivaHWAttrs [1 ] 241 }, 242 {NULL ,NULL ,NULL } 243}; 244 245/* 246* ======== EK_TM4C123GXL_initI2C ======== 247*/ 248void EK_TM4C123GXL_initI2C (void ) 249{ 250/* I2C1 Init */ 251/* Enable the peripheral */ 252SysCtlPeripheralEnable (SYSCTL_PERIPH_I2C1 ); 253 254/* Configure the appropriate pins to be I2C instead of GPIO. */ 255GPIOPinConfigure (GPIO_PA6_I2C1SCL ); 256GPIOPinConfigure (GPIO_PA7_I2C1SDA ); 257GPIOPinTypeI2CSCL (GPIO_PORTA_BASE ,GPIO_PIN_6 ); 258GPIOPinTypeI2C (GPIO_PORTA_BASE ,GPIO_PIN_7 ); 259 260/* I2C3 Init */ 261/* 262* NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI3 or I2C3. Thus, 263* a conflict occurs when the I2C & SPI drivers are used simultaneously in 264* an application. Modify the pin mux settings in this file and resolve the 265* conflict before running your the application. 266*/ 267/* Enable the peripheral */ 268SysCtlPeripheralEnable (SYSCTL_PERIPH_I2C3 ); 269 270/* Configure the appropriate pins to be I2C instead of GPIO. */ 271GPIOPinConfigure (GPIO_PD0_I2C3SCL ); 272GPIOPinConfigure (GPIO_PD1_I2C3SDA ); 273GPIOPinTypeI2CSCL (GPIO_PORTD_BASE ,GPIO_PIN_0 ); 274GPIOPinTypeI2C (GPIO_PORTD_BASE ,GPIO_PIN_1 ); 275 276/* 277* These GPIOs are connected to PD0 and PD1 and need to be brought into a 278* GPIO input state so they don't interfere with I2C communications. 279*/ 280GPIOPinTypeGPIOInput (GPIO_PORTB_BASE ,GPIO_PIN_6 ); 281GPIOPinTypeGPIOInput (GPIO_PORTB_BASE ,GPIO_PIN_7 ); 282 283I2C_init (); 284} 285 286/* 287* =============================== PWM =============================== 288*/ 289/* Place into subsections to allow the TI linker to remove items properly */ 290#if defined(__TI_COMPILER_VERSION__ ) 291#pragma DATA_SECTION(PWM_config, ".const:PWM_config") 292#pragma DATA_SECTION(pwmTivaHWAttrs, ".const:pwmTivaHWAttrs") 293#endif 294 295#include <ti/drivers/PWM.h> 296#include <ti/drivers/pwm/PWMTiva.h> 297 298PWMTiva_Object pwmTivaObjects [EK_TM4C123GXL_PWMCOUNT ]; 299 300const PWMTiva_HWAttrs pwmTivaHWAttrs [EK_TM4C123GXL_PWMCOUNT ]= { 301 { 302 .baseAddr = PWM1_BASE , 303 .pwmOutput = PWM_OUT_6 , 304 .pwmGenOpts = PWM_GEN_MODE_DOWN |PWM_GEN_MODE_DBG_RUN 305 }, 306 { 307 .baseAddr = PWM1_BASE , 308 .pwmOutput = PWM_OUT_7 , 309 .pwmGenOpts = PWM_GEN_MODE_DOWN |PWM_GEN_MODE_DBG_RUN 310 } 311}; 312 313const PWM_Config PWM_config []= { 314 { 315 .fxnTablePtr = & PWMTiva_fxnTable , 316 .object = & pwmTivaObjects [0 ], 317 .hwAttrs = & pwmTivaHWAttrs [0 ] 318 }, 319 { 320 .fxnTablePtr = & PWMTiva_fxnTable , 321 .object = & pwmTivaObjects [1 ], 322 .hwAttrs = & pwmTivaHWAttrs [1 ] 323 }, 324 {NULL ,NULL ,NULL } 325}; 326 327/* 328* ======== EK_TM4C123GXL_initPWM ======== 329*/ 330void EK_TM4C123GXL_initPWM (void ) 331{ 332/* Enable PWM peripherals */ 333SysCtlPeripheralEnable (SYSCTL_PERIPH_PWM1 ); 334 335/* 336* Enable PWM output on GPIO pins. Board_LED1 and Board_LED2 are now 337* controlled by PWM peripheral - Do not use GPIO APIs. 338*/ 339GPIOPinConfigure (GPIO_PF2_M1PWM6 ); 340GPIOPinConfigure (GPIO_PF3_M1PWM7 ); 341GPIOPinTypePWM (GPIO_PORTF_BASE ,GPIO_PIN_2 |GPIO_PIN_3 ); 342 343PWM_init (); 344} 345 346/* 347* =============================== SDSPI =============================== 348*/ 349/* Place into subsections to allow the TI linker to remove items properly */ 350#if defined(__TI_COMPILER_VERSION__ ) 351#pragma DATA_SECTION(SDSPI_config, ".const:SDSPI_config") 352#pragma DATA_SECTION(sdspiTivaHWattrs, ".const:sdspiTivaHWattrs") 353#endif 354 355#include <ti/drivers/SDSPI.h> 356#include <ti/drivers/sdspi/SDSPITiva.h> 357 358SDSPITiva_Object sdspiTivaObjects [EK_TM4C123GXL_SDSPICOUNT ]; 359 360const SDSPITiva_HWAttrs sdspiTivaHWattrs [EK_TM4C123GXL_SDSPICOUNT ]= { 361 { 362 .baseAddr = SSI2_BASE , 363 364 .portSCK = GPIO_PORTB_BASE , 365 .pinSCK = GPIO_PIN_4 , 366 .portMISO = GPIO_PORTB_BASE , 367 .pinMISO = GPIO_PIN_6 , 368 .portMOSI = GPIO_PORTB_BASE , 369 .pinMOSI = GPIO_PIN_7 , 370 .portCS = GPIO_PORTA_BASE , 371 .pinCS = GPIO_PIN_5 , 372 } 373}; 374 375const SDSPI_Config SDSPI_config []= { 376 { 377 .fxnTablePtr = & SDSPITiva_fxnTable , 378 .object = & sdspiTivaObjects [0 ], 379 .hwAttrs = & sdspiTivaHWattrs [0 ] 380 }, 381 {NULL ,NULL ,NULL } 382}; 383 384/* 385* ======== EK_TM4C123GXL_initSDSPI ======== 386*/ 387void EK_TM4C123GXL_initSDSPI (void ) 388{ 389/* Enable the peripherals used by the SD Card */ 390SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI2 ); 391 392/* Configure pad settings */ 393GPIOPadConfigSet (GPIO_PORTB_BASE , 394GPIO_PIN_4 |GPIO_PIN_7 , 395GPIO_STRENGTH_4MA ,GPIO_PIN_TYPE_STD ); 396 397GPIOPadConfigSet (GPIO_PORTB_BASE , 398GPIO_PIN_6 , 399GPIO_STRENGTH_4MA ,GPIO_PIN_TYPE_STD_WPU ); 400 401GPIOPadConfigSet (GPIO_PORTA_BASE , 402GPIO_PIN_5 , 403GPIO_STRENGTH_4MA ,GPIO_PIN_TYPE_STD ); 404 405GPIOPinConfigure (GPIO_PB4_SSI2CLK ); 406GPIOPinConfigure (GPIO_PB6_SSI2RX ); 407GPIOPinConfigure (GPIO_PB7_SSI2TX ); 408 409/* 410* These GPIOs are connected to PB6 and PB7 and need to be brought into a 411* GPIO input state so they don't interfere with SPI communications. 412*/ 413GPIOPinTypeGPIOInput (GPIO_PORTD_BASE ,GPIO_PIN_0 ); 414GPIOPinTypeGPIOInput (GPIO_PORTD_BASE ,GPIO_PIN_1 ); 415 416SDSPI_init (); 417} 418 419/* 420* =============================== SPI =============================== 421*/ 422/* Place into subsections to allow the TI linker to remove items properly */ 423#if defined(__TI_COMPILER_VERSION__ ) 424#pragma DATA_SECTION(SPI_config, ".const:SPI_config") 425#pragma DATA_SECTION(spiTivaDMAHWAttrs, ".const:spiTivaDMAHWAttrs") 426#endif 427 428#include <ti/drivers/SPI.h> 429#include <ti/drivers/spi/SPITivaDMA.h> 430 431SPITivaDMA_Object spiTivaDMAObjects [EK_TM4C123GXL_SPICOUNT ]; 432 433#if defined(__TI_COMPILER_VERSION__ ) 434#pragma DATA_ALIGN(spiTivaDMAscratchBuf, 32) 435#elif defined(__IAR_SYSTEMS_ICC__ ) 436#pragma data_alignment=32 437#elif defined(__GNUC__ ) 438__attribute__ ((aligned (32 ))) 439#endif 440uint32_t spiTivaDMAscratchBuf [EK_TM4C123GXL_SPICOUNT ]; 441 442const SPITivaDMA_HWAttrs spiTivaDMAHWAttrs [EK_TM4C123GXL_SPICOUNT ]= { 443 { 444 .baseAddr = SSI0_BASE , 445 .intNum = INT_SSI0 , 446 .intPriority = (~0 ), 447 .scratchBufPtr = & spiTivaDMAscratchBuf [0 ], 448 .defaultTxBufValue = 0 , 449 .rxChannelIndex = UDMA_CHANNEL_SSI0RX , 450 .txChannelIndex = UDMA_CHANNEL_SSI0TX , 451 .channelMappingFxn = uDMAChannelAssign , 452 .rxChannelMappingFxnArg = UDMA_CH10_SSI0RX , 453 .txChannelMappingFxnArg = UDMA_CH11_SSI0TX 454 }, 455 { 456 .baseAddr = SSI2_BASE , 457 .intNum = INT_SSI2 , 458 .intPriority = (~0 ), 459 .scratchBufPtr = & spiTivaDMAscratchBuf [1 ], 460 .defaultTxBufValue = 0 , 461 .rxChannelIndex = UDMA_SEC_CHANNEL_UART2RX_12 , 462 .txChannelIndex = UDMA_SEC_CHANNEL_UART2TX_13 , 463 .channelMappingFxn = uDMAChannelAssign , 464 .rxChannelMappingFxnArg = UDMA_CH12_SSI2RX , 465 .txChannelMappingFxnArg = UDMA_CH13_SSI2TX 466 }, 467 { 468 .baseAddr = SSI3_BASE , 469 .intNum = INT_SSI3 , 470 .intPriority = (~0 ), 471 .scratchBufPtr = & spiTivaDMAscratchBuf [2 ], 472 .defaultTxBufValue = 0 , 473 .rxChannelIndex = UDMA_SEC_CHANNEL_TMR2A_14 , 474 .txChannelIndex = UDMA_SEC_CHANNEL_TMR2B_15 , 475 .channelMappingFxn = uDMAChannelAssign , 476 .rxChannelMappingFxnArg = UDMA_CH14_SSI3RX , 477 .txChannelMappingFxnArg = UDMA_CH15_SSI3TX 478 } 479}; 480 481const SPI_Config SPI_config []= { 482 { 483 .fxnTablePtr = & SPITivaDMA_fxnTable , 484 .object = & spiTivaDMAObjects [0 ], 485 .hwAttrs = & spiTivaDMAHWAttrs [0 ] 486 }, 487 { 488 .fxnTablePtr = & SPITivaDMA_fxnTable , 489 .object = & spiTivaDMAObjects [1 ], 490 .hwAttrs = & spiTivaDMAHWAttrs [1 ] 491 }, 492 { 493 .fxnTablePtr = & SPITivaDMA_fxnTable , 494 .object = & spiTivaDMAObjects [2 ], 495 .hwAttrs = & spiTivaDMAHWAttrs [2 ] 496 }, 497 {NULL ,NULL ,NULL }, 498}; 499 500/* 501* ======== EK_TM4C123GXL_initSPI ======== 502*/ 503void EK_TM4C123GXL_initSPI (void ) 504{ 505/* SPI0 */ 506SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI0 ); 507 508/* Need to unlock PF0 */ 509GPIOPinConfigure (GPIO_PA2_SSI0CLK ); 510GPIOPinConfigure (GPIO_PA3_SSI0FSS ); 511GPIOPinConfigure (GPIO_PA4_SSI0RX ); 512GPIOPinConfigure (GPIO_PA5_SSI0TX ); 513 514GPIOPinTypeSSI (GPIO_PORTA_BASE ,GPIO_PIN_2 |GPIO_PIN_3 | 515GPIO_PIN_4 |GPIO_PIN_5 ); 516 517/* SSI2 */ 518SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI2 ); 519 520GPIOPinConfigure (GPIO_PB4_SSI2CLK ); 521GPIOPinConfigure (GPIO_PB5_SSI2FSS ); 522GPIOPinConfigure (GPIO_PB6_SSI2RX ); 523GPIOPinConfigure (GPIO_PB7_SSI2TX ); 524 525GPIOPinTypeSSI (GPIO_PORTB_BASE ,GPIO_PIN_4 |GPIO_PIN_5 | 526GPIO_PIN_6 |GPIO_PIN_7 ); 527 528/* SSI3 */ 529/* 530* NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI3 or I2C3. Thus, 531* a conflict occurs when the I2C & SPI drivers are used simultaneously in 532* an application. Modify the pin mux settings in this file and resolve the 533* conflict before running your the application. 534*/ 535SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI3 ); 536 537GPIOPinConfigure (GPIO_PD0_SSI3CLK ); 538GPIOPinConfigure (GPIO_PD1_SSI3FSS ); 539GPIOPinConfigure (GPIO_PD2_SSI3RX ); 540GPIOPinConfigure (GPIO_PD3_SSI3TX ); 541 542GPIOPinTypeSSI (GPIO_PORTD_BASE ,GPIO_PIN_0 |GPIO_PIN_1 | 543GPIO_PIN_2 |GPIO_PIN_3 ); 544 545EK_TM4C123GXL_initDMA (); 546SPI_init (); 547} 548 549/* 550* =============================== UART =============================== 551*/ 552/* Place into subsections to allow the TI linker to remove items properly */ 553#if defined(__TI_COMPILER_VERSION__ ) 554#pragma DATA_SECTION(UART_config, ".const:UART_config") 555#pragma DATA_SECTION(uartTivaHWAttrs, ".const:uartTivaHWAttrs") 556#endif 557 558#include <ti/drivers/UART.h> 559#if TI_DRIVERS_UART_DMA 560#include <ti/drivers/uart/UARTTivaDMA.h> 561 562UARTTivaDMA_Object uartTivaObjects [EK_TM4C123GXL_UARTCOUNT ]; 563 564const UARTTivaDMA_HWAttrs uartTivaHWAttrs [EK_TM4C123GXL_UARTCOUNT ]= { 565 { 566 .baseAddr = UART0_BASE , 567 .intNum = INT_UART0 , 568 .intPriority = (~0 ), 569 .rxChannelIndex = UDMA_CH8_UART0RX , 570 .txChannelIndex = UDMA_CH9_UART0TX , 571 } 572}; 573 574const UART_Config UART_config []= { 575 { 576 .fxnTablePtr = & UARTTivaDMA_fxnTable , 577 .object = & uartTivaObjects [0 ], 578 .hwAttrs = & uartTivaHWAttrs [0 ] 579 }, 580 {NULL ,NULL ,NULL } 581}; 582#else 583#include <ti/drivers/uart/UARTTiva.h> 584 585UARTTiva_Object uartTivaObjects [EK_TM4C123GXL_UARTCOUNT ]; 586unsigned char uartTivaRingBuffer [EK_TM4C123GXL_UARTCOUNT ][32 ]; 587 588/* UART configuration structure */ 589const UARTTiva_HWAttrs uartTivaHWAttrs [EK_TM4C123GXL_UARTCOUNT ]= { 590 { 591 .baseAddr = UART0_BASE , 592 .intNum = INT_UART0 , 593 .intPriority = (~0 ), 594 .flowControl = UART_FLOWCONTROL_NONE , 595 .ringBufPtr = uartTivaRingBuffer [0 ], 596 .ringBufSize = sizeof (uartTivaRingBuffer [0 ]) 597 } 598}; 599 600const UART_Config UART_config []= { 601 { 602 .fxnTablePtr = & UARTTiva_fxnTable , 603 .object = & uartTivaObjects [0 ], 604 .hwAttrs = & uartTivaHWAttrs [0 ] 605 }, 606 {NULL ,NULL ,NULL } 607}; 608#endif /* TI_DRIVERS_UART_DMA */ 609 610/* 611* ======== EK_TM4C123GXL_initUART ======== 612*/ 613void EK_TM4C123GXL_initUART (void ) 614{ 615/* Enable and configure the peripherals used by the uart. */ 616SysCtlPeripheralEnable (SYSCTL_PERIPH_UART0 ); 617GPIOPinConfigure (GPIO_PA0_U0RX ); 618GPIOPinConfigure (GPIO_PA1_U0TX ); 619GPIOPinTypeUART (GPIO_PORTA_BASE ,GPIO_PIN_0 |GPIO_PIN_1 ); 620 621/* Initialize the UART driver */ 622#if TI_DRIVERS_UART_DMA 623EK_TM4C123GXL_initDMA (); 624#endif 625UART_init (); 626} 627 628/* 629* =============================== USB =============================== 630*/ 631/* 632* ======== EK_TM4C123GXL_initUSB ======== 633* This function just turns on the USB 634*/ 635void EK_TM4C123GXL_initUSB (EK_TM4C123GXL_USBMode usbMode ) 636{ 637/* Enable the USB peripheral and PLL */ 638SysCtlPeripheralEnable (SYSCTL_PERIPH_USB0 ); 639SysCtlUSBPLLEnable (); 640 641/* Setup pins for USB operation */ 642GPIOPinTypeUSBAnalog (GPIO_PORTD_BASE ,GPIO_PIN_4 |GPIO_PIN_5 ); 643 644if (usbMode == EK_TM4C123GXL_USBHOST ) { 645System_abort ("USB host not supported\n" ); 646 } 647} 648 649/* 650* =============================== Watchdog =============================== 651*/ 652/* Place into subsections to allow the TI linker to remove items properly */ 653#if defined(__TI_COMPILER_VERSION__ ) 654#pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config") 655#pragma DATA_SECTION(watchdogTivaHWAttrs, ".const:watchdogTivaHWAttrs") 656#endif 657 658#include <ti/drivers/Watchdog.h> 659#include <ti/drivers/watchdog/WatchdogTiva.h> 660 661WatchdogTiva_Object watchdogTivaObjects [EK_TM4C123GXL_WATCHDOGCOUNT ]; 662 663const WatchdogTiva_HWAttrs watchdogTivaHWAttrs [EK_TM4C123GXL_WATCHDOGCOUNT ]= { 664 { 665 .baseAddr = WATCHDOG0_BASE , 666 .intNum = INT_WATCHDOG , 667 .intPriority = (~0 ), 668 .reloadValue = 80000000 // 1 second period at default CPU clock freq 669 }, 670}; 671 672const Watchdog_Config Watchdog_config []= { 673 { 674 .fxnTablePtr = & WatchdogTiva_fxnTable , 675 .object = & watchdogTivaObjects [0 ], 676 .hwAttrs = & watchdogTivaHWAttrs [0 ] 677 }, 678 {NULL ,NULL ,NULL }, 679}; 680 681/* 682* ======== EK_TM4C123GXL_initWatchdog ======== 683* 684* NOTE: To use the other watchdog timer with base address WATCHDOG1_BASE, 685* an additional function call may need be made to enable PIOSC. Enabling 686* WDOG1 does not do this. Enabling another peripheral that uses PIOSC 687* such as ADC0 or SSI0, however, will do so. Example: 688* 689* SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); 690* SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG1); 691* 692* See the following forum post for more information: 693* http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/p/176487/654390.aspx#654390 694*/ 695void EK_TM4C123GXL_initWatchdog (void ) 696{ 697/* Enable peripherals used by Watchdog */ 698SysCtlPeripheralEnable (SYSCTL_PERIPH_WDOG0 ); 699 700Watchdog_init (); 701} 702 703/* 704* =============================== WiFi =============================== 705*/ 706/* Place into subsections to allow the TI linker to remove items properly */ 707#if defined(__TI_COMPILER_VERSION__ ) 708#pragma DATA_SECTION(WiFi_config, ".const:WiFi_config") 709#pragma DATA_SECTION(wiFiCC3100HWAttrs, ".const:wiFiCC3100HWAttrs") 710#endif 711 712#include <ti/drivers/WiFi.h> 713#include <ti/drivers/wifi/WiFiCC3100.h> 714 715WiFiCC3100_Object wiFiCC3100Objects [EK_TM4C123GXL_WIFICOUNT ]; 716 717const WiFiCC3100_HWAttrs wiFiCC3100HWAttrs [EK_TM4C123GXL_WIFICOUNT ]= { 718 { 719 .irqPort = GPIO_PORTB_BASE , 720 .irqPin = GPIO_PIN_2 , 721 .irqIntNum = INT_GPIOB , 722 723 .csPort = GPIO_PORTE_BASE , 724 .csPin = GPIO_PIN_0 , 725 726 .enPort = GPIO_PORTE_BASE , 727 .enPin = GPIO_PIN_4 728 } 729}; 730 731const WiFi_Config WiFi_config []= { 732 { 733 .fxnTablePtr = & WiFiCC3100_fxnTable , 734 .object = & wiFiCC3100Objects [0 ], 735 .hwAttrs = & wiFiCC3100HWAttrs [0 ] 736 }, 737 {NULL ,NULL ,NULL }, 738}; 739 740/* 741* ======== EK_TM4C123GXL_initWiFi ======== 742*/ 743void EK_TM4C123GXL_initWiFi (void ) 744{ 745/* Configure EN & CS pins to disable CC3100 */ 746GPIOPinTypeGPIOOutput (GPIO_PORTE_BASE ,GPIO_PIN_0 |GPIO_PIN_4 ); 747GPIOPinWrite (GPIO_PORTE_BASE ,GPIO_PIN_0 ,GPIO_PIN_0 ); 748GPIOPinWrite (GPIO_PORTE_BASE ,GPIO_PIN_4 ,0 ); 749 750/* Configure SSI2 for CC3100 */ 751SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI2 ); 752GPIOPinConfigure (GPIO_PB4_SSI2CLK ); 753GPIOPinConfigure (GPIO_PB6_SSI2RX ); 754GPIOPinConfigure (GPIO_PB7_SSI2TX ); 755GPIOPinTypeSSI (GPIO_PORTB_BASE ,GPIO_PIN_4 |GPIO_PIN_6 |GPIO_PIN_7 ); 756 757/* Configure IRQ pin */ 758GPIOPinTypeGPIOInput (GPIO_PORTB_BASE ,GPIO_PIN_2 ); 759GPIOPadConfigSet (GPIO_PORTB_BASE ,GPIO_PIN_2 ,GPIO_STRENGTH_2MA , 760GPIO_PIN_TYPE_STD_WPD ); 761GPIOIntTypeSet (GPIO_PORTB_BASE ,GPIO_PIN_2 ,GPIO_RISING_EDGE ); 762 763SPI_init (); 764EK_TM4C123GXL_initDMA (); 765 766WiFi_init (); 767}