LibDriver X9CXX
Loading...
Searching...
No Matches
driver_x9cxx_basic.c
Go to the documentation of this file.
1
36
37#include "driver_x9cxx_basic.h"
38
39static x9cxx_handle_t gs_handle;
40
88
96uint8_t x9cxx_basic_deinit(void)
97{
98 /* deinit x9cxx */
99 if (x9cxx_deinit(&gs_handle) != 0)
100 {
101 return 1;
102 }
103
104 return 0;
105}
106
116{
117 uint8_t res;
118
119 /* reset to min */
120 res = x9cxx_reset_to_min(&gs_handle, store_enable);
121 if (res != 0)
122 {
123 return 1;
124 }
125
126 return 0;
127}
128
138{
139 uint8_t res;
140
141 /* reset to max */
142 res = x9cxx_reset_to_max(&gs_handle, store_enable);
143 if (res != 0)
144 {
145 return 1;
146 }
147
148 return 0;
149}
150
160uint8_t x9cxx_basic_increment(uint8_t step, x9cxx_bool_t store_enable)
161{
162 uint8_t res;
163
164 /* increment */
165 res = x9cxx_increment(&gs_handle, step, store_enable);
166 if (res != 0)
167 {
168 return 1;
169 }
170
171 return 0;
172}
173
183uint8_t x9cxx_basic_decrement(uint8_t step, x9cxx_bool_t store_enable)
184{
185 uint8_t res;
186
187 /* decrement */
188 res = x9cxx_decrement(&gs_handle, step, store_enable);
189 if (res != 0)
190 {
191 return 1;
192 }
193
194 return 0;
195}
196
206uint8_t x9cxx_basic_set_absolute_step(uint8_t step, x9cxx_bool_t store_enable)
207{
208 uint8_t res;
209
210 /* set absolute step counter */
211 res = x9cxx_set_absolute_step_counter(&gs_handle, step, store_enable);
212 if (res != 0)
213 {
214 return 1;
215 }
216
217 return 0;
218}
219
229uint8_t x9cxx_basic_set_absolute_resistor(float ohm, x9cxx_bool_t store_enable)
230{
231 uint8_t res;
232 uint8_t step;
233
234 /* convert to register */
235 res = x9cxx_resistor_convert_to_register(&gs_handle, ohm, &step);
236 if (res != 0)
237 {
238 return 1;
239 }
240
241 /* set absolute step counter */
242 res = x9cxx_set_absolute_step_counter(&gs_handle, step, store_enable);
243 if (res != 0)
244 {
245 return 1;
246 }
247
248 return 0;
249}
250
260uint8_t x9cxx_basic_get_resistor(uint8_t *step, float *ohm)
261{
262 uint8_t res;
263
264 /* get step counter */
265 res = x9cxx_get_step_counter(&gs_handle, step);
266 if (res != 0)
267 {
268 return 1;
269 }
270
271 /* convert to data */
272 res = x9cxx_resistor_convert_to_data(&gs_handle, *step, ohm);
273 if (res != 0)
274 {
275 return 1;
276 }
277
278 return 0;
279}
driver x9cxx basic header file
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
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_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_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
uint8_t x9cxx_basic_set_absolute_resistor(float ohm, x9cxx_bool_t store_enable)
basic example set absolute resistor
uint8_t x9cxx_basic_deinit(void)
basic example deinit
uint8_t x9cxx_basic_init(x9cxx_type_t type)
basic example init
uint8_t x9cxx_basic_increment(uint8_t step, x9cxx_bool_t store_enable)
basic example increment
uint8_t x9cxx_basic_set_absolute_step(uint8_t step, x9cxx_bool_t store_enable)
basic example set absolute step
uint8_t x9cxx_basic_reset_to_max(x9cxx_bool_t store_enable)
basic example reset to max
uint8_t x9cxx_basic_reset_to_min(x9cxx_bool_t store_enable)
basic example reset to min
uint8_t x9cxx_basic_get_resistor(uint8_t *step, float *ohm)
basic example get resistor
uint8_t x9cxx_basic_decrement(uint8_t step, x9cxx_bool_t store_enable)
basic example decrement
void x9cxx_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t x9cxx_interface_inc_gpio_init(void)
interface inc gpio init
uint8_t x9cxx_interface_cs_gpio_write(uint8_t value)
interface cs gpio write
uint8_t x9cxx_interface_cs_gpio_init(void)
interface cs gpio init
uint8_t x9cxx_interface_inc_gpio_deinit(void)
interface inc gpio deinit
uint8_t x9cxx_interface_up_down_gpio_write(uint8_t value)
interface up down gpio write
uint8_t x9cxx_interface_up_down_gpio_deinit(void)
interface up down gpio deinit
void x9cxx_interface_delay_us(uint32_t us)
interface delay us
uint8_t x9cxx_interface_up_down_gpio_init(void)
interface up down gpio init
uint8_t x9cxx_interface_inc_gpio_write(uint8_t value)
interface inc gpio write
void x9cxx_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t x9cxx_interface_cs_gpio_deinit(void)
interface cs gpio deinit