LibDriver TM1622
Loading...
Searching...
No Matches
driver_tm1622_output.c
Go to the documentation of this file.
1
36
38
39static tm1622_handle_t gs_handle;
40
48uint8_t tm1622_output_init(void)
49{
50 uint8_t res;
51
52 /* link interface function */
70
71 /* tm1622 init */
72 res = tm1622_init(&gs_handle);
73 if (res != 0)
74 {
75 tm1622_interface_debug_print("tm1622: init failed.\n");
76
77 return 1;
78 }
79
80 /* set default clock */
82 if (res != 0)
83 {
84 tm1622_interface_debug_print("tm1622: set clock failed.\n");
85 (void)tm1622_deinit(&gs_handle);
86
87 return 1;
88 }
89
90 /* enable oscillator */
91 res = tm1622_set_oscillator(&gs_handle, TM1622_BOOL_TRUE);
92 if (res != 0)
93 {
94 tm1622_interface_debug_print("tm1622: set oscillator failed.\n");
95 (void)tm1622_deinit(&gs_handle);
96
97 return 1;
98 }
99
100 /* enable lcd bias */
101 res = tm1622_set_lcd_bias(&gs_handle, TM1622_BOOL_TRUE);
102 if (res != 0)
103 {
104 tm1622_interface_debug_print("tm1622: set lcd bias failed.\n");
105 (void)tm1622_deinit(&gs_handle);
106
107 return 1;
108 }
109
110 /* set normal mode */
111 res = tm1622_set_mode(&gs_handle, TM1622_MODE_NORMAL);
112 if (res != 0)
113 {
114 tm1622_interface_debug_print("tm1622: set mode failed.\n");
115 (void)tm1622_deinit(&gs_handle);
116
117 return 1;
118 }
119
120 /* set freq clock 1hz, wdt 4s */
121 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F1);
122 if (res != 0)
123 {
124 tm1622_interface_debug_print("tm1622: set freq failed.\n");
125 (void)tm1622_deinit(&gs_handle);
126
127 return 1;
128 }
129
130 /* set tone freq 2k */
131 res = tm1622_set_tone_freq(&gs_handle, TM1622_TONE_FREQ_2K);
132 if (res != 0)
133 {
134 tm1622_interface_debug_print("tm1622: set tone freq failed.\n");
135 (void)tm1622_deinit(&gs_handle);
136
137 return 1;
138 }
139
140 /* disable tone */
141 res = tm1622_set_tone(&gs_handle, TM1622_BOOL_FALSE);
142 if (res != 0)
143 {
144 tm1622_interface_debug_print("tm1622: set tone failed.\n");
145 (void)tm1622_deinit(&gs_handle);
146
147 return 1;
148 }
149
150 /* disable timer */
151 res = tm1622_set_timer(&gs_handle, TM1622_BOOL_FALSE);
152 if (res != 0)
153 {
154 tm1622_interface_debug_print("tm1622: set timer failed.\n");
155 (void)tm1622_deinit(&gs_handle);
156
157 return 1;
158 }
159
160 /* clear timer */
161 res = tm1622_clear_timer(&gs_handle);
162 if (res != 0)
163 {
164 tm1622_interface_debug_print("tm1622: clear timer failed.\n");
165 (void)tm1622_deinit(&gs_handle);
166
167 return 1;
168 }
169
170 /* disable watchdog */
171 res = tm1622_set_watchdog(&gs_handle, TM1622_BOOL_FALSE);
172 if (res != 0)
173 {
174 tm1622_interface_debug_print("tm1622: set watchdog failed.\n");
175 (void)tm1622_deinit(&gs_handle);
176
177 return 1;
178 }
179
180 /* clear watchdog */
181 res = tm1622_clear_watchdog(&gs_handle);
182 if (res != 0)
183 {
184 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
185 (void)tm1622_deinit(&gs_handle);
186
187 return 1;
188 }
189
190 /* enable interrupt */
191 res = tm1622_set_irq(&gs_handle, TM1622_BOOL_TRUE);
192 if (res != 0)
193 {
194 tm1622_interface_debug_print("tm1622: set irq failed.\n");
195 (void)tm1622_deinit(&gs_handle);
196
197 return 1;
198 }
199
200 /* clear segment */
201 res = tm1622_clear_segment(&gs_handle);
202 if (res != 0)
203 {
204 tm1622_interface_debug_print("tm1622: clear segment failed.\n");
205 (void)tm1622_deinit(&gs_handle);
206
207 return 1;
208 }
209
210 return 0;
211}
212
223uint8_t tm1622_output_write(uint8_t addr, uint8_t *data, uint8_t len)
224{
225 uint8_t res;
226
227 /* write segment */
228 res = tm1622_write_segment(&gs_handle, addr, data, len);
229 if (res != 0)
230 {
231 return 1;
232 }
233
234 return 0;
235}
236
245{
246 uint8_t res;
247
248 /* clear segment */
249 res = tm1622_clear_segment(&gs_handle);
250 if (res != 0)
251 {
252 return 1;
253 }
254
255 return 0;
256}
257
266{
267 uint8_t res;
268
269 /* enable lcd bias */
270 res = tm1622_set_lcd_bias(&gs_handle, TM1622_BOOL_TRUE);
271 if (res != 0)
272 {
273 return 1;
274 }
275
276 return 0;
277}
278
287{
288 uint8_t res;
289
290 /* disable lcd bias */
291 res = tm1622_set_lcd_bias(&gs_handle, TM1622_BOOL_FALSE);
292 if (res != 0)
293 {
294 return 1;
295 }
296
297 return 0;
298}
299
308{
309 uint8_t res;
310
311 /* deinit tm1622 */
312 res = tm1622_deinit(&gs_handle);
313 if (res != 0)
314 {
315 return 1;
316 }
317
318 return 0;
319}
320
330{
331 uint8_t res;
332
333 /* set freq */
334 res = tm1622_set_freq(&gs_handle, freq);
335 if (res != 0)
336 {
337 return 1;
338 }
339
340 return 0;
341}
342
352{
353 uint8_t res;
354
355 /* set timer */
356 res = tm1622_set_timer(&gs_handle, enable);
357 if (res != 0)
358 {
359 return 1;
360 }
361
362 /* clear timer */
363 res = tm1622_clear_timer(&gs_handle);
364 if (res != 0)
365 {
366 return 1;
367 }
368
369 return 0;
370}
371
381{
382 uint8_t res;
383
384 /* set watchdog */
385 res = tm1622_set_watchdog(&gs_handle, enable);
386 if (res != 0)
387 {
388 return 1;
389 }
390
391 /* clear watchdog */
392 res = tm1622_clear_watchdog(&gs_handle);
393 if (res != 0)
394 {
395 return 1;
396 }
397
398 return 0;
399}
400
409{
410 uint8_t res;
411
412 /* clear watchdog */
413 res = tm1622_clear_watchdog(&gs_handle);
414 if (res != 0)
415 {
416 return 1;
417 }
418
419 return 0;
420}
driver tm1622 output header file
uint8_t tm1622_clear_timer(tm1622_handle_t *handle)
clear timer
uint8_t tm1622_set_lcd_bias(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable lcd bias
uint8_t tm1622_clear_segment(tm1622_handle_t *handle)
clear segment
uint8_t tm1622_write_segment(tm1622_handle_t *handle, uint8_t addr, uint8_t *data, uint8_t len)
write segment
uint8_t tm1622_clear_watchdog(tm1622_handle_t *handle)
clear watchdog
tm1622_freq_t
tm1622 freq enumeration definition
uint8_t tm1622_set_tone_freq(tm1622_handle_t *handle, tm1622_tone_freq_t freq)
set tone freq
uint8_t tm1622_set_watchdog(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable watchdog
struct tm1622_handle_s tm1622_handle_t
tm1622 handle structure definition
uint8_t tm1622_set_timer(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable timer
uint8_t tm1622_set_clock(tm1622_handle_t *handle, tm1622_clock_t clk)
set clock
tm1622_bool_t
tm1622 bool enumeration definition
uint8_t tm1622_deinit(tm1622_handle_t *handle)
close the chip
uint8_t tm1622_set_freq(tm1622_handle_t *handle, tm1622_freq_t freq)
set freq
uint8_t tm1622_init(tm1622_handle_t *handle)
initialize the chip
uint8_t tm1622_set_tone(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable tone
uint8_t tm1622_set_oscillator(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable oscillator
uint8_t tm1622_set_irq(tm1622_handle_t *handle, tm1622_bool_t enable)
enable or disable irq
uint8_t tm1622_set_mode(tm1622_handle_t *handle, tm1622_mode_t mode)
set mode
@ TM1622_FREQ_F1
@ TM1622_TONE_FREQ_2K
@ TM1622_MODE_NORMAL
@ TM1622_BOOL_FALSE
@ TM1622_BOOL_TRUE
uint8_t tm1622_output_set_watchdog(tm1622_bool_t enable)
output example set watchdog
uint8_t tm1622_output_display_on(void)
output example display on
uint8_t tm1622_output_init(void)
output example init
uint8_t tm1622_output_set_timer(tm1622_bool_t enable)
output example set timer
uint8_t tm1622_output_clear(void)
output example clear
uint8_t tm1622_output_display_off(void)
output example display off
uint8_t tm1622_output_set_freq(tm1622_freq_t freq)
output example set freq
uint8_t tm1622_output_feed_watchdog(void)
output example feed watchdog
#define TM1622_OUTPUT_DEFAULT_CLOCK
tm1622 output example default definition
uint8_t tm1622_output_write(uint8_t addr, uint8_t *data, uint8_t len)
output example write
uint8_t tm1622_output_deinit(void)
output example deinit
uint8_t tm1622_interface_rd_gpio_init(void)
interface rd gpio init
uint8_t tm1622_interface_cs_gpio_write(uint8_t level)
interface cs gpio write
uint8_t tm1622_interface_cs_gpio_init(void)
interface cs gpio init
uint8_t tm1622_interface_cs_gpio_deinit(void)
interface cs gpio deinit
uint8_t tm1622_interface_rd_gpio_write(uint8_t level)
interface rd gpio write
uint8_t tm1622_interface_wr_gpio_write(uint8_t level)
interface wr gpio write
void tm1622_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t tm1622_interface_wr_gpio_init(void)
interface wr gpio init
uint8_t tm1622_interface_wr_gpio_deinit(void)
interface wr gpio deinit
uint8_t tm1622_interface_data_gpio_init(void)
interface data gpio init
void tm1622_interface_delay_us(uint32_t us)
interface delay us
void tm1622_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t tm1622_interface_data_gpio_deinit(void)
interface data gpio deinit
uint8_t tm1622_interface_data_gpio_read(uint8_t *level)
interface data gpio read
uint8_t tm1622_interface_rd_gpio_deinit(void)
interface rd gpio deinit
uint8_t tm1622_interface_data_gpio_write(uint8_t level)
interface data gpio write