LibDriver LAN8720
Loading...
Searching...
No Matches
driver_lan8720.c
Go to the documentation of this file.
1
36
37#include "driver_lan8720.h"
38
42#define CHIP_NAME "Microchip LAN8720"
43#define MANUFACTURER_NAME "Microchip"
44#define SUPPLY_VOLTAGE_MIN 3.0f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 60.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
50
54#define LAN8720_REG_BASIC_CONTROL 0x00
55#define LAN8720_REG_BASIC_STATUS 0x01
56#define LAN8720_REG_PHY_IDENTIFIER_1 0x02
57#define LAN8720_REG_PHY_IDENTIFIER_2 0x03
58#define LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT 0x04
59#define LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY 0x05
60#define LAN8720_REG_AUTO_NEGOTIATION_EXPANSION 0x06
61#define LAN8720_REG_MODE_CONTROL_STATUS 0x11
62#define LAN8720_REG_SPECIAL_MODES 0x12
63#define LAN8720_REG_SYMBOL_ERROR_COUNTER_REGISTER 0x1A
64#define LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS 0x1B
65#define LAN8720_REG_INTERRUPT_SOURCE_FLAG 0x1D
66#define LAN8720_REG_INTERRUPT_MASK 0x1E
67#define LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS 0x1F
68
79static uint8_t a_lan8720_smi_read(lan8720_handle_t *handle, uint8_t reg, uint16_t *data)
80{
81 if (handle->smi_read(handle->smi_addr, reg, data) != 0) /* read data */
82 {
83 return 1; /* return error */
84 }
85
86 return 0; /* success return 0 */
87}
88
99static uint8_t a_lan8720_smi_write(lan8720_handle_t *handle, uint8_t reg, uint16_t data)
100{
101 if (handle->smi_write(handle->smi_addr, reg, data) != 0) /* write data */
102 {
103 return 1; /* return error */
104 }
105
106 return 0; /* success return 0 */
107}
108
119uint8_t lan8720_set_address(lan8720_handle_t *handle, uint8_t addr)
120{
121 if (handle == NULL) /* check handle */
122 {
123 return 2; /* return error */
124 }
125 if (addr > 0x1F) /* check addr */
126 {
127 handle->debug_print("lan8720: addr > 0x1F.\n"); /* addr > 0x1F */
128
129 return 4; /* return error */
130 }
131
132 handle->smi_addr = addr; /* set smi addr */
133
134 return 0; /* success return 0 */
135}
136
146uint8_t lan8720_get_address(lan8720_handle_t *handle, uint8_t *addr)
147{
148 if (handle == NULL) /* check handle */
149 {
150 return 2; /* return error */
151 }
152
153 *addr = handle->smi_addr; /* get smi address */
154
155 return 0; /* success return 0 */
156}
157
170{
171 uint16_t config;
172
173 if (handle == NULL) /* check handle */
174 {
175 return 2; /* return error */
176 }
177 if (handle->debug_print == NULL) /* check debug_print */
178 {
179 return 3; /* return error */
180 }
181 if (handle->smi_init == NULL) /* check smi_init */
182 {
183 handle->debug_print("lan8720: smi_init is null.\n"); /* smi_init is null */
184
185 return 3; /* return error */
186 }
187 if (handle->smi_deinit == NULL) /* check smi_deinit */
188 {
189 handle->debug_print("lan8720: smi_deinit is null.\n"); /* smi_deinit is null */
190
191 return 3; /* return error */
192 }
193 if (handle->smi_read == NULL) /* check smi_read */
194 {
195 handle->debug_print("lan8720: smi_read is null.\n"); /* smi_read is null */
196
197 return 3; /* return error */
198 }
199 if (handle->smi_write == NULL) /* check smi_write */
200 {
201 handle->debug_print("lan8720: smi_write is null.\n"); /* smi_write is null */
202
203 return 3; /* return error */
204 }
205 if (handle->reset_gpio_init == NULL) /* check reset_gpio_init */
206 {
207 handle->debug_print("lan8720: reset_gpio_init is null.\n"); /* reset_gpio_init is null */
208
209 return 3; /* return error */
210 }
211 if (handle->reset_gpio_deinit == NULL) /* check reset_gpio_deinit */
212 {
213 handle->debug_print("lan8720: reset_gpio_deinit is null.\n"); /* reset_gpio_deinit is null */
214
215 return 3; /* return error */
216 }
217 if (handle->reset_gpio_write == NULL) /* check reset_gpio_write */
218 {
219 handle->debug_print("lan8720: reset_gpio_write is null.\n"); /* reset_gpio_write is null */
220
221 return 3; /* return error */
222 }
223 if (handle->delay_ms == NULL) /* check delay_ms */
224 {
225 handle->debug_print("lan8720: delay_ms is null.\n"); /* delay_ms is null */
226
227 return 3; /* return error */
228 }
229
230 if (handle->reset_gpio_init() != 0) /* reset gpio init */
231 {
232 handle->debug_print("lan8720: reset gpio init failed.\n"); /* reset gpio init failed */
233
234 return 1; /* return error */
235 }
236 if (handle->reset_gpio_write(0) != 0) /* set low */
237 {
238 handle->debug_print("lan8720: reset gpio write failed.\n"); /* reset gpio write failed */
239 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
240
241 return 1; /* return error */
242 }
243 handle->delay_ms(50); /* delay 50 ms */
244 if (handle->reset_gpio_write(1) != 0) /* set high */
245 {
246 handle->debug_print("lan8720: reset gpio write failed.\n"); /* reset gpio write failed */
247 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
248
249 return 1; /* return error */
250 }
251 handle->delay_ms(10); /* delay 10 ms */
252 if (handle->smi_init() != 0) /* smi init */
253 {
254 handle->debug_print("lan8720: smi init failed.\n"); /* smi init failed */
255 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
256
257 return 1; /* return error */
258 }
259
260 if (a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config) != 0) /* read basic control */
261 {
262 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
263 (void)handle->smi_deinit(); /* smi deinit */
264 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
265
266 return 4; /* return error */
267 }
268 config &= ~(1 << 15); /* clear config */
269 config |= 1 << 15; /* set soft reset */
270 if (a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config) != 0) /* write basic control */
271 {
272 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
273 (void)handle->smi_deinit(); /* smi deinit */
274 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
275
276 return 4; /* return error */
277 }
278 handle->delay_ms(50); /* delay 50 ms */
279 if (a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config) != 0) /* read basic control */
280 {
281 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
282 (void)handle->smi_deinit(); /* smi deinit */
283 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
284
285 return 4; /* return error */
286 }
287 if ((config & (1 <<15)) != 0) /* check self-clear bit */
288 {
289 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
290 (void)handle->smi_deinit(); /* smi deinit */
291 (void)handle->reset_gpio_deinit(); /* reset gpio deinit */
292
293 return 4; /* return error */
294 }
295 handle->inited = 1; /* flag inited */
296
297 return 0; /* success return 0 */
298}
299
312{
313 uint8_t res;
314 uint16_t config;
315
316 if (handle == NULL) /* check handle */
317 {
318 return 2; /* return error */
319 }
320 if (handle->inited != 1) /* check handle initialization */
321 {
322 return 3; /* return error */
323 }
324
325 if (a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config) != 0) /* read basic control */
326 {
327 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
328
329 return 4; /* return error */
330 }
331 config &= ~(1 << 12); /* clear config */
332 if (a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config) != 0) /* write basic control */
333 {
334 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
335
336 return 4; /* return error */
337 }
338 config &= ~(1 << 11); /* clear config */
339 config |= 1 << 11; /* set power down */
340 if (a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config) != 0) /* write basic control */
341 {
342 handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
343
344 return 4; /* return error */
345 }
346 res = handle->smi_deinit(); /* close smi */
347 if (res != 0) /* check the result */
348 {
349 handle->debug_print("lan8720: smi deinit failed.\n"); /* smi deinit failed */
350
351 return 1; /* return error */
352 }
353 res = handle->reset_gpio_deinit(); /* close reset gpio */
354 if (res != 0) /* check the result */
355 {
356 handle->debug_print("lan8720: reset gpio deinit failed.\n"); /* reset gpio deinit failed */
357
358 return 1; /* return error */
359 }
360 handle->inited = 0; /* flag close */
361
362 return 0; /* success return 0 */
363}
364
377{
378 uint8_t res;
379 uint16_t config;
380
381 if (handle == NULL) /* check handle */
382 {
383 return 2; /* return error */
384 }
385 if (handle->inited != 1) /* check handle initialization */
386 {
387 return 3; /* return error */
388 }
389
390 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
391 if (res != 0) /* check result */
392 {
393 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
394
395 return 1; /* return error */
396 }
397 config &= ~(1 << 15); /* clear config */
398 config |= enable << 15; /* set bool */
399 if (enable == LAN8720_BOOL_TRUE) /* check command */
400 {
401 config = 0x8000U; /* set command */
402 }
403 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
404 if (res != 0) /* check result */
405 {
406 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
407
408 return 1; /* return error */
409 }
410
411 return 0; /* success return 0 */
412}
413
426{
427 uint8_t res;
428 uint16_t config;
429
430 if (handle == NULL) /* check handle */
431 {
432 return 2; /* return error */
433 }
434 if (handle->inited != 1) /* check handle initialization */
435 {
436 return 3; /* return error */
437 }
438
439 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
440 if (res != 0) /* check result */
441 {
442 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
443
444 return 1; /* return error */
445 }
446 *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
447
448 return 0; /* success return 0 */
449}
450
463{
464 uint8_t res;
465 uint16_t config;
466
467 if (handle == NULL) /* check handle */
468 {
469 return 2; /* return error */
470 }
471 if (handle->inited != 1) /* check handle initialization */
472 {
473 return 3; /* return error */
474 }
475
476 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
477 if (res != 0) /* check result */
478 {
479 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
480
481 return 1; /* return error */
482 }
483 config &= ~(1 << 14); /* clear config */
484 config |= enable << 14; /* set bool */
485 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
486 if (res != 0) /* check result */
487 {
488 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
489
490 return 1; /* return error */
491 }
492
493 return 0; /* success return 0 */
494}
495
508{
509 uint8_t res;
510 uint16_t config;
511
512 if (handle == NULL) /* check handle */
513 {
514 return 2; /* return error */
515 }
516 if (handle->inited != 1) /* check handle initialization */
517 {
518 return 3; /* return error */
519 }
520
521 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
522 if (res != 0) /* check result */
523 {
524 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
525
526 return 1; /* return error */
527 }
528 *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
529
530 return 0; /* success return 0 */
531}
532
545{
546 uint8_t res;
547 uint16_t config;
548
549 if (handle == NULL) /* check handle */
550 {
551 return 2; /* return error */
552 }
553 if (handle->inited != 1) /* check handle initialization */
554 {
555 return 3; /* return error */
556 }
557
558 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
559 if (res != 0) /* check result */
560 {
561 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
562
563 return 1; /* return error */
564 }
565 config &= ~(1 << 13); /* clear config */
566 config |= speed << 13; /* set speed */
567 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
568 if (res != 0) /* check result */
569 {
570 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
571
572 return 1; /* return error */
573 }
574
575 return 0; /* success return 0 */
576}
577
590{
591 uint8_t res;
592 uint16_t config;
593
594 if (handle == NULL) /* check handle */
595 {
596 return 2; /* return error */
597 }
598 if (handle->inited != 1) /* check handle initialization */
599 {
600 return 3; /* return error */
601 }
602
603 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
604 if (res != 0) /* check result */
605 {
606 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
607
608 return 1; /* return error */
609 }
610 *speed = (lan8720_speed_t)((config >> 13) & 0x01); /* get the speed */
611
612 return 0; /* success return 0 */
613}
614
627{
628 uint8_t res;
629 uint16_t config;
630
631 if (handle == NULL) /* check handle */
632 {
633 return 2; /* return error */
634 }
635 if (handle->inited != 1) /* check handle initialization */
636 {
637 return 3; /* return error */
638 }
639
640 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
641 if (res != 0) /* check result */
642 {
643 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
644
645 return 1; /* return error */
646 }
647 config &= ~(1 << 12); /* clear config */
648 config |= enable << 12; /* set bool */
649 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
650 if (res != 0) /* check result */
651 {
652 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
653
654 return 1; /* return error */
655 }
656
657 return 0; /* success return 0 */
658}
659
672{
673 uint8_t res;
674 uint16_t config;
675
676 if (handle == NULL) /* check handle */
677 {
678 return 2; /* return error */
679 }
680 if (handle->inited != 1) /* check handle initialization */
681 {
682 return 3; /* return error */
683 }
684
685 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
686 if (res != 0) /* check result */
687 {
688 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
689
690 return 1; /* return error */
691 }
692 *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
693
694 return 0; /* success return 0 */
695}
696
709{
710 uint8_t res;
711 uint16_t config;
712
713 if (handle == NULL) /* check handle */
714 {
715 return 2; /* return error */
716 }
717 if (handle->inited != 1) /* check handle initialization */
718 {
719 return 3; /* return error */
720 }
721
722 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
723 if (res != 0) /* check result */
724 {
725 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
726
727 return 1; /* return error */
728 }
729
730 config &= ~(1 << 12); /* clear config */
731 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
732 if (res != 0) /* check result */
733 {
734 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
735
736 return 1; /* return error */
737 }
738
739 config &= ~(1 << 11); /* clear config */
740 config |= enable << 11; /* set bool */
741 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
742 if (res != 0) /* check result */
743 {
744 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
745
746 return 1; /* return error */
747 }
748
749 return 0; /* success return 0 */
750}
751
764{
765 uint8_t res;
766 uint16_t config;
767
768 if (handle == NULL) /* check handle */
769 {
770 return 2; /* return error */
771 }
772 if (handle->inited != 1) /* check handle initialization */
773 {
774 return 3; /* return error */
775 }
776
777 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
778 if (res != 0) /* check result */
779 {
780 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
781
782 return 1; /* return error */
783 }
784 *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
785
786 return 0; /* success return 0 */
787}
788
801{
802 uint8_t res;
803 uint16_t config;
804
805 if (handle == NULL) /* check handle */
806 {
807 return 2; /* return error */
808 }
809 if (handle->inited != 1) /* check handle initialization */
810 {
811 return 3; /* return error */
812 }
813
814 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
815 if (res != 0) /* check result */
816 {
817 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
818
819 return 1; /* return error */
820 }
821 config &= ~(1 << 10); /* clear config */
822 config |= enable << 10; /* set bool */
823 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
824 if (res != 0) /* check result */
825 {
826 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
827
828 return 1; /* return error */
829 }
830
831 return 0; /* success return 0 */
832}
833
846{
847 uint8_t res;
848 uint16_t config;
849
850 if (handle == NULL) /* check handle */
851 {
852 return 2; /* return error */
853 }
854 if (handle->inited != 1) /* check handle initialization */
855 {
856 return 3; /* return error */
857 }
858
859 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
860 if (res != 0) /* check result */
861 {
862 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
863
864 return 1; /* return error */
865 }
866 *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
867
868 return 0; /* success return 0 */
869}
870
883{
884 uint8_t res;
885 uint16_t config;
886
887 if (handle == NULL) /* check handle */
888 {
889 return 2; /* return error */
890 }
891 if (handle->inited != 1) /* check handle initialization */
892 {
893 return 3; /* return error */
894 }
895
896 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
897 if (res != 0) /* check result */
898 {
899 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
900
901 return 1; /* return error */
902 }
903 config &= ~(1 << 9); /* clear config */
904 config |= enable << 9; /* set bool */
905 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
906 if (res != 0) /* check result */
907 {
908 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
909
910 return 1; /* return error */
911 }
912
913 return 0; /* success return 0 */
914}
915
928{
929 uint8_t res;
930 uint16_t config;
931
932 if (handle == NULL) /* check handle */
933 {
934 return 2; /* return error */
935 }
936 if (handle->inited != 1) /* check handle initialization */
937 {
938 return 3; /* return error */
939 }
940
941 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
942 if (res != 0) /* check result */
943 {
944 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
945
946 return 1; /* return error */
947 }
948 *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
949
950 return 0; /* success return 0 */
951}
952
965{
966 uint8_t res;
967 uint16_t config;
968
969 if (handle == NULL) /* check handle */
970 {
971 return 2; /* return error */
972 }
973 if (handle->inited != 1) /* check handle initialization */
974 {
975 return 3; /* return error */
976 }
977
978 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
979 if (res != 0) /* check result */
980 {
981 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
982
983 return 1; /* return error */
984 }
985 config &= ~(1 << 8); /* clear config */
986 config |= mode << 8; /* set mode */
987 res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
988 if (res != 0) /* check result */
989 {
990 handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
991
992 return 1; /* return error */
993 }
994
995 return 0; /* success return 0 */
996}
997
1010{
1011 uint8_t res;
1012 uint16_t config;
1013
1014 if (handle == NULL) /* check handle */
1015 {
1016 return 2; /* return error */
1017 }
1018 if (handle->inited != 1) /* check handle initialization */
1019 {
1020 return 3; /* return error */
1021 }
1022
1023 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
1024 if (res != 0) /* check result */
1025 {
1026 handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
1027
1028 return 1; /* return error */
1029 }
1030 *mode = (lan8720_duplex_t)((config >> 8) & 0x01); /* get the mode */
1031
1032 return 0; /* success return 0 */
1033}
1034
1047{
1048 uint8_t res;
1049 uint16_t config;
1050
1051 if (handle == NULL) /* check handle */
1052 {
1053 return 2; /* return error */
1054 }
1055 if (handle->inited != 1) /* check handle initialization */
1056 {
1057 return 3; /* return error */
1058 }
1059
1060 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1061 if (res != 0) /* check result */
1062 {
1063 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1064
1065 return 1; /* return error */
1066 }
1067 *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
1068
1069 return 0; /* success return 0 */
1070}
1071
1084{
1085 uint8_t res;
1086 uint16_t config;
1087
1088 if (handle == NULL) /* check handle */
1089 {
1090 return 2; /* return error */
1091 }
1092 if (handle->inited != 1) /* check handle initialization */
1093 {
1094 return 3; /* return error */
1095 }
1096
1097 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1098 if (res != 0) /* check result */
1099 {
1100 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1101
1102 return 1; /* return error */
1103 }
1104 *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
1105
1106 return 0; /* success return 0 */
1107}
1108
1121{
1122 uint8_t res;
1123 uint16_t config;
1124
1125 if (handle == NULL) /* check handle */
1126 {
1127 return 2; /* return error */
1128 }
1129 if (handle->inited != 1) /* check handle initialization */
1130 {
1131 return 3; /* return error */
1132 }
1133
1134 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1135 if (res != 0) /* check result */
1136 {
1137 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1138
1139 return 1; /* return error */
1140 }
1141 *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
1142
1143 return 0; /* success return 0 */
1144}
1145
1158{
1159 uint8_t res;
1160 uint16_t config;
1161
1162 if (handle == NULL) /* check handle */
1163 {
1164 return 2; /* return error */
1165 }
1166 if (handle->inited != 1) /* check handle initialization */
1167 {
1168 return 3; /* return error */
1169 }
1170
1171 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1172 if (res != 0) /* check result */
1173 {
1174 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1175
1176 return 1; /* return error */
1177 }
1178 *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
1179
1180 return 0; /* success return 0 */
1181}
1182
1195{
1196 uint8_t res;
1197 uint16_t config;
1198
1199 if (handle == NULL) /* check handle */
1200 {
1201 return 2; /* return error */
1202 }
1203 if (handle->inited != 1) /* check handle initialization */
1204 {
1205 return 3; /* return error */
1206 }
1207
1208 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1209 if (res != 0) /* check result */
1210 {
1211 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1212
1213 return 1; /* return error */
1214 }
1215 *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
1216
1217 return 0; /* success return 0 */
1218}
1219
1232{
1233 uint8_t res;
1234 uint16_t config;
1235
1236 if (handle == NULL) /* check handle */
1237 {
1238 return 2; /* return error */
1239 }
1240 if (handle->inited != 1) /* check handle initialization */
1241 {
1242 return 3; /* return error */
1243 }
1244
1245 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1246 if (res != 0) /* check result */
1247 {
1248 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1249
1250 return 1; /* return error */
1251 }
1252 *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
1253
1254 return 0; /* success return 0 */
1255}
1256
1269{
1270 uint8_t res;
1271 uint16_t config;
1272
1273 if (handle == NULL) /* check handle */
1274 {
1275 return 2; /* return error */
1276 }
1277 if (handle->inited != 1) /* check handle initialization */
1278 {
1279 return 3; /* return error */
1280 }
1281
1282 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1283 if (res != 0) /* check result */
1284 {
1285 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1286
1287 return 1; /* return error */
1288 }
1289 *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
1290
1291 return 0; /* success return 0 */
1292}
1293
1306{
1307 uint8_t res;
1308 uint16_t config;
1309
1310 if (handle == NULL) /* check handle */
1311 {
1312 return 2; /* return error */
1313 }
1314 if (handle->inited != 1) /* check handle initialization */
1315 {
1316 return 3; /* return error */
1317 }
1318
1319 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1320 if (res != 0) /* check result */
1321 {
1322 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1323
1324 return 1; /* return error */
1325 }
1326 *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
1327
1328 return 0; /* success return 0 */
1329}
1330
1343{
1344 uint8_t res;
1345 uint16_t config;
1346
1347 if (handle == NULL) /* check handle */
1348 {
1349 return 2; /* return error */
1350 }
1351 if (handle->inited != 1) /* check handle initialization */
1352 {
1353 return 3; /* return error */
1354 }
1355
1356 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1357 if (res != 0) /* check result */
1358 {
1359 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1360
1361 return 1; /* return error */
1362 }
1363 *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
1364
1365 return 0; /* success return 0 */
1366}
1367
1380{
1381 uint8_t res;
1382 uint16_t config;
1383
1384 if (handle == NULL) /* check handle */
1385 {
1386 return 2; /* return error */
1387 }
1388 if (handle->inited != 1) /* check handle initialization */
1389 {
1390 return 3; /* return error */
1391 }
1392
1393 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1394 if (res != 0) /* check result */
1395 {
1396 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1397
1398 return 1; /* return error */
1399 }
1400 *enable = (lan8720_bool_t)((config >> 4) & 0x01); /* get the bool */
1401
1402 return 0; /* success return 0 */
1403}
1404
1417{
1418 uint8_t res;
1419 uint16_t config;
1420
1421 if (handle == NULL) /* check handle */
1422 {
1423 return 2; /* return error */
1424 }
1425 if (handle->inited != 1) /* check handle initialization */
1426 {
1427 return 3; /* return error */
1428 }
1429
1430 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1431 if (res != 0) /* check result */
1432 {
1433 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1434
1435 return 1; /* return error */
1436 }
1437 *enable = (lan8720_bool_t)((config >> 3) & 0x01); /* get the bool */
1438
1439 return 0; /* success return 0 */
1440}
1441
1454{
1455 uint8_t res;
1456 uint16_t config;
1457
1458 if (handle == NULL) /* check handle */
1459 {
1460 return 2; /* return error */
1461 }
1462 if (handle->inited != 1) /* check handle initialization */
1463 {
1464 return 3; /* return error */
1465 }
1466
1467 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1468 if (res != 0) /* check result */
1469 {
1470 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1471
1472 return 1; /* return error */
1473 }
1474 *status = (lan8720_link_t)((config >> 2) & 0x01); /* get the link status */
1475
1476 return 0; /* success return 0 */
1477}
1478
1491{
1492 uint8_t res;
1493 uint16_t config;
1494
1495 if (handle == NULL) /* check handle */
1496 {
1497 return 2; /* return error */
1498 }
1499 if (handle->inited != 1) /* check handle initialization */
1500 {
1501 return 3; /* return error */
1502 }
1503
1504 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1505 if (res != 0) /* check result */
1506 {
1507 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1508
1509 return 1; /* return error */
1510 }
1511 *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
1512
1513 return 0; /* success return 0 */
1514}
1515
1528{
1529 uint8_t res;
1530 uint16_t config;
1531
1532 if (handle == NULL) /* check handle */
1533 {
1534 return 2; /* return error */
1535 }
1536 if (handle->inited != 1) /* check handle initialization */
1537 {
1538 return 3; /* return error */
1539 }
1540
1541 res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1542 if (res != 0) /* check result */
1543 {
1544 handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1545
1546 return 1; /* return error */
1547 }
1548 *enable = (lan8720_bool_t)((config >> 0) & 0x01); /* get the bool */
1549
1550 return 0; /* success return 0 */
1551}
1552
1569uint8_t lan8720_set_identifier(lan8720_handle_t *handle, uint32_t phy_id,
1570 uint8_t model_number, uint8_t revision_number)
1571{
1572 uint8_t res;
1573 uint16_t config;
1574
1575 if (handle == NULL) /* check handle */
1576 {
1577 return 2; /* return error */
1578 }
1579 if (handle->inited != 1) /* check handle initialization */
1580 {
1581 return 3; /* return error */
1582 }
1583 if (phy_id > 0x3FFFFF) /* check phy_id */
1584 {
1585 handle->debug_print("lan8720: phy_id > 0x3FFFFF.\n"); /* phy_id > 0x3FFFFF */
1586
1587 return 4; /* return error */
1588 }
1589 if (model_number > 0x3F) /* check model_number */
1590 {
1591 handle->debug_print("lan8720: model_number > 0x3F.\n"); /* model_number > 0x3F */
1592
1593 return 5; /* return error */
1594 }
1595 if (revision_number > 0xF) /* check revision_number */
1596 {
1597 handle->debug_print("lan8720: revision_number > 0xF.\n"); /* revision_number > 0xF*/
1598
1599 return 6; /* return error */
1600 }
1601
1602 config = phy_id & 0xFFFFL; /* set phy id bit3 - bit18 */
1603 res = a_lan8720_smi_write(handle, LAN8720_REG_PHY_IDENTIFIER_1, config); /* write phy identifier 1 */
1604 if (res != 0) /* check result */
1605 {
1606 handle->debug_print("lan8720: write phy identifier 1 failed.\n"); /* write phy identifier 1 failed */
1607
1608 return 1; /* return error */
1609 }
1610
1611 config = (((phy_id >> 16) & 0x3F) << 10)
1612 | ((model_number & 0x3F) << 4) | (revision_number & 0xF); /* set phy id bit`19 - bit24, model number, revision_number number */
1613 res = a_lan8720_smi_write(handle, LAN8720_REG_PHY_IDENTIFIER_2, config); /* write phy identifier 2 */
1614 if (res != 0) /* check result */
1615 {
1616 handle->debug_print("lan8720: write phy identifier 2 failed.\n"); /* write phy identifier 2 failed */
1617
1618 return 1; /* return error */
1619 }
1620
1621 return 0; /* success return 0 */
1622}
1623
1637uint8_t lan8720_get_identifier(lan8720_handle_t *handle, uint32_t *phy_id,
1638 uint8_t *model_number, uint8_t *revision_number)
1639{
1640 uint8_t res;
1641 uint16_t config1;
1642 uint16_t config2;
1643
1644 if (handle == NULL) /* check handle */
1645 {
1646 return 2; /* return error */
1647 }
1648 if (handle->inited != 1) /* check handle initialization */
1649 {
1650 return 3; /* return error */
1651 }
1652
1653 res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_IDENTIFIER_1, &config1); /* read phy identifier 1 */
1654 if (res != 0) /* check result */
1655 {
1656 handle->debug_print("lan8720: read phy identifier 1 failed.\n"); /* read phy identifier 1 failed */
1657
1658 return 1; /* return error */
1659 }
1660 res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_IDENTIFIER_2, &config2); /* read phy identifier 2 */
1661 if (res != 0) /* check result */
1662 {
1663 handle->debug_print("lan8720: read phy identifier 2 failed.\n"); /* read phy identifier 2 failed */
1664
1665 return 1; /* return error */
1666 }
1667 *phy_id = config1 | (uint32_t)((config2 >> 10) & 0x3F) << 16; /* get phy_id */
1668 *model_number = (config2 >> 4) & 0x3F; /* get model_number */
1669 *revision_number = (config2 >> 0) & 0xF; /* get revision_number */
1670
1671 return 0; /* success return 0 */
1672}
1673
1686{
1687 uint8_t res;
1688 uint16_t config;
1689
1690 if (handle == NULL) /* check handle */
1691 {
1692 return 2; /* return error */
1693 }
1694 if (handle->inited != 1) /* check handle initialization */
1695 {
1696 return 3; /* return error */
1697 }
1698
1699 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1700 if (res != 0) /* check result */
1701 {
1702 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1703
1704 return 1; /* return error */
1705 }
1706 config &= ~(1 << 13); /* clear config */
1707 config |= enable << 13; /* set bool */
1708 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1709 if (res != 0) /* check result */
1710 {
1711 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1712
1713 return 1; /* return error */
1714 }
1715
1716 return 0; /* success return 0 */
1717}
1718
1731{
1732 uint8_t res;
1733 uint16_t config;
1734
1735 if (handle == NULL) /* check handle */
1736 {
1737 return 2; /* return error */
1738 }
1739 if (handle->inited != 1) /* check handle initialization */
1740 {
1741 return 3; /* return error */
1742 }
1743
1744 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1745 if (res != 0) /* check result */
1746 {
1747 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1748
1749 return 1; /* return error */
1750 }
1751 *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
1752
1753 return 0; /* success return 0 */
1754}
1755
1768{
1769 uint8_t res;
1770 uint16_t config;
1771
1772 if (handle == NULL) /* check handle */
1773 {
1774 return 2; /* return error */
1775 }
1776 if (handle->inited != 1) /* check handle initialization */
1777 {
1778 return 3; /* return error */
1779 }
1780
1781 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1782 if (res != 0) /* check result */
1783 {
1784 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1785
1786 return 1; /* return error */
1787 }
1788 config &= ~(3 << 10); /* clear config */
1789 config |= pause << 10; /* set pause */
1790 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1791 if (res != 0) /* check result */
1792 {
1793 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1794
1795 return 1; /* return error */
1796 }
1797
1798 return 0; /* success return 0 */
1799}
1800
1813{
1814 uint8_t res;
1815 uint16_t config;
1816
1817 if (handle == NULL) /* check handle */
1818 {
1819 return 2; /* return error */
1820 }
1821 if (handle->inited != 1) /* check handle initialization */
1822 {
1823 return 3; /* return error */
1824 }
1825
1826 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1827 if (res != 0) /* check result */
1828 {
1829 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1830
1831 return 1; /* return error */
1832 }
1833 *pause = (lan8720_pause_t)((config >> 10) & 0x03); /* get the pause */
1834
1835 return 0; /* success return 0 */
1836}
1837
1850{
1851 uint8_t res;
1852 uint16_t config;
1853
1854 if (handle == NULL) /* check handle */
1855 {
1856 return 2; /* return error */
1857 }
1858 if (handle->inited != 1) /* check handle initialization */
1859 {
1860 return 3; /* return error */
1861 }
1862
1863 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1864 if (res != 0) /* check result */
1865 {
1866 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1867
1868 return 1; /* return error */
1869 }
1870 config &= ~(1 << 8); /* clear config */
1871 config |= enable << 8; /* set bool */
1872 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1873 if (res != 0) /* check result */
1874 {
1875 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1876
1877 return 1; /* return error */
1878 }
1879
1880 return 0; /* success return 0 */
1881}
1882
1895{
1896 uint8_t res;
1897 uint16_t config;
1898
1899 if (handle == NULL) /* check handle */
1900 {
1901 return 2; /* return error */
1902 }
1903 if (handle->inited != 1) /* check handle initialization */
1904 {
1905 return 3; /* return error */
1906 }
1907
1908 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1909 if (res != 0) /* check result */
1910 {
1911 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1912
1913 return 1; /* return error */
1914 }
1915 *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
1916
1917 return 0; /* success return 0 */
1918}
1919
1932{
1933 uint8_t res;
1934 uint16_t config;
1935
1936 if (handle == NULL) /* check handle */
1937 {
1938 return 2; /* return error */
1939 }
1940 if (handle->inited != 1) /* check handle initialization */
1941 {
1942 return 3; /* return error */
1943 }
1944
1945 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1946 if (res != 0) /* check result */
1947 {
1948 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1949
1950 return 1; /* return error */
1951 }
1952 config &= ~(1 << 7); /* clear config */
1953 config |= enable << 7; /* set bool */
1954 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1955 if (res != 0) /* check result */
1956 {
1957 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1958
1959 return 1; /* return error */
1960 }
1961
1962 return 0; /* success return 0 */
1963}
1964
1977{
1978 uint8_t res;
1979 uint16_t config;
1980
1981 if (handle == NULL) /* check handle */
1982 {
1983 return 2; /* return error */
1984 }
1985 if (handle->inited != 1) /* check handle initialization */
1986 {
1987 return 3; /* return error */
1988 }
1989
1990 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1991 if (res != 0) /* check result */
1992 {
1993 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1994
1995 return 1; /* return error */
1996 }
1997 *enable = (lan8720_bool_t)((config >> 7) & 0x01); /* get the bool */
1998
1999 return 0; /* success return 0 */
2000}
2001
2014{
2015 uint8_t res;
2016 uint16_t config;
2017
2018 if (handle == NULL) /* check handle */
2019 {
2020 return 2; /* return error */
2021 }
2022 if (handle->inited != 1) /* check handle initialization */
2023 {
2024 return 3; /* return error */
2025 }
2026
2027 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2028 if (res != 0) /* check result */
2029 {
2030 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2031
2032 return 1; /* return error */
2033 }
2034 config &= ~(1 << 6); /* clear config */
2035 config |= enable << 6; /* set bool */
2036 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2037 if (res != 0) /* check result */
2038 {
2039 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2040
2041 return 1; /* return error */
2042 }
2043
2044 return 0; /* success return 0 */
2045}
2046
2059{
2060 uint8_t res;
2061 uint16_t config;
2062
2063 if (handle == NULL) /* check handle */
2064 {
2065 return 2; /* return error */
2066 }
2067 if (handle->inited != 1) /* check handle initialization */
2068 {
2069 return 3; /* return error */
2070 }
2071
2072 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2073 if (res != 0) /* check result */
2074 {
2075 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2076
2077 return 1; /* return error */
2078 }
2079 *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
2080
2081 return 0; /* success return 0 */
2082}
2083
2096{
2097 uint8_t res;
2098 uint16_t config;
2099
2100 if (handle == NULL) /* check handle */
2101 {
2102 return 2; /* return error */
2103 }
2104 if (handle->inited != 1) /* check handle initialization */
2105 {
2106 return 3; /* return error */
2107 }
2108
2109 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2110 if (res != 0) /* check result */
2111 {
2112 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2113
2114 return 1; /* return error */
2115 }
2116 config &= ~(1 << 5); /* clear config */
2117 config |= enable << 5; /* set bool */
2118 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2119 if (res != 0) /* check result */
2120 {
2121 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2122
2123 return 1; /* return error */
2124 }
2125
2126 return 0; /* success return 0 */
2127}
2128
2141{
2142 uint8_t res;
2143 uint16_t config;
2144
2145 if (handle == NULL) /* check handle */
2146 {
2147 return 2; /* return error */
2148 }
2149 if (handle->inited != 1) /* check handle initialization */
2150 {
2151 return 3; /* return error */
2152 }
2153
2154 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2155 if (res != 0) /* check result */
2156 {
2157 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2158
2159 return 1; /* return error */
2160 }
2161 *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
2162
2163 return 0; /* success return 0 */
2164}
2165
2179{
2180 uint8_t res;
2181 uint16_t config;
2182
2183 if (handle == NULL) /* check handle */
2184 {
2185 return 2; /* return error */
2186 }
2187 if (handle->inited != 1) /* check handle initialization */
2188 {
2189 return 3; /* return error */
2190 }
2191 if (selector > 0x1F) /* check selector */
2192 {
2193 handle->debug_print("lan8720: selector > 0x1F.\n"); /* selector > 0x1F */
2194
2195 return 4; /* return error */
2196 }
2197
2198 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2199 if (res != 0) /* check result */
2200 {
2201 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2202
2203 return 1; /* return error */
2204 }
2205 config &= ~(0x1F << 0); /* clear config */
2206 config |= selector << 0; /* set selector */
2207 res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2208 if (res != 0) /* check result */
2209 {
2210 handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2211
2212 return 1; /* return error */
2213 }
2214
2215 return 0; /* success return 0 */
2216}
2217
2230{
2231 uint8_t res;
2232 uint16_t config;
2233
2234 if (handle == NULL) /* check handle */
2235 {
2236 return 2; /* return error */
2237 }
2238 if (handle->inited != 1) /* check handle initialization */
2239 {
2240 return 3; /* return error */
2241 }
2242
2243 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2244 if (res != 0) /* check result */
2245 {
2246 handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2247
2248 return 1; /* return error */
2249 }
2250 *selector = (config) & 0x1F; /*get selector */
2251
2252 return 0; /* success return 0 */
2253}
2254
2267{
2268 uint8_t res;
2269 uint16_t config;
2270
2271 if (handle == NULL) /* check handle */
2272 {
2273 return 2; /* return error */
2274 }
2275 if (handle->inited != 1) /* check handle initialization */
2276 {
2277 return 3; /* return error */
2278 }
2279
2280 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2281 if (res != 0) /* check result */
2282 {
2283 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2284
2285 return 1; /* return error */
2286 }
2287 *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
2288
2289 return 0; /* success return 0 */
2290}
2291
2304{
2305 uint8_t res;
2306 uint16_t config;
2307
2308 if (handle == NULL) /* check handle */
2309 {
2310 return 2; /* return error */
2311 }
2312 if (handle->inited != 1) /* check handle initialization */
2313 {
2314 return 3; /* return error */
2315 }
2316
2317 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2318 if (res != 0) /* check result */
2319 {
2320 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2321
2322 return 1; /* return error */
2323 }
2324 *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
2325
2326 return 0; /* success return 0 */
2327}
2328
2341{
2342 uint8_t res;
2343 uint16_t config;
2344
2345 if (handle == NULL) /* check handle */
2346 {
2347 return 2; /* return error */
2348 }
2349 if (handle->inited != 1) /* check handle initialization */
2350 {
2351 return 3; /* return error */
2352 }
2353
2354 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2355 if (res != 0) /* check result */
2356 {
2357 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2358
2359 return 1; /* return error */
2360 }
2361 *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
2362
2363 return 0; /* success return 0 */
2364}
2365
2378{
2379 uint8_t res;
2380 uint16_t config;
2381
2382 if (handle == NULL) /* check handle */
2383 {
2384 return 2; /* return error */
2385 }
2386 if (handle->inited != 1) /* check handle initialization */
2387 {
2388 return 3; /* return error */
2389 }
2390
2391 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2392 if (res != 0) /* check result */
2393 {
2394 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2395
2396 return 1; /* return error */
2397 }
2398 *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
2399
2400 return 0; /* success return 0 */
2401}
2402
2415{
2416 uint8_t res;
2417 uint16_t config;
2418
2419 if (handle == NULL) /* check handle */
2420 {
2421 return 2; /* return error */
2422 }
2423 if (handle->inited != 1) /* check handle initialization */
2424 {
2425 return 3; /* return error */
2426 }
2427
2428 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2429 if (res != 0) /* check result */
2430 {
2431 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2432
2433 return 1; /* return error */
2434 }
2435 *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
2436
2437 return 0; /* success return 0 */
2438}
2439
2452{
2453 uint8_t res;
2454 uint16_t config;
2455
2456 if (handle == NULL) /* check handle */
2457 {
2458 return 2; /* return error */
2459 }
2460 if (handle->inited != 1) /* check handle initialization */
2461 {
2462 return 3; /* return error */
2463 }
2464
2465 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2466 if (res != 0) /* check result */
2467 {
2468 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2469
2470 return 1; /* return error */
2471 }
2472 *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
2473
2474 return 0; /* success return 0 */
2475}
2476
2489{
2490 uint8_t res;
2491 uint16_t config;
2492
2493 if (handle == NULL) /* check handle */
2494 {
2495 return 2; /* return error */
2496 }
2497 if (handle->inited != 1) /* check handle initialization */
2498 {
2499 return 3; /* return error */
2500 }
2501
2502 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2503 if (res != 0) /* check result */
2504 {
2505 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2506
2507 return 1; /* return error */
2508 }
2509 *enable = (lan8720_bool_t)((config >> 7) & 0x01); /* get the bool */
2510
2511 return 0; /* success return 0 */
2512}
2513
2526{
2527 uint8_t res;
2528 uint16_t config;
2529
2530 if (handle == NULL) /* check handle */
2531 {
2532 return 2; /* return error */
2533 }
2534 if (handle->inited != 1) /* check handle initialization */
2535 {
2536 return 3; /* return error */
2537 }
2538
2539 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2540 if (res != 0) /* check result */
2541 {
2542 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2543
2544 return 1; /* return error */
2545 }
2546 *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
2547
2548 return 0; /* success return 0 */
2549}
2550
2563{
2564 uint8_t res;
2565 uint16_t config;
2566
2567 if (handle == NULL) /* check handle */
2568 {
2569 return 2; /* return error */
2570 }
2571 if (handle->inited != 1) /* check handle initialization */
2572 {
2573 return 3; /* return error */
2574 }
2575
2576 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2577 if (res != 0) /* check result */
2578 {
2579 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2580
2581 return 1; /* return error */
2582 }
2583 *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
2584
2585 return 0; /* success return 0 */
2586}
2587
2600{
2601 uint8_t res;
2602 uint16_t config;
2603
2604 if (handle == NULL) /* check handle */
2605 {
2606 return 2; /* return error */
2607 }
2608 if (handle->inited != 1) /* check handle initialization */
2609 {
2610 return 3; /* return error */
2611 }
2612
2613 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2614 if (res != 0) /* check result */
2615 {
2616 handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2617
2618 return 1; /* return error */
2619 }
2620 *selector = config & 0x1F; /* get the selector */
2621
2622 return 0; /* success return 0 */
2623}
2624
2637{
2638 uint8_t res;
2639 uint16_t config;
2640
2641 if (handle == NULL) /* check handle */
2642 {
2643 return 2; /* return error */
2644 }
2645 if (handle->inited != 1) /* check handle initialization */
2646 {
2647 return 3; /* return error */
2648 }
2649
2650 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2651 if (res != 0) /* check result */
2652 {
2653 handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2654
2655 return 1; /* return error */
2656 }
2657 *enable = (lan8720_bool_t)((config >> 4) & 0x01); /* get the bool */
2658
2659 return 0; /* success return 0 */
2660}
2661
2674{
2675 uint8_t res;
2676 uint16_t config;
2677
2678 if (handle == NULL) /* check handle */
2679 {
2680 return 2; /* return error */
2681 }
2682 if (handle->inited != 1) /* check handle initialization */
2683 {
2684 return 3; /* return error */
2685 }
2686
2687 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2688 if (res != 0) /* check result */
2689 {
2690 handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2691
2692 return 1; /* return error */
2693 }
2694 *enable = (lan8720_bool_t)((config >> 3) & 0x01); /* get the bool */
2695
2696 return 0; /* success return 0 */
2697}
2698
2711{
2712 uint8_t res;
2713 uint16_t config;
2714
2715 if (handle == NULL) /* check handle */
2716 {
2717 return 2; /* return error */
2718 }
2719 if (handle->inited != 1) /* check handle initialization */
2720 {
2721 return 3; /* return error */
2722 }
2723
2724 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2725 if (res != 0) /* check result */
2726 {
2727 handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2728
2729 return 1; /* return error */
2730 }
2731 *enable = (lan8720_bool_t)((config >> 2) & 0x01); /* get the bool */
2732
2733 return 0; /* success return 0 */
2734}
2735
2748{
2749 uint8_t res;
2750 uint16_t config;
2751
2752 if (handle == NULL) /* check handle */
2753 {
2754 return 2; /* return error */
2755 }
2756 if (handle->inited != 1) /* check handle initialization */
2757 {
2758 return 3; /* return error */
2759 }
2760
2761 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2762 if (res != 0) /* check result */
2763 {
2764 handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2765
2766 return 1; /* return error */
2767 }
2768 *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
2769
2770 return 0; /* success return 0 */
2771}
2772
2785{
2786 uint8_t res;
2787 uint16_t config;
2788
2789 if (handle == NULL) /* check handle */
2790 {
2791 return 2; /* return error */
2792 }
2793 if (handle->inited != 1) /* check handle initialization */
2794 {
2795 return 3; /* return error */
2796 }
2797
2798 res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2799 if (res != 0) /* check result */
2800 {
2801 handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2802
2803 return 1; /* return error */
2804 }
2805 *enable = (lan8720_bool_t)((config >> 0) & 0x01); /* get the bool */
2806
2807 return 0; /* success return 0 */
2808}
2809
2822{
2823 uint8_t res;
2824 uint16_t config;
2825
2826 if (handle == NULL) /* check handle */
2827 {
2828 return 2; /* return error */
2829 }
2830 if (handle->inited != 1) /* check handle initialization */
2831 {
2832 return 3; /* return error */
2833 }
2834
2835 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2836 if (res != 0) /* check result */
2837 {
2838 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2839
2840 return 1; /* return error */
2841 }
2842 config &= ~(1 << 13); /* clear config */
2843 config |= enable << 13; /* set bool */
2844 res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
2845 if (res != 0) /* check result */
2846 {
2847 handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
2848
2849 return 1; /* return error */
2850 }
2851
2852 return 0; /* success return 0 */
2853}
2854
2867{
2868 uint8_t res;
2869 uint16_t config;
2870
2871 if (handle == NULL) /* check handle */
2872 {
2873 return 2; /* return error */
2874 }
2875 if (handle->inited != 1) /* check handle initialization */
2876 {
2877 return 3; /* return error */
2878 }
2879
2880 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2881 if (res != 0) /* check result */
2882 {
2883 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2884
2885 return 1; /* return error */
2886 }
2887 *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
2888
2889 return 0; /* success return 0 */
2890}
2891
2904{
2905 uint8_t res;
2906 uint16_t config;
2907
2908 if (handle == NULL) /* check handle */
2909 {
2910 return 2; /* return error */
2911 }
2912 if (handle->inited != 1) /* check handle initialization */
2913 {
2914 return 3; /* return error */
2915 }
2916
2917 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2918 if (res != 0) /* check result */
2919 {
2920 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2921
2922 return 1; /* return error */
2923 }
2924 config &= ~(1 << 9); /* clear config */
2925 config |= enable << 9; /* set bool */
2926 res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
2927 if (res != 0) /* check result */
2928 {
2929 handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
2930
2931 return 1; /* return error */
2932 }
2933
2934 return 0; /* success return 0 */
2935}
2936
2949{
2950 uint8_t res;
2951 uint16_t config;
2952
2953 if (handle == NULL) /* check handle */
2954 {
2955 return 2; /* return error */
2956 }
2957 if (handle->inited != 1) /* check handle initialization */
2958 {
2959 return 3; /* return error */
2960 }
2961
2962 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2963 if (res != 0) /* check result */
2964 {
2965 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2966
2967 return 1; /* return error */
2968 }
2969 *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
2970
2971 return 0; /* success return 0 */
2972}
2973
2986{
2987 uint8_t res;
2988 uint16_t config;
2989
2990 if (handle == NULL) /* check handle */
2991 {
2992 return 2; /* return error */
2993 }
2994 if (handle->inited != 1) /* check handle initialization */
2995 {
2996 return 3; /* return error */
2997 }
2998
2999 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
3000 if (res != 0) /* check result */
3001 {
3002 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
3003
3004 return 1; /* return error */
3005 }
3006 config &= ~(1 << 6); /* clear config */
3007 config |= enable << 6; /* set bool */
3008 res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
3009 if (res != 0) /* check result */
3010 {
3011 handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
3012
3013 return 1; /* return error */
3014 }
3015
3016 return 0; /* success return 0 */
3017}
3018
3031{
3032 uint8_t res;
3033 uint16_t config;
3034
3035 if (handle == NULL) /* check handle */
3036 {
3037 return 2; /* return error */
3038 }
3039 if (handle->inited != 1) /* check handle initialization */
3040 {
3041 return 3; /* return error */
3042 }
3043
3044 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
3045 if (res != 0) /* check result */
3046 {
3047 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
3048
3049 return 1; /* return error */
3050 }
3051 *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
3052
3053 return 0; /* success return 0 */
3054}
3055
3068{
3069 uint8_t res;
3070 uint16_t config;
3071
3072 if (handle == NULL) /* check handle */
3073 {
3074 return 2; /* return error */
3075 }
3076 if (handle->inited != 1) /* check handle initialization */
3077 {
3078 return 3; /* return error */
3079 }
3080
3081 res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
3082 if (res != 0) /* check result */
3083 {
3084 handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
3085
3086 return 1; /* return error */
3087 }
3088 *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
3089
3090 return 0; /* success return 0 */
3091}
3092
3105{
3106 uint8_t res;
3107 uint16_t config;
3108
3109 if (handle == NULL) /* check handle */
3110 {
3111 return 2; /* return error */
3112 }
3113 if (handle->inited != 1) /* check handle initialization */
3114 {
3115 return 3; /* return error */
3116 }
3117
3118 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3119 if (res != 0) /* check result */
3120 {
3121 handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3122
3123 return 1; /* return error */
3124 }
3125 config &= ~(0x07 << 5); /* clear config */
3126 config |= mode << 5; /* set mode */
3127 res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_MODES, config); /* write special modes */
3128 if (res != 0) /* check result */
3129 {
3130 handle->debug_print("lan8720: write special modes failed.\n"); /* write special modes failed */
3131
3132 return 1; /* return error */
3133 }
3134
3135 return 0; /* success return 0 */
3136}
3137
3150{
3151 uint8_t res;
3152 uint16_t config;
3153
3154 if (handle == NULL) /* check handle */
3155 {
3156 return 2; /* return error */
3157 }
3158 if (handle->inited != 1) /* check handle initialization */
3159 {
3160 return 3; /* return error */
3161 }
3162
3163 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3164 if (res != 0) /* check result */
3165 {
3166 handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3167
3168 return 1; /* return error */
3169 }
3170 *mode = (lan8720_mode_t)((config >> 5) & 0x07); /* get the mode */
3171
3172 return 0; /* success return 0 */
3173}
3174
3187uint8_t lan8720_set_phy_address(lan8720_handle_t *handle, uint8_t addr)
3188{
3189 uint8_t res;
3190 uint16_t config;
3191
3192 if (handle == NULL) /* check handle */
3193 {
3194 return 2; /* return error */
3195 }
3196 if (handle->inited != 1) /* check handle initialization */
3197 {
3198 return 3; /* return error */
3199 }
3200 if (addr > 0x1F) /* check result */
3201 {
3202 handle->debug_print("lan8720: addr > 0x1F.\n"); /* addr > 0x1F */
3203
3204 return 4; /* return error */
3205 }
3206
3207 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3208 if (res != 0) /* check result */
3209 {
3210 handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3211
3212 return 1; /* return error */
3213 }
3214 config &= ~(0x1F << 0); /* clear config */
3215 config |= addr << 0; /* set addr */
3216 res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_MODES, config); /* write special modes */
3217 if (res != 0) /* check result */
3218 {
3219 handle->debug_print("lan8720: write special modes failed.\n"); /* write special modes failed */
3220
3221 return 1; /* return error */
3222 }
3223
3224 return 0; /* success return 0 */
3225}
3226
3238uint8_t lan8720_get_phy_address(lan8720_handle_t *handle, uint8_t *addr)
3239{
3240 uint8_t res;
3241 uint16_t config;
3242
3243 if (handle == NULL) /* check handle */
3244 {
3245 return 2; /* return error */
3246 }
3247 if (handle->inited != 1) /* check handle initialization */
3248 {
3249 return 3; /* return error */
3250 }
3251
3252 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3253 if (res != 0) /* check result */
3254 {
3255 handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3256
3257 return 1; /* return error */
3258 }
3259 *addr = config & 0x1F; /* get addr */
3260
3261 return 0; /* success return 0 */
3262}
3263
3276{
3277 uint8_t res;
3278 uint16_t config;
3279
3280 if (handle == NULL) /* check handle */
3281 {
3282 return 2; /* return error */
3283 }
3284 if (handle->inited != 1) /* check handle initialization */
3285 {
3286 return 3; /* return error */
3287 }
3288
3289 res = a_lan8720_smi_read(handle, LAN8720_REG_SYMBOL_ERROR_COUNTER_REGISTER, &config); /* read symbol error counter */
3290 if (res != 0) /* check result */
3291 {
3292 handle->debug_print("lan8720: read symbol error counter failed.\n"); /* read symbol error counter failed */
3293
3294 return 1; /* return error */
3295 }
3296 *cnt = config; /* get cnt */
3297
3298 return 0; /* success return 0 */
3299}
3300
3313{
3314 uint8_t res;
3315 uint16_t config;
3316
3317 if (handle == NULL) /* check handle */
3318 {
3319 return 2; /* return error */
3320 }
3321 if (handle->inited != 1) /* check handle initialization */
3322 {
3323 return 3; /* return error */
3324 }
3325
3326 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3327 if (res != 0) /* check result */
3328 {
3329 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3330
3331 return 1; /* return error */
3332 }
3333 config &= ~(1 << 15); /* clear config */
3334 config |= (!enable) << 15; /* set bool */
3335 res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3336 if (res != 0) /* check result */
3337 {
3338 handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3339
3340 return 1; /* return error */
3341 }
3342
3343 return 0; /* success return 0 */
3344}
3345
3358{
3359 uint8_t res;
3360 uint16_t config;
3361
3362 if (handle == NULL) /* check handle */
3363 {
3364 return 2; /* return error */
3365 }
3366 if (handle->inited != 1) /* check handle initialization */
3367 {
3368 return 3; /* return error */
3369 }
3370
3371 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3372 if (res != 0) /* check result */
3373 {
3374 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3375
3376 return 1; /* return error */
3377 }
3378 *enable = (lan8720_bool_t)(!((config >> 15) & 0x01)); /* get the bool */
3379
3380 return 0; /* success return 0 */
3381}
3382
3395{
3396 uint8_t res;
3397 uint16_t config;
3398
3399 if (handle == NULL) /* check handle */
3400 {
3401 return 2; /* return error */
3402 }
3403 if (handle->inited != 1) /* check handle initialization */
3404 {
3405 return 3; /* return error */
3406 }
3407
3408 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3409 if (res != 0) /* check result */
3410 {
3411 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3412
3413 return 1; /* return error */
3414 }
3415 config &= ~(1 << 13); /* clear config */
3416 config |= select << 13; /* set select */
3417 res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3418 if (res != 0) /* check result */
3419 {
3420 handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3421
3422 return 1; /* return error */
3423 }
3424
3425 return 0; /* success return 0 */
3426}
3427
3440{
3441 uint8_t res;
3442 uint16_t config;
3443
3444 if (handle == NULL) /* check handle */
3445 {
3446 return 2; /* return error */
3447 }
3448 if (handle->inited != 1) /* check handle initialization */
3449 {
3450 return 3; /* return error */
3451 }
3452
3453 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3454 if (res != 0) /* check result */
3455 {
3456 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3457
3458 return 1; /* return error */
3459 }
3460 *select = (lan8720_manual_channel_select_t)((config >> 13) & 0x01); /* get select */
3461
3462 return 0; /* success return 0 */
3463}
3464
3477{
3478 uint8_t res;
3479 uint16_t config;
3480
3481 if (handle == NULL) /* check handle */
3482 {
3483 return 2; /* return error */
3484 }
3485 if (handle->inited != 1) /* check handle initialization */
3486 {
3487 return 3; /* return error */
3488 }
3489
3490 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3491 if (res != 0) /* check result */
3492 {
3493 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3494
3495 return 1; /* return error */
3496 }
3497 config &= ~(1 << 11); /* clear config */
3498 config |= enable << 11; /* set bool */
3499 res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3500 if (res != 0) /* check result */
3501 {
3502 handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3503
3504 return 1; /* return error */
3505 }
3506
3507 return 0; /* success return 0 */
3508}
3509
3522{
3523 uint8_t res;
3524 uint16_t config;
3525
3526 if (handle == NULL) /* check handle */
3527 {
3528 return 2; /* return error */
3529 }
3530 if (handle->inited != 1) /* check handle initialization */
3531 {
3532 return 3; /* return error */
3533 }
3534
3535 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3536 if (res != 0) /* check result */
3537 {
3538 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3539
3540 return 1; /* return error */
3541 }
3542 *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
3543
3544 return 0; /* success return 0 */
3545}
3546
3559{
3560 uint8_t res;
3561 uint16_t config;
3562
3563 if (handle == NULL) /* check handle */
3564 {
3565 return 2; /* return error */
3566 }
3567 if (handle->inited != 1) /* check handle initialization */
3568 {
3569 return 3; /* return error */
3570 }
3571
3572 res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3573 if (res != 0) /* check result */
3574 {
3575 handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3576
3577 return 1; /* return error */
3578 }
3579 *polarity = (lan8720_polarity_t)((config >> 4) & 0x01); /* get the polarity */
3580
3581 return 0; /* success return 0 */
3582}
3583
3597{
3598 uint8_t res;
3599 uint16_t config;
3600
3601 if (handle == NULL) /* check handle */
3602 {
3603 return 2; /* return error */
3604 }
3605 if (handle->inited != 1) /* check handle initialization */
3606 {
3607 return 3; /* return error */
3608 }
3609
3610 res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_SOURCE_FLAG, &config); /* read interrupt source */
3611 if (res != 0) /* check result */
3612 {
3613 handle->debug_print("lan8720: read interrupt source failed.\n"); /* read interrupt source failed */
3614
3615 return 1; /* return error */
3616 }
3617 *enable = (lan8720_bool_t)((config >> interrupt) & 0x01); /* get the bool */
3618
3619 return 0; /* success return 0 */
3620}
3621
3635{
3636 uint8_t res;
3637 uint16_t config;
3638
3639 if (handle == NULL) /* check handle */
3640 {
3641 return 2; /* return error */
3642 }
3643 if (handle->inited != 1) /* check handle initialization */
3644 {
3645 return 3; /* return error */
3646 }
3647
3648 res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_MASK, &config); /* read interrupt mask */
3649 if (res != 0) /* check result */
3650 {
3651 handle->debug_print("lan8720: read interrupt mask failed.\n"); /* read interrupt mask failed */
3652
3653 return 1; /* return error */
3654 }
3655 config &= ~(1 << interrupt); /* clear config */
3656 config |= enable << interrupt; /* set polarity */
3657 res = a_lan8720_smi_write(handle, LAN8720_REG_INTERRUPT_MASK, config); /* write interrupt mask */
3658 if (res != 0) /* check result */
3659 {
3660 handle->debug_print("lan8720: write interrupt mask failed.\n"); /* write interrupt mask failed */
3661
3662 return 1; /* return error */
3663 }
3664
3665 return 0; /* success return 0 */
3666}
3667
3681{
3682 uint8_t res;
3683 uint16_t config;
3684
3685 if (handle == NULL) /* check handle */
3686 {
3687 return 2; /* return error */
3688 }
3689 if (handle->inited != 1) /* check handle initialization */
3690 {
3691 return 3; /* return error */
3692 }
3693
3694 res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_MASK, &config); /* read interrupt mask */
3695 if (res != 0) /* check result */
3696 {
3697 handle->debug_print("lan8720: read interrupt mask failed.\n"); /* read interrupt mask failed */
3698
3699 return 1; /* return error */
3700 }
3701 *enable = (lan8720_bool_t)((config >> interrupt) & 0x01); /* get the bool */
3702
3703 return 0; /* success return 0 */
3704}
3705
3718{
3719 uint8_t res;
3720 uint16_t config;
3721
3722 if (handle == NULL) /* check handle */
3723 {
3724 return 2; /* return error */
3725 }
3726 if (handle->inited != 1) /* check handle initialization */
3727 {
3728 return 3; /* return error */
3729 }
3730
3731 res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS, &config); /* read phy special control status */
3732 if (res != 0) /* check result */
3733 {
3734 handle->debug_print("lan8720: read phy special control status failed.\n"); /* read phy special control status failed */
3735
3736 return 1; /* return error */
3737 }
3738 *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
3739
3740 return 0; /* success return 0 */
3741}
3742
3755{
3756 uint8_t res;
3757 uint16_t config;
3758
3759 if (handle == NULL) /* check handle */
3760 {
3761 return 2; /* return error */
3762 }
3763 if (handle->inited != 1) /* check handle initialization */
3764 {
3765 return 3; /* return error */
3766 }
3767
3768 res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS, &config); /* read phy special control status */
3769 if (res != 0) /* check result */
3770 {
3771 handle->debug_print("lan8720: read phy special control status failed.\n"); /* read phy special control status failed */
3772
3773 return 1; /* return error */
3774 }
3775 *speed = (lan8720_speed_indication_t)((config >> 2) & 0x07); /* get the speed indication */
3776
3777 return 0; /* success return 0 */
3778}
3779
3793uint8_t lan8720_set_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t value)
3794{
3795 if (handle == NULL) /* check handle */
3796 {
3797 return 2; /* return error */
3798 }
3799 if (handle->inited != 1) /* check handle initialization */
3800 {
3801 return 3; /* return error */
3802 }
3803 if (reg > 0x1F) /* check reg */
3804 {
3805 handle->debug_print("lan8720: reg > 0x1F.\n"); /* reg > 0x1F */
3806
3807 return 4; /* return error */
3808 }
3809
3810 return a_lan8720_smi_write(handle, reg, value); /* write reg */
3811}
3812
3826uint8_t lan8720_get_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t *value)
3827{
3828 if (handle == NULL) /* check handle */
3829 {
3830 return 2; /* return error */
3831 }
3832 if (handle->inited != 1) /* check handle initialization */
3833 {
3834 return 3; /* return error */
3835 }
3836 if (reg > 0x1F) /* check reg */
3837 {
3838 handle->debug_print("lan8720: reg > 0x1F.\n"); /* reg > 0x1F */
3839
3840 return 4; /* return error */
3841 }
3842
3843 return a_lan8720_smi_read(handle, reg, value); /* read reg */
3844}
3845
3855{
3856 if (info == NULL) /* check handle */
3857 {
3858 return 2; /* return error */
3859 }
3860
3861 memset(info, 0, sizeof(lan8720_info_t)); /* initialize lan8720 info structure */
3862 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
3863 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
3864 strncpy(info->interface, "SMI RMII", 16); /* copy interface name */
3865 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
3866 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
3867 info->max_current_ma = MAX_CURRENT; /* set maximum current */
3868 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
3869 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
3870 info->driver_version = DRIVER_VERSION; /* set driver version */
3871
3872 return 0; /* success return 0 */
3873}
#define LAN8720_REG_SPECIAL_MODES
#define MAX_CURRENT
#define LAN8720_REG_PHY_IDENTIFIER_2
#define LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS
#define LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY
#define LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS
#define SUPPLY_VOLTAGE_MAX
#define LAN8720_REG_BASIC_STATUS
#define LAN8720_REG_INTERRUPT_MASK
#define TEMPERATURE_MAX
#define LAN8720_REG_AUTO_NEGOTIATION_EXPANSION
#define LAN8720_REG_BASIC_CONTROL
chip register definition
#define MANUFACTURER_NAME
#define LAN8720_REG_MODE_CONTROL_STATUS
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define LAN8720_REG_PHY_IDENTIFIER_1
#define LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT
#define CHIP_NAME
chip information definition
#define DRIVER_VERSION
#define LAN8720_REG_SYMBOL_ERROR_COUNTER_REGISTER
#define LAN8720_REG_INTERRUPT_SOURCE_FLAG
driver lan8720 header file
uint8_t lan8720_get_auto_negotiation_expansion_link_partner_auto_negotiation_able(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion link partner auto negotiation able status
uint8_t lan8720_get_auto_negotiation_link_partner_ability_remote_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability remote fault status
uint8_t lan8720_get_auto_negotiation_done(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation done status
uint8_t lan8720_set_energy_detect_power_down_mode(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable energy detect power down mode
uint8_t lan8720_get_auto_negotiation_advertisement_100base_tx_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 100base tx full duplex status
uint8_t lan8720_get_auto_negotiation_link_partner_ability_selector_field(lan8720_handle_t *handle, uint8_t *selector)
get auto negotiation link partner ability selector field
uint8_t lan8720_get_auto_mdix(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto mdix status
uint8_t lan8720_get_auto_negotiation_advertisement_10base_t_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 10base t full duplex status
uint8_t lan8720_get_interrupt_mask(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
get interrupt mask status
uint8_t lan8720_get_energy_detected(lan8720_handle_t *handle, lan8720_bool_t *enable)
get energy detected status
uint8_t lan8720_get_phy_address(lan8720_handle_t *handle, uint8_t *addr)
get phy address
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_tx(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability 100base tx status
uint8_t lan8720_get_auto_negotiation_advertisement_remote_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement remote fault status
uint8_t lan8720_set_interrupt_mask(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t enable)
set interrupt mask
uint8_t lan8720_set_auto_negotiation_advertisement_pause(lan8720_handle_t *handle, lan8720_pause_t pause)
set auto negotiation advertisement pause
uint8_t lan8720_set_auto_negotiation_advertisement_10base_t(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation advertisement 10base t
lan8720_polarity_t
lan8720 polarity enumeration definition
uint8_t lan8720_get_symbol_error_counter(lan8720_handle_t *handle, uint16_t *cnt)
get symbol error counter
uint8_t lan8720_get_auto_negotiation_advertisement_100base_tx(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 100base tx status
struct lan8720_info_s lan8720_info_t
lan8720 information structure definition
uint8_t lan8720_get_energy_detect_power_down_mode(lan8720_handle_t *handle, lan8720_bool_t *enable)
get energy detect power down mode status
uint8_t lan8720_get_auto_negotiation_advertisement_selector_field(lan8720_handle_t *handle, uint8_t *selector)
get auto negotiation advertisement selector field
uint8_t lan8720_set_auto_negotiation_advertisement_100base_tx_full_duplex(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation advertisement 100base tx full duplex
lan8720_mode_t
lan8720 mode enumeration definition
uint8_t lan8720_get_auto_negotiation_link_partner_ability_next_page(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability next page status
uint8_t lan8720_get_auto_negotiation_link_partner_ability_10base_t(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability 10base t status
uint8_t lan8720_get_auto_negotiation_link_partner_ability_10base_t_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability 10base t full duplex status
uint8_t lan8720_get_polarity(lan8720_handle_t *handle, lan8720_polarity_t *polarity)
get polarity
uint8_t lan8720_set_auto_negotiation_advertisement_100base_tx(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation advertisement 100base tx
lan8720_manual_channel_select_t
lan8720 manual channel select enumeration definition
uint8_t lan8720_get_auto_negotiation_expansion_page_received(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion page received status
uint8_t lan8720_get_auto_negotiation_expansion_link_partner_next_page_able(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion link partner next page able status
uint8_t lan8720_set_phy_address(lan8720_handle_t *handle, uint8_t addr)
set phy address
lan8720_interrupt_t
lan8720 interrupt enumeration definition
uint8_t lan8720_set_auto_negotiation_advertisement_selector_field(lan8720_handle_t *handle, uint8_t selector)
set auto negotiation advertisement selector field
uint8_t lan8720_get_far_loop_back(lan8720_handle_t *handle, lan8720_bool_t *enable)
get far loop back status
uint8_t lan8720_set_identifier(lan8720_handle_t *handle, uint32_t phy_id, uint8_t model_number, uint8_t revision_number)
set identifier
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_t4(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability 100base t4 status
uint8_t lan8720_set_far_loop_back(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable far loop back
uint8_t lan8720_get_identifier(lan8720_handle_t *handle, uint32_t *phy_id, uint8_t *model_number, uint8_t *revision_number)
get identifier
uint8_t lan8720_set_mode(lan8720_handle_t *handle, lan8720_mode_t mode)
set mode
uint8_t lan8720_set_manual_channel_select(lan8720_handle_t *handle, lan8720_manual_channel_select_t select)
set manual channel select
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_tx_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability 100base tx full duplex status
uint8_t lan8720_get_auto_negotiation_link_partner_ability_acknowledge(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability acknowledge status
uint8_t lan8720_set_auto_negotiation_advertisement_remote_fault(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation advertisement remote fault
uint8_t lan8720_get_interrupt_flag(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
get interrupt flag status
uint8_t lan8720_get_speed_indication(lan8720_handle_t *handle, lan8720_speed_indication_t *speed)
get speed indication
uint8_t lan8720_get_auto_negotiation_link_partner_ability_pause(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation link partner ability pause status
uint8_t lan8720_get_auto_negotiation_expansion_parallel_detection_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion parallel detection fault status
uint8_t lan8720_get_auto_negotiation_advertisement_pause(lan8720_handle_t *handle, lan8720_pause_t *pause)
get auto negotiation advertisement pause
uint8_t lan8720_set_auto_negotiation_advertisement_10base_t_full_duplex(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation advertisement 10base t full duplex
uint8_t lan8720_get_sqe_test_off(lan8720_handle_t *handle, lan8720_bool_t *enable)
get sqe test off status
lan8720_speed_indication_t
lan8720 speed indication enumeration definition
uint8_t lan8720_get_manual_channel_select(lan8720_handle_t *handle, lan8720_manual_channel_select_t *select)
get manual channel select
uint8_t lan8720_get_alternate_interrupt_mode(lan8720_handle_t *handle, lan8720_bool_t *enable)
get alternate interrupt mode status
uint8_t lan8720_set_auto_mdix(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto mdix
uint8_t lan8720_set_alternate_interrupt_mode(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable alternate interrupt mode
struct lan8720_handle_s lan8720_handle_t
lan8720 handle structure definition
uint8_t lan8720_get_auto_negotiation_expansion_next_page_able(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion next page able status
uint8_t lan8720_get_mode(lan8720_handle_t *handle, lan8720_mode_t *mode)
get mode
uint8_t lan8720_get_auto_negotiation_advertisement_10base_t(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 10base t status
lan8720_pause_t
lan8720 pause enumeration definition
uint8_t lan8720_set_sqe_test_off(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable sqe test off
uint8_t lan8720_set_duplex_mode(lan8720_handle_t *handle, lan8720_duplex_t mode)
set duplex mode
uint8_t lan8720_get_auto_negotiate_ability(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiate ability status
uint8_t lan8720_get_extended_status_information(lan8720_handle_t *handle, lan8720_bool_t *enable)
get extended status information status
uint8_t lan8720_get_electrical_isolation(lan8720_handle_t *handle, lan8720_bool_t *enable)
get electrical isolation status
uint8_t lan8720_get_100base_t4(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t4 status
uint8_t lan8720_set_loop_back(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable loop back
uint8_t lan8720_get_address(lan8720_handle_t *handle, uint8_t *addr)
get the chip address
uint8_t lan8720_get_link_status(lan8720_handle_t *handle, lan8720_link_t *status)
get link status
uint8_t lan8720_set_speed_select(lan8720_handle_t *handle, lan8720_speed_t speed)
set speed select
uint8_t lan8720_get_restart_auto_negotiate(lan8720_handle_t *handle, lan8720_bool_t *enable)
get restart auto negotiate status
uint8_t lan8720_init(lan8720_handle_t *handle)
initialize the chip
uint8_t lan8720_get_duplex_mode(lan8720_handle_t *handle, lan8720_duplex_t *mode)
get duplex mode
uint8_t lan8720_get_100base_tx_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base tx full duplex status
lan8720_bool_t
lan8720 bool enumeration definition
uint8_t lan8720_deinit(lan8720_handle_t *handle)
close the chip
uint8_t lan8720_get_auto_negotiation(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation status
uint8_t lan8720_get_remote_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get remote fault status
lan8720_duplex_t
lan8720 duplex enumeration definition
uint8_t lan8720_set_restart_auto_negotiate(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable restart auto negotiate
uint8_t lan8720_get_100base_t2_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t2 half duplex status
uint8_t lan8720_get_100base_tx_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base tx half duplex status
uint8_t lan8720_get_loop_back(lan8720_handle_t *handle, lan8720_bool_t *enable)
get loop back status
uint8_t lan8720_get_10base_t_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 10base t full duplex status
uint8_t lan8720_set_soft_reset(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable soft reset
uint8_t lan8720_get_speed_select(lan8720_handle_t *handle, lan8720_speed_t *speed)
get speed select status
lan8720_link_t
lan8720 link enumeration definition
uint8_t lan8720_set_auto_negotiation(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation
uint8_t lan8720_get_soft_reset(lan8720_handle_t *handle, lan8720_bool_t *enable)
get soft reset status
uint8_t lan8720_get_auto_negotiate_complete(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiate complete status
uint8_t lan8720_get_100base_t2_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t2 full duplex status
uint8_t lan8720_get_10base_t_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 10base t half duplex status
uint8_t lan8720_info(lan8720_info_t *info)
get chip's information
uint8_t lan8720_set_power_down(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable power down
uint8_t lan8720_get_extended_capabilities(lan8720_handle_t *handle, lan8720_bool_t *enable)
get extended capabilities status
uint8_t lan8720_get_jabber_detect(lan8720_handle_t *handle, lan8720_bool_t *enable)
get jabber detect status
lan8720_speed_t
lan8720 speed enumeration definition
uint8_t lan8720_set_address(lan8720_handle_t *handle, uint8_t addr)
set the chip address
uint8_t lan8720_get_power_down(lan8720_handle_t *handle, lan8720_bool_t *enable)
get power down status
uint8_t lan8720_set_electrical_isolation(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable electrical isolation
@ LAN8720_BOOL_TRUE
uint8_t lan8720_set_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t value)
set the chip register
uint8_t lan8720_get_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t *value)
get the chip register
uint8_t(* smi_deinit)(void)
uint8_t(* smi_write)(uint8_t addr, uint8_t reg, uint16_t data)
void(* delay_ms)(uint32_t ms)
uint8_t(* smi_init)(void)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* reset_gpio_init)(void)
uint8_t(* smi_read)(uint8_t addr, uint8_t reg, uint16_t *data)
uint8_t(* reset_gpio_write)(uint8_t level)
uint32_t driver_version
char manufacturer_name[32]