42#define CHIP_NAME "Titan Micro Electronics TM1640"
43#define MANUFACTURER_NAME "Titan Micro Electronics"
44#define SUPPLY_VOLTAGE_MIN 3.0f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 200.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
54#define TM1640_COMMAND_DATA (1 << 6)
55#define TM1640_COMMAND_DISPLAY (2 << 6)
56#define TM1640_COMMAND_ADDRESS (3 << 6)
143 for (i = 0; i < 8; i++)
150 if ((temp & 0x1) != 0)
197static uint8_t a_tm1640_write(
tm1640_handle_t *handle, uint8_t cmd, uint8_t *buf, uint16_t len)
202 res = a_tm1640_start(handle);
208 res = a_tm1640_byte(handle, cmd);
214 for (i = 0; i < len; i++)
216 res = a_tm1640_byte(handle, buf[i]);
223 res = a_tm1640_stop(handle);
257 handle->
debug_print(
"tm1640: sclk_gpio_init is null.\n");
263 handle->
debug_print(
"tm1640: sclk_gpio_deinit is null.\n");
269 handle->
debug_print(
"tm1640: sclk_gpio_write is null.\n");
275 handle->
debug_print(
"tm1640: din_gpio_init is null.\n");
281 handle->
debug_print(
"tm1640: din_gpio_deinit is null.\n");
287 handle->
debug_print(
"tm1640: din_gpio_write is null.\n");
293 handle->
debug_print(
"tm1640: delay_us is null.\n");
299 handle->
debug_print(
"tm1640: delay_ms is null.\n");
307 handle->
debug_print(
"tm1640: sclk gpio init failed.\n");
314 handle->
debug_print(
"tm1640: din gpio init failed.\n");
322 handle->
debug_print(
"tm1640: sclk gpio write failed.\n");
331 handle->
debug_print(
"tm1640: din gpio write failed.\n");
340 res = a_tm1640_write(handle, cmd, NULL, 0);
381 res = a_tm1640_write(handle, cmd, NULL, 0);
392 handle->
debug_print(
"tm1640: sclk gpio deinit failed.\n");
399 handle->
debug_print(
"tm1640: din gpio deinit failed.\n");
436 res = a_tm1640_write(handle, cmd, NULL, 0);
501 res = a_tm1640_write(handle, cmd, NULL, 0);
566 res = a_tm1640_write(handle, cmd, NULL, 0);
631 res = a_tm1640_write(handle, cmd, NULL, 0);
683 uint8_t data[16] = {0};
695 res = a_tm1640_write(handle, cmd, NULL, 0);
705 for (i = 0; i < 16; i++)
711 res = a_tm1640_write(handle, cmd, &temp, 1);
723 res = a_tm1640_write(handle, cmd, data, 16);
771 res = a_tm1640_write(handle, cmd, NULL, 0);
781 for (i = 0; i < len; i++)
787 res = a_tm1640_write(handle, cmd, &temp, 1);
799 res = a_tm1640_write(handle, cmd, data, len);
837 res = a_tm1640_write(handle, cmd, data, len);
#define TM1640_COMMAND_ADDRESS
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define TM1640_COMMAND_DISPLAY
#define CHIP_NAME
chip information definition
#define TM1640_COMMAND_DATA
chip command definition
driver tm1640 header file
uint8_t tm1640_deinit(tm1640_handle_t *handle)
close the chip
uint8_t tm1640_info(tm1640_info_t *info)
get chip's information
tm1640_pulse_width_t
tm1640 pulse width enumeration definition
#define TM1640_COMMAND_DATA_DELAY
tm1640 command data delay definition
uint8_t tm1640_get_address_mode(tm1640_handle_t *handle, tm1640_address_mode_t *mode)
get address mode
uint8_t tm1640_get_test_mode(tm1640_handle_t *handle, tm1640_bool_t *enable)
get test mode status
tm1640_bool_t
tm1640 bool enumeration definition
uint8_t tm1640_init(tm1640_handle_t *handle)
initialize the chip
uint8_t tm1640_set_pulse_width(tm1640_handle_t *handle, tm1640_pulse_width_t width)
set pulse width
tm1640_address_mode_t
tm1640 address mode enumeration definition
uint8_t tm1640_clear_segment(tm1640_handle_t *handle)
clear segment
struct tm1640_handle_s tm1640_handle_t
tm1640 handle structure definition
uint8_t tm1640_write_segment(tm1640_handle_t *handle, uint8_t addr, uint8_t *data, uint8_t len)
write segment
uint8_t tm1640_set_test_mode(tm1640_handle_t *handle, tm1640_bool_t enable)
enable or disable test mode
uint8_t tm1640_get_pulse_width(tm1640_handle_t *handle, tm1640_pulse_width_t *width)
get pulse width
uint8_t tm1640_set_address_mode(tm1640_handle_t *handle, tm1640_address_mode_t mode)
set address mode
uint8_t tm1640_get_display(tm1640_handle_t *handle, tm1640_bool_t *enable)
get display status
struct tm1640_info_s tm1640_info_t
tm1640 information structure definition
uint8_t tm1640_set_display(tm1640_handle_t *handle, tm1640_bool_t enable)
enable or disable display
uint8_t tm1640_set_reg(tm1640_handle_t *handle, uint8_t cmd, uint8_t *data, uint8_t len)
set the chip register
void(* delay_ms)(uint32_t ms)
uint8_t(* sclk_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* din_gpio_init)(void)
uint8_t(* din_gpio_deinit)(void)
void(* delay_us)(uint32_t us)
uint8_t(* din_gpio_write)(uint8_t level)
uint8_t(* sclk_gpio_init)(void)
uint8_t(* sclk_gpio_write)(uint8_t level)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v