Ejemplo n.º 1
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;
    }
}
Ejemplo n.º 2
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
}
Ejemplo n.º 3
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();
  }
}
Ejemplo n.º 4
0
void LCD_SendByte(unsigned char a)
{
	unsigned char i,d;
	LCD_CS_HIGH();
	LCD_SIO_OUT();
	for(i=0;i<8;i++)
	{
		LCD_SCK_LOW();  //clrbit(LCD_CTRL,E);  
		d = a&0x80;
		if(d)
			LCD_SIO_HIGH();	//setbit(LCD_CTRL,RW);
		else
			LCD_SIO_LOW();	//clrbit(LCD_CTRL,RW);
		a<<=1;
		LCD_SCK_HIGH();  //setbit(LCD_CTRL,E); //上升弦发送
	}
	LCD_CS_LOW();
}