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.

Declaring SDSPI

Hello,

    Can anyone tell me what is the function of the code statements marked in red in the below code section. This code section is used to define the SD SPI mode of communication.

-

#if TI_DRIVERS_SDSPI_INCLUDED
#include <ti/drivers/SDSPI.h>
#include <ti/drivers/sdspi/SDSPITiva.h>

/* SDSPI objects */
SDSPITiva_Object sdspiTivaobjects[EK_TM4C1294XL_SDSPICOUNT];

/* SDSPI configuration structure, describing which pins are to be used */
const SDSPITiva_HWAttrs sdspiTivaHWattrs[EK_TM4C1294XL_SDSPICOUNT] = {
{
SSI2_BASE, /* SPI base address */

GPIO_PORTD_BASE, /* The GPIO port used for the SPI pins */
GPIO_PIN_3, /* SCK */
GPIO_PIN_0, /* MISO */
GPIO_PIN_1, /* MOSI */

GPIO_PORTC_BASE, /* Chip select port */
GPIO_PIN_7, /* Chip select pin */

GPIO_PORTB_BASE, /* GPIO TX port */
GPIO_PIN_1, /* GPIO TX pin */
},
{
SSI3_BASE, /* SPI base address */

GPIO_PORTQ_BASE, /* The GPIO port used for the SPI pins */
GPIO_PIN_0, /* SCK */
GPIO_PIN_3, /* MISO */
GPIO_PIN_2, /* MOSI */

GPIO_PORTP_BASE, /* Chip select port */
GPIO_PIN_4, /* Chip select pin */

GPIO_PORTQ_BASE, /* GPIO TX port */
GPIO_PIN_2, /* GPIO TX pin */
}
};

const SDSPI_Config SDSPI_config[] = {
{&SDSPITiva_fxnTable, &sdspiTivaobjects[0], &sdspiTivaHWattrs[0]},
{&SDSPITiva_fxnTable, &sdspiTivaobjects[1], &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();
}
#endif /* TI_DRIVERS_SDSPI_INCLUDED */

-

Thanks

Regards

Soumyajit

  • Hi Soumyajit,

    /*
    * 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);

    On the launchpad, PA2 and PA3 are shorted via a resistor with PQ2 and PQ3 respectively. To avoid having PA2 and PA3 electrically interfere with PQ2 and PQ3, PA2 and PA3 are configured as inputs.

    The resistors were added to comply with TI's standardization of boosterpack headers (with originally started with MSP430 devices). With MSP430, it happens to be that those pins can be used in either I2C or SPI modes and since that's not possible on Tiva devices, a shortening resistor was added.

    Having said that, when you do move to a production board, you will probably not want to short those 2 pins together and then you wouldn't need to add the red code.

  • Thanks Tom,
    This answers my query.

    Regards
    Soumyajit