LibDriver X9CXX
Loading...
Searching...
No Matches
driver_x9cxx.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_X9CXX_H
38#define DRIVER_X9CXX_H
39
40#include <stdint.h>
41#include <stdio.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62#ifndef X9CXX_STEP_DELAY_US
63 #define X9CXX_STEP_DELAY_US 10
64#endif
65
69#ifndef X9CXX_OPERATE_DELAY_US
70 #define X9CXX_OPERATE_DELAY_US 10
71#endif
72
76#ifndef X9CXX_STORE_DELAY_MS
77 #define X9CXX_STORE_DELAY_MS 30
78#endif
79
83typedef enum
84{
85 X9C102 = 1000,
86 X9C103 = 10000,
87 X9C503 = 50000,
88 X9C104 = 100000,
90
94typedef enum
95{
99
103typedef struct x9cxx_handle_s
104{
105 uint8_t (*cs_gpio_init)(void);
106 uint8_t (*cs_gpio_deinit)(void);
107 uint8_t (*cs_gpio_write)(uint8_t value);
108 uint8_t (*up_down_gpio_init)(void);
109 uint8_t (*up_down_gpio_deinit)(void);
110 uint8_t (*up_down_gpio_write)(uint8_t value);
111 uint8_t (*inc_gpio_init)(void);
112 uint8_t (*inc_gpio_deinit)(void);
113 uint8_t (*inc_gpio_write)(uint8_t value);
114 void (*debug_print)(const char *const fmt, ...);
115 void (*delay_ms)(uint32_t ms);
116 void (*delay_us)(uint32_t us);
117 uint8_t inited;
118 uint8_t valid;
119 uint8_t step;
120 uint32_t type;
122
138
142
149
156#define DRIVER_X9CXX_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
157
164#define DRIVER_X9CXX_LINK_CS_GPIO_INIT(HANDLE, FUC) (HANDLE)->cs_gpio_init = FUC
165
172#define DRIVER_X9CXX_LINK_CS_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->cs_gpio_deinit = FUC
173
180#define DRIVER_X9CXX_LINK_CS_GPIO_WRITE(HANDLE, FUC) (HANDLE)->cs_gpio_write = FUC
181
188#define DRIVER_X9CXX_LINK_UP_DOWN_GPIO_INIT(HANDLE, FUC) (HANDLE)->up_down_gpio_init = FUC
189
196#define DRIVER_X9CXX_LINK_UP_DOWN_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->up_down_gpio_deinit = FUC
197
204#define DRIVER_X9CXX_LINK_UP_DOWN_GPIO_WRITE(HANDLE, FUC) (HANDLE)->up_down_gpio_write = FUC
205
212#define DRIVER_X9CXX_LINK_INC_GPIO_INIT(HANDLE, FUC) (HANDLE)->inc_gpio_init = FUC
213
220#define DRIVER_X9CXX_LINK_INC_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->inc_gpio_deinit = FUC
221
228#define DRIVER_X9CXX_LINK_INC_GPIO_WRITE(HANDLE, FUC) (HANDLE)->inc_gpio_write = FUC
229
236#define DRIVER_X9CXX_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
237
244#define DRIVER_X9CXX_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
245
252#define DRIVER_X9CXX_LINK_DELAY_US(HANDLE, FUC) (HANDLE)->delay_us = FUC
253
257
264
273uint8_t x9cxx_info(x9cxx_info_t *info);
274
284uint8_t x9cxx_set_type(x9cxx_handle_t *handle, x9cxx_type_t type);
285
295uint8_t x9cxx_get_type(x9cxx_handle_t *handle, x9cxx_type_t *type);
296
307uint8_t x9cxx_init(x9cxx_handle_t *handle);
308
319uint8_t x9cxx_deinit(x9cxx_handle_t *handle);
320
332uint8_t x9cxx_reset_to_min(x9cxx_handle_t *handle, x9cxx_bool_t store_enable);
333
345uint8_t x9cxx_reset_to_max(x9cxx_handle_t *handle, x9cxx_bool_t store_enable);
346
359uint8_t x9cxx_increment(x9cxx_handle_t *handle, uint8_t step, x9cxx_bool_t store_enable);
360
373uint8_t x9cxx_decrement(x9cxx_handle_t *handle, uint8_t step, x9cxx_bool_t store_enable);
374
391uint8_t x9cxx_set_absolute_step_counter(x9cxx_handle_t *handle, uint8_t counter, x9cxx_bool_t store_enable);
392
404uint8_t x9cxx_get_step_counter(x9cxx_handle_t *handle, uint8_t *counter);
405
417uint8_t x9cxx_resistor_convert_to_register(x9cxx_handle_t *handle, float ohm, uint8_t *step);
418
430uint8_t x9cxx_resistor_convert_to_data(x9cxx_handle_t *handle, uint8_t step, float *ohm);
431
435
439
440#ifdef __cplusplus
441}
442#endif
443
444#endif
struct x9cxx_handle_s x9cxx_handle_t
x9cxx handle structure definition
uint8_t x9cxx_set_absolute_step_counter(x9cxx_handle_t *handle, uint8_t counter, x9cxx_bool_t store_enable)
set absolute step counter
uint8_t x9cxx_increment(x9cxx_handle_t *handle, uint8_t step, x9cxx_bool_t store_enable)
increment
struct x9cxx_info_s x9cxx_info_t
x9cxx information structure definition
uint8_t x9cxx_set_type(x9cxx_handle_t *handle, x9cxx_type_t type)
set chip type
x9cxx_type_t
x9cxx type enumeration definition
uint8_t x9cxx_get_step_counter(x9cxx_handle_t *handle, uint8_t *counter)
get step counter
uint8_t x9cxx_decrement(x9cxx_handle_t *handle, uint8_t step, x9cxx_bool_t store_enable)
decrement
uint8_t x9cxx_get_type(x9cxx_handle_t *handle, x9cxx_type_t *type)
get chip type
uint8_t x9cxx_resistor_convert_to_register(x9cxx_handle_t *handle, float ohm, uint8_t *step)
resistor convert to register
uint8_t x9cxx_reset_to_min(x9cxx_handle_t *handle, x9cxx_bool_t store_enable)
reset to min
x9cxx_bool_t
x9cxx bool enumeration definition
uint8_t x9cxx_info(x9cxx_info_t *info)
get chip's information
uint8_t x9cxx_init(x9cxx_handle_t *handle)
initialize the chip
uint8_t x9cxx_resistor_convert_to_data(x9cxx_handle_t *handle, uint8_t step, float *ohm)
resistor convert to data
uint8_t x9cxx_reset_to_max(x9cxx_handle_t *handle, x9cxx_bool_t store_enable)
reset to max
uint8_t x9cxx_deinit(x9cxx_handle_t *handle)
close the chip
@ X9C104
@ X9C503
@ X9C102
@ X9C103
@ X9CXX_BOOL_TRUE
@ X9CXX_BOOL_FALSE
x9cxx handle structure definition
uint8_t(* inc_gpio_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* cs_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* inc_gpio_write)(uint8_t value)
void(* delay_us)(uint32_t us)
uint8_t(* up_down_gpio_write)(uint8_t value)
uint8_t(* cs_gpio_init)(void)
uint8_t(* up_down_gpio_deinit)(void)
uint8_t(* up_down_gpio_init)(void)
uint8_t(* inc_gpio_deinit)(void)
uint8_t(* cs_gpio_write)(uint8_t value)
x9cxx information structure definition
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
float max_current_ma
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]