void glcd_spi_write(uint8_t c) { GLCD_SELECT(); SpiChnPutC(SPI_CHANNEL2, c); // Wait until the byte is sent before deselecting while(SpiChnIsBusy(SPI_CHANNEL2)); GLCD_DESELECT(); }
void glcd_reset(void) { GLCD_SELECT(); GLCD_RESET_LOW(); delay_ms(GLCD_RESET_TIME); GLCD_RESET_HIGH(); // Wait until the byte is sent before deselecting while(SpiChnIsBusy(SPI_CHANNEL2)); GLCD_DESELECT(); }
/************************************************************** * Function name : WriteDrive * Purpose : Write a cmd to the drive. * Arguments : None. * Returns : None. *************************************************************/ void WriteDrive(INT32 DRV, INT32 msg) { int i=0; if(DRV == DRVA) { while(SpiChnIsBusy(SPI4+1)); DRVA_SC = 1; Spi.SendCharacter(SPI4, msg); for (i = 0; i < 1000; i++); // Small delay necessary for the drive while(SpiChnIsBusy(SPI4+1)); DRVA_SC = 0; } else if(DRV == DRVB) { while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 1; Spi.SendCharacter(SPI4, msg); for (i = 0; i < 1000; i++); // Small delay necessary for the drive while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 0; } else if(DRV == DRVAB) { while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 1; DRVA_SC = 1; Spi.SendCharacter(SPI4, msg); for (i = 0; i < 1000; i++); // Small delay necessary for the drive while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 0; DRVA_SC = 0; } }
/************************************************************** * Function name : ReadDrive * Purpose : Read a msg from the drive. Not used * Arguments : None. * Returns : None. *************************************************************/ INT32 ReadDrive(INT32 DRV, INT32 msg) { int i=0; INT32 data; if(DRV == DRVA) { while(SpiChnIsBusy(SPI4+1)); DRVA_SC = 1; // Spi.SendCharacter(SPI4, msg | (1 << 15)); Spi.SendCharacter(SPI4, msg); while(SpiChnIsBusy(SPI4+1)); data = Spi.GetCharacter(SPI4); while(SpiChnIsBusy(SPI4+1)); data = Spi.GetCharacter(SPI4); DRVA_SC = 0; } else if(DRV == DRVB){ while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 1; // Spi.SendCharacter(SPI4, msg | (1 << 15)); Spi.SendCharacter(SPI4, msg); while(SpiChnIsBusy(SPI4+1)); data = Spi.GetCharacter(SPI4); while(SpiChnIsBusy(SPI4+1)); data = Spi.GetCharacter(SPI4); DRVB_SC = 0; } else if(DRV == DRVAB){ while(SpiChnIsBusy(SPI4+1)); DRVB_SC = 1; DRVA_SC = 1; // Spi.SendCharacter(SPI4, msg | (1 << 15)); Spi.SendCharacter(SPI4, msg); while(SpiChnIsBusy(SPI4+1)); data = Spi.GetCharacter(SPI4); DRVB_SC = 0; DRVA_SC = 0; } return data; }