Hello,
I am trying to interface LS013B7DH06 Sharp-memory LCD with K60 via SPI interface. I have written my spi_write function as follows,
{SPI2_PUSHR = ((SPI_PUSHR_CTAS(0x00)) | (SPI_PUSHR_PCS(63)) | (SPI_PUSHR_CONT_MASK) | SPI_PUSHR_TXDATA(0x20));
while(((SPI2_SR & SPI_SR_TCF_MASK) == 0));
SPI2_SR |= SPI_SR_TCF_MASK;
SPI2_SR |= SPI_SR_TFFF_MASK;
// end of queue
SPI2_PUSHR = ((SPI_PUSHR_CTAS(0x00)) | (SPI_PUSHR_PCS(63))| (SPI_PUSHR_EOQ_MASK) | (SPI_PUSHR_CONT_MASK & 0x00) | SPI_PUSHR_TXDATA(0x00));
while(((SPI2_SR & SPI_SR_TCF_MASK) == 0));
SPI2_SR |= SPI_SR_TCF_MASK;
SPI2_SR |= SPI_SR_TFFF_MASK;}
Lcd write is happening fine and i am able to write all my graphics api. Now when i try to write the SPI_Write Function using the following code,
void bspSpiWrite ( uint8_t addr)
{
uint8_t buffer[1];
uint32_t data;
_mqx_int result;
buffer[0]= addr; // (0x20) 0r (0x80)
result = fwrite( buffer, 1, sizeof(buffer), spifd);
if (result != 1)
printf("ERROR");
else
printf("OK");
fflush(spifd);
}
Now since its a complete MQX api (fwrite) and this is what i need to implement, my code is not working if i use the above function. May i request anyone to please explain me why it is working with 1st case and why not with 2nd? What is wrong with the 2nd function??
It would be a great if someone helps me out on this.
Thanks in advance.
Solved! Go to Solution.
Hi Nithin:
Since I don't see your whole source, especially where you open this spi device , It is hard to locate the root cause. I would suggest you check the the chip select.
For more details, please see chapter 9.6, Using the SPI driver
Freescale_MQX_4_2\doc\mqx\MQX_IO_User_Guide.pdf
For details how to implement SPI, please look at SPI example codel
Freescale_MQX_4_2\mqx\examples\spi
Regards
Daniel
Hi Nithin:
Since I don't see your whole source, especially where you open this spi device , It is hard to locate the root cause. I would suggest you check the the chip select.
For more details, please see chapter 9.6, Using the SPI driver
Freescale_MQX_4_2\doc\mqx\MQX_IO_User_Guide.pdf
For details how to implement SPI, please look at SPI example codel
Freescale_MQX_4_2\mqx\examples\spi
Regards
Daniel
Thank you for the reply Daniel.