예제 #1
0
파일: aspi.c 프로젝트: BenZoFly/opentx
// 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();
}
예제 #2
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);
  }
}
예제 #3
0
파일: aspi.c 프로젝트: BenZoFly/opentx
void AspiCmd(uint8_t Command_Byte)
{
  LCD_A0_LOW() ;
  LCD_NCS_LOW() ;  
  while ( ( SPI3->SR & SPI_SR_TXE ) == 0 ) {
    // wait
  }
  (void)SPI3->DR ;		// Clear receive
  SPI3->DR = Command_Byte ;
  while ( ( SPI3->SR & SPI_SR_RXNE ) == 0 ) {
    // wait
  }
  LCD_NCS_HIGH() ;
}
예제 #4
0
/**
  * @brief  Send a byte to LCD
  * @param  DataType Type of Data to be sent
  * @param  DataToSend Data to be sent
  * @retval None
  */
void LCD_SendByte(uint8_t DataType, uint8_t DataToSend)
{
  /* Enable access to LCD */
  LCD_NCS_HIGH();

  /* Send Synchro/Mode byte */
  LCD_SPISendByte(DataType);

  /* Send byte high nibble */
  LCD_SPISendByte((uint8_t)(DataToSend & (uint8_t)0xF0));

  /* Send byte low nibble */
  LCD_SPISendByte((uint8_t)((uint8_t)(DataToSend << 4) & (uint8_t)0xF0));
  _delay_(80);

  /* Disable access to LCD */
  LCD_NCS_LOW();
}
예제 #5
0
파일: aspi.c 프로젝트: Plohish/opentx
//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();  
}
예제 #6
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;
}
예제 #7
0
파일: aspi.cpp 프로젝트: chrisshum128/mbtx
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();
}
예제 #8
0
void refreshDisplay()
{
	Set_Address( 0, 0 ) ;
	
  LCD_NCS_LOW() ;  
	GPIOC->BSRRL = PIN_LCD_A0 ;			// A0 high

	convertDisplay() ;

//	setupSPIdma() ;
	DmaDebugDone = 0 ;
	startSpiDma() ;

//	DMA1_Stream7->CR |= DMA_SxCR_EN ;		// Enable DMA
//	SPI3->CR2 |= SPI_CR2_TXDMAEN ;
//	uint32_t x ;
	if ( Main_running )
	{
		CoWaitForSingleFlag( LcdFlag, 10 ) ;
		DmaDebugDone = 0x80 ;
	}

//	if ( x == E_OK )
//	{
//	}

//	while ( ( DMA1->HISR & DMA_HISR_TCIF7 ) == 0 )
//	{
//		// wait
//		if ( DmaDone )
//		{
//			DmaDebugNDTR = DMA1_Stream7->NDTR ;
//			DmaDebugDone = 1 ;
//		}
//	}
//	DmaDebugDone |= 0x20 ;

	while ( DmaDone == 0 )
	{
		// wait
//		if ( DMA1->HISR & DMA_HISR_TCIF7 )
//		{
//			SPI3->CR2 &= ~SPI_CR2_TXDMAEN ;
//			DMA1_Stream7->CR &= ~DMA_SxCR_EN ;		// Disable DMA
//			break ;
//		}
	}
	DmaDebugDone |= 1 ;
	if ( DMA1_Stream7->CR & DMA_SxCR_EN )
	{
		DmaDebugDone |= 0x10 ;
	}

//	if ( DMA1_Stream7->NDTR )
//	{
//		while ( ( DMA1->HISR & DMA_HISR_TCIF7 ) == 0 )
//		{
//			// wait
//		}
//		DmaDebugDone |= 0x20 ;
//	}

//	SPI3->CR2 &= ~SPI_CR2_TXDMAEN ;
//	DMA1_Stream7->CR &= ~DMA_SxCR_EN ;		// Disable DMA

	while ( ( SPI3->SR & SPI_SR_TXE ) == 0 )
	{
			
	} // Last byte being sent
	while ( SPI3->SR & SPI_SR_BSY )
	{
		// wait
	}
  GPIOA->BSRRL = PIN_LCD_NCS ;		// CS high
}