Part Number: TM4C1294NCPDT
Tool/software: TI-RTOS
Respected sir,
Please reply as soon as possible. Its urgent.
I am trying to integrate tcpecho example into my code. But as soon as i add Globals in rtos for NDK, it starts giving exception at following line.
SSIDataPut(SSI2_BASE, adcTxBuffer[0]);
while(SSIDataGetNonBlocking(SSI2_BASE, &adcresult))
{
}
Without NDK my code works perfectly fine. As soon as i try to add NDK it start creating problem. I have attache snaps of problem.
Also i have attached some important files.
/*
* Copyright (c) 2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== EK_TM4C1294XL.c ========
* This file is responsible for setting up the board specific items for the
* EK_TM4C1294XL board.
*/
#include <stdint.h>
#include <stdbool.h>
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <inc/hw_ints.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <inc/hw_gpio.h>
#include <driverlib/flash.h>
#include <driverlib/gpio.h>
#include <driverlib/i2c.h>
#include <driverlib/pin_map.h>
#include <driverlib/pwm.h>
#include <driverlib/ssi.h>
#include <driverlib/sysctl.h>
#include <driverlib/uart.h>
#include <driverlib/qei.h>
#include <driverlib/epi.h>
#include <driverlib/can.h>
#include <driverlib/udma.h>
#include "EK_TM4C1294XL.h"
#ifndef TI_DRIVERS_UART_DMA
#define TI_DRIVERS_UART_DMA 0
#endif
#ifndef TI_EXAMPLES_PPP
#define TI_EXAMPLES_PPP 0
#else
/* prototype for NIMU init function */
extern int USBSerialPPP_NIMUInit();
#endif
/*
* =============================== DMA ===============================
*/
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN(dmaControlTable, 1024)
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=1024
#elif defined(__GNUC__)
__attribute__ ((aligned (1024)))
#endif
static tDMAControlTable dmaControlTable[32];
static bool dmaInitialized = false;
/* Hwi_Struct used in the initDMA Hwi_construct call */
static Hwi_Struct dmaHwiStruct;
/* Hwi_Struct used in the usbBusFault Hwi_construct call */
static Hwi_Struct usbBusFaultHwiStruct;
/*
* ======== dmaErrorHwi ========
*/
static Void dmaErrorHwi(UArg arg)
{
System_printf("DMA error code: %d\n", uDMAErrorStatusGet());
uDMAErrorStatusClear();
System_abort("DMA error!!");
}
/*
* ======== EK_TM4C1294XL_usbBusFaultHwi ========
*/
static Void EK_TM4C1294XL_usbBusFaultHwi(UArg arg)
{
/*
* This function should be modified to appropriately manage handle
* a USB bus fault.
*/
System_printf("USB bus fault detected.");
Hwi_clearInterrupt(INT_GPIOQ4);
System_abort("USB error!!");
}
/*
* ======== EK_TM4C1294XL_initDMA ========
*/
void EK_TM4C1294XL_initDMA(void)
{
Error_Block eb;
Hwi_Params hwiParams;
if (!dmaInitialized) {
Error_init(&eb);
Hwi_Params_init(&hwiParams);
Hwi_construct(&(dmaHwiStruct), INT_UDMAERR, dmaErrorHwi,
&hwiParams, &eb);
if (Error_check(&eb)) {
System_abort("Couldn't construct DMA error hwi");
}
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
uDMAEnable();
uDMAControlBaseSet(dmaControlTable);
dmaInitialized = true;
}
}
/*
* =============================== General ===============================
*/
/*
* ======== EK_TM4C1294XL_initGeneral ========
*/
void EK_TM4C1294XL_initGeneral(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOT);
}
/*
* =============================== EMAC ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(EMAC_config, ".const:EMAC_config")
#pragma DATA_SECTION(emacHWAttrs, ".const:emacHWAttrs")
#pragma DATA_SECTION(NIMUDeviceTable, ".data:NIMUDeviceTable")
#endif
#include <ti/drivers/EMAC.h>
#include <ti/drivers/emac/EMACSnow.h>
/*
* Required by the Networking Stack (NDK). This array must be NULL terminated.
* This can be removed if NDK is not used.
* Double curly braces are needed to avoid GCC bug #944572
* https://bugs.launchpad.net/gcc-linaro/+bug/944572
*/
NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[2] = {
{
#if TI_EXAMPLES_PPP
/* Use PPP driver for PPP example only */
.init = USBSerialPPP_NIMUInit
#else
/* Default: use Ethernet driver */
.init = EMACSnow_NIMUInit
#endif
},
{NULL}
};
EMACSnow_Object emacObjects[EK_TM4C1294XL_EMACCOUNT];
/*
* EMAC configuration structure
* Set user/company specific MAC octates. The following sets the address
* to ff-ff-ff-ff-ff-ff. Users need to change this to make the label on
* their boards.
*/
unsigned char macAddress[6] = {0x00, 0x1a, 0xb6, 0x02, 0xc8, 0x5b};
const EMACSnow_HWAttrs emacHWAttrs[EK_TM4C1294XL_EMACCOUNT] = {
{
.baseAddr = EMAC0_BASE,
.intNum = INT_EMAC0,
.intPriority = (~0),
.macAddress = macAddress
}
};
const EMAC_Config EMAC_config[] = {
{
.fxnTablePtr = &EMACSnow_fxnTable,
.object = &emacObjects[0],
.hwAttrs = &emacHWAttrs[0]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initEMAC ========
*/
void EK_TM4C1294XL_initEMAC(void)
{
uint32_t ulUser0, ulUser1;
/* Get the MAC address */
FlashUserGet(&ulUser0, &ulUser1);
if ((ulUser0 != 0xffffffff) && (ulUser1 != 0xffffffff)) {
System_printf("Using MAC address in flash\n");
/*
* Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
* address needed to program the hardware registers, then program the MAC
* address into the Ethernet Controller registers.
*/
macAddress[0] = ((ulUser0 >> 0) & 0xff);
macAddress[1] = ((ulUser0 >> 8) & 0xff);
macAddress[2] = ((ulUser0 >> 16) & 0xff);
macAddress[3] = ((ulUser1 >> 0) & 0xff);
macAddress[4] = ((ulUser1 >> 8) & 0xff);
macAddress[5] = ((ulUser1 >> 16) & 0xff);
}
else if (macAddress[0] == 0xff && macAddress[1] == 0xff &&
macAddress[2] == 0xff && macAddress[3] == 0xff &&
macAddress[4] == 0xff && macAddress[5] == 0xff) {
System_abort("Change the macAddress variable to match your boards MAC sticker");
}
GPIOPinConfigure(GPIO_PF0_EN0LED0); /* EK_TM4C1294XL_USR_D3 */
GPIOPinConfigure(GPIO_PF4_EN0LED1); /* EK_TM4C1294XL_USR_D4 */
GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
/* Once EMAC_init is called, EMAC_config cannot be changed */
EMAC_init();
}
/*
* =============================== GPIO ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(GPIOTiva_config, ".const:GPIOTiva_config")
#endif
#include <ti/drivers/GPIO.h>
#include <ti/drivers/gpio/GPIOTiva.h>
/*
* Array of Pin configurations
* NOTE: The order of the pin configurations must coincide with what was
* defined in EK_TM4C1294XL.h
* NOTE: Pins not used for interrupts should be placed at the end of the
* array. Callback entries can be omitted from callbacks array to
* reduce memory usage.
*/
GPIO_PinConfig gpioPinConfigs[] = {
/* Input pins */
/* EK_TM4C1294XL_USR_SW1 */
GPIOTiva_PL_6 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_HIGH, // GPIO_CFG_IN_INT_HIGH
// GPIOTiva_PJ_0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
/* EK_TM4C1294XL_USR_SW2 */
GPIOTiva_PJ_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
/* Output pins */
/* EK_TM4C1294XL_USR_D1 */
GPIOTiva_PK_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* EK_TM4C1294XL_USR_D2 */
GPIOTiva_PP_3 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
//****************************************************************************
//DAC CS
GPIOTiva_PQ_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
//ADC INT
GPIOTiva_PP_2 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING,
//RS485
GPIOTiva_PE_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
//LDAC
GPIOTiva_PE_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
//GPIO
GPIOTiva_PN_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
//ADC CONVST
GPIOTiva_PE_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
};
/*
* Array of callback function pointers
* NOTE: The order of the pin configurations must coincide with what was
* defined in EK_TM4C1294XL.h
* NOTE: Pins not used for interrupts can be omitted from callbacks array to
* reduce memory usage (if placed at end of gpioPinConfigs array).
*/
GPIO_CallbackFxn gpioCallbackFunctions[] = {
NULL, /* EK_TM4C1294XL_USR_SW1 */
NULL /* EK_TM4C1294XL_USR_SW2 */
};
/* The device-specific GPIO_config structure */
const GPIOTiva_Config GPIOTiva_config = {
.pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
.callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
.numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
.numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
.intPriority = (~0)
};
/*
* ======== EK_TM4C1294XL_initGPIO ========
*/
void EK_TM4C1294XL_initGPIO(void)
{
/* Initialize peripheral and pins */
GPIO_init();
}
/*
* =============================== I2C ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(I2C_config, ".const:I2C_config")
#pragma DATA_SECTION(i2cTivaHWAttrs, ".const:i2cTivaHWAttrs")
#endif
#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CTiva.h>
I2CTiva_Object i2cTivaObjects[EK_TM4C1294XL_I2CCOUNT];
const I2CTiva_HWAttrs i2cTivaHWAttrs[EK_TM4C1294XL_I2CCOUNT] = {
{
.baseAddr = I2C2_BASE,
.intNum = INT_I2C2,
.intPriority = (~0)
},
{
.baseAddr = I2C8_BASE,
.intNum = INT_I2C8,
.intPriority = (~0)
}
};
const I2C_Config I2C_config[] = {
{
.fxnTablePtr = &I2CTiva_fxnTable,
.object = &i2cTivaObjects[0],
.hwAttrs = &i2cTivaHWAttrs[0]
},
{
.fxnTablePtr = &I2CTiva_fxnTable,
.object = &i2cTivaObjects[1],
.hwAttrs = &i2cTivaHWAttrs[1]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initI2C ========
*/
void EK_TM4C1294XL_initI2C(void)
{
/* I2C7 Init */
/*
* NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI2 or I2C7. Thus,
* a conflict occurs when the I2C & SPI drivers are used simultaneously in
* an application. Modify the pin mux settings in this file and resolve the
* conflict before running your the application.
*/
/* Enable the peripheral */
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);
/* Configure the appropriate pins to be I2C instead of GPIO. */
GPIOPinConfigure(GPIO_PN5_I2C2SCL);
GPIOPinConfigure(GPIO_PL0_I2C2SDA);
GPIOPinTypeI2CSCL(GPIO_PORTN_BASE, GPIO_PIN_5);
GPIOPinTypeI2C(GPIO_PORTL_BASE, GPIO_PIN_0);
// /* I2C8 Init */
// /* Enable the peripheral */
// SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C8);
//
// /* Configure the appropriate pins to be I2C instead of GPIO. */
// GPIOPinConfigure(GPIO_PA2_I2C8SCL);
// GPIOPinConfigure(GPIO_PA3_I2C8SDA);
// GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_2);
// GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_3);
I2C_init();
}
/*
* =============================== PWM ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(PWM_config, ".const:PWM_config")
#pragma DATA_SECTION(pwmTivaHWAttrs, ".const:pwmTivaHWAttrs")
#endif
#include <ti/drivers/PWM.h>
#include <ti/drivers/pwm/PWMTiva.h>
PWMTiva_Object pwmTivaObjects[EK_TM4C1294XL_PWMCOUNT];
const PWMTiva_HWAttrs pwmTivaHWAttrs[EK_TM4C1294XL_PWMCOUNT] = {
{
.baseAddr = PWM0_BASE,
.pwmOutput = PWM_OUT_2,
.pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
},
{
.baseAddr = PWM0_BASE,
.pwmOutput = PWM_OUT_3,
.pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
}
};
const PWM_Config PWM_config[] = {
{
.fxnTablePtr = &PWMTiva_fxnTable,
.object = &pwmTivaObjects[0],
.hwAttrs = &pwmTivaHWAttrs[0]
},
{
.fxnTablePtr = &PWMTiva_fxnTable,
.object = &pwmTivaObjects[1],
.hwAttrs = &pwmTivaHWAttrs[1]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initPWM ========
*/
void EK_TM4C1294XL_initPWM(void)
{
/* Enable PWM peripherals */
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
/*
* Enable PWM output on GPIO pins. PWM output is connected to an Ethernet
* LED on the development board (D4). The PWM configuration
* below will disable Ethernet functionality.
*/
GPIOPinConfigure(GPIO_PF2_M0PWM2);
GPIOPinConfigure(GPIO_PF3_M0PWM3);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
PWM_init();
}
/*
* =============================== SDSPI ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(SDSPI_config, ".const:SDSPI_config")
#pragma DATA_SECTION(sdspiTivaHWattrs, ".const:sdspiTivaHWattrs")
#endif
#include <ti/drivers/SDSPI.h>
#include <ti/drivers/sdspi/SDSPITiva.h>
SDSPITiva_Object sdspiTivaObjects[EK_TM4C1294XL_SDSPICOUNT];
const SDSPITiva_HWAttrs sdspiTivaHWattrs[EK_TM4C1294XL_SDSPICOUNT] = {
{
.baseAddr = SSI2_BASE,
.portSCK = GPIO_PORTD_BASE,
.pinSCK = GPIO_PIN_3,
.portMISO = GPIO_PORTD_BASE,
.pinMISO = GPIO_PIN_0,
.portMOSI = GPIO_PORTD_BASE,
.pinMOSI = GPIO_PIN_1,
.portCS = GPIO_PORTC_BASE,
.pinCS = GPIO_PIN_7,
},
{
.baseAddr = SSI3_BASE,
.portSCK = GPIO_PORTQ_BASE,
.pinSCK = GPIO_PIN_0,
.portMISO = GPIO_PORTQ_BASE,
.pinMISO = GPIO_PIN_3,
.portMOSI = GPIO_PORTQ_BASE,
.pinMOSI = GPIO_PIN_2,
.portCS = GPIO_PORTP_BASE,
.pinCS = GPIO_PIN_4,
}
};
const SDSPI_Config SDSPI_config[] = {
{
.fxnTablePtr = &SDSPITiva_fxnTable,
.object = &sdspiTivaObjects[0],
.hwAttrs = &sdspiTivaHWattrs[0]
},
{
.fxnTablePtr = &SDSPITiva_fxnTable,
.object = &sdspiTivaObjects[1],
.hwAttrs = &sdspiTivaHWattrs[1]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initSDSPI ========
*/
void EK_TM4C1294XL_initSDSPI(void)
{
/* SDSPI0 configuration */
/* Enable the peripherals used by the SD Card */
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
/* Configure pad settings */
GPIOPadConfigSet(GPIO_PORTD_BASE,
GPIO_PIN_3 | GPIO_PIN_1,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTD_BASE,
GPIO_PIN_0,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(GPIO_PORTC_BASE,
GPIO_PIN_7,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
/* SDSPI1 configuration */
/* Enable the peripherals used by the SD Card */
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
/* Configure pad settings */
GPIOPadConfigSet(GPIO_PORTQ_BASE,
GPIO_PIN_0 | GPIO_PIN_2,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTQ_BASE,
GPIO_PIN_3,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(GPIO_PORTP_BASE,
GPIO_PIN_4,
GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
GPIOPinConfigure(GPIO_PQ0_SSI3CLK);
GPIOPinConfigure(GPIO_PQ3_SSI3XDAT1);
GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0);
/*
* These GPIOs are connected to PA2 and PA3 and need to be brought into a
* GPIO input state so they don't interfere with SPI communications.
*/
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2);
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_3);
SDSPI_init();
}
/*
* =============================== SPI ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(SPI_config, ".const:SPI_config")
#pragma DATA_SECTION(spiTivaDMAHWAttrs, ".const:spiTivaDMAHWAttrs")
#endif
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPITivaDMA.h>
SPITivaDMA_Object spiTivaDMAObjects[EK_TM4C1294XL_SPICOUNT];
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN(spiTivaDMAscratchBuf, 32)
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=32
#elif defined(__GNUC__)
__attribute__ ((aligned (32)))
#endif
uint32_t spiTivaDMAscratchBuf[EK_TM4C1294XL_SPICOUNT];
const SPITivaDMA_HWAttrs spiTivaDMAHWAttrs[EK_TM4C1294XL_SPICOUNT] = {
{
.baseAddr = SSI2_BASE,
.intNum = INT_SSI2,
.intPriority = (~0),
.scratchBufPtr = &spiTivaDMAscratchBuf[0],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_SEC_CHANNEL_UART2RX_12,
.txChannelIndex = UDMA_SEC_CHANNEL_UART2TX_13,
.channelMappingFxn = uDMAChannelAssign,
.rxChannelMappingFxnArg = UDMA_CH12_SSI2RX,
.txChannelMappingFxnArg = UDMA_CH13_SSI2TX
},
{
.baseAddr = SSI3_BASE,
.intNum = INT_SSI3,
.intPriority = (~0),
.scratchBufPtr = &spiTivaDMAscratchBuf[1],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_SEC_CHANNEL_TMR2A_14,
.txChannelIndex = UDMA_SEC_CHANNEL_TMR2B_15,
.channelMappingFxn = uDMAChannelAssign,
.rxChannelMappingFxnArg = UDMA_CH14_SSI3RX,
.txChannelMappingFxnArg = UDMA_CH15_SSI3TX
},
{
.baseAddr = SSI0_BASE,
.intNum = INT_SSI0,
.intPriority = (~0),
.scratchBufPtr = &spiTivaDMAscratchBuf[2],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_SEC_CHANNEL_SSI1RX,
.txChannelIndex = UDMA_SEC_CHANNEL_SSI1TX,
.channelMappingFxn = uDMAChannelAssign,
.rxChannelMappingFxnArg = UDMA_CH10_SSI0RX,
.txChannelMappingFxnArg = UDMA_CH11_SSI0TX
},
{
.baseAddr = SSI1_BASE,
.intNum = INT_SSI1,
.intPriority = (~0),
.scratchBufPtr = &spiTivaDMAscratchBuf[3],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_SEC_CHANNEL_ADC10,
.txChannelIndex = UDMA_SEC_CHANNEL_ADC11,
.channelMappingFxn = uDMAChannelAssign,
.rxChannelMappingFxnArg = UDMA_CH24_SSI1RX,
.txChannelMappingFxnArg = UDMA_CH25_SSI1TX
}
};
const SPI_Config SPI_config[] = {
{
.fxnTablePtr = &SPITivaDMA_fxnTable,
.object = &spiTivaDMAObjects[0],
.hwAttrs = &spiTivaDMAHWAttrs[0]
},
{
.fxnTablePtr = &SPITivaDMA_fxnTable,
.object = &spiTivaDMAObjects[1],
.hwAttrs = &spiTivaDMAHWAttrs[1]
},
{
.fxnTablePtr = &SPITivaDMA_fxnTable,
.object = &spiTivaDMAObjects[2],
.hwAttrs = &spiTivaDMAHWAttrs[2]
},
{
.fxnTablePtr = &SPITivaDMA_fxnTable,
.object = &spiTivaDMAObjects[3],
.hwAttrs = &spiTivaDMAHWAttrs[3]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initSPI ========
*/
void EK_TM4C1294XL_initSPI(void)
{
/* SSI2 */
/*
* NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI2 or I2C7. Thus,
* a conflict occurs when the I2C & SPI drivers are used simultaneously in
* an application. Modify the pin mux settings in this file and resolve the
* conflict before running your the application.
*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD2_SSI2FSS);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
GPIO_PIN_2 | GPIO_PIN_3);
// GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_2);
// GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, 4);
/* SSI3 */
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
GPIOPinConfigure(GPIO_PQ0_SSI3CLK);
//GPIOPinConfigure(GPIO_PQ1_SSI3FSS);
GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0);
GPIOPinConfigure(GPIO_PQ3_SSI3XDAT1);
GPIOPinTypeSSI(GPIO_PORTQ_BASE, GPIO_PIN_0 |GPIO_PIN_2 | GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE,GPIO_PIN_1);
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1,2);
//********************************SSI0*************************************************************************
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5);
//********************************SSI1*************************************************************************
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
GPIOPinConfigure(GPIO_PB5_SSI1CLK);
GPIOPinConfigure(GPIO_PB4_SSI1FSS);
GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);
GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 |GPIO_PIN_5);
EK_TM4C1294XL_initDMA();
SPI_init();
}
//********************************************************************************
//********************************************************************************
//********************************************************************************
/*
* =============================== QEI ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(QEI_config, ".const:QEI_config")
#pragma DATA_SECTION(qeiTivaHWAttrs, ".const:qeiTivaHWAttrs")
#endif
#include <ti/drivers/QEI.h>
#include <ti/drivers/qei/QEITiva.h>
QEITiva_Object qeiTivaObjects[EK_TM4C1294XL_QEICOUNT];
const QEITiva_HWAttrs qeiTivaHWAttrs[EK_TM4C1294XL_QEICOUNT] = {
{
.baseAddr = QEI0_BASE,
.intNum = INT_QEI0
// .pwmOutput = PWM_OUT_0,
// .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
}
};
const QEI_Config QEI_config[] = {
{
.fxnTablePtr = &QEITiva_fxnTable,
.object = &qeiTivaObjects[0],
.hwAttrs = &qeiTivaHWAttrs[0]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initPWM ========
*/
void EK_TM4C1294XL_initQEI(void)
{
// PL2 PHB0
// PL3 IDX0
// PL1 PHA0
// Enable the QEI0 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0);
// For this example QEI is used with PortL.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
// Configure the GPIO pin muxing to select QEI functions for these pins.
GPIOPinConfigure(GPIO_PL1_PHA0);
GPIOPinConfigure(GPIO_PL2_PHB0);
GPIOPinConfigure(GPIO_PL3_IDX0);
// Configure the QEI function for this pin.
GPIOPinTypeQEI(GPIO_PORTL_BASE, GPIO_PIN_1);
GPIOPinTypeQEI(GPIO_PORTL_BASE, GPIO_PIN_2);
GPIOPinTypeQEI(GPIO_PORTL_BASE, GPIO_PIN_3);
/* Initialize the QEI driver */
QEI_init();
}
//***************************************************************************************
//***************************************************************************************
/*
* =============================== EPI ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(EPI_config, ".const:EPI_config")
#pragma DATA_SECTION(epiTivaHWAttrs, ".const:epiTivaHWAttrs")
#endif
#include <ti/drivers/EPI.h>
#include <ti/drivers/epi/EPITiva.h>
EPITiva_Object epiTivaObjects[EK_TM4C1294XL_EPICOUNT];
const EPITiva_HWAttrs epiTivaHWAttrs[EK_TM4C1294XL_EPICOUNT] = {
{
.baseAddr = EPI0_BASE,
.intNum = INT_EPI0
// .pwmOutput = PWM_OUT_0,
// .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
}
};
const EPI_Config EPI_config[] = {
{
.fxnTablePtr = &EPITiva_fxnTable,
.object = &epiTivaObjects[0],
.hwAttrs = &epiTivaHWAttrs[0]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initPWM ========
*/
void EK_TM4C1294XL_initEPI(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EPI0)) //wait for it to be ready
{
}
GPIOPinConfigure(GPIO_PH0_EPI0S0);
GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_0); //D0
GPIOPinConfigure(GPIO_PH1_EPI0S1);
GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_1); //D1
GPIOPinConfigure(GPIO_PH2_EPI0S2);
GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_2); //D2
GPIOPinConfigure(GPIO_PH3_EPI0S3);
GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_3); //D3
GPIOPinConfigure(GPIO_PC7_EPI0S4);
GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_7); //D4
GPIOPinConfigure(GPIO_PC6_EPI0S5);
GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_6); //D5
GPIOPinConfigure(GPIO_PC5_EPI0S6);
GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_5); //D6
GPIOPinConfigure(GPIO_PC4_EPI0S7);
GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_4); //D7
GPIOPinConfigure(GPIO_PA6_EPI0S8);
GPIOPinTypeEPI(GPIO_PORTA_BASE, GPIO_PIN_6); //D8
GPIOPinConfigure(GPIO_PA7_EPI0S9);
GPIOPinTypeEPI(GPIO_PORTA_BASE, GPIO_PIN_7); //D9
GPIOPinConfigure(GPIO_PG1_EPI0S10);
GPIOPinTypeEPI(GPIO_PORTG_BASE, GPIO_PIN_1); //D10
GPIOPinConfigure(GPIO_PG0_EPI0S11);
GPIOPinTypeEPI(GPIO_PORTG_BASE, GPIO_PIN_0); //D11
GPIOPinConfigure(GPIO_PM3_EPI0S12);
GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_3); //D12
GPIOPinConfigure(GPIO_PM2_EPI0S13);
GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_2); //D13
GPIOPinConfigure(GPIO_PM1_EPI0S14);
GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_1); //D14
GPIOPinConfigure(GPIO_PM0_EPI0S15);
GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_0); //D15
GPIOPinConfigure(GPIO_PK7_EPI0S24);
GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_7); //A0 //A8
GPIOPinConfigure(GPIO_PK6_EPI0S25);
GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_6); //A1 //A9
GPIOPinConfigure(GPIO_PL4_EPI0S26);
GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_4); //A2//A10
GPIOPinConfigure(GPIO_PB2_EPI0S27);
GPIOPinTypeEPI(GPIO_PORTB_BASE, GPIO_PIN_2); //A3//A11
GPIOPinConfigure(GPIO_PB3_EPI0S28);
GPIOPinTypeEPI(GPIO_PORTB_BASE, GPIO_PIN_3); //WR//RDn
GPIOPinConfigure(GPIO_PN2_EPI0S29);
GPIOPinTypeEPI(GPIO_PORTN_BASE, GPIO_PIN_2); //RD//WRn
GPIOPinConfigure(GPIO_PN3_EPI0S30);
GPIOPinTypeEPI(GPIO_PORTN_BASE, GPIO_PIN_3); //FSS//ALE
GPIOPinConfigure(GPIO_PK5_EPI0S31);
GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_5); //CLK//CLK
/* Initialize the EPI driver */
EPI_init();
}
//***************************************************************************************
//***************************************************************************************
/*
* =============================== CAN ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(CAN_config, ".const:CAN_config")
#pragma DATA_SECTION(canTivaHWAttrs, ".const:canTivaHWAttrs")
#endif
#include <ti/drivers/CAN.h>
#include <ti/drivers/can/CANTiva.h>
CANTiva_Object canTivaObjects[EK_TM4C1294XL_CANCOUNT];
const CANTiva_HWAttrs canTivaHWAttrs[EK_TM4C1294XL_CANCOUNT] = {
{
.baseAddr = CAN1_BASE,
.intNum = INT_CAN1
// .pwmOutput = PWM_OUT_0,
// .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
}
};
const CAN_Config CAN_config[] = {
{
.fxnTablePtr = &CANTiva_fxnTable,
.object = &canTivaObjects[0],
.hwAttrs = &canTivaHWAttrs[0]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initPWM ========
*/
void EK_TM4C1294XL_initCAN(void)
{
// For this example CAN1 is used with RX and TX pins on port B4 and B5.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// Configure the GPIO pin muxing to select CAN1 functions for these pins.
GPIOPinConfigure(GPIO_PB0_CAN1RX);
GPIOPinConfigure(GPIO_PB1_CAN1TX);
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
/* Initialize the QEI driver */
CAN_init();
}
//***************************************************************************************
/*
* =============================== UART ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(UART_config, ".const:UART_config")
#pragma DATA_SECTION(uartTivaHWAttrs, ".const:uartTivaHWAttrs")
#endif
#include <ti/drivers/UART.h>
#if TI_DRIVERS_UART_DMA
#include <ti/drivers/uart/UARTTivaDMA.h>
UARTTivaDMA_Object uartTivaObjects[EK_TM4C1294XL_UARTCOUNT];
const UARTTivaDMA_HWAttrs uartTivaHWAttrs[EK_TM4C1294XL_UARTCOUNT] = {
{
.baseAddr = UART0_BASE,
.intNum = INT_UART0,
.intPriority = (~0),
.rxChannelIndex = UDMA_CH8_UART0RX,
.txChannelIndex = UDMA_CH9_UART0TX,
},
{
.baseAddr = UART6_BASE,
.intNum = INT_UART6,
.intPriority = (~0),
.rxChannelIndex = UDMA_CH8_UART6RX,
.txChannelIndex = UDMA_CH9_UART6TX,
},
{
.baseAddr = UART2_BASE,
.intNum = INT_UART2,
.intPriority = (~0),
.rxChannelIndex = UDMA_CH8_UART2RX,
.txChannelIndex = UDMA_CH9_UART2TX,
}
};
const UART_Config UART_config[] = {
{
.fxnTablePtr = &UARTTivaDMA_fxnTable,
.object = &uartTivaObjects[0],
.hwAttrs = &uartTivaHWAttrs[0]
},
{
.fxnTablePtr = &UARTTivaDMA_fxnTable,
.object = &uartTivaObjects[1],
.hwAttrs = &uartTivaHWAttrs[1]
},
{
.fxnTablePtr = &UARTTivaDMA_fxnTable,
.object = &uartTivaObjects[2],
.hwAttrs = &uartTivaHWAttrs[2]
},
{NULL, NULL, NULL}
};
#else
#include <ti/drivers/uart/UARTTiva.h>
UARTTiva_Object uartTivaObjects[EK_TM4C1294XL_UARTCOUNT];
unsigned char uartTivaRingBuffer[EK_TM4C1294XL_UARTCOUNT][32];
/* UART configuration structure */
const UARTTiva_HWAttrs uartTivaHWAttrs[EK_TM4C1294XL_UARTCOUNT] = {
{
.baseAddr = UART0_BASE,
.intNum = INT_UART0,
.intPriority = (~0),
.flowControl = UART_FLOWCONTROL_NONE,
.ringBufPtr = uartTivaRingBuffer[0],
.ringBufSize = sizeof(uartTivaRingBuffer[0])
},
{
.baseAddr = UART6_BASE,
.intNum = INT_UART6,
.intPriority = (~0),
.flowControl = UART_FLOWCONTROL_NONE,
.ringBufPtr = uartTivaRingBuffer[1],
.ringBufSize = sizeof(uartTivaRingBuffer[1])
},
{
.baseAddr = UART2_BASE,
.intNum = INT_UART2,
.intPriority = (~0),
.flowControl = UART_FLOWCONTROL_NONE,
.ringBufPtr = uartTivaRingBuffer[2],
.ringBufSize = sizeof(uartTivaRingBuffer[2])
}
};
const UART_Config UART_config[] = {
{
.fxnTablePtr = &UARTTiva_fxnTable,
.object = &uartTivaObjects[0],
.hwAttrs = &uartTivaHWAttrs[0]
},
{
.fxnTablePtr = &UARTTiva_fxnTable,
.object = &uartTivaObjects[1],
.hwAttrs = &uartTivaHWAttrs[1]
},
{
.fxnTablePtr = &UARTTiva_fxnTable,
.object = &uartTivaObjects[2],
.hwAttrs = &uartTivaHWAttrs[2]
},
{NULL, NULL, NULL}
};
#endif /* TI_DRIVERS_UART_DMA */
/*
* ======== EK_TM4C1294XL_initUART ========
*/
void EK_TM4C1294XL_initUART(void)
{
/* Enable and configure the peripherals used by the uart. */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
/* Enable and configure the peripherals used by the uart. */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
GPIOPinConfigure(GPIO_PP0_U6RX);
GPIOPinConfigure(GPIO_PP1_U6TX);
GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);
/* Enable and configure the peripherals used by the uart. */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
GPIOPinConfigure(GPIO_PD4_U2RX);
GPIOPinConfigure(GPIO_PD5_U2TX);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
/* Initialize the UART driver */
#if TI_DRIVERS_UART_DMA
EK_TM4C1294XL_initDMA();
#endif
UART_init();
}
/*
* =============================== USB ===============================
*/
/*
* ======== EK_TM4C1294XL_initUSB ========
* This function just turns on the USB
*/
void EK_TM4C1294XL_initUSB(EK_TM4C1294XL_USBMode usbMode)
{
Error_Block eb;
Hwi_Params hwiParams;
/* Enable the USB peripheral and PLL */
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
SysCtlUSBPLLEnable();
/* Setup pins for USB operation */
GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
/* Additional configurations for Host mode */
if (usbMode == EK_TM4C1294XL_USBHOST) {
/* Configure the pins needed */
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xff;
GPIOPinConfigure(GPIO_PD6_USB0EPEN);
GPIOPinTypeUSBDigital(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
/*
* USB bus fault is routed to pin PQ4. We create a Hwi to allow us
* to detect power faults and recover gracefully or terminate the
* program. PQ4 is active low; set the pin as input with a weak
* pull-up.
*/
GPIOPadConfigSet(GPIO_PORTQ_BASE, GPIO_PIN_4,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);
GPIOIntClear(GPIO_PORTQ_BASE, GPIO_PIN_4);
/* Create a Hwi for PQ4 pin. */
Error_init(&eb);
Hwi_Params_init(&hwiParams);
Hwi_construct(&(usbBusFaultHwiStruct), INT_GPIOQ4,
EK_TM4C1294XL_usbBusFaultHwi, &hwiParams, &eb);
if (Error_check(&eb)) {
System_abort("Couldn't construct USB bus fault hwi");
}
}
}
/*
* =============================== USBMSCHFatFs ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(USBMSCHFatFs_config, ".const:USBMSCHFatFs_config")
#pragma DATA_SECTION(usbmschfatfstivaHWAttrs, ".const:usbmschfatfstivaHWAttrs")
#endif
#include <ti/drivers/USBMSCHFatFs.h>
#include <ti/drivers/usbmschfatfs/USBMSCHFatFsTiva.h>
USBMSCHFatFsTiva_Object usbmschfatfstivaObjects[EK_TM4C1294XL_USBMSCHFatFsCOUNT];
const USBMSCHFatFsTiva_HWAttrs usbmschfatfstivaHWAttrs[EK_TM4C1294XL_USBMSCHFatFsCOUNT] = {
{
.intNum = INT_USB0,
.intPriority = (~0)
}
};
const USBMSCHFatFs_Config USBMSCHFatFs_config[] = {
{
.fxnTablePtr = &USBMSCHFatFsTiva_fxnTable,
.object = &usbmschfatfstivaObjects[0],
.hwAttrs = &usbmschfatfstivaHWAttrs[0]
},
{NULL, NULL, NULL}
};
/*
* ======== EK_TM4C1294XL_initUSBMSCHFatFs ========
*/
void EK_TM4C1294XL_initUSBMSCHFatFs(void)
{
/* Initialize the DMA control table */
EK_TM4C1294XL_initDMA();
/* Call the USB initialization function for the USB Reference modules */
EK_TM4C1294XL_initUSB(EK_TM4C1294XL_USBHOST);
USBMSCHFatFs_init();
}
/*
* =============================== Watchdog ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config")
#pragma DATA_SECTION(watchdogTivaHWAttrs, ".const:watchdogTivaHWAttrs")
#endif
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/watchdog/WatchdogTiva.h>
WatchdogTiva_Object watchdogTivaObjects[EK_TM4C1294XL_WATCHDOGCOUNT];
const WatchdogTiva_HWAttrs watchdogTivaHWAttrs[EK_TM4C1294XL_WATCHDOGCOUNT] = {
{
.baseAddr = WATCHDOG0_BASE,
.intNum = INT_WATCHDOG,
.intPriority = (~0),
.reloadValue = 80000000 // 1 second period at default CPU clock freq
},
};
const Watchdog_Config Watchdog_config[] = {
{
.fxnTablePtr = &WatchdogTiva_fxnTable,
.object = &watchdogTivaObjects[0],
.hwAttrs = &watchdogTivaHWAttrs[0]
},
{NULL, NULL, NULL},
};
/*
* ======== EK_TM4C1294XL_initWatchdog ========
*
* NOTE: To use the other watchdog timer with base address WATCHDOG1_BASE,
* an additional function call may need be made to enable PIOSC. Enabling
* WDOG1 does not do this. Enabling another peripheral that uses PIOSC
* such as ADC0 or SSI0, however, will do so. Example:
*
* SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
* SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG1);
*
* See the following forum post for more information:
* http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/p/176487/654390.aspx#654390
*/
void EK_TM4C1294XL_initWatchdog(void)
{
/* Enable peripherals used by Watchdog */
SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
Watchdog_init();
}
/*
* =============================== WiFi ===============================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(WiFi_config, ".const:WiFi_config")
#pragma DATA_SECTION(wiFiCC3100HWAttrs, ".const:wiFiCC3100HWAttrs")
#endif
#include <ti/drivers/WiFi.h>
#include <ti/drivers/wifi/WiFiCC3100.h>
WiFiCC3100_Object wiFiCC3100Objects[EK_TM4C1294XL_WIFICOUNT];
const WiFiCC3100_HWAttrs wiFiCC3100HWAttrs[EK_TM4C1294XL_WIFICOUNT] = {
{
.irqPort = GPIO_PORTM_BASE,
.irqPin = GPIO_PIN_3,
.irqIntNum = INT_GPIOM,
.csPort = GPIO_PORTH_BASE,
.csPin = GPIO_PIN_2,
.enPort = GPIO_PORTC_BASE,
.enPin = GPIO_PIN_6
}
};
const WiFi_Config WiFi_config[] = {
{
.fxnTablePtr = &WiFiCC3100_fxnTable,
.object = &wiFiCC3100Objects[0],
.hwAttrs = &wiFiCC3100HWAttrs[0]
},
{NULL,NULL, NULL},
};
/*
* ======== EK_TM4C1294XL_initWiFi ========
*/
void EK_TM4C1294XL_initWiFi(void)
{
/* Configure EN & CS pins to disable CC3100 */
GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_2);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6);
GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0);
/* Configure SSI2 for CC3100 */
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3);
/* Configure IRQ pin */
GPIOPinTypeGPIOInput(GPIO_PORTM_BASE, GPIO_PIN_3);
GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPD);
GPIOIntTypeSet(GPIO_PORTM_BASE, GPIO_PIN_3, GPIO_RISING_EDGE);
SPI_init();
EK_TM4C1294XL_initDMA();
WiFi_init();
}
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
/* ================ Defaults (module) configuration ================ */
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Text = xdc.useModule('xdc.runtime.Text');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
/*
* A flag to allow module names to be loaded on the target. Module name
* strings are placed in the .const section for debugging purposes.
*
* Pick one:
* - true (default)
* Setting this parameter to true will include name strings in the .const
* section so that Errors and Asserts are easier to debug.
* - false
* Setting this parameter to false will reduce footprint in the .const
* section. As a result, Error and Assert messages will contain an
* "unknown module" prefix instead of the actual module name.
*/
Defaults.common$.namedModule = true;
//Defaults.common$.namedModule = false;
/* ================ Error configuration ================ */
var Error = xdc.useModule('xdc.runtime.Error');
/*
* This function is called to handle all raised errors, but unlike
* Error.raiseHook, this function is responsible for completely handling the
* error with an appropriately initialized Error_Block.
*
* Pick one:
* - Error.policyDefault (default)
* Calls Error.raiseHook with an initialized Error_Block structure and logs
* the error using the module's logger.
* - Error.policySpin
* Simple alternative that traps on a while(1) loop for minimized target
* footprint.
* Using Error.policySpin, the Error.raiseHook will NOT called.
*/
Error.policyFxn = Error.policyDefault;
//Error.policyFxn = Error.policySpin;
/*
* If Error.policyFxn is set to Error.policyDefault, this function is called
* whenever an error is raised by the Error module.
*
* Pick one:
* - Error.print (default)
* Errors are formatted and output via System_printf() for easier
* debugging.
* - null
* Errors are not formatted or logged. This option reduces code footprint.
* - non-null function
* Errors invoke custom user function. See the Error module documentation
* for more details.
*/
Error.raiseHook = Error.print;
//Error.raiseHook = null;
//Error.raiseHook = "&myErrorFxn";
/*
* If Error.policyFxn is set to Error.policyDefault, this option applies to the
* maximum number of times the Error.raiseHook function can be recursively
* invoked. This option limits the possibility of an infinite recursion that
* could lead to a stack overflow.
* The default value is 16.
*/
Error.maxDepth = 2;
/* ================ Hwi configuration ================ */
var halHwi = xdc.useModule('ti.sysbios.hal.Hwi');
var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');
/*
* Checks for Hwi (system) stack overruns while in the Idle loop.
*
* Pick one:
* - true (default)
* Checks the top word for system stack overflows during the idle loop and
* raises an Error if one is detected.
* - false
* Disabling the runtime check improves runtime performance and yields a
* reduced flash footprint.
*/
halHwi.checkStackFlag = true;
//halHwi.checkStackFlag = false;
/*
* The following options alter the system's behavior when a hardware exception
* is detected.
*
* Pick one:
* - Hwi.enableException = true
* This option causes the default m3Hwi.excHandlerFunc function to fully
* decode an exception and dump the registers to the system console.
* This option raises errors in the Error module and displays the
* exception in ROV.
* - Hwi.enableException = false
* This option reduces code footprint by not decoding or printing the
* exception to the system console.
* It however still raises errors in the Error module and displays the
* exception in ROV.
* - Hwi.excHandlerFunc = null
* This is the most aggressive option for code footprint savings; but it
* can difficult to debug exceptions. It reduces flash footprint by
* plugging in a default while(1) trap when exception occur. This option
* does not raise an error with the Error module.
*/
m3Hwi.enableException = true;
//m3Hwi.enableException = false;
//m3Hwi.excHandlerFunc = null;
/*
* Enable hardware exception generation when dividing by zero.
*
* Pick one:
* - 0 (default)
* Disables hardware exceptions when dividing by zero
* - 1
* Enables hardware exceptions when dividing by zero
*/
m3Hwi.nvicCCR.DIV_0_TRP = 0;
//m3Hwi.nvicCCR.DIV_0_TRP = 1;
/*
* Enable hardware exception generation for invalid data alignment.
*
* Pick one:
* - 0 (default)
* Disables hardware exceptions for data alignment
* - 1
* Enables hardware exceptions for data alignment
*/
m3Hwi.nvicCCR.UNALIGN_TRP = 0;
/*
* The Idle module is used to specify a list of functions to be called when no
* other tasks are running in the system.
*
* Functions added here will be run continuously within the idle task.
*
* Function signature:
* Void func(Void);
*/
//Idle.addFunc("&myIdleFunc");
/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
/*
* Enable asserts in the BIOS library.
*
* Pick one:
* - true (default)
* Enables asserts for debugging purposes.
* - false
* Disables asserts for a reduced code footprint and better performance.
*/
BIOS.assertsEnabled = true;
//BIOS.assertsEnabled = false;
/*
* Specify default heap size for BIOS.
*/
BIOS.heapSize = 20480;
/*
* A flag to determine if xdc.runtime sources are to be included in a custom
* built BIOS library.
*
* Pick one:
* - false (default)
* The pre-built xdc.runtime library is provided by the respective target
* used to build the application.
* - true
* xdc.runtime library sources are to be included in the custom BIOS
* library. This option yields the most efficient library in both code
* footprint and runtime performance.
*/
BIOS.includeXdcRuntime = false;
//BIOS.includeXdcRuntime = true;
/*
* The SYS/BIOS runtime is provided in the form of a library that is linked
* with the application. Several forms of this library are provided with the
* SYS/BIOS product.
*
* Pick one:
* - BIOS.LibType_Custom
* Custom built library that is highly optimized for code footprint and
* runtime performance.
* - BIOS.LibType_Debug
* Custom built library that is non-optimized that can be used to
* single-step through APIs with a debugger.
*
*/
BIOS.libType = BIOS.LibType_Custom;
//BIOS.libType = BIOS.LibType_Debug;
/*
* Runtime instance creation enable flag.
*
* Pick one:
* - true (default)
* Allows Mod_create() and Mod_delete() to be called at runtime which
* requires a default heap for dynamic memory allocation.
* - false
* Reduces code footprint by disallowing Mod_create() and Mod_delete() to
* be called at runtime. Object instances are constructed via
* Mod_construct() and destructed via Mod_destruct().
*/
BIOS.runtimeCreatesEnabled = true;
//BIOS.runtimeCreatesEnabled = false;
/*
* Enable logs in the BIOS library.
*
* Pick one:
* - true (default)
* Enables logs for debugging purposes.
* - false
* Disables logging for reduced code footprint and improved runtime
* performance.
*/
BIOS.logsEnabled = true;
/*
* The Memory module itself simply provides a common interface for any
* variety of system and application specific memory management policies
* implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
*/
/* ================ Program configuration ================ */
/*
* Program.stack is ignored with IAR. Use the project options in
* IAR Embedded Workbench to alter the system stack size.
*/
if (!Program.build.target.$name.match(/iar/)) {
/*
* Reducing the system stack size (used by ISRs and Swis) to reduce
* RAM usage.
*/
Program.stack = 40960;
}
/*
* Enable Semihosting for GNU targets to print to CCS console
*/
if (Program.build.target.$name.match(/gnu/)) {
var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
}
/* ================ Semaphore configuration ================ */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
/*
* Enables global support for Task priority pend queuing.
*
* Pick one:
* - true (default)
* This allows pending tasks to be serviced based on their task priority.
* - false
* Pending tasks are services based on first in, first out basis.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Semaphore.supportsPriority = true;
Semaphore.supportsPriority = false;
/*
* Allows for the implicit posting of events through the semaphore,
* disable for additional code saving.
*
* Pick one:
* - true
* This allows the Semaphore module to post semaphores and events
* simultaneously.
* - false (default)
* Events must be explicitly posted to unblock tasks.
*
*/
//Semaphore.supportsEvents = true;
Semaphore.supportsEvents = false;
/* ================ Swi configuration ================ */
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
/*
* A software interrupt is an object that encapsulates a function to be
* executed and a priority. Software interrupts are prioritized, preempt tasks
* and are preempted by hardware interrupt service routines.
*
* This module is included to allow Swi's in a users' application.
*/
/* ================ System configuration ================ */
var System = xdc.useModule('xdc.runtime.System');
/*
* The Abort handler is called when the system exits abnormally.
*
* Pick one:
* - System.abortStd (default)
* Call the ANSI C Standard 'abort()' to terminate the application.
* - System.abortSpin
* A lightweight abort function that loops indefinitely in a while(1) trap
* function.
* - A custom abort handler
* A user-defined function. See the System module documentation for
* details.
*/
System.abortFxn = System.abortStd;
//System.abortFxn = System.abortSpin;
//System.abortFxn = "&myAbortSystem";
/*
* The Exit handler is called when the system exits normally.
*
* Pick one:
* - System.exitStd (default)
* Call the ANSI C Standard 'exit()' to terminate the application.
* - System.exitSpin
* A lightweight exit function that loops indefinitely in a while(1) trap
* function.
* - A custom exit function
* A user-defined function. See the System module documentation for
* details.
*/
System.exitFxn = System.exitStd;
//System.exitFxn = System.exitSpin;
//System.exitFxn = "&myExitSystem";
/*
* Minimize exit handler array in the System module. The System module includes
* an array of functions that are registered with System_atexit() which is
* called by System_exit(). The default value is 8.
*/
System.maxAtexitHandlers = 2;
/*
* The System.SupportProxy defines a low-level implementation of System
* functions such as System_printf(), System_flush(), etc.
*
* Pick one pair:
* - SysMin
* This module maintains an internal configurable circular buffer that
* stores the output until System_flush() is called.
* The size of the circular buffer is set via SysMin.bufSize.
* - SysCallback
* SysCallback allows for user-defined implementations for System APIs.
* The SysCallback support proxy has a smaller code footprint and can be
* used to supply custom System_printf services.
* The default SysCallback functions point to stub functions. See the
* SysCallback module's documentation.
*/
var SysMin = xdc.useModule('xdc.runtime.SysMin');
SysMin.bufSize = 128;
System.SupportProxy = SysMin;
//var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
//System.SupportProxy = SysCallback;
//SysCallback.abortFxn = "&myUserAbort";
//SysCallback.exitFxn = "&myUserExit";
//SysCallback.flushFxn = "&myUserFlush";
//SysCallback.putchFxn = "&myUserPutch";
//SysCallback.readyFxn = "&myUserReady";
/* ================ Task configuration ================ */
var Task = xdc.useModule('ti.sysbios.knl.Task');
/*
* Check task stacks for overflow conditions.
*
* Pick one:
* - true (default)
* Enables runtime checks for task stack overflow conditions during
* context switching ("from" and "to")
* - false
* Disables runtime checks for task stack overflow conditions.
*/
Task.checkStackFlag = true;
//Task.checkStackFlag = false;
/*
* Set the default task stack size when creating tasks.
*
* The default is dependent on the device being used. Reducing the default stack
* size yields greater memory savings.
*/
Task.defaultStackSize = 4096;
/*
* Enables the idle task.
*
* Pick one:
* - true (default)
* Creates a task with priority of 0 which calls idle hook functions. This
* option must be set to true to gain power savings provided by the Power
* module.
* - false
* No idle task is created. This option consumes less memory as no
* additional default task stack is needed.
* To gain power savings by the Power module without having the idle task,
* add Idle.run as the Task.allBlockedFunc.
*/
Task.enableIdleTask = true;
//Task.enableIdleTask = false;
//Task.allBlockedFunc = Idle.run;
/*
* If Task.enableIdleTask is set to true, this option sets the idle task's
* stack size.
*
* Reducing the idle stack size yields greater memory savings.
*/
Task.idleTaskStackSize = 4096;
/*
* Reduce the number of task priorities.
* The default is 16.
* Decreasing the number of task priorities yield memory savings.
*/
Task.numPriorities = 16;
//Text.isLoaded = false;
/* ================ Types configuration ================ */
var Types = xdc.useModule('xdc.runtime.Types');
/*
* This module defines basic constants and types used throughout the
* xdc.runtime package.
*/
/* ================ TI-RTOS middleware configuration ================ */
var mwConfig = xdc.useModule('ti.mw.Config');
/*
* Include TI-RTOS middleware libraries
*/
/* ================ TI-RTOS drivers' configuration ================ */
var driversConfig = xdc.useModule('ti.drivers.Config');
/*
* Include TI-RTOS drivers
*
* Pick one:
* - driversConfig.LibType_NonInstrumented (default)
* Use TI-RTOS drivers library optimized for footprint and performance
* without asserts or logs.
* - driversConfig.LibType_Instrumented
* Use TI-RTOS drivers library for debugging with asserts and logs enabled.
*/
driversConfig.libType = driversConfig.LibType_NonInstrumented;
//driversConfig.libType = driversConfig.LibType_Instrumented;
/* ================ Application Specific Instances ================ */
/* ================ NDK configuration ================ */
var Ndk = xdc.loadPackage('ti.ndk.config');
var Global = xdc.useModule('ti.ndk.config.Global');
var Ip = xdc.useModule('ti.ndk.config.Ip');
var Udp = xdc.useModule('ti.ndk.config.Udp');
var Tcp = xdc.useModule('ti.ndk.config.Tcp');
Global.IPv6 = false;
Global.stackLibType = Global.MIN;
Global.networkOpenHook = "&netOpenHook";
/* automatically call fdOpen/CloseSession for our sockets Task */
Global.autoOpenCloseFD = true;
Global.pktNumFrameBufs = 10;
Global.memRawPageCount = 6;
Global.ndkThreadStackSize = 20480;
Global.lowTaskStackSize = 4096;
Global.normTaskStackSize = 4096;
Global.highTaskStackSize = 4096;
Tcp.transmitBufSize = 1024;
Tcp.receiveBufSize = 1024;
Ip.autoIp = false;
Ip.address = "192.168.1.1";
Ip.domainName = "";
Ip.mask = "255.255.252.0";
Ip.gatewayIpAddr = "";
/* ================ Main configuration ================ */
var Main = xdc.useModule('xdc.runtime.Main');
Idle.idleFxns[0] = "&run_forever";
BIOS.rtsGateType = BIOS.NoLocking;
var task0Params = new Task.Params();
task0Params.instance.name = "boot";
task0Params.priority = 2;
task0Params.stackSize = 4096;
Program.global.boot = Task.create("&echoFxn", task0Params);
var task1Params = new Task.Params();
task1Params.instance.name = "epihandle";
task1Params.priority = 3;
task1Params.stackSize = 4096;
Program.global.epihandle = Task.create("&epiFxn", task1Params);
var task2Params = new Task.Params();
task2Params.instance.name = "encoder";
task2Params.priority = 3;
task2Params.stackSize = 4096;
Program.global.encoder = Task.create("&qeiFxn", task2Params);
var task3Params = new Task.Params();
task3Params.instance.name = "EEPROM";
task3Params.priority = 3;
task3Params.stackSize = 4096;
Program.global.EEPROM = Task.create("&i2cFxn", task3Params);
var task4Params = new Task.Params();
task4Params.instance.name = "my_ping";
task4Params.stackSize = 4096;
task4Params.priority = 2;
Program.global.my_ping = Task.create("&pingFxn", task4Params);
var task5Params = new Task.Params();
task5Params.instance.name = "spi";
task5Params.priority = 3;
task5Params.stackSize = 4096;
Program.global.spi = Task.create("&spiFxn", task5Params);
var task7Params = new Task.Params();
task7Params.instance.name = "dac";
task7Params.stackSize = 4096;
task7Params.priority = 2;
Program.global.dac = Task.create("&dacFxn", task7Params);
var task8Params = new Task.Params();
task8Params.instance.name = "abschannel0";
task8Params.stackSize = 4096;
task8Params.priority = 2;
Program.global.abschannel0 = Task.create("&absaFxn", task8Params);
var task9Params = new Task.Params();
task9Params.instance.name = "abschannel1";
task9Params.stackSize = 4096;
task9Params.priority = 2;
Program.global.abschannel1 = Task.create("&absbFxn", task9Params);
var task10Params = new Task.Params();
task10Params.instance.name = "my_user";
task10Params.priority = 2;
task10Params.stackSize = 8192;
Program.global.my_user = Task.create("&user_function", task10Params);
var task11Params = new Task.Params();
task11Params.instance.name = "proface";
task11Params.priority = 4;
Program.global.proface = Task.create("&my_touch_scan", task11Params);
var task12Params = new Task.Params();
task12Params.instance.name = "can_master";
task12Params.priority = 2;
Program.global.can_master = Task.create("&canFxn", task12Params);
var task13Params = new Task.Params();
task13Params.instance.name = "pwm_led";
task13Params.priority = 2;
Program.global.pwm_led = Task.create("&pwmFxn", task13Params);
var task13Params0 = new Task.Params();
task13Params0.instance.name = "myadc";
task13Params0.priority = 6;
Program.global.myadc = Task.create("&ADS833x_ReadData", task13Params0);
var task14Params = new Task.Params();
task14Params.instance.name = "rs485";
task14Params.priority = 3;
Program.global.rs485 = Task.create("&rs485Fxn", task14Params);
var timer0Params = new Timer.Params();
timer0Params.instance.name = "sysok";
timer0Params.period = 1000000;
Program.global.sysok = Timer.create(-1, "&systemok_led", timer0Params);
var timer1Params = new Timer.Params();
timer1Params.instance.name = "Mrtimer";
timer1Params.period = 1000;
timer1Params.startMode = xdc.module("ti.sysbios.interfaces.ITimer").StartMode_AUTO;
Program.global.Mrtimer = Timer.create(-1, "&my_timer", timer1Params);
Clock.tickPeriod = 1000;
Clock.swiPriority = 15;
Also initialization of SPI is as follows
Void spiFxn (UArg arg0, UArg arg1)
{
// SPI_Handle masterSpi;
// SPI_Transaction masterTransaction;
//************************************SPI FOR DAC*************************************
/* Initialize SPI handle as default master */
SPI_Params spiParamsdac;
SPI_Params_init(&spiParamsdac);
spiParamsdac.transferMode = SPI_MODE_BLOCKING;
spiParamsdac.transferTimeout = SPI_WAIT_FOREVER;
spiParamsdac.transferCallbackFxn = NULL;
spiParamsdac.mode = SPI_MASTER;
spiParamsdac.bitRate = 1000000;
spiParamsdac.dataSize =8;
spiParamsdac.frameFormat =SPI_POL1_PHA1;
spiParamsdac.custom =(uintptr_t) NULL;
masterSpi = SPI_open(Board_SPI1, &spiParamsdac); // change the cs pin to GPIO
if (masterSpi == NULL) {
System_abort("Error initializing DAC_SPI\n");
}
else {
// System_printf("DAC_SPI initialized\n");
// System_flush();
}
/* Initialize master SPI transaction structure */
masterTransaction.count = SPI_MSG_LENGTH;
masterTransaction.txBuf = (Ptr)masterTxBuffer;
masterTransaction.rxBuf = (Ptr)masterRxBuffer;
GPIO_write(Board_LDAC, 0); // LDAC PIN OF DAC ALWAYS KEEP LOW
////***************************SPI FOR ADC*************************************************
SPI_Params spiParams;
SPI_Params_init(&spiParams);
spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.transferTimeout = SPI_WAIT_FOREVER;
spiParams.transferCallbackFxn = NULL;
spiParams.mode = SPI_MASTER;
spiParams.bitRate = 1000000;
spiParams.dataSize =16;
spiParams.frameFormat =SPI_POL1_PHA0;
spiParams.custom =(uintptr_t) NULL;
adcSpi = SPI_open(Board_SPI0, &spiParams);
if (adcSpi == NULL) {
System_abort("Error initializing ADC_SPI\n");
}
else {
// System_printf("ADC_SPI initialized\n");
// System_flush();
}
/* Initialize master SPI transaction structure */
adcTransaction.count = ADC_SPI_MSG_LENGTH;
adcTransaction.txBuf = (Ptr)adcTxBuffer;
adcTransaction.rxBuf = (Ptr)adcRxBuffer;
// User specific code, enable interrupts:
Xint1Count = 0; // Count XINT1 interrupts
TimerCount = 0; // Count Timer0 interrupts
LoopCount = 0; // Count times through idle loop
Flag = 0;
Reg_Word = 0;
// Initialize Buffer Tables
for (n=0; n<BUF_SIZE; n++)
{
ADS833x_Buf[n] = n;
}
for (n=0; n<SIZE; n++)
{
ADS833x_Result[n] = n;
}
ADS833x_init();
// Step 6. IDLE loop:
// Select input Channel if Manual Channel Selection is enabled in CFR register
ADS833x_Buf[2] = ADS833x_CFR_Reg & 0x0800;
if (ADS833x_Buf[2] == 0)
{
System_printf("\n manual channel select\n");
System_flush();
Channel_Number = 0; // Should be 0~7,Channel number for Manual channel select
ADS833x_Channel_Select(Channel_Number); // Select ADC input channel // CHANGE THE CHANNEL IN TIMER INTERRUPT ALSO
}
////**************************************************END ADC******************************************************
////**************************************************ABSOLUTE ENCODER*************************************
////**************************************************Channel 0*************************************
SPI_Params spiParamsabsa;
SPI_Params_init(&spiParamsabsa);
spiParamsabsa.transferMode = SPI_MODE_BLOCKING;
spiParamsabsa.transferTimeout = SPI_WAIT_FOREVER;
spiParamsabsa.transferCallbackFxn = NULL;
spiParamsabsa.mode = SPI_MASTER;
spiParamsabsa.bitRate = 295000; //295K
spiParamsabsa.dataSize =16;
spiParamsabsa.frameFormat = SPI_POL1_PHA1;
spiParamsabsa.custom =(uintptr_t) NULL;
absaSpi = SPI_open(Board_SPI2, &spiParamsabsa);
if (absaSpi == NULL) {
System_abort("Error initializing ABSA_SPI\n");
}
else {
System_printf("ABSA_SPI initialized\n");
System_flush();
}
/* Initialize master SPI transaction structure */
absaTransaction.count = ABSA_SPI_MSG_LENGTH;
absaTransaction.txBuf = (Ptr)absaTxBuffer;
absaTransaction.rxBuf = (Ptr)absaRxBuffer;
//**************************************************Channel 1*************************************
SPI_Params chanbParams;
SPI_Params_init(&chanbParams);
chanbParams.transferMode = SPI_MODE_BLOCKING;
chanbParams.transferTimeout = SPI_WAIT_FOREVER;
chanbParams.transferCallbackFxn = NULL;
chanbParams.mode = SPI_MASTER;
chanbParams.bitRate = 295000;
chanbParams.dataSize =16;
chanbParams.frameFormat =SPI_POL1_PHA1;
// chanbParams.custom =(uintptr_t) NULL;
absbSpi = SPI_open(Board_SPI3, &chanbParams);
if (absbSpi == NULL) {
System_abort("Error initializing ABSB_SPI\n");
}
else {
System_printf("ABSB_SPI initialized\n");
System_flush();
}
/* Initialize master SPI transaction structure */
bTransaction.count = ABSB_SPI_MSG_LENGTH;
bTransaction.txBuf = (Ptr)bTxBuffer;
bTransaction.rxBuf = (Ptr)bRxBuffer;
timerFlag = 1;
//**************************************************END ABSOLUTE ENCODER*************************************
}
I am not using SPI_transfer(). Instead i am using library functions as given above.
Again please reply as soon as possible, its really urgent.
Regards,
Digvijay