Hi,
I'm working with an OMAPL137 EVM Board and I'm trying to communicate with an ADC through the SPI interface using the PSP drivers but so far I haven't been able to make it work. I configure the SPI parameters and it all says it works, but when I use the GIO_read, the values read are not what they are supposed to be. I'm trying to use the SPI0 interface. Here's a snippet of the code:
GIO_Handle spi_handle = NULL;
Spi_Params spi_params;
void spi_initParams(void) {
spi_params = Spi_PARAMS;
spi_params.hwiNumber = 8;
spi_params.spiHWCfgData.intrLevel = FALSE;
spi_params.opMode = Spi_OpMode_INTERRUPT;
spi_params.outputClkFreq = 18000000;
spi_params.loopbackEnabled = FALSE;
spi_params.edmaHandle = NULL;
spi_params.spiHWCfgData.configDatafmt[0].charLength = 16;
spi_params.spiHWCfgData.configDatafmt[0].clkHigh = TRUE;
spi_params.spiHWCfgData.configDatafmt[0].lsbFirst = FALSE;
spi_params.spiHWCfgData.configDatafmt[0].oddParity = FALSE;
spi_params.spiHWCfgData.configDatafmt[0].parityEnable = FALSE ;
spi_params.spiHWCfgData.configDatafmt[0].phaseIn = FALSE ;
spi_params.spiHWCfgData.configDatafmt[0].waitEnable = TRUE;
spi_params.spiHWCfgData.intrLevel = FALSE;
}
void spi_start(void) {
GIO_Attrs gio_attrs = GIO_ATTRS;
Spi_ChanParams chan_params;
chan_params.hGpio = NULL;
/* create SPI channel for transmission */
spi_handle = GIO_create("/Spi0",IOM_INOUT,NULL,&chan_params,&gio_attrs);
if (NULL != spi_handle) {
LOG_printf(&trace, "SPI Driver Handle correct initialization!\n");
} else {
LOG_printf(&trace, "\r\n SPI Driver Handle creation Failed ");
}
}
Int spi_read() {
Uint32 i, j;
Int status = IOM_COMPLETED;
Spi_DataParam dataparam;
size_t size = 0;
/* clear the input and output buffers */
memset(loopRead , 0x00, sizeof(loopRead));
/* clear the spi params data structure */
memset(&dataparam,0x00, sizeof(Spi_DataParam));
dataparam.bufLen = 6 * WORD;
dataparam.inBuffer = &loopRead[0];
dataparam.outBuffer = NULL;
dataparam.dataFormat = Spi_DataFormat_0;
dataparam.chipSelect = 0x1;
size = dataparam.bufLen;
GIO_write(spi_handle, &dataparam, &size);
for (i = 0; i < 6; i++) {
for (j = 0; j < WORD; j++) {
LOG_printf(&trace, "data[%d+%d]%x", i,j,loopRead[i * WORD + j]);
}
}
return status;
}
Please, can anyone help me with this problem? or does anyone have a working code for a similar interface that could help me?
Thanks in advance,
- Aquiles Lacruz