LibDriver MAX7219
Loading...
Searching...
No Matches
driver_max7219_display_test.c
Go to the documentation of this file.
1
37
39
40static max7219_handle_t gs_handle;
41
50{
51 uint8_t res;
52 max7219_info_t info;
53
54 /* link functions */
62
63 /* max7219 info */
64 res = max7219_info(&info);
65 if (res != 0)
66 {
67 max7219_interface_debug_print("max7219: get info failed.\n");
68
69 return 1;
70 }
71 else
72 {
73 /* print chip information */
74 max7219_interface_debug_print("max7219: chip is %s.\n", info.chip_name);
75 max7219_interface_debug_print("max7219: manufacturer is %s.\n", info.manufacturer_name);
76 max7219_interface_debug_print("max7219: interface is %s.\n", info.interface);
77 max7219_interface_debug_print("max7219: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
78 max7219_interface_debug_print("max7219: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
79 max7219_interface_debug_print("max7219: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
80 max7219_interface_debug_print("max7219: max current is %0.2fmA.\n", info.max_current_ma);
81 max7219_interface_debug_print("max7219: max temperature is %0.1fC.\n", info.temperature_max);
82 max7219_interface_debug_print("max7219: min temperature is %0.1fC.\n", info.temperature_min);
83 }
84
85 /* start display test */
86 max7219_interface_debug_print("max7219: start display test.\n");
87
88 /* max7219 init */
89 res = max7219_init(&gs_handle);
90 if (res != 0)
91 {
92 max7219_interface_debug_print("max7219: init failed.\n");
93
94 return 1;
95 }
96
97 /* max7219 set scan limit */
99 if (res != 0)
100 {
101 max7219_interface_debug_print("max7219: set scan limit failed.\n");
102 (void)max7219_deinit(&gs_handle);
103
104 return 1;
105 }
106
107 /* max7219 set intensity */
109 if (res != 0)
110 {
111 max7219_interface_debug_print("max7219: set intensity failed.\n");
112 (void)max7219_deinit(&gs_handle);
113
114 return 1;
115 }
116
117 /* max7219 set display test mode */
119 if (res != 0)
120 {
121 max7219_interface_debug_print("max7219: set display test mode failed.\n");
122 (void)max7219_deinit(&gs_handle);
123
124 return 1;
125 }
126
127 /* max7219 set decode */
129 if (res != 0)
130 {
131 max7219_interface_debug_print("max7219: set decode failed.\n");
132 (void)max7219_deinit(&gs_handle);
133
134 return 1;
135 }
136
137 /* max7219 set mode */
138 res = max7219_set_mode(&gs_handle, MAX7219_MODE_NORMAL);
139 if (res != 0)
140 {
141 max7219_interface_debug_print("max7219: set mode failed.\n");
142 (void)max7219_deinit(&gs_handle);
143
144 return 1;
145 }
146
147 /* display test */
148 max7219_interface_debug_print("max7219: display test.\n");
149
150 /* max7219 set display test mode */
152 if (res != 0)
153 {
154 max7219_interface_debug_print("max7219: set display test mode failed.\n");
155 (void)max7219_deinit(&gs_handle);
156
157 return 1;
158 }
159
160 /* delay 3000 ms */
162
163 /* max7219 set display test mode */
165 if (res != 0)
166 {
167 max7219_interface_debug_print("max7219: set display test mode failed.\n");
168 (void)max7219_deinit(&gs_handle);
169
170 return 1;
171 }
172
173 /* code display */
174 max7219_interface_debug_print("max7219: code display.\n");
175
176 /* max7219 set decode */
178 if (res != 0)
179 {
180 max7219_interface_debug_print("max7219: set decode failed.\n");
181 (void)max7219_deinit(&gs_handle);
182
183 return 1;
184 }
186 if (res != 0)
187 {
188 max7219_interface_debug_print("max7219: set display failed.\n");
189 (void)max7219_deinit(&gs_handle);
190
191 return 1;
192 }
194 if (res != 0)
195 {
196 max7219_interface_debug_print("max7219: set display failed.\n");
197 (void)max7219_deinit(&gs_handle);
198
199 return 1;
200 }
202 if (res != 0)
203 {
204 max7219_interface_debug_print("max7219: set display failed.\n");
205 (void)max7219_deinit(&gs_handle);
206
207 return 1;
208 }
210 if (res != 0)
211 {
212 max7219_interface_debug_print("max7219: set display failed.\n");
213 (void)max7219_deinit(&gs_handle);
214
215 return 1;
216 }
218 if (res != 0)
219 {
220 max7219_interface_debug_print("max7219: set display failed.\n");
221 (void)max7219_deinit(&gs_handle);
222
223 return 1;
224 }
226 if (res != 0)
227 {
228 max7219_interface_debug_print("max7219: set display failed.\n");
229 (void)max7219_deinit(&gs_handle);
230
231 return 1;
232 }
234 if (res != 0)
235 {
236 max7219_interface_debug_print("max7219: set display failed.\n");
237 (void)max7219_deinit(&gs_handle);
238
239 return 1;
240 }
242 if (res != 0)
243 {
244 max7219_interface_debug_print("max7219: set display failed.\n");
245 (void)max7219_deinit(&gs_handle);
246
247 return 1;
248 }
249
250 /* delay 3000 ms */
253 if (res != 0)
254 {
255 max7219_interface_debug_print("max7219: set display failed.\n");
256 (void)max7219_deinit(&gs_handle);
257
258 return 1;
259 }
261 if (res != 0)
262 {
263 max7219_interface_debug_print("max7219: set display failed.\n");
264 (void)max7219_deinit(&gs_handle);
265
266 return 1;
267 }
269 if (res != 0)
270 {
271 max7219_interface_debug_print("max7219: set display failed.\n");
272 (void)max7219_deinit(&gs_handle);
273
274 return 1;
275 }
277 if (res != 0)
278 {
279 max7219_interface_debug_print("max7219: set display failed.\n");
280 (void)max7219_deinit(&gs_handle);
281
282 return 1;
283 }
285 if (res != 0)
286 {
287 max7219_interface_debug_print("max7219: set display failed.\n");
288 (void)max7219_deinit(&gs_handle);
289
290 return 1;
291 }
293 if (res != 0)
294 {
295 max7219_interface_debug_print("max7219: set display failed.\n");
296 (void)max7219_deinit(&gs_handle);
297
298 return 1;
299 }
301 if (res != 0)
302 {
303 max7219_interface_debug_print("max7219: set display failed.\n");
304 (void)max7219_deinit(&gs_handle);
305
306 return 1;
307 }
309 if (res != 0)
310 {
311 max7219_interface_debug_print("max7219: set display failed.\n");
312 (void)max7219_deinit(&gs_handle);
313
314 return 1;
315 }
316
317 /* delay 3000 ms */
319
320 /* no decode display */
321 max7219_interface_debug_print("max7219: no decode display.\n");
322
323 /* max7219 set decode */
325 if (res != 0)
326 {
327 max7219_interface_debug_print("max7219: set decode failed.\n");
328 (void)max7219_deinit(&gs_handle);
329
330 return 1;
331 }
333 if (res != 0)
334 {
335 max7219_interface_debug_print("max7219: set display failed.\n");
336 (void)max7219_deinit(&gs_handle);
337
338 return 1;
339 }
341 if (res != 0)
342 {
343 max7219_interface_debug_print("max7219: set display failed.\n");
344 (void)max7219_deinit(&gs_handle);
345
346 return 1;
347 }
349 if (res != 0)
350 {
351 max7219_interface_debug_print("max7219: set display failed.\n");
352 (void)max7219_deinit(&gs_handle);
353
354 return 1;
355 }
357 if (res != 0)
358 {
359 max7219_interface_debug_print("max7219: set display failed.\n");
360 (void)max7219_deinit(&gs_handle);
361
362 return 1;
363 }
365 if (res != 0)
366 {
367 max7219_interface_debug_print("max7219: set display failed.\n");
368 (void)max7219_deinit(&gs_handle);
369
370 return 1;
371 }
373 if (res != 0)
374 {
375 max7219_interface_debug_print("max7219: set display failed.\n");
376 (void)max7219_deinit(&gs_handle);
377
378 return 1;
379 }
381 if (res != 0)
382 {
383 max7219_interface_debug_print("max7219: set display failed.\n");
384 (void)max7219_deinit(&gs_handle);
385
386 return 1;
387 }
389 if (res != 0)
390 {
391 max7219_interface_debug_print("max7219: set display failed.\n");
392 (void)max7219_deinit(&gs_handle);
393
394 return 1;
395 }
396
397 /* delay 3000 ms */
400 if (res != 0)
401 {
402 max7219_interface_debug_print("max7219: set display failed.\n");
403 (void)max7219_deinit(&gs_handle);
404
405 return 1;
406 }
408 if (res != 0)
409 {
410 max7219_interface_debug_print("max7219: set display failed.\n");
411 (void)max7219_deinit(&gs_handle);
412
413 return 1;
414 }
416 if (res != 0)
417 {
418 max7219_interface_debug_print("max7219: set display failed.\n");
419 (void)max7219_deinit(&gs_handle);
420
421 return 1;
422 }
424 if (res != 0)
425 {
426 max7219_interface_debug_print("max7219: set display failed.\n");
427 (void)max7219_deinit(&gs_handle);
428
429 return 1;
430 }
432 if (res != 0)
433 {
434 max7219_interface_debug_print("max7219: set display failed.\n");
435 (void)max7219_deinit(&gs_handle);
436
437 return 1;
438 }
440 if (res != 0)
441 {
442 max7219_interface_debug_print("max7219: set display failed.\n");
443 (void)max7219_deinit(&gs_handle);
444
445 return 1;
446 }
448 if (res != 0)
449 {
450 max7219_interface_debug_print("max7219: set display failed.\n");
451 (void)max7219_deinit(&gs_handle);
452
453 return 1;
454 }
456 if (res != 0)
457 {
458 max7219_interface_debug_print("max7219: set display failed.\n");
459 (void)max7219_deinit(&gs_handle);
460
461 return 1;
462 }
463
464 /* delay 3000 ms */
466
467 /* intensity test */
468 max7219_interface_debug_print("max7219: intensity test.\n");
469
470 /* intensity 31/32 */
471 max7219_interface_debug_print("max7219: intensity 31/32.\n");
472
473 /* max7219 set intensity */
475 if (res != 0)
476 {
477 max7219_interface_debug_print("max7219: set intensity failed.\n");
478 (void)max7219_deinit(&gs_handle);
479
480 return 1;
481 }
482
483 /* delay 3000 ms */
485
486 /* intensity 21/32 */
487 max7219_interface_debug_print("max7219: intensity 21/32.\n");
488
489 /* max7219 set intensity */
491 if (res != 0)
492 {
493 max7219_interface_debug_print("max7219: set intensity failed.\n");
494 (void)max7219_deinit(&gs_handle);
495
496 return 1;
497 }
498
499 /* delay 3000 ms */
501
502 /* intensity 11/32 */
503 max7219_interface_debug_print("max7219: intensity 11/32.\n");
504
505 /* max7219 set intensity */
507 if (res != 0)
508 {
509 max7219_interface_debug_print("max7219: set intensity failed.\n");
510 (void)max7219_deinit(&gs_handle);
511
512 return 1;
513 }
514
515 /* delay 3000 ms */
517
518 /* intensity 1/32 */
519 max7219_interface_debug_print("max7219: intensity 1/32.\n");
520
521 /* max7219 set intensity */
523 if (res != 0)
524 {
525 max7219_interface_debug_print("max7219: set intensity failed.\n");
526 (void)max7219_deinit(&gs_handle);
527
528 return 1;
529 }
530
531 /* delay 3000 ms */
533
534 /* max7219 set intensity */
536 if (res != 0)
537 {
538 max7219_interface_debug_print("max7219: set intensity failed.\n");
539 (void)max7219_deinit(&gs_handle);
540
541 return 1;
542 }
543
544 /* scan limit test */
545 max7219_interface_debug_print("max7219: scan limit test.\n");
546
547 /* scan limit 0-7 */
548 max7219_interface_debug_print("max7219: scan limit 0-7.\n");
549
550 /* max7219 set scan limit */
552 if (res != 0)
553 {
554 max7219_interface_debug_print("max7219: set scan limit failed.\n");
555 (void)max7219_deinit(&gs_handle);
556
557 return 1;
558 }
559
560 /* delay 3000 ms */
562
563 /* scan limit 0-6 */
564 max7219_interface_debug_print("max7219: scan limit 0-6.\n");
565
566 /* max7219 set scan limit */
568 if (res != 0)
569 {
570 max7219_interface_debug_print("max7219: set scan limit failed.\n");
571 (void)max7219_deinit(&gs_handle);
572
573 return 1;
574 }
575
576 /* delay 3000 ms */
578
579 /* scan limit 0-5 */
580 max7219_interface_debug_print("max7219: scan limit 0-5.\n");
581
582 /* max7219 set scan limit */
584 if (res != 0)
585 {
586 max7219_interface_debug_print("max7219: set scan limit failed.\n");
587 (void)max7219_deinit(&gs_handle);
588
589 return 1;
590 }
591
592 /* delay 3000 ms */
594
595 /* scan limit 0-4 */
596 max7219_interface_debug_print("max7219: scan limit 0-4.\n");
597
598 /* max7219 set scan limit */
600 if (res != 0)
601 {
602 max7219_interface_debug_print("max7219: set scan limit failed.\n");
603 (void)max7219_deinit(&gs_handle);
604
605 return 1;
606 }
607
608 /* delay 3000 ms */
610
611 /* scan limit 0-3 */
612 max7219_interface_debug_print("max7219: scan limit 0-3.\n");
613
614 /* max7219 set scan limit */
616 if (res != 0)
617 {
618 max7219_interface_debug_print("max7219: set scan limit failed.\n");
619 (void)max7219_deinit(&gs_handle);
620
621 return 1;
622 }
623
624 /* delay 3000 ms */
626
627 /* scan limit 0-2 */
628 max7219_interface_debug_print("max7219: scan limit 0-2.\n");
629
630 /* max7219 set scan limit */
632 if (res != 0)
633 {
634 max7219_interface_debug_print("max7219: set scan limit failed.\n");
635 (void)max7219_deinit(&gs_handle);
636
637 return 1;
638 }
639
640 /* delay 3000 ms */
642
643 /* scan limit 0-1 */
644 max7219_interface_debug_print("max7219: scan limit 0-1.\n");
645
646 /* max7219 set scan limit */
648 if (res != 0)
649 {
650 max7219_interface_debug_print("max7219: set scan limit failed.\n");
651 (void)max7219_deinit(&gs_handle);
652
653 return 1;
654 }
655
656 /* delay 3000 ms */
658
659 /* scan limit 0-0 */
660 max7219_interface_debug_print("max7219: scan limit 0-0.\n");
661
662 /* max7219 set scan limit */
664 if (res != 0)
665 {
666 max7219_interface_debug_print("max7219: set scan limit failed.\n");
667 (void)max7219_deinit(&gs_handle);
668
669 return 1;
670 }
671
672 /* delay 3000 ms */
674
675 /* finish display test */
676 max7219_interface_debug_print("max7219: finish display test.\n");
677 (void)max7219_deinit(&gs_handle);
678
679 return 0;
680}
driver max7219 display test header file
uint8_t max7219_set_display(max7219_handle_t *handle, max7219_digital_t digital, uint8_t data)
set the display content
uint8_t max7219_set_decode(max7219_handle_t *handle, max7219_decode_t decode)
set the decode mode
uint8_t max7219_set_scan_limit(max7219_handle_t *handle, max7219_scan_limit_t limit)
set the scan limit
uint8_t max7219_info(max7219_info_t *info)
get chip's information
uint8_t max7219_init(max7219_handle_t *handle)
initialize the chip
uint8_t max7219_set_intensity(max7219_handle_t *handle, max7219_intensity_t intensity)
set the display intensity
uint8_t max7219_set_mode(max7219_handle_t *handle, max7219_mode_t mode)
set the chip mode
uint8_t max7219_deinit(max7219_handle_t *handle)
close the chip
struct max7219_info_s max7219_info_t
max7219 info structure definition
struct max7219_handle_s max7219_handle_t
max7219 handle structure definition
uint8_t max7219_set_display_test_mode(max7219_handle_t *handle, max7219_display_test_mode_t mode)
set the display test mode
@ MAX7219_DISPLAY_TEST_MODE_ON
@ MAX7219_DISPLAY_TEST_MODE_OFF
@ MAX7219_DECODE_CODEB_DIGITS_7_0
@ MAX7219_DECODE_CODEB_DIGITS_NONE
@ MAX7219_SCAN_LIMIT_DIGIT_0_0
@ MAX7219_SCAN_LIMIT_DIGIT_0_2
@ MAX7219_SCAN_LIMIT_DIGIT_0_5
@ MAX7219_SCAN_LIMIT_DIGIT_0_6
@ MAX7219_SCAN_LIMIT_DIGIT_0_7
@ MAX7219_SCAN_LIMIT_DIGIT_0_1
@ MAX7219_SCAN_LIMIT_DIGIT_0_3
@ MAX7219_SCAN_LIMIT_DIGIT_0_4
@ MAX7219_DIGITAL_0
@ MAX7219_DIGITAL_5
@ MAX7219_DIGITAL_2
@ MAX7219_DIGITAL_6
@ MAX7219_DIGITAL_1
@ MAX7219_DIGITAL_7
@ MAX7219_DIGITAL_4
@ MAX7219_DIGITAL_3
@ MAX7219_NO_DECODE_FONT_5
@ MAX7219_NO_DECODE_FONT_1
@ MAX7219_NO_DECODE_FONT_E
@ MAX7219_NO_DECODE_FONT_7
@ MAX7219_NO_DECODE_FONT_LINE
@ MAX7219_NO_DECODE_FONT_4
@ MAX7219_NO_DECODE_FONT_H
@ MAX7219_NO_DECODE_FONT_BLACK
@ MAX7219_NO_DECODE_FONT_0
@ MAX7219_NO_DECODE_FONT_P
@ MAX7219_NO_DECODE_FONT_9
@ MAX7219_NO_DECODE_FONT_2
@ MAX7219_NO_DECODE_FONT_8
@ MAX7219_NO_DECODE_FONT_3
@ MAX7219_NO_DECODE_FONT_6
@ MAX7219_NO_DECODE_FONT_L
@ MAX7219_MODE_NORMAL
@ MAX7219_SEGMENT_DP
@ MAX7219_INTENSITY_1_32
@ MAX7219_INTENSITY_11_32
@ MAX7219_INTENSITY_31_32
@ MAX7219_INTENSITY_21_32
@ MAX7219_CODEB_FONT_2
@ MAX7219_CODEB_FONT_9
@ MAX7219_CODEB_FONT_5
@ MAX7219_CODEB_FONT_BLACK
@ MAX7219_CODEB_FONT_0
@ MAX7219_CODEB_FONT_4
@ MAX7219_CODEB_FONT_3
@ MAX7219_CODEB_FONT_8
@ MAX7219_CODEB_FONT_L
@ MAX7219_CODEB_FONT_H
@ MAX7219_CODEB_FONT_LINE
@ MAX7219_CODEB_FONT_7
@ MAX7219_CODEB_FONT_6
@ MAX7219_CODEB_FONT_P
@ MAX7219_CODEB_FONT_E
@ MAX7219_CODEB_FONT_1
uint8_t max7219_interface_spi_init(void)
interface spi bus init
uint8_t max7219_interface_spi_deinit(void)
interface spi bus deinit
uint8_t max7219_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t max7219_interface_spi_write_cmd(uint8_t *buf, uint16_t len)
interface spi bus write command
void max7219_interface_delay_ms(uint32_t ms)
interface delay ms
void max7219_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t max7219_display_test(void)
display test
uint32_t driver_version
char manufacturer_name[32]