Exemple #1
0
// Analog SPI
void AspiCmd(u8 Command_Byte)
{
    int i=8; 
    LCD_A0_LOW();

    LCD_CLK_HIGH();
    LCD_CLK_HIGH();
    LCD_NCS_LOW();
 
    while (i--) {
      LCD_CLK_LOW();

      if (Command_Byte&0x80)
        LCD_MOSI_HIGH();
      else
        LCD_MOSI_LOW();

      Command_Byte <<= 1;
      LCD_CLK_LOW(); \
      LCD_CLK_LOW(); \

      LCD_CLK_HIGH();
      LCD_CLK_HIGH();
    }

    LCD_NCS_HIGH();  
    LCD_A0_HIGH();
}
Exemple #2
0
void lcd_send_byte(unsigned char byte)
{
    unsigned char i, temp;


    temp = byte;

    for(i = 0; i < 8; i++)
    {
        LCD_SCK_LOW();

        if(temp & 0x80)
        {
            LCD_MOSI_HIGH();
        }
        else
        {
            LCD_MOSI_LOW();
        }

        LCD_SCK_HIGH();

        temp <<= 1;
    }
}
Exemple #3
0
/** Initialise the LCD
 *
 * Sets up the pins required to communicate with the LCD screen and then does
 * the actual chipset initialisation. The pin numbers to use are defined in
 * @ref hardware.h.
 */
void lcdInit() {
  LCD_SCK_SET_OUTPUT();
  LCD_MOSI_SET_OUTPUT();
  LCD_CD_SET_OUTPUT();

  LCD_SCK_LOW();
  LCD_MOSI_LOW();
  LCD_CD_LOW();

#if defined(LCD_USE_PROGRAM_RESET) 
  LCD_RESET_SET_OUTPUT();
  LCD_RESET_LOW();
  // Do a hard reset on the LCD
  waitReset();
  //PORTB |= (1 << LCD_RESET);
  LCD_RESET_HIGH();
#endif

  // Initialise the LCD
  lcdCommand(0x21);  // LCD Extended Commands.
  lcdCommand(0x80|LCD_CONTRAST_VALUE);  // Set LCD Vop (Contrast).
  lcdCommand(0x04);  // Set Temp coefficent.
  lcdCommand(0x14);  // LCD bias mode 1:48.
  lcdCommand(0x20);  // LCD Normal commands
  lcdCommand(0x08 | 0x04);  // Normal display, horizontal addressing
}
Exemple #4
0
/** Transfer data to a slave (MSB first)
 *
 * @param sck the pin to use for the SCK output
 * @param mosi the pin to use for the MOSI output
 * @param data the data to transfer
 * @param bits the number of bits to transfer
 */
void sspiOutMSB(uint8_t data) {
  uint8_t bit;
  for(bit = 0x80; bit; bit >>= 1) {
    // Bring the clock low
    LCD_SCK_LOW();
    // Set data
    if(data & bit) {
      LCD_MOSI_HIGH();
    } else {
      LCD_MOSI_LOW();
    }
    // Bring the clock high
    LCD_SCK_HIGH();
  }
}
Exemple #5
0
//Anolog spi
void AspiData(u8 Para_data)
{
    int i=8;
    LCD_CLK_HIGH();
    LCD_A0_HIGH();
    LCD_NCS_LOW();
    while (i--) {
    	LCD_CLK_LOW();
        if (Para_data&0x80)
          LCD_MOSI_HIGH();
        else
          LCD_MOSI_LOW();
        Para_data <<= 1;
        __no_operation();
        LCD_CLK_HIGH();
        __no_operation();
    }
    LCD_NCS_HIGH();
    LCD_A0_HIGH();  
}
Exemple #6
0
void AspiCmd(uint8_t Command_Byte)
{
    int i=8; 
    LCD_A0_LOW();

    LCD_CLK_HIGH();
    LCD_NCS_LOW();  
 
    while (i--) 
    { 
	    LCD_CLK_LOW(); 
	    if(Command_Byte&0x80)
	{
        LCD_MOSI_HIGH();
    }
	else LCD_MOSI_LOW();

	Command_Byte=Command_Byte<<1; 
	LCD_CLK_HIGH();  
    } 
    LCD_NCS_HIGH();  
    LCD_A0_HIGH();
}