本文整理汇总了C++中SPIx_Write函数的典型用法代码示例。如果您正苦于以下问题:C++ SPIx_Write函数的具体用法?C++ SPIx_Write怎么用?C++ SPIx_Write使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SPIx_Write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LCD_IO_ReadData
/**
* @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;
}
示例2: EEPROM_SPI_IO_ReadData
/**
* @brief Read data from SPI EEPROM driver
* @param MemAddress: Internal memory address
* @param pBuffer: Pointer to data buffer
* @param BufferSize: Amount of data to be read
* @retval HAL_StatusTypeDef HAL Status
*/
HAL_StatusTypeDef EEPROM_SPI_IO_ReadData(uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
{
/*!< Select the EEPROM: Chip Select low */
EEPROM_CS_LOW();
/*!< Send "Write to Memory " instruction */
SPIx_Write(EEPROM_CMD_READ);
/*!< Send MemAddress high nibble address byte to write to */
SPIx_Write((MemAddress & 0xFF0000) >> 16);
/*!< Send WriteAddr medium nibble address byte to write to */
SPIx_Write((MemAddress & 0xFF00) >> 8);
/*!< Send WriteAddr low nibble address byte to write to */
SPIx_Write(MemAddress & 0xFF);
while ((BufferSize)--) /*!< while there is data to be read */
{
/*!< Read a byte from the EEPROM */
*pBuffer = SPIx_Read();
/*!< Point to the next location where the byte read will be saved */
pBuffer++;
}
/*!< Deselect the EEPROM: Chip Select high */
EEPROM_CS_HIGH();
return HAL_OK;
}
示例3: LCD_IO_ReadData
/**
* @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;
}
示例4: EEPROM_SPI_IO_WriteData
/**
* @brief Write data to SPI EEPROM driver
* @param MemAddress: Internal memory address
* @param pBuffer: Pointer to data buffer
* @param BufferSize: Amount of data to be read
* @retval HAL_StatusTypeDef HAL Status
*/
HAL_StatusTypeDef EEPROM_SPI_IO_WriteData(uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
{
/*!< Enable the write access to the EEPROM */
/*!< Select the EEPROM: Chip Select low */
EEPROM_CS_LOW();
/*!< Send "Write Enable" instruction */
SPIx_Write(EEPROM_CMD_WREN);
/*!< Deselect the EEPROM: Chip Select high */
EEPROM_CS_HIGH();
/*!< Select the EEPROM: Chip Select low */
EEPROM_CS_LOW();
/*!< Send "Write to Memory " instruction */
/* Send the byte */
SPIx_Write(EEPROM_CMD_WRITE);
/*!< Send MemAddress high nibble address byte to write to */
SPIx_Write((MemAddress & 0xFF0000) >> 16);
/*!< Send MemAddress medium nibble address byte to write to */
SPIx_Write((MemAddress & 0xFF00) >> 8);
/*!< Send MemAddress low nibble address byte to write to */
SPIx_Write(MemAddress & 0xFF);
/*!< while there is data to be written on the EEPROM */
while ((BufferSize)--)
{
/*!< Send the current byte */
SPIx_Write(*pBuffer);
/*!< Point on the next byte to be written */
pBuffer++;
}
/*!< Deselect the EEPROM: Chip Select high */
EEPROM_CS_HIGH();
/*!< Wait the end of EEPROM writing */
EEPROM_SPI_IO_WaitEepromStandbyState();
/*!< Disable the write access to the EEROM */
EEPROM_CS_LOW();
/*!< Send "Write Disable" instruction */
SPIx_Write(EEPROM_CMD_WRDI);
/*!< Deselect the EEPROM: Chip Select high */
EEPROM_CS_HIGH();
return HAL_OK;
}
示例5: LCD_IO_WriteReg
/**
* @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();
}
示例6: LCD_IO_WriteMultipleData
/**
* @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();
}
示例7: LCD_IO_WriteData
/**
* @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();
}
示例8: EEPROM_SPI_IO_WaitEepromStandbyState
/**
* @brief Wait response from the SPI EEPROM
* @param None
* @retval HAL_StatusTypeDef HAL Status
*/
HAL_StatusTypeDef EEPROM_SPI_IO_WaitEepromStandbyState(void)
{
uint32_t timeout = 0xFFFF;
uint32_t eepromstatus;
/*!< Select the EEPROM: Chip Select low */
EEPROM_CS_LOW();
/*!< Send "Read Status Register" instruction */
SPIx_Write(EEPROM_CMD_RDSR);
/*!< Loop as long as the memory is busy with a write cycle */
do
{
/*!< Send a dummy byte to generate the clock needed by the EEPROM
and put the value of the status register in EEPROM Status variable */
eepromstatus = SPIx_Read();
timeout --;
}
while (((eepromstatus & EEPROM_WIP_FLAG) == SET) && timeout); /* Write in progress */
/*!< Deselect the EEPROM: Chip Select high */
EEPROM_CS_HIGH();
if ((eepromstatus & EEPROM_WIP_FLAG) != SET)
{
/* Right response got */
return HAL_OK;
}
else
{
/* After time out */
return HAL_TIMEOUT;
}
}
示例9: ControlOut_WriteTlc5615
/**
* @brief 写数据到 TLC5615 DAC0
* @param Value: 写入的值
* @retval 无
*/
static void ControlOut_WriteTlc5615(uint16_t Value)
{
uint16_t dac_value;
uint8_t highbyte;
uint8_t lowbyte;
/* 按照DAC数据格式移动 */
dac_value = (Value&0x3FF)<<2;
/* 取出高低字节 */
highbyte = dac_value>>8;
lowbyte = dac_value&0xFF;
/* 分别发送高、低字节 */
SPIx_Write( highbyte );
SPIx_Write( lowbyte );
}
示例10: LCD_IO_WriteReg
/**
* @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();
}
示例11: LCD_IO_WriteData
/**
* @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();
}
示例12: LCD_IO_WriteReg
/**
* @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();
}
示例13: LCD_IO_WriteMultipleData
/**
* @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();
}
示例14: LCD_IO_WriteData
/**
* @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();
}
示例15: LCD_IO_ReadData
/**
* @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;
}