42#define CHIP_NAME "Texas Instruments TPL0501"
43#define MANUFACTURER_NAME "Texas Instruments"
44#define SUPPLY_VOLTAGE_MIN 2.7f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 5.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 125.0f
49#define DRIVER_VERSION 1000
95 handle->
debug_print(
"tpl0501: spi_init is null.\n");
101 handle->
debug_print(
"tpl0501: spi_deinit is null.\n");
107 handle->
debug_print(
"tpl0501: spi_write_cmd is null.\n");
113 handle->
debug_print(
"tpl0501: delay_ms is null.\n");
120 handle->
debug_print(
"tpl0501: spi init failed.\n");
155 handle->
debug_print(
"tpl0501: spi deinit failed.\n");
188 res =a_tpl0501_spi_write(handle, raw);
191 handle->
debug_print(
"tpl0501: read data failed.\n");
213 float percentage, uint8_t *reg,
214 float *wl_ohm,
float *hw_ohm)
225 *reg = (uint8_t)(percentage / 100.0f * 256);
226 *wl_ohm = 100 * 1000 * (percentage / 100.0f);
227 *hw_ohm = 100 * 1000 - (*wl_ohm);
246 uint8_t reg,
float *percentage,
247 float *wl_ohm,
float *hw_ohm)
258 *percentage = (float)((
float)(reg) / 256.0f) * 100.0f;
259 *wl_ohm = 100 * 1000 * ((float)reg / 256.0f);
260 *hw_ohm = 100 * 1000 - (*wl_ohm);
287 return a_tpl0501_spi_write(handle, raw);
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver tpl0501 header file
uint8_t tpl0501_percentage_convert_to_data(tpl0501_handle_t *handle, uint8_t reg, float *percentage, float *wl_ohm, float *hw_ohm)
convert the register raw data to percentage
uint8_t tpl0501_info(tpl0501_info_t *info)
get chip's information
uint8_t tpl0501_deinit(tpl0501_handle_t *handle)
close the chip
uint8_t tpl0501_percentage_convert_to_register(tpl0501_handle_t *handle, float percentage, uint8_t *reg, float *wl_ohm, float *hw_ohm)
convert the percentage to the register raw data
uint8_t tpl0501_init(tpl0501_handle_t *handle)
initialize the chip
struct tpl0501_info_s tpl0501_info_t
tpl0501 information structure definition
uint8_t tpl0501_write(tpl0501_handle_t *handle, uint8_t raw)
write data
struct tpl0501_handle_s tpl0501_handle_t
tpl0501 handle structure definition
uint8_t tpl0501_set_reg(tpl0501_handle_t *handle, uint8_t raw)
set the chip register
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v