// Distinguishing write data, DC (GPIOA2_BASE) set to high void writeData(unsigned char c) { unsigned long ulDummy; GPIOPinWrite(GPIOA2_BASE, 0x40, 0x40); SPICSEnable(GSPI_BASE); SPIDataPut(GSPI_BASE, c); SPIDataGet(GSPI_BASE, &ulDummy); SPICSDisable(GSPI_BASE); }
//***************************************************************************** // //! \brief Write an byte to SPI Bus then read back an byte. //! //! \param data is the byte to be transfered. //! //! \return the byte read back from spi salave. //! \note after read byte, you must wait 10us. // //***************************************************************************** uint8_t SpiDrv_Transfer(uint8_t ucData) { /* uint8_t recv = 0; recv = xSPISingleDataReadWrite(xSPI1_BASE, data); //This delay is must //Note By CooCox Cedar delay(0x5F); return (recv); */ unsigned long ucRecv = 0; while(xSPIIsTxEmpty(xSPI1_BASE) == xfalse); SPIDataPut(xSPI1_BASE, ucData); while(SPIIsRxNotEmpty(xSPI1_BASE) == xfalse); xSPIDataGet(xSPI1_BASE, &ucRecv); delay(0x5F); return (ucRecv); }