LibDriver TM1622
Loading...
Searching...
No Matches
driver_tm1622_output_test.c
Go to the documentation of this file.
1
36
38
42static tm1622_handle_t gs_handle;
43
51uint8_t tm1622_output_test(void)
52{
53 uint8_t res;
54 tm1622_info_t info;
55
56 /* link interface function */
74
75 /* get information */
76 res = tm1622_info(&info);
77 if (res != 0)
78 {
79 tm1622_interface_debug_print("tm1622: get info failed.\n");
80
81 return 1;
82 }
83 else
84 {
85 /* print chip info */
86 tm1622_interface_debug_print("tm1622: chip is %s.\n", info.chip_name);
87 tm1622_interface_debug_print("tm1622: manufacturer is %s.\n", info.manufacturer_name);
88 tm1622_interface_debug_print("tm1622: interface is %s.\n", info.interface);
89 tm1622_interface_debug_print("tm1622: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
90 tm1622_interface_debug_print("tm1622: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
91 tm1622_interface_debug_print("tm1622: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
92 tm1622_interface_debug_print("tm1622: max current is %0.2fmA.\n", info.max_current_ma);
93 tm1622_interface_debug_print("tm1622: max temperature is %0.1fC.\n", info.temperature_max);
94 tm1622_interface_debug_print("tm1622: min temperature is %0.1fC.\n", info.temperature_min);
95 }
96
97 /* start output test */
98 tm1622_interface_debug_print("tm1622: start output test.\n");
99
100 /* tm1622 init */
101 res = tm1622_init(&gs_handle);
102 if (res != 0)
103 {
104 tm1622_interface_debug_print("tm1622: init failed.\n");
105
106 return 1;
107 }
108
109 /* set clock */
110 res = tm1622_set_clock(&gs_handle, TM1622_CLOCK_RC_32K);
111 if (res != 0)
112 {
113 tm1622_interface_debug_print("tm1622: set clock failed.\n");
114 (void)tm1622_deinit(&gs_handle);
115
116 return 1;
117 }
118
119 /* enable oscillator */
120 res = tm1622_set_oscillator(&gs_handle, TM1622_BOOL_TRUE);
121 if (res != 0)
122 {
123 tm1622_interface_debug_print("tm1622: set oscillator failed.\n");
124 (void)tm1622_deinit(&gs_handle);
125
126 return 1;
127 }
128
129 /* enable lcd bias */
130 res = tm1622_set_lcd_bias(&gs_handle, TM1622_BOOL_TRUE);
131 if (res != 0)
132 {
133 tm1622_interface_debug_print("tm1622: set lcd bias failed.\n");
134 (void)tm1622_deinit(&gs_handle);
135
136 return 1;
137 }
138
139 /* set normal mode */
140 res = tm1622_set_mode(&gs_handle, TM1622_MODE_NORMAL);
141 if (res != 0)
142 {
143 tm1622_interface_debug_print("tm1622: set mode failed.\n");
144 (void)tm1622_deinit(&gs_handle);
145
146 return 1;
147 }
148
149 /* disable tone */
150 res = tm1622_set_tone(&gs_handle, TM1622_BOOL_FALSE);
151 if (res != 0)
152 {
153 tm1622_interface_debug_print("tm1622: set tone failed.\n");
154 (void)tm1622_deinit(&gs_handle);
155
156 return 1;
157 }
158
159 /* disable timer */
160 res = tm1622_set_timer(&gs_handle, TM1622_BOOL_FALSE);
161 if (res != 0)
162 {
163 tm1622_interface_debug_print("tm1622: set timer failed.\n");
164 (void)tm1622_deinit(&gs_handle);
165
166 return 1;
167 }
168
169 /* clear timer */
170 res = tm1622_clear_timer(&gs_handle);
171 if (res != 0)
172 {
173 tm1622_interface_debug_print("tm1622: clear timer failed.\n");
174 (void)tm1622_deinit(&gs_handle);
175
176 return 1;
177 }
178
179 /* disable watchdog */
180 res = tm1622_set_watchdog(&gs_handle, TM1622_BOOL_FALSE);
181 if (res != 0)
182 {
183 tm1622_interface_debug_print("tm1622: set watchdog failed.\n");
184 (void)tm1622_deinit(&gs_handle);
185
186 return 1;
187 }
188
189 /* clear watchdog */
190 res = tm1622_clear_watchdog(&gs_handle);
191 if (res != 0)
192 {
193 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
194 (void)tm1622_deinit(&gs_handle);
195
196 return 1;
197 }
198
199 /* enable interrupt */
200 res = tm1622_set_irq(&gs_handle, TM1622_BOOL_TRUE);
201 if (res != 0)
202 {
203 tm1622_interface_debug_print("tm1622: set irq failed.\n");
204 (void)tm1622_deinit(&gs_handle);
205
206 return 1;
207 }
208
209 /* clear segment */
210 res = tm1622_clear_segment(&gs_handle);
211 if (res != 0)
212 {
213 tm1622_interface_debug_print("tm1622: clear segment failed.\n");
214 (void)tm1622_deinit(&gs_handle);
215
216 return 1;
217 }
218
219 /* set freq clock 1hz, wdt 4s */
220 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F1);
221 if (res != 0)
222 {
223 tm1622_interface_debug_print("tm1622: set freq failed.\n");
224 (void)tm1622_deinit(&gs_handle);
225
226 return 1;
227 }
228
229 /* enable timer */
230 res = tm1622_set_timer(&gs_handle, TM1622_BOOL_TRUE);
231 if (res != 0)
232 {
233 tm1622_interface_debug_print("tm1622: set timer failed.\n");
234 (void)tm1622_deinit(&gs_handle);
235
236 return 1;
237 }
238
239 /* clock 1hz test */
240 tm1622_interface_debug_print("tm1622: clock 1hz test.\n");
241
242 /* delay 5000ms */
244
245 /* set freq clock 2hz, wdt 2s */
246 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F2);
247 if (res != 0)
248 {
249 tm1622_interface_debug_print("tm1622: set freq failed.\n");
250 (void)tm1622_deinit(&gs_handle);
251
252 return 1;
253 }
254
255 /* clock 2hz test */
256 tm1622_interface_debug_print("tm1622: clock 2hz test.\n");
257
258 /* delay 5000ms */
260
261 /* set freq clock 4hz, wdt 1s */
262 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F4);
263 if (res != 0)
264 {
265 tm1622_interface_debug_print("tm1622: set freq failed.\n");
266 (void)tm1622_deinit(&gs_handle);
267
268 return 1;
269 }
270
271 /* clock 4hz test */
272 tm1622_interface_debug_print("tm1622: clock 4hz test.\n");
273
274 /* delay 5000ms */
276
277 /* set freq clock 8hz, wdt 1/2s */
278 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F8);
279 if (res != 0)
280 {
281 tm1622_interface_debug_print("tm1622: set freq failed.\n");
282 (void)tm1622_deinit(&gs_handle);
283
284 return 1;
285 }
286
287 /* clock 8hz test */
288 tm1622_interface_debug_print("tm1622: clock 8hz test.\n");
289
290 /* delay 5000ms */
292
293 /* set freq clock 16hz, wdt 1/4s */
294 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F16);
295 if (res != 0)
296 {
297 tm1622_interface_debug_print("tm1622: set freq failed.\n");
298 (void)tm1622_deinit(&gs_handle);
299
300 return 1;
301 }
302
303 /* clock 16hz test */
304 tm1622_interface_debug_print("tm1622: clock 16hz test.\n");
305
306 /* delay 5000ms */
308
309 /* set freq clock 32hz, wdt 1/8s */
310 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F32);
311 if (res != 0)
312 {
313 tm1622_interface_debug_print("tm1622: set freq failed.\n");
314 (void)tm1622_deinit(&gs_handle);
315
316 return 1;
317 }
318
319 /* clock 32hz test */
320 tm1622_interface_debug_print("tm1622: clock 32hz test.\n");
321
322 /* delay 5000ms */
324
325 /* set freq clock 64hz, wdt 1/16s */
326 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F64);
327 if (res != 0)
328 {
329 tm1622_interface_debug_print("tm1622: set freq failed.\n");
330 (void)tm1622_deinit(&gs_handle);
331
332 return 1;
333 }
334
335 /* clock 64hz test */
336 tm1622_interface_debug_print("tm1622: clock 64hz test.\n");
337
338 /* delay 5000ms */
340
341 /* set freq clock 128hz, wdt 1/32s */
342 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F128);
343 if (res != 0)
344 {
345 tm1622_interface_debug_print("tm1622: set freq failed.\n");
346 (void)tm1622_deinit(&gs_handle);
347
348 return 1;
349 }
350
351 /* clock 128hz test */
352 tm1622_interface_debug_print("tm1622: clock 128hz test.\n");
353
354 /* delay 5000ms */
356
357 /* disable timer */
358 res = tm1622_set_timer(&gs_handle, TM1622_BOOL_FALSE);
359 if (res != 0)
360 {
361 tm1622_interface_debug_print("tm1622: set timer failed.\n");
362 (void)tm1622_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 /* clear timer */
368 res = tm1622_clear_timer(&gs_handle);
369 if (res != 0)
370 {
371 tm1622_interface_debug_print("tm1622: clear timer failed.\n");
372 (void)tm1622_deinit(&gs_handle);
373
374 return 1;
375 }
376
377 /* enable watchdog */
378 res = tm1622_set_watchdog(&gs_handle, TM1622_BOOL_TRUE);
379 if (res != 0)
380 {
381 tm1622_interface_debug_print("tm1622: set watchdog failed.\n");
382 (void)tm1622_deinit(&gs_handle);
383
384 return 1;
385 }
386
387 /* clear watchdog */
388 res = tm1622_clear_watchdog(&gs_handle);
389 if (res != 0)
390 {
391 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
392 (void)tm1622_deinit(&gs_handle);
393
394 return 1;
395 }
396
397 /* set freq clock 1hz, wdt 4s */
398 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F1);
399 if (res != 0)
400 {
401 tm1622_interface_debug_print("tm1622: set freq failed.\n");
402 (void)tm1622_deinit(&gs_handle);
403
404 return 1;
405 }
406
407 /* wdt 4s test */
408 tm1622_interface_debug_print("tm1622: wdt 4s test.\n");
409
410 /* delay 5000ms */
412
413 /* clear watchdog */
414 res = tm1622_clear_watchdog(&gs_handle);
415 if (res != 0)
416 {
417 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
418 (void)tm1622_deinit(&gs_handle);
419
420 return 1;
421 }
422
423 /* set freq clock 2hz, wdt 2s */
424 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F2);
425 if (res != 0)
426 {
427 tm1622_interface_debug_print("tm1622: set freq failed.\n");
428 (void)tm1622_deinit(&gs_handle);
429
430 return 1;
431 }
432
433 /* wdt 2s test */
434 tm1622_interface_debug_print("tm1622: wdt 2s test.\n");
435
436 /* delay 3000ms */
438
439 /* clear watchdog */
440 res = tm1622_clear_watchdog(&gs_handle);
441 if (res != 0)
442 {
443 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
444 (void)tm1622_deinit(&gs_handle);
445
446 return 1;
447 }
448
449 /* set freq clock 4hz, wdt 1s */
450 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F4);
451 if (res != 0)
452 {
453 tm1622_interface_debug_print("tm1622: set freq failed.\n");
454 (void)tm1622_deinit(&gs_handle);
455
456 return 1;
457 }
458
459 /* wdt 1s test */
460 tm1622_interface_debug_print("tm1622: wdt 1s test.\n");
461
462 /* delay 2000ms */
464
465 /* clear watchdog */
466 res = tm1622_clear_watchdog(&gs_handle);
467 if (res != 0)
468 {
469 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
470 (void)tm1622_deinit(&gs_handle);
471
472 return 1;
473 }
474
475 /* set freq clock 8hz, wdt 1/2s */
476 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F8);
477 if (res != 0)
478 {
479 tm1622_interface_debug_print("tm1622: set freq failed.\n");
480 (void)tm1622_deinit(&gs_handle);
481
482 return 1;
483 }
484
485 /* wdt 1/2s test */
486 tm1622_interface_debug_print("tm1622: wdt 1/2s test.\n");
487
488 /* delay 1000ms */
490
491 /* clear watchdog */
492 res = tm1622_clear_watchdog(&gs_handle);
493 if (res != 0)
494 {
495 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
496 (void)tm1622_deinit(&gs_handle);
497
498 return 1;
499 }
500
501 /* set freq clock 16hz, wdt 1/4s */
502 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F16);
503 if (res != 0)
504 {
505 tm1622_interface_debug_print("tm1622: set freq failed.\n");
506 (void)tm1622_deinit(&gs_handle);
507
508 return 1;
509 }
510
511 /* wdt 1/4s test */
512 tm1622_interface_debug_print("tm1622: wdt 1/4s test.\n");
513
514 /* delay 1000ms */
516
517 /* clear watchdog */
518 res = tm1622_clear_watchdog(&gs_handle);
519 if (res != 0)
520 {
521 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
522 (void)tm1622_deinit(&gs_handle);
523
524 return 1;
525 }
526
527 /* set freq clock 32hz, wdt 1/8s */
528 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F32);
529 if (res != 0)
530 {
531 tm1622_interface_debug_print("tm1622: set freq failed.\n");
532 (void)tm1622_deinit(&gs_handle);
533
534 return 1;
535 }
536
537 /* wdt 1/8s test */
538 tm1622_interface_debug_print("tm1622: wdt 1/8s test.\n");
539
540 /* delay 1000ms */
542
543 /* clear watchdog */
544 res = tm1622_clear_watchdog(&gs_handle);
545 if (res != 0)
546 {
547 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
548 (void)tm1622_deinit(&gs_handle);
549
550 return 1;
551 }
552
553 /* set freq clock 64hz, wdt 1/16s */
554 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F64);
555 if (res != 0)
556 {
557 tm1622_interface_debug_print("tm1622: set freq failed.\n");
558 (void)tm1622_deinit(&gs_handle);
559
560 return 1;
561 }
562
563 /* wdt 1/16s test */
564 tm1622_interface_debug_print("tm1622: wdt 1/16s test.\n");
565
566 /* delay 1000ms */
568
569 /* clear watchdog */
570 res = tm1622_clear_watchdog(&gs_handle);
571 if (res != 0)
572 {
573 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
574 (void)tm1622_deinit(&gs_handle);
575
576 return 1;
577 }
578
579 /* set freq clock 128hz, wdt 1/32s */
580 res = tm1622_set_freq(&gs_handle, TM1622_FREQ_F128);
581 if (res != 0)
582 {
583 tm1622_interface_debug_print("tm1622: set freq failed.\n");
584 (void)tm1622_deinit(&gs_handle);
585
586 return 1;
587 }
588
589 /* wdt 1/32s test */
590 tm1622_interface_debug_print("tm1622: wdt 1/32s test.\n");
591
592 /* delay 1000ms */
594
595 /* disable watchdog */
596 res = tm1622_set_watchdog(&gs_handle, TM1622_BOOL_FALSE);
597 if (res != 0)
598 {
599 tm1622_interface_debug_print("tm1622: set watchdog failed.\n");
600 (void)tm1622_deinit(&gs_handle);
601
602 return 1;
603 }
604
605 /* clear watchdog */
606 res = tm1622_clear_watchdog(&gs_handle);
607 if (res != 0)
608 {
609 tm1622_interface_debug_print("tm1622: clear watchdog failed.\n");
610 (void)tm1622_deinit(&gs_handle);
611
612 return 1;
613 }
614
615 /* finish output test */
616 tm1622_interface_debug_print("tm1622: finish output test.\n");
617 (void)tm1622_deinit(&gs_handle);
618
619 return 0;
620}
driver tm1622 output test 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_clear_watchdog(tm1622_handle_t *handle)
clear watchdog
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
struct tm1622_info_s tm1622_info_t
tm1622 information structure definition
uint8_t tm1622_set_clock(tm1622_handle_t *handle, tm1622_clock_t clk)
set clock
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
uint8_t tm1622_info(tm1622_info_t *info)
get chip's information
@ TM1622_CLOCK_RC_32K
@ TM1622_FREQ_F64
@ TM1622_FREQ_F8
@ TM1622_FREQ_F2
@ TM1622_FREQ_F4
@ TM1622_FREQ_F1
@ TM1622_FREQ_F32
@ TM1622_FREQ_F128
@ TM1622_FREQ_F16
@ TM1622_MODE_NORMAL
@ TM1622_BOOL_FALSE
@ TM1622_BOOL_TRUE
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
uint8_t tm1622_output_test(void)
output test
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]