×
单片机 > 单片机程序设计 > 详情

STM32的HAL库的 I2C和UART使用函数

发布时间:2020-05-21 发布时间:
|


void I2C_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,uint16_t NumByteToWrite){

  //HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)DeviceAddr, pBuffer, NumByteToWrite, 1000);//1000ms 1s 100K字节s

}

 

void I2C_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead){

  uint8_t Register[3]={RegisterAddr};

  HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)DeviceAddr, Register, 1, 1000);

  HAL_I2C_Master_Receive(&hi2c1, (uint16_t)DeviceAddr, pBuffer, NumByteToRead, 1000);

}

HAL_UART_Transmit(&huart1, testChar, 15, 1000);

 

关键字:STM32  HAL库  I2C  UART 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
TQ210天嵌开发板S5PV210 LED闪烁程序C语言代码记录