void ADS1115_ReadRawData(ADS1115_InitTypeDefine *ADS1115_InitStruct)//ADS1115_RawData { unsigned char Result[2]; uint8_t Writebuff[1]; Writebuff[0] = ADS1115_Pointer_ConverReg; HAL_I2C_Master_Transmit(&hi2c1, ADS1115_InitStruct->ADDRESS, Writebuff, 3, 100); HAL_I2C_Master_Receive(&hi2c1, ADS1115_InitStruct->ADDRESS , Result, 2, 100); ADS1115_InitStruct->ADS1115_RawData[ADS1115_InitStruct->CHANNEL] = (int16_t) (((Result[0] << 8) & 0xFF00) | (Result[1] & 0xFF)); //return Writebuff; // ADS1115_ReadRawData(&ADS1115_InitStruct); // 读取原始数据 }怎么输出所得的数据
时间: 2024-03-12 21:45:04 浏览: 52
要输出所获取的数据,您可以使用printf函数或类似的函数来打印数据。以下是一个示例代码:
```
void ADS1115_ReadRawData(ADS1115_InitTypeDefine *ADS1115_InitStruct)
{
unsigned char Result[2];
uint8_t Writebuff[1];
Writebuff[0] = ADS1115_Pointer_ConverReg;
HAL_I2C_Master_Transmit(&hi2c1, ADS1115_InitStruct->ADDRESS, Writebuff, 3, 100);
HAL_I2C_Master_Receive(&hi2c1, ADS1115_InitStruct->ADDRESS , Result, 2, 100);
ADS1115_InitStruct->ADS1115_RawData[ADS1115_InitStruct->CHANNEL] = (int16_t) (((Result[0] << 8) & 0xFF00) | (Result[1] & 0xFF));
// 打印获取到的数据
printf("获取到的原始数据为:%d\n", ADS1115_InitStruct->ADS1115_RawData[ADS1115_InitStruct->CHANNEL]);
}
```
在上面的示例中,我们使用printf函数打印获取到的原始数据。我们使用%d格式说明符来打印整数类型的数据。您可以根据需要使用其他格式说明符来打印不同类型的数据。
阅读全文