Exemple #1
0
void lcdRefresh()
{  
  for (uint32_t y=0; y<LCD_H; y++) {
    uint8_t *p = &displayBuf[(y>>3)*LCD_W];
    uint8_t mask = (1 << (y%8));

    Set_Address(0, y);
    AspiCmd(0xAF);

    LCD_CLK_HIGH();
    LCD_A0_HIGH();
    LCD_NCS_LOW();

    for (uint32_t x=0; x<LCD_W; x++) {
      LCD_WRITE_BIT(p[3*DISPLAY_PLAN_SIZE+x] & mask);
      LCD_WRITE_BIT(p[2*DISPLAY_PLAN_SIZE+x] & mask);
      LCD_WRITE_BIT(p[DISPLAY_PLAN_SIZE+x] & mask);
      LCD_WRITE_BIT(p[x] & mask);
    }

    LCD_NCS_HIGH();
    LCD_A0_HIGH();

    WriteData(0);
  }
}
Exemple #2
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 #3
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 #4
0
/***************************************************************************************************
 * @fn      lcd_data_write
 *
 * @brief   LCD字节写入
 * @param   NULL
 * @return  0 -- success
 ***************************************************************************************************/  
void lcd_data_write(uint8_t data)
{
	LCD_A0_HIGH();
	LCD_NCS_LOW()
	while ( ( LCD_SPI_MASTER->SR & SPI_SR_TXE ) == 0 ) 
	{};
  	(void)LCD_SPI_MASTER->DR ;		// Clear receive
  	LCD_SPI_MASTER->DR = data ;
  	while ( ( LCD_SPI_MASTER->SR & SPI_SR_RXNE ) == 0 ) 
	{};
	LCD_NCS_HIGH();
	
	return 0;
}
Exemple #5
0
/***************************************************************************************************
 * @fn      lcd_data_burst_write
 *
 * @brief   LCD数据批量写入
 * @param   buf -- 要写入的数据的缓存
 *			len -- 写入数据的长度
 * @return  1 --  busy
 *			-1 - failure
 *			0 --  success 
 ***************************************************************************************************/  
int lcd_data_burst_write(uint8_t *buf, uint16_t len)
{
	IF_PTR_IS_NULL_RET_NULLPTR_ERR(buf);

	if(len > LCD_TX_BUFF_SIZE)
	{
		printf("lcd write lenth is too large,return @ %s, %s, %d\r\n", __FILE__, __func__, __LINE__);
		return -1;
	}	
	
	if(g_LcdWriteBusyFlag)
	{
		printf("lcd is busy, return @ %s, %s, %d\r\n", __FILE__, __func__, __LINE__);
		return 1;
	}		

	g_LcdWriteBusyFlag = 1;

	lcd_cursor_addr_set(0,0);		

	LCD_A0_HIGH();
	LCD_NCS_LOW();

	//启动DMA
	DMA_Cmd(LCD_DMA_STREAM, DISABLE);
	DMA_ClearITPendingBit(LCD_DMA_STREAM, LCD_DMA_TC_FLAG);

	memcpy(g_lcdTxBuff, buf, len);
	DMA_SetCurrDataCounter(LCD_DMA_STREAM, len);
	
	SPI_I2S_DMACmd(LCD_SPI_MASTER,SPI_I2S_DMAReq_Tx,ENABLE);
	DMA_ITConfig(LCD_DMA_STREAM, DMA_IT_TC, ENABLE);		
	
	DMA_Cmd(LCD_DMA_STREAM,ENABLE);

	printf("begin lcd dma write @ %s, %s, %d\r\n", __FILE__, __func__, __LINE__);
	printf(" SPI3->CR1:%#x, SPI3->CR2:%#x, SPI3->SR:%#x, DMA1_Stream7->CR:%#x, DMA1->HIFCR:%#x\r\n", SPI3->CR1, SPI3->CR2, SPI3->SR, DMA1_Stream7->CR, DMA1->HIFCR);
	
	return 0;
}
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();
}