コード例 #1
0
/**
  * @brief  Read register value.
  * @param  Reg
  * @retval None
  */
uint16_t LCD_IO_ReadData(uint16_t Reg) 
{
  uint32_t readvalue = 0;

  /* Change BaudRate Prescaler 8 for Read */
  /* Mean SPI baudrate is set to 72/8 = 9 MHz */
  heval_Spi.Instance->CR1 &= 0xFFC7;
  heval_Spi.Instance->CR1 |= SPI_BAUDRATEPRESCALER_8;
  
  /* Send Reg value to Read */
  LCD_IO_WriteReg(Reg);

  /* Reset LCD control line(/CS) and Send command */
  LCD_CS_LOW();
  
  /* Send Start Byte */
  SPIx_Write(START_BYTE | LCD_READ_REG);

  /* Read Upper Byte */
  SPIx_Write(0xFF);
  readvalue = SPIx_Read();
  readvalue = readvalue << 8;
  readvalue |= SPIx_Read();
  
  /* Recover Baud Rate initial value */
  heval_Spi.Instance->CR1 &= 0xFFC7;
  heval_Spi.Instance->CR1 |= heval_Spi.Init.BaudRatePrescaler;

  HAL_Delay(10);

  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
  return readvalue;
}
コード例 #2
0
ファイル: stm32l073z_eval.c プロジェクト: S4mw1s3/Nucleo32
/**
  * @brief  Read register value.
  * @param  Reg
  * @retval None
  */
uint16_t LCD_IO_ReadData(uint16_t Reg) 
{
  uint32_t readvalue = 0;

  /* Send Reg value to Read */
  LCD_IO_WriteReg(Reg);

  /* Reset LCD control line(/CS) and Send command */
  LCD_CS_LOW();
  
  /* Send Start Byte */
  SPIx_Write(START_BYTE | LCD_READ_REG);

  /* Read Upper Byte */
  SPIx_Write(0xFF);
  readvalue = SPIx_Read();
  readvalue = readvalue << 8;
  readvalue |= SPIx_Read();
  
  HAL_Delay(10);

  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
  return readvalue;
}
コード例 #3
0
/**
* @brief  Write register value.
* @param  pData Pointer on the register value
* @param  Size Size of byte to transmit to the register
* @retval None
*/
void LCD_IO_WriteData(uint8_t *pData, uint32_t Size)
{
  uint32_t counter = 0;
  
  /* Reset LCD control line CS */
  LCD_CS_LOW();
  
  /* Send Start Byte */
  SPIx_Write(START_BYTE | LCD_WRITE_REG);

  for (counter = Size; counter != 0; counter--)
  {
    while(((heval_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
    {
    }  
    /* Need to invert bytes for LCD*/
    *((__IO uint8_t*)&heval_Spi.Instance->DR) = *(pData+1);
    
    while(((heval_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
    {
    }  
    *((__IO uint8_t*)&heval_Spi.Instance->DR) = *pData;
    counter--;
    pData += 2;
  }
  
  /* Wait until the bus is ready before releasing Chip select */ 
  while(((heval_Spi.Instance->SR) & SPI_FLAG_BSY) != RESET)
  {
  }  
  
  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
}
/**
  * @brief  Writes register address.
  */
void LCD_IO_WriteReg(uint8_t Reg) 
{
  /* Reset WRX to send command */
  LCD_WRX_LOW();
  
  /* Reset LCD control line(/CS) and Send command */
  LCD_CS_LOW();
  SPIx_Write(Reg);
  
  /* Deselect: Chip Select high */
  LCD_CS_HIGH();
}
/**
  * @brief  Writes register value.
  */
void LCD_IO_WriteData(uint16_t RegValue) 
{
  /* Set WRX to send data */
  LCD_WRX_HIGH();
  
  /* Reset LCD control line(/CS) and Send data */  
  LCD_CS_LOW();
  SPIx_Write(RegValue);
  
  /* Deselect: Chip Select high */
  LCD_CS_HIGH();
}
コード例 #6
0
/**
* @brief  Write register value.
* @param  pData Pointer on the register value
* @param  Size Size of byte to transmit to the register
* @retval None
*/
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size)
{
  uint32_t counter = 0;
  __IO uint32_t data = 0;
  
  /* Reset LCD control line CS */
  LCD_CS_LOW();
  
  /* Set LCD data/command line DC to High */
  LCD_DC_HIGH();

  if (Size == 1)
  {
    /* Only 1 byte to be sent to LCD - general interface can be used */
    /* Send Data */
    SPIx_Write(*pData);
  }
  else
  {
    /* Several data should be sent in a raw */
    /* Direct SPI accesses for optimization */
    for (counter = Size; counter != 0; counter--)
    {
      while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
      {
      }
      /* Need to invert bytes for LCD*/
      *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *(pData+1);
      
      while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
      {
      }
      *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *pData;
      counter--;
      pData += 2;
    }
    
    /* Wait until the bus is ready before releasing Chip select */ 
    while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_BSY) != RESET)
    {
    }  
  } 

  /* Empty the Rx fifo */
  data = *(&hnucleo_Spi.Instance->DR);
  UNUSED(data);  /* Remove GNU warning */

  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
}
コード例 #7
0
/**
  * @brief  Writes command to select the LCD register.
  * @param  LCDReg: Address of the selected register.
  * @retval None
  */
void LCD_IO_WriteReg(uint8_t LCDReg)
{
  /* Reset LCD control line CS */
  LCD_CS_LOW();
  
  /* Set LCD data/command line DC to Low */
  LCD_DC_LOW();
    
  /* Send Command */
  SPIx_Write(LCDReg);
  
  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
}
コード例 #8
0
ファイル: lcd.c プロジェクト: bearxiong99/gas-flow-meter
void lcd_write_data(unsigned char data)
{	
    OS_CPU_SR_ALLOC();
    

    OS_ENTER_CRITICAL();
    
    LCD_RS_HIGH();
    LCD_CS_LOW();
    lcd_send_byte(data);
    LCD_CS_HIGH();

    OS_EXIT_CRITICAL();
}
コード例 #9
0
ファイル: lcd.c プロジェクト: bearxiong99/gas-flow-meter
void lcd_write_cmd(unsigned char cmd)
{   
    OS_CPU_SR_ALLOC();
    

    OS_ENTER_CRITICAL();
    
    LCD_RS_LOW();
    LCD_CS_LOW();
    lcd_send_byte(cmd);
    LCD_CS_HIGH();

    OS_EXIT_CRITICAL();
}
コード例 #10
0
/**
  * @brief  Writes data to select the LCD register.
  *         This function must be used after st7735_WriteReg() function
  * @param  Data: data to write to the selected register.
  * @retval None
  */
void LCD_IO_WriteData(uint8_t Data)
{
    /* Reset LCD control line CS */
    LCD_CS_LOW();

    /* Set LCD data/command line DC to High */
    LCD_DC_HIGH();

    /* Send Data */
    SPIx_Write(Data);

    /* Deselect : Chip Select high */
    LCD_CS_HIGH();
}
コード例 #11
0
ファイル: stm32l073z_eval.c プロジェクト: S4mw1s3/Nucleo32
/**
  * @brief  register address.
  * @param  Reg
  * @retval None
  */
void LCD_IO_WriteReg(uint8_t Reg) 
{
  /* Reset LCD control line(/CS) and Send command */
  LCD_CS_LOW();
  
  /* Send Start Byte */
  SPIx_Write(START_BYTE | SET_INDEX);
  
  /* Write 16-bit Reg Index (High Byte is 0) */
  SPIx_Write(0x00);
  SPIx_Write(Reg);
  
  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
}
コード例 #12
0
ファイル: stm32l073z_eval.c プロジェクト: S4mw1s3/Nucleo32
/**
  * @brief  Write register value.
  * @param  pData Pointer on the register value
  * @param  Size Size of byte to transmit to the register
  * @retval None
  */
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size)
{
  uint32_t counter = 0;
  __IO uint32_t data = 0;

  /* Reset LCD control line(/CS) and Send data */  
  LCD_CS_LOW();

  /* Send Start Byte */
  SPIx_Write(START_BYTE | LCD_WRITE_REG);

  if (Size == 1)
  {
    /* Only 1 byte to be sent to LCD - general interface can be used */
    /* Send Data */
    SPIx_Write(*pData);
  }
  else
  {
    for (counter = Size; counter != 0; counter--)
    {
      while(((heval_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
      {
      }  
      /* Need to invert bytes for LCD*/
      *((__IO uint8_t*)&heval_Spi.Instance->DR) = *(pData+1);
    
      while(((heval_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE)
      {
      }  
      *((__IO uint8_t*)&heval_Spi.Instance->DR) = *pData;
      counter--;
      pData += 2;
    }
    
    /* Wait until the bus is ready before releasing Chip select */ 
    while(((heval_Spi.Instance->SR) & SPI_FLAG_BSY) != RESET)
    {
    }
  }

  /* Empty the Rx fifo */
  data = *(&heval_Spi.Instance->DR);
  UNUSED(data);  /* Remove GNU warning */

  /* Reset LCD control line(/CS) and Send data */  
  LCD_CS_HIGH();
}
コード例 #13
0
ファイル: ST7920.c プロジェクト: haoozi/SIM900A-py
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();
}
コード例 #14
0
void LCDSend(unsigned char data, unsigned char cd)
{
    LCD_CS_LOW();

    if (cd == SEND_CHR)
    {
        LCD_DC_HIGH();
    }
    else
    {
        LCD_DC_LOW();
    }

    // send data over SPI
    SEND_BYTE_SPI();

    LCD_CS_HIGH();
}
コード例 #15
0
ファイル: stm32l073z_eval.c プロジェクト: S4mw1s3/Nucleo32
/**
  * @brief  Configures the LCD_SPI interface.
  * @param  None
  * @retval None
  */
void LCD_IO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct;

  /* Configure the LCD Control pins ------------------------------------------*/
  LCD_NCS_GPIO_CLK_ENABLE();
    
  /* Configure NCS in Output Push-Pull mode */
  GPIO_InitStruct.Pin     = LCD_NCS_PIN;
  GPIO_InitStruct.Mode    = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull    = GPIO_PULLUP;
  GPIO_InitStruct.Speed   = GPIO_SPEED_FREQ_LOW     ;
  HAL_GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStruct);
    
  /* Set or Reset the control line */
  LCD_CS_LOW();
  LCD_CS_HIGH();

  SPIx_Init();
}
/**
  * @brief  Configures the LCD_SPI interface.
  */
void LCD_IO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  
  if(Is_LCD_IO_Initialized == 0)
  {
    Is_LCD_IO_Initialized = 1; 
    
    /* Configure NCS in Output Push-Pull mode */
    LCD_WRX_GPIO_CLK_ENABLE();
    GPIO_InitStructure.Pin     = LCD_WRX_PIN;
    GPIO_InitStructure.Mode    = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.Pull    = GPIO_NOPULL;
    GPIO_InitStructure.Speed   = GPIO_SPEED_FAST;
    HAL_GPIO_Init(LCD_WRX_GPIO_PORT, &GPIO_InitStructure);
    
    LCD_RDX_GPIO_CLK_ENABLE();
    GPIO_InitStructure.Pin     = LCD_RDX_PIN;
    GPIO_InitStructure.Mode    = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.Pull    = GPIO_NOPULL;
    GPIO_InitStructure.Speed   = GPIO_SPEED_FAST;
    HAL_GPIO_Init(LCD_RDX_GPIO_PORT, &GPIO_InitStructure);
    
    /* Configure the LCD Control pins ----------------------------------------*/
    LCD_NCS_GPIO_CLK_ENABLE();
    
    /* Configure NCS in Output Push-Pull mode */
    GPIO_InitStructure.Pin     = LCD_NCS_PIN;
    GPIO_InitStructure.Mode    = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.Pull    = GPIO_NOPULL;
    GPIO_InitStructure.Speed   = GPIO_SPEED_FAST;
    HAL_GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure);
    
    /* Set or Reset the control line */
    LCD_CS_LOW();
    LCD_CS_HIGH();
    
    SPIx_Init();
  }
}
/**
  * @brief  Reads register value.
  * @param  RegValue Address of the register to read
  * @param  ReadSize Number of bytes to read
  * @retval Content of the register value
  */
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) 
{
  uint32_t readvalue = 0;

  /* Select: Chip Select low */
  LCD_CS_LOW();

  /* Reset WRX to send command */
  LCD_WRX_LOW();
  
  SPIx_Write(RegValue);
  
  readvalue = SPIx_Read(ReadSize);

  /* Set WRX to send data */
  LCD_WRX_HIGH();

  /* Deselect: Chip Select high */
  LCD_CS_HIGH();
  
  return readvalue;
}
コード例 #18
0
ファイル: stm32f1xx_LCD.c プロジェクト: salinraj/amigo
void LCD_IO_WriteData(uint16_t LCDData)
{
  /* Reset LCD control line CS */
  LCD_CS_LOW();
  
  /* Set LCD data/command line DC to Low */
  LCD_DC_HIGH();
	 //LCD_RW_LOW();  
  /* Send Command */
  //SPIx_Write(LCDReg);

	 LCD_PORT_Value(LCDData >> 8);
   Toggle_LCD_RW();
	//LCD_RW_HIGH();
  //LCD_RW_LOW();  
  /* Send Command */
  //SPIx_Write(LCDReg);

	 LCD_PORT_Value(LCDData);
   Toggle_LCD_RW();
	//LCD_RW_HIGH();
  /* Deselect : Chip Select high */
  LCD_CS_HIGH();
}
コード例 #19
0
ファイル: stm32f1xx_LCD.c プロジェクト: salinraj/amigo
//void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size)
void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size)
{
  uint32_t counter = 0;
  
  /* Reset LCD control line CS */
  LCD_CS_LOW();
  
  /* Set LCD data/command line DC to High */
  LCD_DC_HIGH();

  if (Size == 1)
  {
    /* Only 1 byte to be sent to LCD - general interface can be used */
    /* Send Data */
   // SPIx_Write(*pData);
		//LCD_RW_LOW();
	LCD_PORT_Value((*pData)>>8);
		//LCD_RW_HIGH();
  Toggle_LCD_RW();
		//LCD_RW_LOW();
		  LCD_PORT_Value(*pData);
		//LCD_RW_HIGH();
  Toggle_LCD_RW();
  }