micro_climate/Drivers/HP203B/hp203b.c

49 lines
1.1 KiB
C
Raw Permalink Normal View History

#include "hp203b.h"
2024-07-18 10:15:50 +00:00
#include "i2c.h"
2024-07-18 08:31:44 +00:00
#include "anemometer_dev.h"
/****************************
2024-07-18 08:31:44 +00:00
*<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>set_mode
*<EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ôӻ<EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-07-18 08:31:44 +00:00
*
*
*<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD>
*****************************/
2024-07-18 08:31:44 +00:00
void hp203_set_mode()
{
2024-07-18 10:15:50 +00:00
uint8_t cmd[1] = {HP20X_CONVERT_OSR1024};
HAL_I2C_Master_Transmit(&hi2c3, HP20X_ADDRESSCMD, cmd, 1, 0xff);
}
/****************************
2024-07-18 08:31:44 +00:00
*<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>Hp203bReadPressure
2024-07-18 10:15:50 +00:00
*<EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-07-18 08:31:44 +00:00
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Press--<EFBFBD><EFBFBD>ѹֵ
*
*
*<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD>
*****************************/
2024-07-18 10:15:50 +00:00
long Hp203b_Pressure = 0;
uint8_t Hp203bPressure_Temp[3] = {0};
2024-07-18 08:31:44 +00:00
void Hp203bReadPressure(void)
{
2024-07-18 10:15:50 +00:00
uint8_t read_command[1] = {HP20X_READ_P};
HAL_I2C_Master_Transmit(&hi2c3, HP20X_ADDRESSCMD, read_command, 1, 0xff);
HAL_I2C_Master_Receive(&hi2c3, HP20X_ADDRESSCMD, Hp203bPressure_Temp, 3, 0xff);
2024-07-18 08:31:44 +00:00
Hp203b_Pressure = Hp203bPressure_Temp[0];
Hp203b_Pressure <<= 8;
Hp203b_Pressure |= Hp203bPressure_Temp[1];
Hp203b_Pressure <<= 8;
Hp203b_Pressure |= Hp203bPressure_Temp[2];
Hp203b_Pressure = Hp203b_Pressure / 100;
g_stMcs_Para.pressure = Hp203b_Pressure;
}
2024-07-18 08:31:44 +00:00