Example #1
0
void Lcd_SetCursor(unsigned int x,unsigned int y)
{
    LCD_WriteRegIndex(0x20);
    LCD_WriteData(x);//水平坐标
    LCD_WriteRegIndex(0x21);
    LCD_WriteData(y);//垂直坐标
}
Example #2
0
/*******************************************************************************
* Function Name  : LCD_WriteRAM_Prepare
* Description    : Prepare to write to the LCD RAM.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteRAM_Prepare(void)
{
    LCD_WriteRegIndex(R34); /* Select GRAM Reg */

    /* Reset LCD control line(/CS) and Send Start-Byte */
    LCD_nCS_StartByte(START_BYTE | LCD_WRITE_REG);
}
Example #3
0
void SPILCD_SetWindow(unsigned int xstat,unsigned int xend,unsigned int ystat,unsigned int yend)
{
    LCD_WriteRegIndex(0x2A);
    LCD_WriteByteSPI(xstat>>8);
    LCD_WriteByteSPI(xstat);
    LCD_WriteByteSPI(xend>>8);
    LCD_WriteByteSPI(xend);

    LCD_WriteRegIndex(0x2B);
    LCD_WriteByteSPI(ystat>>8);
    LCD_WriteByteSPI(ystat);
    LCD_WriteByteSPI(yend>>8);
    LCD_WriteByteSPI(yend);

    LCD_WriteRegIndex(0x2C);

}
Example #4
0
/*******************************************************************************
* Function Name  : LCD_ReadReg
* Description    : Reads the selected LCD Register.
* Input          : None
* Output         : None
* Return         : LCD Register Value.
*******************************************************************************/
u16 LCD_ReadReg(u8 LCD_Reg)
{
    vu16 tmp = 0;
    vu8 i = 0;

    /* SPI3 prescaler: 4 */
    SPI3->CR1 &= 0xFFC7;
    SPI3->CR1 |= 0x0008;

    /* Write 16-bit Index (then Read Reg) */
    LCD_WriteRegIndex(LCD_Reg);

    /* Read 16-bit Reg */
    /* Reset LCD control line(/CS) and Send Start-Byte */
    LCD_nCS_StartByte(START_BYTE | LCD_READ_REG);

    for(i = 0; i < 5; i++) {
        SPI_I2S_SendData(SPI3, 0xFF);

        while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) != RESET) {
            vBlockToWait( 1 );
        }
        /* One byte of invalid dummy data read after the start byte */
        while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) {
            vBlockToWait( 1 );
        }
        SPI_I2S_ReceiveData(SPI3);
    }

    SPI_I2S_SendData(SPI3, 0xFF);
    /* Read upper byte */
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) != RESET) {
        vBlockToWait( 1 );
    }
    /* Read lower byte */
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) {
        vBlockToWait( 1 );
    }
    tmp = SPI_I2S_ReceiveData(SPI3);


    SPI_I2S_SendData(SPI3, 0xFF);
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) != RESET) {
        vBlockToWait( 1 );
    }
    /* Read lower byte */
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) {
        vBlockToWait( 1 );
    }
    tmp = ((tmp & 0xFF) << 8) | SPI_I2S_ReceiveData(SPI3);

    LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);

    /* SPI3 prescaler: 2 */
    SPI3->CR1 &= 0xFFC7;

    return tmp;
}
/**
  * @brief  Reads the selected LCD Register.
  * @param  None
  * @retval LCD Register Value.
  */
uint16_t LCD_ReadReg(uint8_t LCD_Reg)
{
  uint16_t tmp = 0;
  uint8_t i = 0;
  
  /* LCD_SPI prescaler: 4 */
  LCD_SPI->CR1 &= 0xFFC7;
  LCD_SPI->CR1 |= 0x0008;
  /* Write 16-bit Index (then Read Reg) */
  LCD_WriteRegIndex(LCD_Reg);
  /* Read 16-bit Reg */
  /* Reset LCD control line(/CS) and Send Start-Byte */
  LCD_nCS_StartByte(START_BYTE | LCD_READ_REG);
  
  for(i = 0; i < 5; i++)
  {
    SPI_I2S_SendData(LCD_SPI, 0xFF);
    while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET)
    {
    }
    /* One byte of invalid dummy data read after the start byte */
    while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_RXNE) == RESET)
    {    
    }
    SPI_I2S_ReceiveData(LCD_SPI); 
  }
  SPI_I2S_SendData(LCD_SPI, 0xFF);
  /* Read upper byte */
  while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET)
  {
  }
  /* Read lower byte */
  while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_RXNE) == RESET)
  {
  }
  tmp = SPI_I2S_ReceiveData(LCD_SPI);
  
  
  SPI_I2S_SendData(LCD_SPI, 0xFF);
  while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET)
  {
  }
  /* Read lower byte */
  while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_RXNE) == RESET)
  {
  }
  tmp = ((tmp & 0xFF) << 8) | SPI_I2S_ReceiveData(LCD_SPI);
  LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET);
  /* LCD_SPI prescaler: 2 */
  LCD_SPI->CR1 &= 0xFFC7;
  return tmp;
}
/**
  * @brief  Writes to the selected LCD register.
  * @param  LCD_Reg: address of the selected register.
  * @param  LCD_RegValue: value to write to the selected register.
  * @retval None
  */
void LCD_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue)
{
	/* Write 16-bit Index (then Write Reg) */
	LCD_WriteRegIndex(LCD_Reg);
	/* Write 16-bit Reg */
	/* Reset LCD control line(/CS) and Send Start-Byte */
	LCD_nCS_StartByte(START_BYTE | LCD_WRITE_REG);
	SPI_I2S_SendData(LCD_SPI, LCD_RegValue>>8);
	while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET) {
	}
	SPI_I2S_SendData(LCD_SPI, (LCD_RegValue & 0xFF));
	while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET) {
	}
	LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET);
}
Example #7
0
/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : Writes to the selected LCD register.
* Input          : - LCD_Reg: address of the selected register.
*                  - LCD_RegValue: value to write to the selected register.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{
    /* Write 16-bit Index (then Write Reg) */
    LCD_WriteRegIndex(LCD_Reg);

    /* Write 16-bit Reg */
    /* Reset LCD control line(/CS) and Send Start-Byte */
    LCD_nCS_StartByte(START_BYTE | LCD_WRITE_REG);

    SPI_I2S_SendData(SPI3, LCD_RegValue>>8);
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) != RESET) {
        vBlockToWait( 1 );
    }
    SPI_I2S_SendData(SPI3, (LCD_RegValue & 0xFF));
    while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) != RESET) {
        vBlockToWait( 1 );
    }

    LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
}
Example #8
0
void SPILCD_WriteRAM_Prepare(void)
{
    LCD_WriteRegIndex(0x22);   //写RAM
}
Example #9
0
//关闭反色显示
void LCD_InvDisplayOff()
{
    LCD_WriteRegIndex(0x20);
}
Example #10
0
//开启反色显示
void LCD_InvDisplayOn()
{
    LCD_WriteRegIndex(0x21);
}
Example #11
0
/******************************************
函数名:void ILI9325_CMO24_Initial(void)
功能:对LCD用到的管脚进行初始化设置
******************************************/
void ILI9325_CMO24_Initial(void)
{
    Delayms(10);       //延时10ms
    CSOUT |=CS;        //片选信号  CS
    Delayms(150);      //延时150ms
    CSOUT &=~CS;
    Delayms(25);       //延时10ms
    RS_RST_OUT&=~RST;  //复位信号  RST
    Delayms(150);      //延时150ms
    RS_RST_OUT|=RST;
    Delayms(150);      //延时150ms

    LCD_WriteRegIndex(0x00B0);//{setc, [107], W, 0x000B0}
    LCD_WriteByteSPI(0x0000);//{setp, [104], W, 0x00000}

    LCD_WriteRegIndex(0x00B3);
    LCD_WriteByteSPI( 0x0002);
    LCD_WriteByteSPI(0x0000);
    LCD_WriteByteSPI(0x0000);
    LCD_WriteByteSPI(0x0000);

    LCD_WriteRegIndex(0x00B4);
    LCD_WriteByteSPI(0x0000);

    LCD_WriteRegIndex(0x00C0);
    LCD_WriteByteSPI(0x0013);//
    LCD_WriteByteSPI( 0x003B);//480
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0003);//02
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0001);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0043);

    LCD_WriteRegIndex( 0x00C1);
    LCD_WriteByteSPI( 0x0008);
    LCD_WriteByteSPI( 0x0012);//CLOCK
    LCD_WriteByteSPI( 0x0008);
    LCD_WriteByteSPI( 0x0008);

    LCD_WriteRegIndex( 0x00C4);
    LCD_WriteByteSPI( 0x0011);
    LCD_WriteByteSPI( 0x0007);
    LCD_WriteByteSPI( 0x0003);
    LCD_WriteByteSPI( 0x0003);

    LCD_WriteRegIndex( 0x00C8);//GAMMA
    LCD_WriteByteSPI( 0x0004);
    LCD_WriteByteSPI( 0x0009);
    LCD_WriteByteSPI( 0x0016);
    LCD_WriteByteSPI( 0x005A);
    LCD_WriteByteSPI( 0x0002);
    LCD_WriteByteSPI( 0x000A);
    LCD_WriteByteSPI( 0x0016);
    LCD_WriteByteSPI( 0x0005);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0032);
    LCD_WriteByteSPI( 0x0005);
    LCD_WriteByteSPI( 0x0016);
    LCD_WriteByteSPI( 0x000A);
    LCD_WriteByteSPI( 0x0053);//43/55
    LCD_WriteByteSPI( 0x0008);
    LCD_WriteByteSPI( 0x0016);
    LCD_WriteByteSPI( 0x0009);
    LCD_WriteByteSPI( 0x0004);
    LCD_WriteByteSPI( 0x0032);
    LCD_WriteByteSPI( 0x0000);

    LCD_WriteRegIndex( 0x002A);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0001);
    LCD_WriteByteSPI( 0x003F);//320

    LCD_WriteRegIndex( 0x002B);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0001);
    LCD_WriteByteSPI( 0x00DF);//480

    LCD_WriteRegIndex( 0x0035);
    LCD_WriteByteSPI( 0x0000);

    LCD_WriteRegIndex( 0x003A);
    LCD_WriteByteSPI( 0x0055);

    LCD_WriteRegIndex( 0x0044);
    LCD_WriteByteSPI( 0x0000);
    LCD_WriteByteSPI( 0x0001);

    LCD_WriteRegIndex( 0x002C);
    LCD_WriteRegIndex( 0x0011);

    Delayms(150);

    LCD_WriteRegIndex( 0x00D0);
    LCD_WriteByteSPI( 0x0007);
    LCD_WriteByteSPI( 0x0007);
    LCD_WriteByteSPI( 0x001E);
    LCD_WriteByteSPI( 0x07);
    LCD_WriteByteSPI( 0x03);
    LCD_WriteRegIndex( 0x00D1);
    LCD_WriteByteSPI( 0x0003);
    LCD_WriteByteSPI( 0x0052);//VCM
    LCD_WriteByteSPI( 0x0010);//VDV

    LCD_WriteRegIndex( 0x00D2);
    LCD_WriteByteSPI( 0x0003);
    LCD_WriteByteSPI( 0x0024);

    LCD_WriteRegIndex(0x00B0);//{setc, [107], W, 0x000B0}
    LCD_WriteByteSPI(0x0000);//{setp, [104], W, 0x00000}

    LCD_WriteRegIndex(0x0029);
    Delayms(10);
    LCD_WriteRegIndex(0x0036);
    LCD_WriteByteSPI(0x0028);
}