43#define CHIP_NAME "Aviaic HX711"
44#define MANUFACTURER_NAME "Aviaic"
45#define SUPPLY_VOLTAGE_MIN 2.6f
46#define SUPPLY_VOLTAGE_MAX 5.5f
47#define MAX_CURRENT 1.5f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 2000
62static uint8_t a_hx711_read_ad(
hx711_handle_t *handle, uint8_t len, int32_t *value)
71 handle->
debug_print(
"hx711: clock write 0 failed.\n");
79 if (handle->
bus_read((uint8_t *)&v) != 0)
102 for (i = 0; i < 24; i++)
107 handle->
debug_print(
"hx711: clock write 1 failed.\n");
116 handle->
debug_print(
"hx711: clock write 0 failed.\n");
120 if (handle->
bus_read((uint8_t *)&v) != 0)
138 handle->
debug_print(
"hx711: clock write 1 failed.\n");
146 handle->
debug_print(
"hx711: clock write 0 failed.\n");
154 if ((val & 0x800000) != 0)
161 val = 0xFF000000U | val;
163 *value = (int32_t)u.i_f;
167 *value = (int32_t)val;
201 handle->
debug_print(
"hx711: bus_deinit is null.\n");
213 handle->
debug_print(
"hx711: clock_init is null.\n");
219 handle->
debug_print(
"hx711: clock_deinit is null.\n");
225 handle->
debug_print(
"hx711: clock_write is null.\n");
237 handle->
debug_print(
"hx711: enable_irq is null.\n");
243 handle->
debug_print(
"hx711: disable_irq is null.\n");
250 handle->
debug_print(
"hx711: clock init failed.\n");
290 handle->
debug_print(
"hx711: bus deinit failed.\n");
296 handle->
debug_print(
"hx711: clock deinit failed.\n");
329 handle->
mode = (uint8_t)mode;
330 if (a_hx711_read_ad(handle, handle->
mode, (int32_t *)&value) != 0)
391 if (a_hx711_read_ad(handle, handle->
mode, (int32_t *)raw) != 0)
393 handle->
debug_print(
"hx711: read voltage failed.\n");
399 *voltage_v = (double)(*raw) * (20.0 / (pow(2.0, 24.0))) / 1000.0;
405 *voltage_v = (double)(*raw) * (80.0 / (pow(2.0, 24.0))) / 1000.0;
411 *voltage_v = (double)(*raw) * (40.0 / (pow(2.0, 24.0))) / 1000.0;
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
uint8_t hx711_deinit(hx711_handle_t *handle)
close the chip
uint8_t hx711_get_mode(hx711_handle_t *handle, hx711_mode_t *mode)
get the chip mode
hx711_mode_t
hx711 mode enumeration definition
struct hx711_handle_s hx711_handle_t
hx711 handle structure definition
uint8_t hx711_init(hx711_handle_t *handle)
initialize the chip
uint8_t hx711_set_mode(hx711_handle_t *handle, hx711_mode_t mode)
set the chip mode
struct hx711_info_s hx711_info_t
hx711 info structure definition
uint8_t hx711_info(hx711_info_t *info)
get chip's information
uint8_t hx711_read(hx711_handle_t *handle, int32_t *raw, double *voltage_v)
read the 24 bits raw ad from the chip
@ HX711_MODE_CHANNEL_A_GAIN_64
@ HX711_MODE_CHANNEL_A_GAIN_128
@ HX711_MODE_CHANNEL_B_GAIN_32
uint8_t(* clock_deinit)(void)
uint8_t(* bus_deinit)(void)
void(* debug_print)(const char *const fmt,...)
void(* delay_us)(uint32_t us)
void(* disable_irq)(void)
uint8_t(* bus_read)(uint8_t *value)
uint8_t(* bus_init)(void)
uint8_t(* clock_init)(void)
uint8_t(* clock_write)(uint8_t value)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v