void LCDReset(void) { LED_A_ON(); SetupSpi(SPI_LCD_MODE); LOW(GPIO_LRST); SpinDelay(100); HIGH(GPIO_LRST); SpinDelay(100); LED_A_OFF(); }
//----------------------------------------------------------------------------- // Transmit data over the SPI then receive any incoming data. // Data can be variable length (8 - 16 bits) //----------------------------------------------------------------------------- unsigned int spi_com(unsigned int channel, unsigned int dout, unsigned char last) { unsigned int din; SetupSpi(channel); // enable relevant channel while ( !( AT91C_BASE_SPI->SPI_SR & AT91C_SPI_TDRE ) ); // wait for SPI ready state AT91C_BASE_SPI->SPI_TDR = dout; // send data while ( !( AT91C_BASE_SPI->SPI_SR & AT91C_SPI_RDRF ) ); // wait for incoming data din = AT91C_BASE_SPI->SPI_RDR ; // receive data if (last) AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIEN | AT91C_SPI_LASTXFER; return (din & 0xffff); }
//----------------------------------------------------------------------------- // Send a 16 bit command/data pair to the FPGA. // The bit format is: C3 C2 C1 C0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 // where C is the 4 bit command and D is the 12 bit data //----------------------------------------------------------------------------- void FpgaSendCommand(uint16_t cmd, uint16_t v) { SetupSpi(SPI_FPGA_MODE); while ((AT91C_BASE_SPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); // wait for the transfer to complete AT91C_BASE_SPI->SPI_TDR = AT91C_SPI_LASTXFER | cmd | v; // send the data }