This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SSI and DMA, second chip is not working

Other Parts Discussed in Thread: ADS1255, TM4C123GH6PM

Hi,

I'm trying to read two ADC using DMA, but I'm not being successful with the second ADC, I get data only from the first one, and they pretty much have the same configuration.

I've attached the .c file where we do the configuration, and for the moment the w/r.

a few points to note:

the microprocessor is the TM4C123G6HPM

and the ADCs are the ADS1255

SSI1 is working; 

SSI2 is the one not wirking;

first adc is referenced as U20

and the second is referenced as U21

line 327: we declared FP for the data ready. which calls the SendDataU20 (line 158) and SendDataU21 (line 185)

line 82: U20 interrupt

line 119: U21 interrupt

line 234: is where the DMA is initialized

and starting on line 766 there is the SPI/DMA initialization.

I've also noticed that only one of the interrupts is called, and it seen to be always the last one declared, so in this case: 

        Hwi_construct(&(hwiStruct), INT_SSI2, B134_332_SSI1U21IntHandler,
                      &hwiParams, &eb);
        if (Error_check(&eb)) {
            System_abort("Couldn't create SSI1 U21 Int Handler");
        }

on line 256

is someone has some idea/comment/tip I would appreciate.

Thanks for your help.

Eduardo Pires

/*
 * B134_332.c
 *
 *  Created on: 16.01.2015
 *      Author: EPI
 */

#ifdef B134_332_01

#include <stdint.h>
#include <stdbool.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <inc/hw_ints.h>
#include <inc/hw_gpio.h>
#include <inc/hw_pwm.h>
#include <inc/hw_ssi.h>

#include <driverlib/gpio.h>
#include <driverlib/sysctl.h>
#include <driverlib/i2c.h>
#include <driverlib/ssi.h>
#include <driverlib/udma.h>
#include <driverlib/pin_map.h>

#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>

#include "B134_332_01.h"

///MACROS
#define PWM_GEN_BADDR(_mod_, _gen_)                                           \
                                ((_mod_) + (_gen_))

/*********************************************************************************************************************//**
 *  						=============================== DMA ===============================
 *************************************************************************************************************************/
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN(B134_332_DMAControlTable, 1024)
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=1024
#elif defined(__GNUC__)
__attribute__ ((aligned (1024)))
#endif
static tDMAControlTable B134_332_DMAControlTable[32];
static bool DMA_initialized = false;

/*! Hwi_Struct used in the initDMA Hwi_construct call */
static Hwi_Struct hwiStruct;

/*********************************************************************************************************************//**
 * B134_332_errorDMAHwi
 *************************************************************************************************************************/
static Void B134_332_errorDMAHwi(UArg arg)
{
    System_printf("DMA error code: %d\n", uDMAErrorStatusGet());
    uDMAErrorStatusClear();
    System_abort("DMA error!!");
}

//*****************************************************************************
//
// The count of SSI0 buffers filled
//
//*****************************************************************************
static uint32_t g_ui32SSIRxCount = 0;
static uint32_t g_ui32SSITxCount = 0;

#define SSI_BUFFER_SIZE  3

// buffers
static uint8_t g_ui8TxBufA[3];
static uint8_t g_ui8RxBufA[3];
static uint8_t g_ui8RxBufB[3];
static uint8_t g_ui8TxBufB[3];
//uint32_t rx[3];

static void B134_332_SSI1U20IntHandler(UArg arg)
{
    uint32_t ui32Status;
    uint32_t ui32Mode;

    // get the interrupt status
    ui32Status = SSIIntStatus(SSI1_BASE, 0);

    //check if TX is done
    if(ui32Status & SSI_TXFF) {
    	ui32Mode = uDMAChannelModeGet(UDMA_CHANNEL_SSI1TX);

    	//clear the uDMA Transmit complete bit
    	SSIDMADisable(SSI1_BASE, SSI_DMA_TX);
    	SSIIntClear(SSI1_BASE, SSI_TXFF);

        if(ui32Mode == UDMA_MODE_STOP)
        {
        	//disable uDMA
        	SSIDMADisable(SSI1_BASE, SSI_DMA_RX);

        	//disable interrupt
        	SSIIntDisable(SSI1_BASE,SSI_TXEOT |	//transmit fifo is empty
        							SSI_DMATX |	//DMA Transmit complete
        							SSI_DMARX |	//DMA Receive complete
        							SSI_TXFF  |	//TX FIFO half full or less
        							SSI_RXFF  |	//RX FIFO half full or more
        							SSI_RXTO  |	//rx timeout
        							SSI_RXOR);	//rx error

        	// counter
            g_ui32SSIRxCount++;
        }
    }
}

static void B134_332_SSI1U21IntHandler(UArg arg)
{
    uint32_t ui32Status;
    uint32_t ui32Mode;

    // get the interrupt status
    ui32Status = SSIIntStatus(SSI2_BASE, 0);

    //check if TX is done
    if(ui32Status & SSI_TXFF) {
    	ui32Mode = uDMAChannelModeGet(UDMA_SEC_CHANNEL_UART2TX_13);

    	//clear the uDMA Transmit complete bit
    	SSIDMADisable(SSI2_BASE, SSI_DMA_TX);
    	SSIIntClear(SSI2_BASE, SSI_TXFF);

        if(ui32Mode == UDMA_MODE_STOP)
        {
           	//while(uDMAChannelModeGet(UDMA_SEC_CHANNEL_UART2RX_12) != UDMA_MODE_STOP);

        	//disable uDMA
        	SSIDMADisable(SSI2_BASE, SSI_DMA_RX);

        	//disable interrupt
        	SSIIntDisable(SSI2_BASE,SSI_TXEOT |	//transmit fifo is empty
        							SSI_DMATX |	//DMA Transmit complete
        							SSI_DMARX |	//DMA Receive complete
        							SSI_TXFF  |	//TX FIFO half full or less
        							SSI_RXFF  |	//RX FIFO half full or more
        							SSI_RXTO  |	//rx timeout
        							SSI_RXOR);	//rx error

        	// counter
            g_ui32SSIRxCount++;
        }
    }
}

void SendDataU20()
{
	// counter
	g_ui32SSITxCount++;

	//clear the uDMA Transmit complete bit
	SSIIntClear(SSI1_BASE, SSI_DMATX | SSI_RXFF | SSI_RXOR | SSI_TXFF);

	// enable the ssi interrupts
	SSIIntEnable(SSI1_BASE, SSI_RXFF);
	SSIIntEnable(SSI1_BASE, SSI_TXFF);

	// Set up the transfer parameters for the SSI0RX Channel
	uDMAChannelTransferSet(UDMA_CHANNEL_SSI1RX | UDMA_PRI_SELECT, UDMA_MODE_AUTO, (void *)(SSI1_BASE + SSI_O_DR), &g_ui8RxBufA[0], sizeof(g_ui8RxBufA));
	uDMAChannelEnable(UDMA_CHANNEL_SSI1RX);
	SSIDMAEnable(SSI1_BASE, SSI_DMA_RX);

	// Set up the transfer parameters for the SSI0TX Channel
	uDMAChannelTransferSet(UDMA_CHANNEL_SSI1TX, UDMA_MODE_BASIC, &g_ui8TxBufA[0], (void *)(SSI1_BASE + SSI_O_DR), sizeof(g_ui8TxBufA));

	// enable the uDMA channel
	uDMAChannelEnable(UDMA_CHANNEL_SSI1TX);

	//enable SSI DMA
	SSIDMAEnable(SSI1_BASE, SSI_DMA_TX);
}

void SendDataU21()
{
	// counter
	g_ui32SSITxCount++;

	//clear the uDMA Transmit complete bit
	SSIIntClear(SSI2_BASE, SSI_RXFF | SSI_RXOR | SSI_DMATX | SSI_TXFF); //SSI_TXFF

	// enable the ssi interrupts
	SSIIntEnable(SSI2_BASE, SSI_RXFF);
	SSIIntEnable(SSI2_BASE, SSI_TXFF);

	//while(SSIBusy(SSI2_BASE));
	// Set up the transfer parameters for the SSI0RX Channel
	uDMAChannelTransferSet(UDMA_SEC_CHANNEL_UART2RX_12 | UDMA_PRI_SELECT, UDMA_MODE_AUTO, (void *)(SSI2_BASE + SSI_O_DR), &g_ui8RxBufB[0], sizeof(g_ui8RxBufB));
	uDMAChannelEnable(UDMA_SEC_CHANNEL_UART2RX_12);
	SSIDMAEnable(SSI2_BASE, SSI_DMA_RX);

	// Set up the transfer parameters for the SSI0TX Channel
	uDMAChannelTransferSet(UDMA_SEC_CHANNEL_UART2TX_13 | UDMA_PRI_SELECT, UDMA_MODE_BASIC, &g_ui8TxBufB[0], (void *)(SSI2_BASE + SSI_O_DR), sizeof(g_ui8TxBufB));

	// enable the uDMA channel
	uDMAChannelEnable(UDMA_SEC_CHANNEL_UART2TX_13);

	//enable SSI DMA
	SSIDMAEnable(SSI2_BASE, SSI_DMA_TX);

    /*int i=0;
	// 0000 0000
	SSIDataPut(SSI2_BASE, 0b00000000);
	while(SSIBusy(SSI2_BASE));
	for(i=0; i<60;i++); // wait

	SSIDataPut(SSI2_BASE, 0b00000000);
	while(SSIBusy(SSI2_BASE));
	for(i=0; i<60;i++); // wait

	SSIDataPut(SSI2_BASE, 0b00000000);
	while(SSIBusy(SSI2_BASE));
	for(i=0; i<60;i++); // wait

	// wait 7us
	for(i=0; i < 3; i++)
		SSIDataGet(SSI2_BASE, &g_ui8RxBufB[i]);*/
}

/*********************************************************************************************************************//**
 * B134_332_initDMA
 *************************************************************************************************************************/
void B134_332_initDMA(void)
{
    Error_Block eb;
    Hwi_Params  hwiParams;

    if (!DMA_initialized) {

        Error_init(&eb);

        Hwi_Params_init(&hwiParams);
        Hwi_construct(&(hwiStruct), INT_UDMAERR, B134_332_errorDMAHwi,
                      &hwiParams, &eb);
        if (Error_check(&eb)) {
            System_abort("Couldn't create DMA error hwi");
        }

        Hwi_construct(&(hwiStruct), INT_SSI1, B134_332_SSI1U20IntHandler,
                      &hwiParams, &eb);
        if (Error_check(&eb)) {
            System_abort("Couldn't create SSI1 U20 Int Handler");
        }

        Hwi_construct(&(hwiStruct), INT_SSI2, B134_332_SSI1U21IntHandler,
                      &hwiParams, &eb);
        if (Error_check(&eb)) {
            System_abort("Couldn't create SSI1 U21 Int Handler");
        }

        SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
        uDMAEnable();
        uDMAControlBaseSet(B134_332_DMAControlTable);

        DMA_initialized = true;
    }
}

/*********************************************************************************************************************//**
 *  						=============================== General ===============================
 *************************************************************************************************************************/
/*********************************************************************************************************************//**
 * B134_332_initGeneral
 *************************************************************************************************************************/
void B134_332_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);
}

/*********************************************************************************************************************//**
 *  						=============================== GPIO ===============================
 *************************************************************************************************************************/
/*! Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(GPIO_config, ".const:GPIO_config")
#pragma DATA_SECTION(gpioHWAttrs, ".const:gpioHWAttrs")
#endif

#include <ti/drivers/GPIO.h>

/*! Callback functions for the GPIO interrupt example. */
void gpioADS1255U20Fxn(void);
void gpioADS1255U21Fxn(void);
void gpioADS1146Fxn(void);

/*! GPIO configuration structure */
const GPIO_HWAttrs gpioHWAttrs[B134_332_GPIOCOUNT] = {
	{GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_OUTPUT}, ///< B134_332_LED_GREEN
    {GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_OUTPUT},	///< B134_332_PORTD_PIN7
    //{GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_OUTPUT},  ///< B134_332_NG1
    {GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_OUTPUT},  ///< B134_332_PG1
    {GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_OUTPUT},  ///< B134_332_PG2
    //{GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_INPUT},	///< B134_332_DRDY1
	{GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_INPUT},	///< B134_332_DRDY1
	{GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_INPUT},	///< B134_332_DRDY3
	//{GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_INPUT},  ///< B134_332_DRDY2
    //{GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_INPUT},  ///< B134_332_DRDY3
    //{GPIO_PORTB_BASE, GPIO_PIN_6, GPIO_OUTPUT},  ///< B134_332_HEATER
    {GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_OUTPUT},	///< B134_332_PORTE_PIN1
    {GPIO_PORTE_BASE, GPIO_PIN_2, GPIO_OUTPUT},	///< B134_332_PORTE_PIN2
    {GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_OUTPUT},	///< B134_332_PORTE_PIN3
    {GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_INPUT},	///< B134_332_START_BTN
};

/*! Memory for the GPIO module to construct a Hwi */
Hwi_Struct callbackHwi;

/*! GPIO callback structure to set callbacks for GPIO interrupts */
const GPIO_Callbacks B134_332_gpioPortCCallbacks = {
    GPIO_PORTC_BASE, INT_GPIOC, &callbackHwi,
    {NULL, NULL, NULL, NULL, NULL, gpioADS1255U20Fxn, NULL, gpioADS1255U21Fxn},
};

const GPIO_Config GPIO_config[] = {
	{&gpioHWAttrs[0]},
	{&gpioHWAttrs[1]},
	{&gpioHWAttrs[2]},
	{&gpioHWAttrs[3]},
	{&gpioHWAttrs[4]},
	{&gpioHWAttrs[5]},
	{&gpioHWAttrs[6]},
	{&gpioHWAttrs[7]},
	{&gpioHWAttrs[8]},
	{&gpioHWAttrs[9]},
    {NULL}
};

/*********************************************************************************************************************//**
 * B134_332_initGPIO
 *************************************************************************************************************************/
void B134_332_initGPIO(void)
{
	/*! Setup the LED GPIO pins used */
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0); /*!< B134_332_LED_RED */

    ///************************************************************************
    /// start it positive voltage 0
    /// NG1 PG1 0
    /// NG2 PG2 1

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    //GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_0); //Set CS for Lensdriver ************************remove it
    //GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0); //CSLED down				***************************remove it

    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_2); ///< Set CS for Lensdriver
    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0); ///< CSLED down

    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_3);///< Set CS for Lensdriver
    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_PIN_3);///< CSLED up

    ///*************************************************************************

    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_5);///< DRDY1
    GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
    uint32_t strength;
    uint32_t type;
	GPIOPadConfigGet(GPIO_PORTC_BASE, GPIO_PIN_5,&strength,&type);
	System_printf("strength: %d\n", strength);
	System_printf("type: %d\n", type);
	System_flush();

    //GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_6);///< DRDY2
    //GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_7);//DRDY3
    GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);       ///< Enable PORT-D peripheral
	/*! Setup the button GPIO pins used for the board */
	HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= GPIO_PIN_7;
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_7);  ///< B134_332_PORTD_PIN7
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
	HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;

    ///*************************************************************************

    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_1); ///< B134_332_PORTE_PIN1 up
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, 0); ///< B134_332_PORTE_PIN1 down

    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_2); ///< B134_332_PORTE_PIN2
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, 0); ///< B134_332_PORTE_PIN2 down

    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_3); ///< B134_332_PORTE_PIN3 up
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0); ///< B134_332_PORTE_PIN3 down

    ///*************************************************************************

    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE,GPIO_PIN_5);///< B134_332_START_BTN
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    /*! Once GPIO_init is called, GPIO_config cannot be changed */
    GPIO_init();

    GPIO_write(B134_332_LED_GREEN, B134_332_PIN_OFF);
}

/*********************************************************************************************************************//**
 *  						=============================== 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>

/*! I2C objects */
I2CTiva_Object i2cTivaObjects[B134_332_I2CCOUNT];

/*! I2C configuration structure, describing which pins are to be used */
const I2CTiva_HWAttrs i2cTivaHWAttrs[B134_332_I2CCOUNT] = {
    {I2C1_BASE, INT_I2C1},
    {I2C3_BASE, INT_I2C3},
};

const I2C_Config I2C_config[] = {
    {&I2CTiva_fxnTable, &i2cTivaObjects[0], &i2cTivaHWAttrs[0]},
    {&I2CTiva_fxnTable, &i2cTivaObjects[1], &i2cTivaHWAttrs[1]},
    {NULL, NULL, NULL}
};

/*********************************************************************************************************************//**
 * B134_332_initI2C
 *************************************************************************************************************************/
void B134_332_initI2C(void)
{
    /*! I2C1 Init */
    /*! Enable the peripheral */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);

    /*! Configure the appropriate pins to be I2C instead of GPIO. */
    GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    GPIOPinConfigure(GPIO_PA7_I2C1SDA);
    GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
    GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);

    /*! I2C3 Init */
    /*! Enable the peripheral */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);

    /*! Configure the appropriate pins to be I2C instead of GPIO. */
    GPIOPinConfigure(GPIO_PD0_I2C3SCL);
    GPIOPinConfigure(GPIO_PD1_I2C3SDA);
    GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
    GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);

    /**
     * These GPIOs are connected to PD0 and PD1 and need to be brought into a
     * GPIO input state so they don't interfere with I2C communications.
     */
    //GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6);
    //GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7);

    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>
#include <driverlib/pwm.h>

PWMTiva_Object pwmTivaObjects[B134_332_PWMCOUNT];

/*! PWM configuration structure */
const PWMTiva_HWAttrs pwmTivaHWAttrs[B134_332_PWMCOUNT] = {
    {
        PWM1_BASE,
        PWM_OUT_6,
        PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
    },
    {
        PWM1_BASE,
        PWM_OUT_7,
        PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
    }
};

const PWM_Config PWM_config[] = {
    {&PWMTiva_fxnTable, &pwmTivaObjects[0], &pwmTivaHWAttrs[0]},
    {&PWMTiva_fxnTable, &pwmTivaObjects[1], &pwmTivaHWAttrs[1]},
    {NULL, NULL, NULL}
};

/*********************************************************************************************************************//**
 * B134_332_initPWM
 *************************************************************************************************************************/
void B134_332_initPWM(void)
{
	/// Configure PWM Clock to match system
	SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

	///
	/// Enable PWM peripherals
	///
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //no heater
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); ///< The Tiva Launchpad has two modules (0 and 1). Module 1 covers the LED pins
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); ///< The Tiva Launchpad has two modules (0 and 1). Module 1 covers the LED pins

	/// how to set the period. For a 7300 KHz frequency,
	/// deprecated(the period = (1/7300) * Clock or Clock / 7300)
	/// For 7300Hz (7.3Khz) divide it by 6100
	/// For 1100Hz (1.1Khz) divide it by 914
	uint32_t ulPeriod = SysCtlClockGet() / 914; ///!< PWM frequency 1.1Khz
	uint32_t ulPeriod_ADCClock = 10; ///!< PWM frequency 8MHz
	//uint32_t ulPeriod_heat = SysCtlClockGet() / 700; ///!< PWM frequency 100Hz

	/*!
	 * Enable PWM output on GPIO pins.  Board_LED1 and Board_LED2 are now
	 * controlled by PWM peripheral - Do not use GPIO APIs.
	 */

	///
	///Configure PF1,PF2,PF3 Pins as PWM
	///
	GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
	GPIOPinConfigure(GPIO_PF1_M1PWM5);//<<CLK_IN (LED1)
	GPIOPinConfigure(GPIO_PE4_M1PWM2);//<<GPIO5 (LED2)
	GPIOPinConfigure(GPIO_PC4_M0PWM6);//<<ADC_CLK
	//GPIOPinConfigure(GPIO_PF2_M1PWM6);
	//GPIOPinConfigure(GPIO_PF3_M1PWM7);
	//GPIOPinConfigure(GPIO_PB6_M0PWM0); //no heater
	//GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6); //no heater
	//GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 |GPIO_PIN_3);

	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_4);
	GPIOPinTypePWM(GPIO_PORTC_BASE,GPIO_PIN_4);
	uint32_t strength;
	uint32_t type;
	GPIOPadConfigGet(GPIO_PORTC_BASE, GPIO_PIN_4,&strength,&type);
	System_printf("strength: %d\n", strength);
	System_printf("type: %d\n", type);
	System_flush();

	/**
	 * Configure PWM Options
	 * PWM_GEN_1 Covers M1PWM2 and M1PWM3
	 * PWM_GEN_2 Covers M1PWM4 and M1PWM5
	 * PWM_GEN_3 Covers M1PWM6 and M1PWM7 See page 419 spmu298a.pdf february 07, 2014
	 */
	//PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_SYNC_LOCAL | PWM_GEN_MODE_DBG_RUN); //no heater
	PWMGenConfigure(PWM1_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_SYNC_LOCAL | PWM_GEN_MODE_DBG_RUN);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_SYNC_LOCAL | PWM_GEN_MODE_DBG_RUN);
	PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DB_SYNC_LOCAL | PWM_GEN_MODE_DBG_RUN);
	//PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_SYNC_LOCAL | PWM_GEN_MODE_DBG_RUN);

	///
	/// Set the Period (expressed in clock ticks)
	///
	//PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod_heat); //no heater
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_1, ulPeriod);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ulPeriod);
	//PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ulPeriod);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, ulPeriod_ADCClock);

	///
	/// Set PWM duty
	///
	//PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0); //ulPeriod_heat/2); //no heater
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_2,ulPeriod*0.333f);
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5,ulPeriod*0.333f); //2
	//PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6,ulPeriod/2); //ulPeriod/2-ulPeriod/2*0.1
	//PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7,ulPeriod/2-ulPeriod/0.5f); //ulPeriod/2+ulPeriod/2*0.1
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, ulPeriod_ADCClock/2); //50%Clock Duty Cycle
	uint32_t ui32Gen = PWM_GEN_BADDR(PWM1_BASE, PWM_GEN_1);
	HWREG(ui32Gen + PWM_O_X_GENA) = (PWM_X_GENA_ACTLOAD_NONE |
			    					 PWM_X_GENA_ACTCMPAU_ONE |
			    					 PWM_X_GENA_ACTZERO_NONE |
			                         PWM_X_GENA_ACTCMPAD_ZERO);

	HWREG(ui32Gen + PWM_O_X_GENB) = (PWM_X_GENB_ACTLOAD_NONE |
			    		    		 PWM_X_GENB_ACTCMPAU_ONE |
			    		    		 PWM_X_GENB_ACTZERO_NONE |
			    		    		 PWM_X_GENB_ACTCMPAD_ZERO);

	ui32Gen = PWM_GEN_BADDR(PWM1_BASE, PWM_GEN_2);
	HWREG(ui32Gen + PWM_O_X_GENA) = (PWM_X_GENA_ACTLOAD_NONE |
			    					 PWM_X_GENA_ACTCMPBU_ZERO |
			    					 PWM_X_GENA_ACTZERO_ONE |
			                         PWM_X_GENA_ACTCMPBD_NONE);

	HWREG(ui32Gen + PWM_O_X_GENB) = (PWM_X_GENB_ACTLOAD_NONE |
			    		    		 PWM_X_GENB_ACTCMPBU_ZERO |
			    		    		 PWM_X_GENB_ACTZERO_ONE |
			    		    		 PWM_X_GENB_ACTCMPBD_NONE);

//	ui32Gen = PWM_GEN_BADDR(PWM1_BASE, PWM_GEN_3);
//	HWREG(ui32Gen + PWM_O_X_GENA) = (PWM_X_GENA_ACTLOAD_NONE |
//									 PWM_X_GENA_ACTCMPAU_NONE |
//									 PWM_X_GENA_ACTZERO_ONE |
//									 PWM_X_GENA_ACTCMPAD_ZERO);
//
//	HWREG(ui32Gen + PWM_O_X_GENB) = (PWM_X_GENB_ACTLOAD_ONE |
//									 PWM_X_GENB_ACTCMPAU_ZERO |
//									 PWM_X_GENB_ACTZERO_NONE |
//									 PWM_X_GENB_ACTCMPAD_NONE);

	//PWMOutputInvert(PWM1_BASE, PWM_OUT_7_BIT, true);

	/// we first set the PWM width for all channels to be sync'ed

	/// Enable the PWM generator
	//PWMGenEnable(PWM0_BASE, PWM_GEN_0);
	PWMGenEnable(PWM1_BASE, PWM_GEN_1);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);
	PWMGenEnable(PWM0_BASE, PWM_GEN_3);
	//PWMGenEnable(PWM1_BASE, PWM_GEN_3);

	/**
	 * Reset PWM generator blocks and sync
	 * need to call these functions after each pulse width change
	 */
	PWMSyncTimeBase(PWM1_BASE,PWM_GEN_1_BIT| PWM_GEN_2_BIT);///< First timebase update
	PWMSyncUpdate(PWM1_BASE, PWM_GEN_1_BIT | PWM_GEN_2_BIT);///< then sync update

	/// Turn on the Output pins
	//PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
	//PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT |PWM_OUT_6_BIT|PWM_OUT_7_BIT, true);
	PWMOutputState(PWM1_BASE, PWM_OUT_2_BIT |PWM_OUT_5_BIT, true);
	PWMOutputState(PWM0_BASE, PWM_OUT_6_BIT, true);
	PWM_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>

/*! SPI objects */
SPITivaDMA_Object spiTivaDMAObjects[B134_332_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[B134_332_SPICOUNT];

/** SPI configuration structure, describing which pins are to be used */
const SPITivaDMA_HWAttrs spiTivaDMAHWAttrs[B134_332_SPICOUNT] = {
    {
        SSI0_BASE,
        INT_SSI0,
        &spiTivaDMAscratchBuf[0],
        0,
        UDMA_CHANNEL_SSI0RX,
        UDMA_CHANNEL_SSI0TX,
        uDMAChannelAssign,
        UDMA_CH10_SSI0RX,
        UDMA_CH11_SSI0TX
    },
    {
        SSI1_BASE,
        INT_SSI1,
        &spiTivaDMAscratchBuf[1],
        1,
        UDMA_CHANNEL_SSI1RX,
        UDMA_CHANNEL_SSI1TX,
        uDMAChannelAssign,
        UDMA_CH24_SSI1RX,
        UDMA_CH25_SSI1TX
    },
    {
        SSI2_BASE,
        INT_SSI2,
        &spiTivaDMAscratchBuf[2],
        2,
        UDMA_SEC_CHANNEL_UART2RX_12,
        UDMA_SEC_CHANNEL_UART2TX_13,
        uDMAChannelAssign,
        UDMA_CH12_SSI2RX,
        UDMA_CH13_SSI2TX
    }
};

const SPI_Config SPI_config[] = {
    {&SPITivaDMA_fxnTable, &spiTivaDMAObjects[0], &spiTivaDMAHWAttrs[0]},
    {&SPITivaDMA_fxnTable, &spiTivaDMAObjects[1], &spiTivaDMAHWAttrs[1]},
    {&SPITivaDMA_fxnTable, &spiTivaDMAObjects[2], &spiTivaDMAHWAttrs[2]},
    //{NULL, NULL, NULL},
    //{NULL, NULL, NULL},
    {NULL, NULL, NULL},
};

/*********************************************************************************************************************//**
 * B134_332_initSPI
 *************************************************************************************************************************/
void B134_332_initSPI()
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	/* SPI0 */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);


    /* Need to unlock PF0 */
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    //GPIOPinConfigure(GPIO_PA3_SSI0FSS); //Set CS for Current driver
    GPIOPinConfigure(GPIO_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);


    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_3);//Set CS for Lensdriver
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);//pin up

    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_6); //Set CS for LED
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_PIN_6); //pin up

    //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1); //set CS for ADS1146
    //GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_1, GPIO_PIN_1); //pin up

    //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_0); //set CS for ADS1255 U20
    //GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_0, GPIO_PIN_0); //pin up

    //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_7); //set CS for ADS1255 U21
    //GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_PIN_7); //pin up

    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5); // Do not include CS pin 3 (FSS)

    SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 2000000, 8);//SSI_FRF_TI  SSI_FRF_MOTO_MODE_3
    SSIEnable(SSI0_BASE);

    /* SPI2 */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_SSI2);
    GPIOPinConfigure(GPIO_PB4_SSI2CLK);
    //GPIOPinConfigure(GPIO_PB5_SSI2FSS);
    GPIOPinConfigure(GPIO_PB6_SSI2RX);
    GPIOPinConfigure(GPIO_PB7_SSI2TX);
    GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7); //GPIO_PIN_5 |

    SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 2000000, 8);//SSI_FRF_TI  SSI_FRF_MOTO_MODE_3
    SSIEnable(SSI2_BASE);

    uint_fast16_t ui16Idx;

    //
    // Fill the TX and RX buffer with a simple data pattern.
    //
    for(ui16Idx = 0; ui16Idx < SSI_BUFFER_SIZE; ui16Idx++)
    {
    	g_ui8TxBufA[ui16Idx] = 0;
    	g_ui8RxBufA[ui16Idx] = 0;
    	g_ui8TxBufB[ui16Idx] = 0;
    	g_ui8RxBufB[ui16Idx] = 0;
    }

    //-----------------------------------------DMA STUFF START------------------------------------------------------------------------------

	// disable all interrupt
	SSIIntDisable(SSI2_BASE,SSI_TXEOT |	//transmit fifo is empty
							SSI_DMATX |	//DMA Transmit complete
							SSI_DMARX |	//DMA Receive complete
							SSI_TXFF  |	//TX FIFO half full or less
							SSI_RXFF  |	//RX FIFO half full or more
							SSI_RXTO  |	//rx timeout
							SSI_RXOR);	//rx error

    // ---SSI1 RX---

	uDMAChannelAssign(UDMA_CH12_SSI2RX);

	uDMAChannelSelectSecondary(UDMA_DEF_RESERVED_SEC_UART2RX);

	uDMAChannelDisable(UDMA_SEC_CHANNEL_UART2RX_12);

    //
    // Put the attributes in a known state for the uDMA SSI0RX channel.  These
    // should already be disabled by default.
    //
    uDMAChannelAttributeDisable(UDMA_SEC_CHANNEL_UART2RX_12,
                                    UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
                                    (UDMA_ATTR_HIGH_PRIORITY |
                                    UDMA_ATTR_REQMASK));

    // Configure the control parameters for the primary control structure for
    // the SSIORX channel.
    uDMAChannelControlSet(UDMA_SEC_CHANNEL_UART2RX_12 | UDMA_PRI_SELECT,
                              UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
                              UDMA_ARB_1);
    // ---SS1 TX---

    uDMAChannelAssign(UDMA_CH13_SSI2TX);

    //uDMAChannelSelectSecondary(UDMA_DEF_RESERVED_SEC_UART2TX);

    uDMAChannelDisable(UDMA_SEC_CHANNEL_UART2TX_13);

    // Put the attributes in a known state for the uDMA SSI0TX channel.  These
    // should already be disabled by default.
    uDMAChannelAttributeDisable(UDMA_SEC_CHANNEL_UART2TX_13,
	 							    UDMA_ATTR_ALTSELECT |
	 							    UDMA_ATTR_HIGH_PRIORITY |
	 							    UDMA_ATTR_REQMASK);

    // Configure the control parameters for the SSI0 TX.
    uDMAChannelControlSet(UDMA_SEC_CHANNEL_UART2TX_13 | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1);

    //-----------------------------------------DMA STUFF END---------------------------------------------------------------------------------




    /* SPI1 */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_SSI1);
    GPIOPinConfigure(GPIO_PF2_SSI1CLK);
    //GPIOPinConfigure(GPIO_PF3_SSI1FSS);
    GPIOPinConfigure(GPIO_PD2_SSI1RX);
    GPIOPinConfigure(GPIO_PD3_SSI1TX);
    GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_2); //GPIO_PIN_3
    GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 2000000, 8);//SSI_FRF_TI  SSI_FRF_MOTO_MODE_3

    SSIEnable(SSI1_BASE);

    //-----------------------------------------DMA STUFF START------------------------------------------------------------------------------

	// disable all interrupt
	SSIIntDisable(SSI1_BASE,SSI_TXEOT |	//transmit fifo is empty
							SSI_DMATX |	//DMA Transmit complete
							SSI_DMARX |	//DMA Receive complete
							SSI_TXFF  |	//TX FIFO half full or less
							SSI_RXFF  |	//RX FIFO half full or more
							SSI_RXTO  |	//rx timeout
							SSI_RXOR);	//rx error

    // ---SSI1 RX---

	uDMAChannelAssign(UDMA_CH24_SSI1RX);

	uDMAChannelDisable(UDMA_CHANNEL_SSI1RX);

    //
    // Put the attributes in a known state for the uDMA SSI0RX channel.  These
    // should already be disabled by default.
    //
    uDMAChannelAttributeDisable(UDMA_CHANNEL_SSI1RX,
                                    UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
                                    (UDMA_ATTR_HIGH_PRIORITY |
                                    UDMA_ATTR_REQMASK));

    // Configure the control parameters for the primary control structure for
    // the SSIORX channel.
    uDMAChannelControlSet(UDMA_CHANNEL_SSI1RX | UDMA_PRI_SELECT,
                              UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
                              UDMA_ARB_1);
    // ---SS1 TX---

    uDMAChannelAssign(UDMA_CH25_SSI1TX);

    uDMAChannelDisable(UDMA_CHANNEL_SSI1TX);

    // Put the attributes in a known state for the uDMA SSI0TX channel.  These
    // should already be disabled by default.
    uDMAChannelAttributeDisable(UDMA_CHANNEL_SSI1TX,
	 							    UDMA_ATTR_ALTSELECT |
	 							    UDMA_ATTR_HIGH_PRIORITY |
	 							    UDMA_ATTR_REQMASK);

    // Configure the control parameters for the SSI0 TX.
    uDMAChannelControlSet(UDMA_CHANNEL_SSI1TX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1);

    //-----------------------------------------DMA STUFF END---------------------------------------------------------------------------------

    SPI_init();
}

/*********************************************************************************************************************//**
 * Dani function
 * @param current
 *************************************************************************************************************************/
void B134_332_spiSendDALED(uint16_t current){

	current=current<<2;

	uint8_t currentLow=current&0x00FF;
	uint8_t currentHigh=current>>8;

	SSIDisable(SSI0_BASE);
	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8);//SSI_FRF_TI  SSI_FRF_MOTO_MODE_3
	SSIEnable(SSI0_BASE);

	int i;
	for(i=0; i<500;i++); ///< wait

	//GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_PIN_6);//CSLED up
	GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, 0);//CSLED down

	for(i=0; i<50;i++); ///< wait

	SSIDataPut(SSI0_BASE, currentHigh);
	while(SSIBusy(SSI0_BASE))
	{
	}
	SSIDataPut(SSI0_BASE, currentLow);
	while(SSIBusy(SSI0_BASE))
	{
	}

	for(i=0; i<50;i++); ///< wait

	GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_PIN_6);//CSLED up
}

/*********************************************************************************************************************//**
 *  						=============================== USB ===============================
 *************************************************************************************************************************/
/*********************************************************************************************************************//**
 *  This function just turns on the USB
 *************************************************************************************************************************/
void B134_332_initUSB(B134_332_USBMode usbMode)
{
    /*! Enable the USB peripheral and PLL */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    SysCtlUSBPLLEnable();

    /*! Setup pins for USB operation */
    GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);

    if (usbMode == B134_332_USBHOST) {
        System_abort("USB host not supported\n");
    }
}

#endif ///< #ifdef B134_332

  • Hello Eduardo,

    First of all unclear to me is which TM4C12x device is this? Secondly did you check that if SSI1 is not at all configured does the ADC control work. That way we can check if there is no Base Address or configuration issue.

    Regards
    Amit
  • Hi Amit,

    It is the TM4C123GH6PM, we found the problem Friday evening, but didn't have time to post to result before.

    Before all signals seen correct on the oscilloscope, but we weren't get something from RX.

    we had PB6 initialized for SSI, as follow:

        GPIOPinConfigure(GPIO_PB4_SSI2CLK);
        //GPIOPinConfigure(GPIO_PB5_SSI2FSS);
        GPIOPinConfigure(GPIO_PB6_SSI2RX);
        GPIOPinConfigure(GPIO_PB7_SSI2TX);
        GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7);

    but it turns out, we had to declare it as well as a GPIO output:

    GPIOPinTypeGPIOInput(GPIO_PORTB_BASE,GPIO_PIN_6);
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_6, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    now SSI1 and SSI2 are fine, working as expected.

    For the second problem I reported, we had to change this:

    Hwi_construct(&(hwiStruct), INT_SSI2, B134_332_SSI1U21IntHandler,
                  &hwiParams, &eb);
    if (Error_check(&eb)) {
        System_abort("Couldn't create SSI1 U21 Int Handler");
    }

    to this:

    Hwi_create(INT_SSI2, B134_332_SSI2U21IntHandler,
    			  &hwiParams, &eb);
    if (Error_check(&eb)) {
    	System_abort("Couldn't create SSI1 Int Handler");
    }