LibDriver LAN8720  1.0.0
LAN8720 full-featured driver
driver_lan8720.c
Go to the documentation of this file.
1 
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
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
79 static 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 
99 static 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 
119 uint8_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 
146 uint8_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 << 11); /* clear config */
332  config |= 1 << 11; /* set soft reset */
333  if (a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config) != 0) /* write basic control */
334  {
335  handle->debug_print("lan8720: reset failed.\n"); /* reset failed */
336 
337  return 4; /* return error */
338  }
339  res = handle->smi_deinit(); /* close smi */
340  if (res != 0) /* check the result */
341  {
342  handle->debug_print("lan8720: smi deinit failed.\n"); /* smi deinit failed */
343 
344  return 1; /* return error */
345  }
346  res = handle->reset_gpio_deinit(); /* close reset gpio */
347  if (res != 0) /* check the result */
348  {
349  handle->debug_print("lan8720: reset gpio deinit failed.\n"); /* reset gpio deinit failed */
350 
351  return 1; /* return error */
352  }
353  handle->inited = 0; /* flag close */
354 
355  return 0; /* success return 0 */
356 }
357 
370 {
371  uint8_t res;
372  uint16_t config;
373 
374  if (handle == NULL) /* check handle */
375  {
376  return 2; /* return error */
377  }
378  if (handle->inited != 1) /* check handle initialization */
379  {
380  return 3; /* return error */
381  }
382 
383  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
384  if (res != 0) /* check result */
385  {
386  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
387 
388  return 1; /* return error */
389  }
390  config &= ~(1 << 15); /* clear config */
391  config |= enable << 15; /* set bool */
392  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
393  if (res != 0) /* check result */
394  {
395  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
396 
397  return 1; /* return error */
398  }
399 
400  return 0; /* success return 0 */
401 }
402 
415 {
416  uint8_t res;
417  uint16_t config;
418 
419  if (handle == NULL) /* check handle */
420  {
421  return 2; /* return error */
422  }
423  if (handle->inited != 1) /* check handle initialization */
424  {
425  return 3; /* return error */
426  }
427 
428  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
429  if (res != 0) /* check result */
430  {
431  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
432 
433  return 1; /* return error */
434  }
435  *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
436 
437  return 0; /* success return 0 */
438 }
439 
452 {
453  uint8_t res;
454  uint16_t config;
455 
456  if (handle == NULL) /* check handle */
457  {
458  return 2; /* return error */
459  }
460  if (handle->inited != 1) /* check handle initialization */
461  {
462  return 3; /* return error */
463  }
464 
465  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
466  if (res != 0) /* check result */
467  {
468  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
469 
470  return 1; /* return error */
471  }
472  config &= ~(1 << 14); /* clear config */
473  config |= enable << 14; /* set bool */
474  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
475  if (res != 0) /* check result */
476  {
477  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
478 
479  return 1; /* return error */
480  }
481 
482  return 0; /* success return 0 */
483 }
484 
497 {
498  uint8_t res;
499  uint16_t config;
500 
501  if (handle == NULL) /* check handle */
502  {
503  return 2; /* return error */
504  }
505  if (handle->inited != 1) /* check handle initialization */
506  {
507  return 3; /* return error */
508  }
509 
510  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
511  if (res != 0) /* check result */
512  {
513  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
514 
515  return 1; /* return error */
516  }
517  *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
518 
519  return 0; /* success return 0 */
520 }
521 
534 {
535  uint8_t res;
536  uint16_t config;
537 
538  if (handle == NULL) /* check handle */
539  {
540  return 2; /* return error */
541  }
542  if (handle->inited != 1) /* check handle initialization */
543  {
544  return 3; /* return error */
545  }
546 
547  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
548  if (res != 0) /* check result */
549  {
550  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
551 
552  return 1; /* return error */
553  }
554  config &= ~(1 << 13); /* clear config */
555  config |= speed << 13; /* set speed */
556  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
557  if (res != 0) /* check result */
558  {
559  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
560 
561  return 1; /* return error */
562  }
563 
564  return 0; /* success return 0 */
565 }
566 
579 {
580  uint8_t res;
581  uint16_t config;
582 
583  if (handle == NULL) /* check handle */
584  {
585  return 2; /* return error */
586  }
587  if (handle->inited != 1) /* check handle initialization */
588  {
589  return 3; /* return error */
590  }
591 
592  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
593  if (res != 0) /* check result */
594  {
595  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
596 
597  return 1; /* return error */
598  }
599  *speed = (lan8720_speed_t)((config >> 13) & 0x01); /* get the speed */
600 
601  return 0; /* success return 0 */
602 }
603 
616 {
617  uint8_t res;
618  uint16_t config;
619 
620  if (handle == NULL) /* check handle */
621  {
622  return 2; /* return error */
623  }
624  if (handle->inited != 1) /* check handle initialization */
625  {
626  return 3; /* return error */
627  }
628 
629  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
630  if (res != 0) /* check result */
631  {
632  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
633 
634  return 1; /* return error */
635  }
636  config &= ~(1 << 12); /* clear config */
637  config |= enable << 12; /* set bool */
638  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
639  if (res != 0) /* check result */
640  {
641  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
642 
643  return 1; /* return error */
644  }
645 
646  return 0; /* success return 0 */
647 }
648 
661 {
662  uint8_t res;
663  uint16_t config;
664 
665  if (handle == NULL) /* check handle */
666  {
667  return 2; /* return error */
668  }
669  if (handle->inited != 1) /* check handle initialization */
670  {
671  return 3; /* return error */
672  }
673 
674  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
675  if (res != 0) /* check result */
676  {
677  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
678 
679  return 1; /* return error */
680  }
681  *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
682 
683  return 0; /* success return 0 */
684 }
685 
698 {
699  uint8_t res;
700  uint16_t config;
701 
702  if (handle == NULL) /* check handle */
703  {
704  return 2; /* return error */
705  }
706  if (handle->inited != 1) /* check handle initialization */
707  {
708  return 3; /* return error */
709  }
710 
711  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
712  if (res != 0) /* check result */
713  {
714  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
715 
716  return 1; /* return error */
717  }
718  config &= ~(1 << 11); /* clear config */
719  config |= enable << 11; /* set bool */
720  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
721  if (res != 0) /* check result */
722  {
723  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
724 
725  return 1; /* return error */
726  }
727 
728  return 0; /* success return 0 */
729 }
730 
743 {
744  uint8_t res;
745  uint16_t config;
746 
747  if (handle == NULL) /* check handle */
748  {
749  return 2; /* return error */
750  }
751  if (handle->inited != 1) /* check handle initialization */
752  {
753  return 3; /* return error */
754  }
755 
756  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
757  if (res != 0) /* check result */
758  {
759  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
760 
761  return 1; /* return error */
762  }
763  *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
764 
765  return 0; /* success return 0 */
766 }
767 
780 {
781  uint8_t res;
782  uint16_t config;
783 
784  if (handle == NULL) /* check handle */
785  {
786  return 2; /* return error */
787  }
788  if (handle->inited != 1) /* check handle initialization */
789  {
790  return 3; /* return error */
791  }
792 
793  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
794  if (res != 0) /* check result */
795  {
796  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
797 
798  return 1; /* return error */
799  }
800  config &= ~(1 << 10); /* clear config */
801  config |= enable << 10; /* set bool */
802  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
803  if (res != 0) /* check result */
804  {
805  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
806 
807  return 1; /* return error */
808  }
809 
810  return 0; /* success return 0 */
811 }
812 
825 {
826  uint8_t res;
827  uint16_t config;
828 
829  if (handle == NULL) /* check handle */
830  {
831  return 2; /* return error */
832  }
833  if (handle->inited != 1) /* check handle initialization */
834  {
835  return 3; /* return error */
836  }
837 
838  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
839  if (res != 0) /* check result */
840  {
841  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
842 
843  return 1; /* return error */
844  }
845  *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
846 
847  return 0; /* success return 0 */
848 }
849 
862 {
863  uint8_t res;
864  uint16_t config;
865 
866  if (handle == NULL) /* check handle */
867  {
868  return 2; /* return error */
869  }
870  if (handle->inited != 1) /* check handle initialization */
871  {
872  return 3; /* return error */
873  }
874 
875  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
876  if (res != 0) /* check result */
877  {
878  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
879 
880  return 1; /* return error */
881  }
882  config &= ~(1 << 9); /* clear config */
883  config |= enable << 9; /* set bool */
884  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
885  if (res != 0) /* check result */
886  {
887  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
888 
889  return 1; /* return error */
890  }
891 
892  return 0; /* success return 0 */
893 }
894 
907 {
908  uint8_t res;
909  uint16_t config;
910 
911  if (handle == NULL) /* check handle */
912  {
913  return 2; /* return error */
914  }
915  if (handle->inited != 1) /* check handle initialization */
916  {
917  return 3; /* return error */
918  }
919 
920  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
921  if (res != 0) /* check result */
922  {
923  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
924 
925  return 1; /* return error */
926  }
927  *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
928 
929  return 0; /* success return 0 */
930 }
931 
944 {
945  uint8_t res;
946  uint16_t config;
947 
948  if (handle == NULL) /* check handle */
949  {
950  return 2; /* return error */
951  }
952  if (handle->inited != 1) /* check handle initialization */
953  {
954  return 3; /* return error */
955  }
956 
957  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
958  if (res != 0) /* check result */
959  {
960  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
961 
962  return 1; /* return error */
963  }
964  config &= ~(1 << 8); /* clear config */
965  config |= mode << 8; /* set mode */
966  res = a_lan8720_smi_write(handle, LAN8720_REG_BASIC_CONTROL, config); /* write basic control */
967  if (res != 0) /* check result */
968  {
969  handle->debug_print("lan8720: write basic control failed.\n"); /* write basic control failed */
970 
971  return 1; /* return error */
972  }
973 
974  return 0; /* success return 0 */
975 }
976 
989 {
990  uint8_t res;
991  uint16_t config;
992 
993  if (handle == NULL) /* check handle */
994  {
995  return 2; /* return error */
996  }
997  if (handle->inited != 1) /* check handle initialization */
998  {
999  return 3; /* return error */
1000  }
1001 
1002  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_CONTROL, &config); /* read basic control */
1003  if (res != 0) /* check result */
1004  {
1005  handle->debug_print("lan8720: read basic control failed.\n"); /* read basic control failed */
1006 
1007  return 1; /* return error */
1008  }
1009  *mode = (lan8720_duplex_t)((config >> 8) & 0x01); /* get the mode */
1010 
1011  return 0; /* success return 0 */
1012 }
1013 
1026 {
1027  uint8_t res;
1028  uint16_t config;
1029 
1030  if (handle == NULL) /* check handle */
1031  {
1032  return 2; /* return error */
1033  }
1034  if (handle->inited != 1) /* check handle initialization */
1035  {
1036  return 3; /* return error */
1037  }
1038 
1039  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1040  if (res != 0) /* check result */
1041  {
1042  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1043 
1044  return 1; /* return error */
1045  }
1046  *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
1047 
1048  return 0; /* success return 0 */
1049 }
1050 
1063 {
1064  uint8_t res;
1065  uint16_t config;
1066 
1067  if (handle == NULL) /* check handle */
1068  {
1069  return 2; /* return error */
1070  }
1071  if (handle->inited != 1) /* check handle initialization */
1072  {
1073  return 3; /* return error */
1074  }
1075 
1076  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1077  if (res != 0) /* check result */
1078  {
1079  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1080 
1081  return 1; /* return error */
1082  }
1083  *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
1084 
1085  return 0; /* success return 0 */
1086 }
1087 
1100 {
1101  uint8_t res;
1102  uint16_t config;
1103 
1104  if (handle == NULL) /* check handle */
1105  {
1106  return 2; /* return error */
1107  }
1108  if (handle->inited != 1) /* check handle initialization */
1109  {
1110  return 3; /* return error */
1111  }
1112 
1113  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1114  if (res != 0) /* check result */
1115  {
1116  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1117 
1118  return 1; /* return error */
1119  }
1120  *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
1121 
1122  return 0; /* success return 0 */
1123 }
1124 
1137 {
1138  uint8_t res;
1139  uint16_t config;
1140 
1141  if (handle == NULL) /* check handle */
1142  {
1143  return 2; /* return error */
1144  }
1145  if (handle->inited != 1) /* check handle initialization */
1146  {
1147  return 3; /* return error */
1148  }
1149 
1150  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1151  if (res != 0) /* check result */
1152  {
1153  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1154 
1155  return 1; /* return error */
1156  }
1157  *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
1158 
1159  return 0; /* success return 0 */
1160 }
1161 
1174 {
1175  uint8_t res;
1176  uint16_t config;
1177 
1178  if (handle == NULL) /* check handle */
1179  {
1180  return 2; /* return error */
1181  }
1182  if (handle->inited != 1) /* check handle initialization */
1183  {
1184  return 3; /* return error */
1185  }
1186 
1187  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1188  if (res != 0) /* check result */
1189  {
1190  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1191 
1192  return 1; /* return error */
1193  }
1194  *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
1195 
1196  return 0; /* success return 0 */
1197 }
1198 
1211 {
1212  uint8_t res;
1213  uint16_t config;
1214 
1215  if (handle == NULL) /* check handle */
1216  {
1217  return 2; /* return error */
1218  }
1219  if (handle->inited != 1) /* check handle initialization */
1220  {
1221  return 3; /* return error */
1222  }
1223 
1224  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1225  if (res != 0) /* check result */
1226  {
1227  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1228 
1229  return 1; /* return error */
1230  }
1231  *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
1232 
1233  return 0; /* success return 0 */
1234 }
1235 
1248 {
1249  uint8_t res;
1250  uint16_t config;
1251 
1252  if (handle == NULL) /* check handle */
1253  {
1254  return 2; /* return error */
1255  }
1256  if (handle->inited != 1) /* check handle initialization */
1257  {
1258  return 3; /* return error */
1259  }
1260 
1261  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1262  if (res != 0) /* check result */
1263  {
1264  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1265 
1266  return 1; /* return error */
1267  }
1268  *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
1269 
1270  return 0; /* success return 0 */
1271 }
1272 
1285 {
1286  uint8_t res;
1287  uint16_t config;
1288 
1289  if (handle == NULL) /* check handle */
1290  {
1291  return 2; /* return error */
1292  }
1293  if (handle->inited != 1) /* check handle initialization */
1294  {
1295  return 3; /* return error */
1296  }
1297 
1298  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1299  if (res != 0) /* check result */
1300  {
1301  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1302 
1303  return 1; /* return error */
1304  }
1305  *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
1306 
1307  return 0; /* success return 0 */
1308 }
1309 
1322 {
1323  uint8_t res;
1324  uint16_t config;
1325 
1326  if (handle == NULL) /* check handle */
1327  {
1328  return 2; /* return error */
1329  }
1330  if (handle->inited != 1) /* check handle initialization */
1331  {
1332  return 3; /* return error */
1333  }
1334 
1335  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1336  if (res != 0) /* check result */
1337  {
1338  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1339 
1340  return 1; /* return error */
1341  }
1342  *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
1343 
1344  return 0; /* success return 0 */
1345 }
1346 
1359 {
1360  uint8_t res;
1361  uint16_t config;
1362 
1363  if (handle == NULL) /* check handle */
1364  {
1365  return 2; /* return error */
1366  }
1367  if (handle->inited != 1) /* check handle initialization */
1368  {
1369  return 3; /* return error */
1370  }
1371 
1372  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1373  if (res != 0) /* check result */
1374  {
1375  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1376 
1377  return 1; /* return error */
1378  }
1379  *enable = (lan8720_bool_t)((config >> 4) & 0x01); /* get the bool */
1380 
1381  return 0; /* success return 0 */
1382 }
1383 
1396 {
1397  uint8_t res;
1398  uint16_t config;
1399 
1400  if (handle == NULL) /* check handle */
1401  {
1402  return 2; /* return error */
1403  }
1404  if (handle->inited != 1) /* check handle initialization */
1405  {
1406  return 3; /* return error */
1407  }
1408 
1409  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1410  if (res != 0) /* check result */
1411  {
1412  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1413 
1414  return 1; /* return error */
1415  }
1416  *enable = (lan8720_bool_t)((config >> 3) & 0x01); /* get the bool */
1417 
1418  return 0; /* success return 0 */
1419 }
1420 
1433 {
1434  uint8_t res;
1435  uint16_t config;
1436 
1437  if (handle == NULL) /* check handle */
1438  {
1439  return 2; /* return error */
1440  }
1441  if (handle->inited != 1) /* check handle initialization */
1442  {
1443  return 3; /* return error */
1444  }
1445 
1446  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1447  if (res != 0) /* check result */
1448  {
1449  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1450 
1451  return 1; /* return error */
1452  }
1453  *status = (lan8720_link_t)((config >> 2) & 0x01); /* get the link status */
1454 
1455  return 0; /* success return 0 */
1456 }
1457 
1470 {
1471  uint8_t res;
1472  uint16_t config;
1473 
1474  if (handle == NULL) /* check handle */
1475  {
1476  return 2; /* return error */
1477  }
1478  if (handle->inited != 1) /* check handle initialization */
1479  {
1480  return 3; /* return error */
1481  }
1482 
1483  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1484  if (res != 0) /* check result */
1485  {
1486  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1487 
1488  return 1; /* return error */
1489  }
1490  *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
1491 
1492  return 0; /* success return 0 */
1493 }
1494 
1507 {
1508  uint8_t res;
1509  uint16_t config;
1510 
1511  if (handle == NULL) /* check handle */
1512  {
1513  return 2; /* return error */
1514  }
1515  if (handle->inited != 1) /* check handle initialization */
1516  {
1517  return 3; /* return error */
1518  }
1519 
1520  res = a_lan8720_smi_read(handle, LAN8720_REG_BASIC_STATUS, &config); /* read status control */
1521  if (res != 0) /* check result */
1522  {
1523  handle->debug_print("lan8720: read status control failed.\n"); /* read status control failed */
1524 
1525  return 1; /* return error */
1526  }
1527  *enable = (lan8720_bool_t)((config >> 0) & 0x01); /* get the bool */
1528 
1529  return 0; /* success return 0 */
1530 }
1531 
1548 uint8_t lan8720_set_identifier(lan8720_handle_t *handle, uint32_t phy_id,
1549  uint8_t model_number, uint8_t revision_number)
1550 {
1551  uint8_t res;
1552  uint16_t config;
1553 
1554  if (handle == NULL) /* check handle */
1555  {
1556  return 2; /* return error */
1557  }
1558  if (handle->inited != 1) /* check handle initialization */
1559  {
1560  return 3; /* return error */
1561  }
1562  if (phy_id > 0x3FFFFF) /* check phy_id */
1563  {
1564  handle->debug_print("lan8720: phy_id > 0x3FFFFF.\n"); /* phy_id > 0x3FFFFF */
1565 
1566  return 4; /* return error */
1567  }
1568  if (model_number > 0x3F) /* check model_number */
1569  {
1570  handle->debug_print("lan8720: model_number > 0x3F.\n"); /* model_number > 0x3F */
1571 
1572  return 5; /* return error */
1573  }
1574  if (revision_number > 0xF) /* check revision_number */
1575  {
1576  handle->debug_print("lan8720: revision_number > 0xF.\n"); /* revision_number > 0xF*/
1577 
1578  return 6; /* return error */
1579  }
1580 
1581  config = phy_id & 0xFFFFL; /* set phy id bit3 - bit18 */
1582  res = a_lan8720_smi_write(handle, LAN8720_REG_PHY_IDENTIFIER_1, config); /* write phy identifier 1 */
1583  if (res != 0) /* check result */
1584  {
1585  handle->debug_print("lan8720: write phy identifier 1 failed.\n"); /* write phy identifier 1 failed */
1586 
1587  return 1; /* return error */
1588  }
1589 
1590  config = (((phy_id >> 16) & 0x3F) << 10)
1591  | ((model_number & 0x3F) << 4) | (revision_number & 0xF); /* set phy id bit`19 - bit24, model number, revision_number number */
1592  res = a_lan8720_smi_write(handle, LAN8720_REG_PHY_IDENTIFIER_2, config); /* write phy identifier 2 */
1593  if (res != 0) /* check result */
1594  {
1595  handle->debug_print("lan8720: write phy identifier 2 failed.\n"); /* write phy identifier 2 failed */
1596 
1597  return 1; /* return error */
1598  }
1599 
1600  return 0; /* success return 0 */
1601 }
1602 
1616 uint8_t lan8720_get_identifier(lan8720_handle_t *handle, uint32_t *phy_id,
1617  uint8_t *model_number, uint8_t *revision_number)
1618 {
1619  uint8_t res;
1620  uint16_t config1;
1621  uint16_t config2;
1622 
1623  if (handle == NULL) /* check handle */
1624  {
1625  return 2; /* return error */
1626  }
1627  if (handle->inited != 1) /* check handle initialization */
1628  {
1629  return 3; /* return error */
1630  }
1631 
1632  res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_IDENTIFIER_1, &config1); /* read phy identifier 1 */
1633  if (res != 0) /* check result */
1634  {
1635  handle->debug_print("lan8720: read phy identifier 1 failed.\n"); /* read phy identifier 1 failed */
1636 
1637  return 1; /* return error */
1638  }
1639  res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_IDENTIFIER_2, &config2); /* read phy identifier 2 */
1640  if (res != 0) /* check result */
1641  {
1642  handle->debug_print("lan8720: read phy identifier 2 failed.\n"); /* read phy identifier 2 failed */
1643 
1644  return 1; /* return error */
1645  }
1646  *phy_id = config1 | (uint32_t)((config2 >> 10) & 0x3F) << 16; /* get phy_id */
1647  *model_number = (config2 >> 4) & 0x3F; /* get model_number */
1648  *revision_number = (config2 >> 0) & 0xF; /* get revision_number */
1649 
1650  return 0; /* success return 0 */
1651 }
1652 
1665 {
1666  uint8_t res;
1667  uint16_t config;
1668 
1669  if (handle == NULL) /* check handle */
1670  {
1671  return 2; /* return error */
1672  }
1673  if (handle->inited != 1) /* check handle initialization */
1674  {
1675  return 3; /* return error */
1676  }
1677 
1678  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1679  if (res != 0) /* check result */
1680  {
1681  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1682 
1683  return 1; /* return error */
1684  }
1685  config &= ~(1 << 13); /* clear config */
1686  config |= enable << 13; /* set bool */
1687  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1688  if (res != 0) /* check result */
1689  {
1690  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1691 
1692  return 1; /* return error */
1693  }
1694 
1695  return 0; /* success return 0 */
1696 }
1697 
1710 {
1711  uint8_t res;
1712  uint16_t config;
1713 
1714  if (handle == NULL) /* check handle */
1715  {
1716  return 2; /* return error */
1717  }
1718  if (handle->inited != 1) /* check handle initialization */
1719  {
1720  return 3; /* return error */
1721  }
1722 
1723  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1724  if (res != 0) /* check result */
1725  {
1726  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1727 
1728  return 1; /* return error */
1729  }
1730  *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
1731 
1732  return 0; /* success return 0 */
1733 }
1734 
1747 {
1748  uint8_t res;
1749  uint16_t config;
1750 
1751  if (handle == NULL) /* check handle */
1752  {
1753  return 2; /* return error */
1754  }
1755  if (handle->inited != 1) /* check handle initialization */
1756  {
1757  return 3; /* return error */
1758  }
1759 
1760  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1761  if (res != 0) /* check result */
1762  {
1763  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1764 
1765  return 1; /* return error */
1766  }
1767  config &= ~(3 << 10); /* clear config */
1768  config |= pause << 10; /* set pause */
1769  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1770  if (res != 0) /* check result */
1771  {
1772  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1773 
1774  return 1; /* return error */
1775  }
1776 
1777  return 0; /* success return 0 */
1778 }
1779 
1792 {
1793  uint8_t res;
1794  uint16_t config;
1795 
1796  if (handle == NULL) /* check handle */
1797  {
1798  return 2; /* return error */
1799  }
1800  if (handle->inited != 1) /* check handle initialization */
1801  {
1802  return 3; /* return error */
1803  }
1804 
1805  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1806  if (res != 0) /* check result */
1807  {
1808  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1809 
1810  return 1; /* return error */
1811  }
1812  *pause = (lan8720_pause_t)((config >> 10) & 0x03); /* get the pause */
1813 
1814  return 0; /* success return 0 */
1815 }
1816 
1829 {
1830  uint8_t res;
1831  uint16_t config;
1832 
1833  if (handle == NULL) /* check handle */
1834  {
1835  return 2; /* return error */
1836  }
1837  if (handle->inited != 1) /* check handle initialization */
1838  {
1839  return 3; /* return error */
1840  }
1841 
1842  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1843  if (res != 0) /* check result */
1844  {
1845  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1846 
1847  return 1; /* return error */
1848  }
1849  config &= ~(1 << 8); /* clear config */
1850  config |= enable << 8; /* set bool */
1851  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1852  if (res != 0) /* check result */
1853  {
1854  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1855 
1856  return 1; /* return error */
1857  }
1858 
1859  return 0; /* success return 0 */
1860 }
1861 
1874 {
1875  uint8_t res;
1876  uint16_t config;
1877 
1878  if (handle == NULL) /* check handle */
1879  {
1880  return 2; /* return error */
1881  }
1882  if (handle->inited != 1) /* check handle initialization */
1883  {
1884  return 3; /* return error */
1885  }
1886 
1887  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1888  if (res != 0) /* check result */
1889  {
1890  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1891 
1892  return 1; /* return error */
1893  }
1894  *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
1895 
1896  return 0; /* success return 0 */
1897 }
1898 
1911 {
1912  uint8_t res;
1913  uint16_t config;
1914 
1915  if (handle == NULL) /* check handle */
1916  {
1917  return 2; /* return error */
1918  }
1919  if (handle->inited != 1) /* check handle initialization */
1920  {
1921  return 3; /* return error */
1922  }
1923 
1924  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1925  if (res != 0) /* check result */
1926  {
1927  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1928 
1929  return 1; /* return error */
1930  }
1931  config &= ~(1 << 7); /* clear config */
1932  config |= enable << 7; /* set bool */
1933  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
1934  if (res != 0) /* check result */
1935  {
1936  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
1937 
1938  return 1; /* return error */
1939  }
1940 
1941  return 0; /* success return 0 */
1942 }
1943 
1956 {
1957  uint8_t res;
1958  uint16_t config;
1959 
1960  if (handle == NULL) /* check handle */
1961  {
1962  return 2; /* return error */
1963  }
1964  if (handle->inited != 1) /* check handle initialization */
1965  {
1966  return 3; /* return error */
1967  }
1968 
1969  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
1970  if (res != 0) /* check result */
1971  {
1972  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
1973 
1974  return 1; /* return error */
1975  }
1976  *enable = (lan8720_bool_t)((config >> 7) & 0x01); /* get the bool */
1977 
1978  return 0; /* success return 0 */
1979 }
1980 
1993 {
1994  uint8_t res;
1995  uint16_t config;
1996 
1997  if (handle == NULL) /* check handle */
1998  {
1999  return 2; /* return error */
2000  }
2001  if (handle->inited != 1) /* check handle initialization */
2002  {
2003  return 3; /* return error */
2004  }
2005 
2006  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2007  if (res != 0) /* check result */
2008  {
2009  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2010 
2011  return 1; /* return error */
2012  }
2013  config &= ~(1 << 6); /* clear config */
2014  config |= enable << 6; /* set bool */
2015  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2016  if (res != 0) /* check result */
2017  {
2018  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2019 
2020  return 1; /* return error */
2021  }
2022 
2023  return 0; /* success return 0 */
2024 }
2025 
2038 {
2039  uint8_t res;
2040  uint16_t config;
2041 
2042  if (handle == NULL) /* check handle */
2043  {
2044  return 2; /* return error */
2045  }
2046  if (handle->inited != 1) /* check handle initialization */
2047  {
2048  return 3; /* return error */
2049  }
2050 
2051  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2052  if (res != 0) /* check result */
2053  {
2054  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2055 
2056  return 1; /* return error */
2057  }
2058  *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
2059 
2060  return 0; /* success return 0 */
2061 }
2062 
2075 {
2076  uint8_t res;
2077  uint16_t config;
2078 
2079  if (handle == NULL) /* check handle */
2080  {
2081  return 2; /* return error */
2082  }
2083  if (handle->inited != 1) /* check handle initialization */
2084  {
2085  return 3; /* return error */
2086  }
2087 
2088  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2089  if (res != 0) /* check result */
2090  {
2091  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2092 
2093  return 1; /* return error */
2094  }
2095  config &= ~(1 << 5); /* clear config */
2096  config |= enable << 5; /* set bool */
2097  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2098  if (res != 0) /* check result */
2099  {
2100  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2101 
2102  return 1; /* return error */
2103  }
2104 
2105  return 0; /* success return 0 */
2106 }
2107 
2120 {
2121  uint8_t res;
2122  uint16_t config;
2123 
2124  if (handle == NULL) /* check handle */
2125  {
2126  return 2; /* return error */
2127  }
2128  if (handle->inited != 1) /* check handle initialization */
2129  {
2130  return 3; /* return error */
2131  }
2132 
2133  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2134  if (res != 0) /* check result */
2135  {
2136  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2137 
2138  return 1; /* return error */
2139  }
2140  *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
2141 
2142  return 0; /* success return 0 */
2143 }
2144 
2158 {
2159  uint8_t res;
2160  uint16_t config;
2161 
2162  if (handle == NULL) /* check handle */
2163  {
2164  return 2; /* return error */
2165  }
2166  if (handle->inited != 1) /* check handle initialization */
2167  {
2168  return 3; /* return error */
2169  }
2170  if (selector > 0x1F) /* check selector */
2171  {
2172  handle->debug_print("lan8720: selector > 0x1F.\n"); /* selector > 0x1F */
2173 
2174  return 4; /* return error */
2175  }
2176 
2177  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2178  if (res != 0) /* check result */
2179  {
2180  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2181 
2182  return 1; /* return error */
2183  }
2184  config &= ~(0x1F << 0); /* clear config */
2185  config |= selector << 0; /* set selector */
2186  res = a_lan8720_smi_write(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, config); /* write auto negotiation advertisement */
2187  if (res != 0) /* check result */
2188  {
2189  handle->debug_print("lan8720: write auto negotiation advertisement failed.\n"); /* write auto negotiation advertisement failed */
2190 
2191  return 1; /* return error */
2192  }
2193 
2194  return 0; /* success return 0 */
2195 }
2196 
2209 {
2210  uint8_t res;
2211  uint16_t config;
2212 
2213  if (handle == NULL) /* check handle */
2214  {
2215  return 2; /* return error */
2216  }
2217  if (handle->inited != 1) /* check handle initialization */
2218  {
2219  return 3; /* return error */
2220  }
2221 
2222  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_ADVERTISEMENT, &config); /* read auto negotiation advertisement */
2223  if (res != 0) /* check result */
2224  {
2225  handle->debug_print("lan8720: read auto negotiation advertisement failed.\n"); /* read auto negotiation advertisement failed */
2226 
2227  return 1; /* return error */
2228  }
2229  *selector = (config) & 0x1F; /*get selector */
2230 
2231  return 0; /* success return 0 */
2232 }
2233 
2246 {
2247  uint8_t res;
2248  uint16_t config;
2249 
2250  if (handle == NULL) /* check handle */
2251  {
2252  return 2; /* return error */
2253  }
2254  if (handle->inited != 1) /* check handle initialization */
2255  {
2256  return 3; /* return error */
2257  }
2258 
2259  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2260  if (res != 0) /* check result */
2261  {
2262  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2263 
2264  return 1; /* return error */
2265  }
2266  *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
2267 
2268  return 0; /* success return 0 */
2269 }
2270 
2283 {
2284  uint8_t res;
2285  uint16_t config;
2286 
2287  if (handle == NULL) /* check handle */
2288  {
2289  return 2; /* return error */
2290  }
2291  if (handle->inited != 1) /* check handle initialization */
2292  {
2293  return 3; /* return error */
2294  }
2295 
2296  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2297  if (res != 0) /* check result */
2298  {
2299  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2300 
2301  return 1; /* return error */
2302  }
2303  *enable = (lan8720_bool_t)((config >> 14) & 0x01); /* get the bool */
2304 
2305  return 0; /* success return 0 */
2306 }
2307 
2320 {
2321  uint8_t res;
2322  uint16_t config;
2323 
2324  if (handle == NULL) /* check handle */
2325  {
2326  return 2; /* return error */
2327  }
2328  if (handle->inited != 1) /* check handle initialization */
2329  {
2330  return 3; /* return error */
2331  }
2332 
2333  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2334  if (res != 0) /* check result */
2335  {
2336  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2337 
2338  return 1; /* return error */
2339  }
2340  *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
2341 
2342  return 0; /* success return 0 */
2343 }
2344 
2357 {
2358  uint8_t res;
2359  uint16_t config;
2360 
2361  if (handle == NULL) /* check handle */
2362  {
2363  return 2; /* return error */
2364  }
2365  if (handle->inited != 1) /* check handle initialization */
2366  {
2367  return 3; /* return error */
2368  }
2369 
2370  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2371  if (res != 0) /* check result */
2372  {
2373  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2374 
2375  return 1; /* return error */
2376  }
2377  *enable = (lan8720_bool_t)((config >> 10) & 0x01); /* get the bool */
2378 
2379  return 0; /* success return 0 */
2380 }
2381 
2394 {
2395  uint8_t res;
2396  uint16_t config;
2397 
2398  if (handle == NULL) /* check handle */
2399  {
2400  return 2; /* return error */
2401  }
2402  if (handle->inited != 1) /* check handle initialization */
2403  {
2404  return 3; /* return error */
2405  }
2406 
2407  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2408  if (res != 0) /* check result */
2409  {
2410  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2411 
2412  return 1; /* return error */
2413  }
2414  *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
2415 
2416  return 0; /* success return 0 */
2417 }
2418 
2431 {
2432  uint8_t res;
2433  uint16_t config;
2434 
2435  if (handle == NULL) /* check handle */
2436  {
2437  return 2; /* return error */
2438  }
2439  if (handle->inited != 1) /* check handle initialization */
2440  {
2441  return 3; /* return error */
2442  }
2443 
2444  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2445  if (res != 0) /* check result */
2446  {
2447  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2448 
2449  return 1; /* return error */
2450  }
2451  *enable = (lan8720_bool_t)((config >> 8) & 0x01); /* get the bool */
2452 
2453  return 0; /* success return 0 */
2454 }
2455 
2468 {
2469  uint8_t res;
2470  uint16_t config;
2471 
2472  if (handle == NULL) /* check handle */
2473  {
2474  return 2; /* return error */
2475  }
2476  if (handle->inited != 1) /* check handle initialization */
2477  {
2478  return 3; /* return error */
2479  }
2480 
2481  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2482  if (res != 0) /* check result */
2483  {
2484  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2485 
2486  return 1; /* return error */
2487  }
2488  *enable = (lan8720_bool_t)((config >> 7) & 0x01); /* get the bool */
2489 
2490  return 0; /* success return 0 */
2491 }
2492 
2505 {
2506  uint8_t res;
2507  uint16_t config;
2508 
2509  if (handle == NULL) /* check handle */
2510  {
2511  return 2; /* return error */
2512  }
2513  if (handle->inited != 1) /* check handle initialization */
2514  {
2515  return 3; /* return error */
2516  }
2517 
2518  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2519  if (res != 0) /* check result */
2520  {
2521  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2522 
2523  return 1; /* return error */
2524  }
2525  *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
2526 
2527  return 0; /* success return 0 */
2528 }
2529 
2542 {
2543  uint8_t res;
2544  uint16_t config;
2545 
2546  if (handle == NULL) /* check handle */
2547  {
2548  return 2; /* return error */
2549  }
2550  if (handle->inited != 1) /* check handle initialization */
2551  {
2552  return 3; /* return error */
2553  }
2554 
2555  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2556  if (res != 0) /* check result */
2557  {
2558  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2559 
2560  return 1; /* return error */
2561  }
2562  *enable = (lan8720_bool_t)((config >> 5) & 0x01); /* get the bool */
2563 
2564  return 0; /* success return 0 */
2565 }
2566 
2579 {
2580  uint8_t res;
2581  uint16_t config;
2582 
2583  if (handle == NULL) /* check handle */
2584  {
2585  return 2; /* return error */
2586  }
2587  if (handle->inited != 1) /* check handle initialization */
2588  {
2589  return 3; /* return error */
2590  }
2591 
2592  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_LINK_PARTNER_ABILITY, &config); /* read auto negotiation link partner ability */
2593  if (res != 0) /* check result */
2594  {
2595  handle->debug_print("lan8720: read auto negotiation link partner ability failed.\n"); /* read auto negotiation link partner ability failed */
2596 
2597  return 1; /* return error */
2598  }
2599  *selector = config & 0x1F; /* get the selector */
2600 
2601  return 0; /* success return 0 */
2602 }
2603 
2616 {
2617  uint8_t res;
2618  uint16_t config;
2619 
2620  if (handle == NULL) /* check handle */
2621  {
2622  return 2; /* return error */
2623  }
2624  if (handle->inited != 1) /* check handle initialization */
2625  {
2626  return 3; /* return error */
2627  }
2628 
2629  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2630  if (res != 0) /* check result */
2631  {
2632  handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2633 
2634  return 1; /* return error */
2635  }
2636  *enable = (lan8720_bool_t)((config >> 4) & 0x01); /* get the bool */
2637 
2638  return 0; /* success return 0 */
2639 }
2640 
2653 {
2654  uint8_t res;
2655  uint16_t config;
2656 
2657  if (handle == NULL) /* check handle */
2658  {
2659  return 2; /* return error */
2660  }
2661  if (handle->inited != 1) /* check handle initialization */
2662  {
2663  return 3; /* return error */
2664  }
2665 
2666  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2667  if (res != 0) /* check result */
2668  {
2669  handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2670 
2671  return 1; /* return error */
2672  }
2673  *enable = (lan8720_bool_t)((config >> 3) & 0x01); /* get the bool */
2674 
2675  return 0; /* success return 0 */
2676 }
2677 
2690 {
2691  uint8_t res;
2692  uint16_t config;
2693 
2694  if (handle == NULL) /* check handle */
2695  {
2696  return 2; /* return error */
2697  }
2698  if (handle->inited != 1) /* check handle initialization */
2699  {
2700  return 3; /* return error */
2701  }
2702 
2703  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2704  if (res != 0) /* check result */
2705  {
2706  handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2707 
2708  return 1; /* return error */
2709  }
2710  *enable = (lan8720_bool_t)((config >> 2) & 0x01); /* get the bool */
2711 
2712  return 0; /* success return 0 */
2713 }
2714 
2727 {
2728  uint8_t res;
2729  uint16_t config;
2730 
2731  if (handle == NULL) /* check handle */
2732  {
2733  return 2; /* return error */
2734  }
2735  if (handle->inited != 1) /* check handle initialization */
2736  {
2737  return 3; /* return error */
2738  }
2739 
2740  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2741  if (res != 0) /* check result */
2742  {
2743  handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2744 
2745  return 1; /* return error */
2746  }
2747  *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
2748 
2749  return 0; /* success return 0 */
2750 }
2751 
2764 {
2765  uint8_t res;
2766  uint16_t config;
2767 
2768  if (handle == NULL) /* check handle */
2769  {
2770  return 2; /* return error */
2771  }
2772  if (handle->inited != 1) /* check handle initialization */
2773  {
2774  return 3; /* return error */
2775  }
2776 
2777  res = a_lan8720_smi_read(handle, LAN8720_REG_AUTO_NEGOTIATION_EXPANSION, &config); /* read auto negotiation expansion */
2778  if (res != 0) /* check result */
2779  {
2780  handle->debug_print("lan8720: read auto negotiation expansion failed.\n"); /* read auto negotiation expansion failed */
2781 
2782  return 1; /* return error */
2783  }
2784  *enable = (lan8720_bool_t)((config >> 0) & 0x01); /* get the bool */
2785 
2786  return 0; /* success return 0 */
2787 }
2788 
2801 {
2802  uint8_t res;
2803  uint16_t config;
2804 
2805  if (handle == NULL) /* check handle */
2806  {
2807  return 2; /* return error */
2808  }
2809  if (handle->inited != 1) /* check handle initialization */
2810  {
2811  return 3; /* return error */
2812  }
2813 
2814  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2815  if (res != 0) /* check result */
2816  {
2817  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2818 
2819  return 1; /* return error */
2820  }
2821  config &= ~(1 << 13); /* clear config */
2822  config |= enable << 13; /* set bool */
2823  res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
2824  if (res != 0) /* check result */
2825  {
2826  handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
2827 
2828  return 1; /* return error */
2829  }
2830 
2831  return 0; /* success return 0 */
2832 }
2833 
2846 {
2847  uint8_t res;
2848  uint16_t config;
2849 
2850  if (handle == NULL) /* check handle */
2851  {
2852  return 2; /* return error */
2853  }
2854  if (handle->inited != 1) /* check handle initialization */
2855  {
2856  return 3; /* return error */
2857  }
2858 
2859  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2860  if (res != 0) /* check result */
2861  {
2862  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2863 
2864  return 1; /* return error */
2865  }
2866  *enable = (lan8720_bool_t)((config >> 13) & 0x01); /* get the bool */
2867 
2868  return 0; /* success return 0 */
2869 }
2870 
2883 {
2884  uint8_t res;
2885  uint16_t config;
2886 
2887  if (handle == NULL) /* check handle */
2888  {
2889  return 2; /* return error */
2890  }
2891  if (handle->inited != 1) /* check handle initialization */
2892  {
2893  return 3; /* return error */
2894  }
2895 
2896  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2897  if (res != 0) /* check result */
2898  {
2899  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2900 
2901  return 1; /* return error */
2902  }
2903  config &= ~(1 << 9); /* clear config */
2904  config |= enable << 9; /* set bool */
2905  res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
2906  if (res != 0) /* check result */
2907  {
2908  handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
2909 
2910  return 1; /* return error */
2911  }
2912 
2913  return 0; /* success return 0 */
2914 }
2915 
2928 {
2929  uint8_t res;
2930  uint16_t config;
2931 
2932  if (handle == NULL) /* check handle */
2933  {
2934  return 2; /* return error */
2935  }
2936  if (handle->inited != 1) /* check handle initialization */
2937  {
2938  return 3; /* return error */
2939  }
2940 
2941  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2942  if (res != 0) /* check result */
2943  {
2944  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2945 
2946  return 1; /* return error */
2947  }
2948  *enable = (lan8720_bool_t)((config >> 9) & 0x01); /* get the bool */
2949 
2950  return 0; /* success return 0 */
2951 }
2952 
2965 {
2966  uint8_t res;
2967  uint16_t config;
2968 
2969  if (handle == NULL) /* check handle */
2970  {
2971  return 2; /* return error */
2972  }
2973  if (handle->inited != 1) /* check handle initialization */
2974  {
2975  return 3; /* return error */
2976  }
2977 
2978  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
2979  if (res != 0) /* check result */
2980  {
2981  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
2982 
2983  return 1; /* return error */
2984  }
2985  config &= ~(1 << 6); /* clear config */
2986  config |= enable << 6; /* set bool */
2987  res = a_lan8720_smi_write(handle, LAN8720_REG_MODE_CONTROL_STATUS, config); /* write mode control status */
2988  if (res != 0) /* check result */
2989  {
2990  handle->debug_print("lan8720: write mode control status failed.\n"); /* write mode control status failed */
2991 
2992  return 1; /* return error */
2993  }
2994 
2995  return 0; /* success return 0 */
2996 }
2997 
3010 {
3011  uint8_t res;
3012  uint16_t config;
3013 
3014  if (handle == NULL) /* check handle */
3015  {
3016  return 2; /* return error */
3017  }
3018  if (handle->inited != 1) /* check handle initialization */
3019  {
3020  return 3; /* return error */
3021  }
3022 
3023  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
3024  if (res != 0) /* check result */
3025  {
3026  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
3027 
3028  return 1; /* return error */
3029  }
3030  *enable = (lan8720_bool_t)((config >> 6) & 0x01); /* get the bool */
3031 
3032  return 0; /* success return 0 */
3033 }
3034 
3047 {
3048  uint8_t res;
3049  uint16_t config;
3050 
3051  if (handle == NULL) /* check handle */
3052  {
3053  return 2; /* return error */
3054  }
3055  if (handle->inited != 1) /* check handle initialization */
3056  {
3057  return 3; /* return error */
3058  }
3059 
3060  res = a_lan8720_smi_read(handle, LAN8720_REG_MODE_CONTROL_STATUS, &config); /* read mode control status */
3061  if (res != 0) /* check result */
3062  {
3063  handle->debug_print("lan8720: read mode control status failed.\n"); /* read mode control status failed */
3064 
3065  return 1; /* return error */
3066  }
3067  *enable = (lan8720_bool_t)((config >> 1) & 0x01); /* get the bool */
3068 
3069  return 0; /* success return 0 */
3070 }
3071 
3084 {
3085  uint8_t res;
3086  uint16_t config;
3087 
3088  if (handle == NULL) /* check handle */
3089  {
3090  return 2; /* return error */
3091  }
3092  if (handle->inited != 1) /* check handle initialization */
3093  {
3094  return 3; /* return error */
3095  }
3096 
3097  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3098  if (res != 0) /* check result */
3099  {
3100  handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3101 
3102  return 1; /* return error */
3103  }
3104  config &= ~(0x07 << 5); /* clear config */
3105  config |= mode << 5; /* set mode */
3106  res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_MODES, config); /* write special modes */
3107  if (res != 0) /* check result */
3108  {
3109  handle->debug_print("lan8720: write special modes failed.\n"); /* write special modes failed */
3110 
3111  return 1; /* return error */
3112  }
3113 
3114  return 0; /* success return 0 */
3115 }
3116 
3129 {
3130  uint8_t res;
3131  uint16_t config;
3132 
3133  if (handle == NULL) /* check handle */
3134  {
3135  return 2; /* return error */
3136  }
3137  if (handle->inited != 1) /* check handle initialization */
3138  {
3139  return 3; /* return error */
3140  }
3141 
3142  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3143  if (res != 0) /* check result */
3144  {
3145  handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3146 
3147  return 1; /* return error */
3148  }
3149  *mode = (lan8720_mode_t)((config >> 5) & 0x07); /* get the mode */
3150 
3151  return 0; /* success return 0 */
3152 }
3153 
3166 uint8_t lan8720_set_phy_address(lan8720_handle_t *handle, uint8_t addr)
3167 {
3168  uint8_t res;
3169  uint16_t config;
3170 
3171  if (handle == NULL) /* check handle */
3172  {
3173  return 2; /* return error */
3174  }
3175  if (handle->inited != 1) /* check handle initialization */
3176  {
3177  return 3; /* return error */
3178  }
3179  if (addr > 0x1F) /* check result */
3180  {
3181  handle->debug_print("lan8720: addr > 0x1F.\n"); /* addr > 0x1F */
3182 
3183  return 4; /* return error */
3184  }
3185 
3186  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3187  if (res != 0) /* check result */
3188  {
3189  handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3190 
3191  return 1; /* return error */
3192  }
3193  config &= ~(0x1F << 0); /* clear config */
3194  config |= addr << 0; /* set addr */
3195  res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_MODES, config); /* write special modes */
3196  if (res != 0) /* check result */
3197  {
3198  handle->debug_print("lan8720: write special modes failed.\n"); /* write special modes failed */
3199 
3200  return 1; /* return error */
3201  }
3202 
3203  return 0; /* success return 0 */
3204 }
3205 
3217 uint8_t lan8720_get_phy_address(lan8720_handle_t *handle, uint8_t *addr)
3218 {
3219  uint8_t res;
3220  uint16_t config;
3221 
3222  if (handle == NULL) /* check handle */
3223  {
3224  return 2; /* return error */
3225  }
3226  if (handle->inited != 1) /* check handle initialization */
3227  {
3228  return 3; /* return error */
3229  }
3230 
3231  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_MODES, &config); /* read special modes */
3232  if (res != 0) /* check result */
3233  {
3234  handle->debug_print("lan8720: read special modes failed.\n"); /* read special modes failed */
3235 
3236  return 1; /* return error */
3237  }
3238  *addr = config & 0x1F; /* get addr */
3239 
3240  return 0; /* success return 0 */
3241 }
3242 
3255 {
3256  uint8_t res;
3257  uint16_t config;
3258 
3259  if (handle == NULL) /* check handle */
3260  {
3261  return 2; /* return error */
3262  }
3263  if (handle->inited != 1) /* check handle initialization */
3264  {
3265  return 3; /* return error */
3266  }
3267 
3268  res = a_lan8720_smi_read(handle, LAN8720_REG_SYMBOL_ERROR_COUNTER_REGISTER, &config); /* read symbol error counter */
3269  if (res != 0) /* check result */
3270  {
3271  handle->debug_print("lan8720: read symbol error counter failed.\n"); /* read symbol error counter failed */
3272 
3273  return 1; /* return error */
3274  }
3275  *cnt = config; /* get cnt */
3276 
3277  return 0; /* success return 0 */
3278 }
3279 
3292 {
3293  uint8_t res;
3294  uint16_t config;
3295 
3296  if (handle == NULL) /* check handle */
3297  {
3298  return 2; /* return error */
3299  }
3300  if (handle->inited != 1) /* check handle initialization */
3301  {
3302  return 3; /* return error */
3303  }
3304 
3305  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3306  if (res != 0) /* check result */
3307  {
3308  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3309 
3310  return 1; /* return error */
3311  }
3312  config &= ~(1 << 15); /* clear config */
3313  config |= enable << 15; /* set bool */
3314  res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3315  if (res != 0) /* check result */
3316  {
3317  handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3318 
3319  return 1; /* return error */
3320  }
3321 
3322  return 0; /* success return 0 */
3323 }
3324 
3337 {
3338  uint8_t res;
3339  uint16_t config;
3340 
3341  if (handle == NULL) /* check handle */
3342  {
3343  return 2; /* return error */
3344  }
3345  if (handle->inited != 1) /* check handle initialization */
3346  {
3347  return 3; /* return error */
3348  }
3349 
3350  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3351  if (res != 0) /* check result */
3352  {
3353  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3354 
3355  return 1; /* return error */
3356  }
3357  *enable = (lan8720_bool_t)((config >> 15) & 0x01); /* get the bool */
3358 
3359  return 0; /* success return 0 */
3360 }
3361 
3374 {
3375  uint8_t res;
3376  uint16_t config;
3377 
3378  if (handle == NULL) /* check handle */
3379  {
3380  return 2; /* return error */
3381  }
3382  if (handle->inited != 1) /* check handle initialization */
3383  {
3384  return 3; /* return error */
3385  }
3386 
3387  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3388  if (res != 0) /* check result */
3389  {
3390  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3391 
3392  return 1; /* return error */
3393  }
3394  config &= ~(1 << 13); /* clear config */
3395  config |= select << 13; /* set select */
3396  res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3397  if (res != 0) /* check result */
3398  {
3399  handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3400 
3401  return 1; /* return error */
3402  }
3403 
3404  return 0; /* success return 0 */
3405 }
3406 
3419 {
3420  uint8_t res;
3421  uint16_t config;
3422 
3423  if (handle == NULL) /* check handle */
3424  {
3425  return 2; /* return error */
3426  }
3427  if (handle->inited != 1) /* check handle initialization */
3428  {
3429  return 3; /* return error */
3430  }
3431 
3432  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3433  if (res != 0) /* check result */
3434  {
3435  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3436 
3437  return 1; /* return error */
3438  }
3439  *select = (lan8720_manual_channel_select_t)((config >> 13) & 0x01); /* get select */
3440 
3441  return 0; /* success return 0 */
3442 }
3443 
3456 {
3457  uint8_t res;
3458  uint16_t config;
3459 
3460  if (handle == NULL) /* check handle */
3461  {
3462  return 2; /* return error */
3463  }
3464  if (handle->inited != 1) /* check handle initialization */
3465  {
3466  return 3; /* return error */
3467  }
3468 
3469  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3470  if (res != 0) /* check result */
3471  {
3472  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3473 
3474  return 1; /* return error */
3475  }
3476  config &= ~(1 << 11); /* clear config */
3477  config |= enable << 11; /* set bool */
3478  res = a_lan8720_smi_write(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, config); /* write control status indication */
3479  if (res != 0) /* check result */
3480  {
3481  handle->debug_print("lan8720: write control status indication failed.\n"); /* write control status indication failed */
3482 
3483  return 1; /* return error */
3484  }
3485 
3486  return 0; /* success return 0 */
3487 }
3488 
3501 {
3502  uint8_t res;
3503  uint16_t config;
3504 
3505  if (handle == NULL) /* check handle */
3506  {
3507  return 2; /* return error */
3508  }
3509  if (handle->inited != 1) /* check handle initialization */
3510  {
3511  return 3; /* return error */
3512  }
3513 
3514  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3515  if (res != 0) /* check result */
3516  {
3517  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3518 
3519  return 1; /* return error */
3520  }
3521  *enable = (lan8720_bool_t)((config >> 11) & 0x01); /* get the bool */
3522 
3523  return 0; /* success return 0 */
3524 }
3525 
3538 {
3539  uint8_t res;
3540  uint16_t config;
3541 
3542  if (handle == NULL) /* check handle */
3543  {
3544  return 2; /* return error */
3545  }
3546  if (handle->inited != 1) /* check handle initialization */
3547  {
3548  return 3; /* return error */
3549  }
3550 
3551  res = a_lan8720_smi_read(handle, LAN8720_REG_SPECIAL_CONTROL_STATUS_INDICATIONS, &config); /* read control status indication */
3552  if (res != 0) /* check result */
3553  {
3554  handle->debug_print("lan8720: read control status indication failed.\n"); /* read control status indication failed */
3555 
3556  return 1; /* return error */
3557  }
3558  *polarity = (lan8720_polarity_t)((config >> 4) & 0x01); /* get the polarity */
3559 
3560  return 0; /* success return 0 */
3561 }
3562 
3576 {
3577  uint8_t res;
3578  uint16_t config;
3579 
3580  if (handle == NULL) /* check handle */
3581  {
3582  return 2; /* return error */
3583  }
3584  if (handle->inited != 1) /* check handle initialization */
3585  {
3586  return 3; /* return error */
3587  }
3588 
3589  res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_SOURCE_FLAG, &config); /* read interrupt source */
3590  if (res != 0) /* check result */
3591  {
3592  handle->debug_print("lan8720: read interrupt source failed.\n"); /* read interrupt source failed */
3593 
3594  return 1; /* return error */
3595  }
3596  *enable = (lan8720_bool_t)((config >> interrupt) & 0x01); /* get the bool */
3597 
3598  return 0; /* success return 0 */
3599 }
3600 
3614 {
3615  uint8_t res;
3616  uint16_t config;
3617 
3618  if (handle == NULL) /* check handle */
3619  {
3620  return 2; /* return error */
3621  }
3622  if (handle->inited != 1) /* check handle initialization */
3623  {
3624  return 3; /* return error */
3625  }
3626 
3627  res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_MASK, &config); /* read interrupt mask */
3628  if (res != 0) /* check result */
3629  {
3630  handle->debug_print("lan8720: read interrupt mask failed.\n"); /* read interrupt mask failed */
3631 
3632  return 1; /* return error */
3633  }
3634  config &= ~(1 << interrupt); /* clear config */
3635  config |= enable << interrupt; /* set polarity */
3636  res = a_lan8720_smi_write(handle, LAN8720_REG_INTERRUPT_MASK, config); /* write interrupt mask */
3637  if (res != 0) /* check result */
3638  {
3639  handle->debug_print("lan8720: write interrupt mask failed.\n"); /* write interrupt mask failed */
3640 
3641  return 1; /* return error */
3642  }
3643 
3644  return 0; /* success return 0 */
3645 }
3646 
3660 {
3661  uint8_t res;
3662  uint16_t config;
3663 
3664  if (handle == NULL) /* check handle */
3665  {
3666  return 2; /* return error */
3667  }
3668  if (handle->inited != 1) /* check handle initialization */
3669  {
3670  return 3; /* return error */
3671  }
3672 
3673  res = a_lan8720_smi_read(handle, LAN8720_REG_INTERRUPT_MASK, &config); /* read interrupt mask */
3674  if (res != 0) /* check result */
3675  {
3676  handle->debug_print("lan8720: read interrupt mask failed.\n"); /* read interrupt mask failed */
3677 
3678  return 1; /* return error */
3679  }
3680  *enable = (lan8720_bool_t)((config >> interrupt) & 0x01); /* get the bool */
3681 
3682  return 0; /* success return 0 */
3683 }
3684 
3697 {
3698  uint8_t res;
3699  uint16_t config;
3700 
3701  if (handle == NULL) /* check handle */
3702  {
3703  return 2; /* return error */
3704  }
3705  if (handle->inited != 1) /* check handle initialization */
3706  {
3707  return 3; /* return error */
3708  }
3709 
3710  res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS, &config); /* read phy special control status */
3711  if (res != 0) /* check result */
3712  {
3713  handle->debug_print("lan8720: read phy special control status failed.\n"); /* read phy special control status failed */
3714 
3715  return 1; /* return error */
3716  }
3717  *enable = (lan8720_bool_t)((config >> 12) & 0x01); /* get the bool */
3718 
3719  return 0; /* success return 0 */
3720 }
3721 
3734 {
3735  uint8_t res;
3736  uint16_t config;
3737 
3738  if (handle == NULL) /* check handle */
3739  {
3740  return 2; /* return error */
3741  }
3742  if (handle->inited != 1) /* check handle initialization */
3743  {
3744  return 3; /* return error */
3745  }
3746 
3747  res = a_lan8720_smi_read(handle, LAN8720_REG_PHY_SPECIAL_CONTROL_STATUS, &config); /* read phy special control status */
3748  if (res != 0) /* check result */
3749  {
3750  handle->debug_print("lan8720: read phy special control status failed.\n"); /* read phy special control status failed */
3751 
3752  return 1; /* return error */
3753  }
3754  *speed = (lan8720_speed_indication_t)((config >> 2) & 0x07); /* get the speed indication */
3755 
3756  return 0; /* success return 0 */
3757 }
3758 
3772 uint8_t lan8720_set_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t value)
3773 {
3774  if (handle == NULL) /* check handle */
3775  {
3776  return 2; /* return error */
3777  }
3778  if (handle->inited != 1) /* check handle initialization */
3779  {
3780  return 3; /* return error */
3781  }
3782  if (reg > 0x1F) /* check reg */
3783  {
3784  handle->debug_print("lan8720: reg > 0x1F.\n"); /* reg > 0x1F */
3785 
3786  return 4; /* return error */
3787  }
3788 
3789  return a_lan8720_smi_write(handle, reg, value); /* write reg */
3790 }
3791 
3805 uint8_t lan8720_get_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t *value)
3806 {
3807  if (handle == NULL) /* check handle */
3808  {
3809  return 2; /* return error */
3810  }
3811  if (handle->inited != 1) /* check handle initialization */
3812  {
3813  return 3; /* return error */
3814  }
3815  if (reg > 0x1F) /* check reg */
3816  {
3817  handle->debug_print("lan8720: reg > 0x1F.\n"); /* reg > 0x1F */
3818 
3819  return 4; /* return error */
3820  }
3821 
3822  return a_lan8720_smi_read(handle, reg, value); /* read reg */
3823 }
3824 
3834 {
3835  if (info == NULL) /* check handle */
3836  {
3837  return 2; /* return error */
3838  }
3839 
3840  memset(info, 0, sizeof(lan8720_info_t)); /* initialize lan8720 info structure */
3841  strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
3842  strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
3843  strncpy(info->interface, "SMI RMII", 16); /* copy interface name */
3844  info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
3845  info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
3846  info->max_current_ma = MAX_CURRENT; /* set maximum current */
3847  info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
3848  info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
3849  info->driver_version = DRIVER_VERSION; /* set driver version */
3850 
3851  return 0; /* success return 0 */
3852 }
#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
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
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
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
lan8720 handle structure definition
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)
lan8720 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char interface[16]
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]