LibDriver TM1637
Loading...
Searching...
No Matches
driver_tm1637.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_TM1637_H
38#define DRIVER_TM1637_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
67
71typedef enum
72{
76
91
108
112typedef struct tm1637_handle_s
113{
114 uint8_t (*iic_init)(void);
115 uint8_t (*iic_deinit)(void);
116 uint8_t (*iic_write_cmd_custom)(uint8_t addr, uint8_t *buf, uint16_t len);
117 uint8_t (*iic_read_cmd_custom)(uint8_t addr, uint8_t *buf, uint16_t len);
118 void (*delay_ms)(uint32_t ms);
119 void (*debug_print)(const char *const fmt, ...);
120 uint8_t inited;
121 uint8_t display_conf;
122 uint8_t data_conf;
124
140
144
151
158#define DRIVER_TM1637_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
159
166#define DRIVER_TM1637_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
167
174#define DRIVER_TM1637_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
175
182#define DRIVER_TM1637_LINK_IIC_WRITE_COMMAND_CUSTOM(HANDLE, FUC) (HANDLE)->iic_write_cmd_custom = FUC
183
190#define DRIVER_TM1637_LINK_IIC_READ_COMMAND_CUSTOM(HANDLE, FUC) (HANDLE)->iic_read_cmd_custom = FUC
191
198#define DRIVER_TM1637_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
199
206#define DRIVER_TM1637_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
207
211
218
227uint8_t tm1637_info(tm1637_info_t *info);
228
239uint8_t tm1637_init(tm1637_handle_t *handle);
240
252uint8_t tm1637_deinit(tm1637_handle_t *handle);
253
265
280uint8_t tm1637_write_segment(tm1637_handle_t *handle, uint8_t addr, uint8_t *data, uint8_t len);
281
294uint8_t tm1637_read_segment(tm1637_handle_t *handle, uint8_t *seg, uint8_t *k);
295
308
320
332uint8_t tm1637_set_display(tm1637_handle_t *handle, tm1637_bool_t enable);
333
344uint8_t tm1637_get_display(tm1637_handle_t *handle, tm1637_bool_t *enable);
345
358
370
382uint8_t tm1637_set_test_mode(tm1637_handle_t *handle, tm1637_bool_t enable);
383
394uint8_t tm1637_get_test_mode(tm1637_handle_t *handle, tm1637_bool_t *enable);
395
399
406
420uint8_t tm1637_set_reg(tm1637_handle_t *handle, uint8_t cmd, uint8_t *data, uint8_t len);
421
435uint8_t tm1637_get_reg(tm1637_handle_t *handle, uint8_t cmd, uint8_t *data, uint8_t len);
436
440
444
445#ifdef __cplusplus
446}
447#endif
448
449#endif
tm1637_number_t
tm1637 number enumeration definition
uint8_t tm1637_read_segment(tm1637_handle_t *handle, uint8_t *seg, uint8_t *k)
read segment
uint8_t tm1637_set_address_mode(tm1637_handle_t *handle, tm1637_address_mode_t mode)
set address mode
uint8_t tm1637_info(tm1637_info_t *info)
get chip's information
uint8_t tm1637_deinit(tm1637_handle_t *handle)
close the chip
tm1637_address_mode_t
tm1637 address mode enumeration definition
tm1637_pulse_width_t
tm1637 pulse width enumeration definition
uint8_t tm1637_get_display(tm1637_handle_t *handle, tm1637_bool_t *enable)
get display status
tm1637_bool_t
tm1637 bool enumeration definition
uint8_t tm1637_clear_segment(tm1637_handle_t *handle)
clear segment
uint8_t tm1637_get_test_mode(tm1637_handle_t *handle, tm1637_bool_t *enable)
get test mode status
uint8_t tm1637_get_pulse_width(tm1637_handle_t *handle, tm1637_pulse_width_t *width)
get pulse width
struct tm1637_info_s tm1637_info_t
tm1637 information structure definition
uint8_t tm1637_set_test_mode(tm1637_handle_t *handle, tm1637_bool_t enable)
enable or disable test mode
struct tm1637_handle_s tm1637_handle_t
tm1637 handle structure definition
uint8_t tm1637_write_segment(tm1637_handle_t *handle, uint8_t addr, uint8_t *data, uint8_t len)
write segment
uint8_t tm1637_get_address_mode(tm1637_handle_t *handle, tm1637_address_mode_t *mode)
get address mode
uint8_t tm1637_set_pulse_width(tm1637_handle_t *handle, tm1637_pulse_width_t width)
set pulse width
uint8_t tm1637_set_display(tm1637_handle_t *handle, tm1637_bool_t enable)
enable or disable display
uint8_t tm1637_init(tm1637_handle_t *handle)
initialize the chip
@ TM1637_NUMBER_2
@ TM1637_NUMBER_7
@ TM1637_NUMBER_0
@ TM1637_NUMBER_3
@ TM1637_NUMBER_5
@ TM1637_NUMBER_6
@ TM1637_NUMBER_9
@ TM1637_NUMBER_1
@ TM1637_NUMBER_4
@ TM1637_NUMBER_8
@ TM1637_ADDRESS_MODE_INC
@ TM1637_ADDRESS_MODE_FIX
@ TM1637_PULSE_WIDTH_2_DIV_16
@ TM1637_PULSE_WIDTH_14_DIV_16
@ TM1637_PULSE_WIDTH_11_DIV_16
@ TM1637_PULSE_WIDTH_12_DIV_16
@ TM1637_PULSE_WIDTH_13_DIV_16
@ TM1637_PULSE_WIDTH_10_DIV_16
@ TM1637_PULSE_WIDTH_4_DIV_16
@ TM1637_PULSE_WIDTH_1_DIV_16
@ TM1637_BOOL_FALSE
@ TM1637_BOOL_TRUE
uint8_t tm1637_get_reg(tm1637_handle_t *handle, uint8_t cmd, uint8_t *data, uint8_t len)
get the chip register
uint8_t tm1637_set_reg(tm1637_handle_t *handle, uint8_t cmd, uint8_t *data, uint8_t len)
set the chip register
tm1637 handle structure definition
uint8_t(* iic_write_cmd_custom)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_read_cmd_custom)(uint8_t addr, uint8_t *buf, uint16_t len)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_deinit)(void)
tm1637 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]