Robobo
emac.h
Go to the documentation of this file.
1 
44 #ifndef EMAC_H_INCLUDED
45 #define EMAC_H_INCLUDED
46 
47 #include "../chip.h"
48 //#include "conf_eth.h"
49 
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 
61 #define EMAC_RXD_ADDR_MASK 0xFFFFFFFC
62 #define EMAC_RXD_WRAP (1ul << 1)
63 #define EMAC_RXD_OWNERSHIP (1ul << 0)
65 #define EMAC_RXD_BROADCAST (1ul << 31)
66 #define EMAC_RXD_MULTIHASH (1ul << 30)
67 #define EMAC_RXD_UNIHASH (1ul << 29)
68 #define EMAC_RXD_EXTADDR (1ul << 28)
69 #define EMAC_RXD_ADDR1 (1ul << 26)
70 #define EMAC_RXD_ADDR2 (1ul << 25)
71 #define EMAC_RXD_ADDR3 (1ul << 24)
72 #define EMAC_RXD_ADDR4 (1ul << 23)
73 #define EMAC_RXD_TYPE (1ul << 22)
74 #define EMAC_RXD_VLAN (1ul << 21)
75 #define EMAC_RXD_PRIORITY (1ul << 20)
76 #define EMAC_RXD_PRIORITY_MASK (3ul << 17)
77 #define EMAC_RXD_CFI (1ul << 16)
78 #define EMAC_RXD_EOF (1ul << 15)
79 #define EMAC_RXD_SOF (1ul << 14)
80 #define EMAC_RXD_OFFSET_MASK
81 #define EMAC_RXD_LEN_MASK (0xFFF)
82 #define EMAC_RXD_LENJUMBO_MASK (0x3FFF)
84 #define EMAC_TXD_USED (1ul << 31)
85 #define EMAC_TXD_WRAP (1ul << 30)
86 #define EMAC_TXD_ERROR (1ul << 29)
87 #define EMAC_TXD_UNDERRUN (1ul << 28)
88 #define EMAC_TXD_EXHAUSTED (1ul << 27)
89 #define EMAC_TXD_NOCRC (1ul << 16)
90 #define EMAC_TXD_LAST (1ul << 15)
91 #define EMAC_TXD_LEN_MASK (0x7FF)
94 #define EMAC_FRAME_LENTGH_MAX 1536
95 
96 #define EMAC_RX_UNITSIZE 128
97 #define EMAC_TX_UNITSIZE 1518
100 #define EMAC_CLOCK_SPEED_160MHZ (160*1000*1000)
101 #define EMAC_CLOCK_SPEED_80MHZ (80*1000*1000)
102 #define EMAC_CLOCK_SPEED_40MHZ (40*1000*1000)
103 #define EMAC_CLOCK_SPEED_20MHZ (20*1000*1000)
104 
106 #define EMAC_MAN_CODE_VALUE (10)
107 
109 #define EMAC_MAN_SOF_VALUE (1)
110 
112 #define EMAC_MAN_RW_TYPE (2)
113 
115 #define EMAC_MAN_READ_ONLY (1)
116 
118 #define EMAC_ADDR_LENGTH (6)
119 
123 typedef enum {
124  EMAC_OK = 0,
130  EMAC_INVALID = 0xFF, /* Invalid */
132 
133 #if defined __ICCARM__
134 #pragma pack(4) /* IAR */
135 #define __attribute__(...) /* IAR */
136 #endif /* IAR */
137 
139 typedef struct emac_rx_descriptor {
140  union emac_rx_addr {
141  uint32_t val;
143  uint32_t b_ownership:1,
144  b_wrap:1,
145  addr_dw:30;
146  } bm;
147  } addr;
149  uint32_t val;
151  uint32_t len:12,
152  offset:2,
153  b_sof:1,
154  b_eof:1,
155  b_cfi:1,
156  vlan_priority:3,
157  b_priority_detected:1,
158  b_vlan_detected:1,
159  b_type_id_match:1,
160  b_addr4match:1,
161  b_addr3match:1,
162  b_addr2match:1,
163  b_addr1match:1,
164  reserved:1,
165  b_ext_addr_match:1,
166  b_uni_hash_match:1,
167  b_multi_hash_match:1,
168  b_boardcast_detect:1;
169  } bm;
170  } status;
171 } __attribute__ ((packed, aligned(8))) emac_rx_descriptor_t; /* GCC */
172 
174 typedef struct emac_tx_descriptor {
175  uint32_t addr;
177  uint32_t val;
179  uint32_t len:11,
180  reserved:4,
181  b_last_buffer:1,
182  b_no_crc:1,
183  reserved1:10,
184  b_exhausted:1,
185  b_underrun:1,
186  b_error:1,
187  b_wrap:1,
188  b_used:1;
189  } bm;
190  } status;
191 } __attribute__ ((packed, aligned(8))) emac_tx_descriptor_t; /* GCC */
192 
193 #ifdef __ICCARM__ /* IAR */
194 #pragma pack()
195 #endif
196 
200 typedef struct emac_options {
201  /* Enable/Disable CopyAllFrame */
202  uint8_t uc_copy_all_frame;
203  /* Enable/Disable NoBroadCast */
204  uint8_t uc_no_boardcast;
205  /* MAC address */
206  uint8_t uc_mac_addr[EMAC_ADDR_LENGTH];
208 
210 typedef void (*emac_dev_tx_cb_t) (uint32_t ul_status);
212 typedef void (*emac_dev_wakeup_cb_t) (void);
213 
217 typedef struct emac_device {
218 
228  uint8_t *p_tx_buffer;
230  uint8_t *p_rx_buffer;
232  emac_rx_descriptor_t *p_rx_dscr;
234  emac_tx_descriptor_t *p_tx_dscr;
242  uint16_t us_rx_list_size;
244  uint16_t us_rx_idx;
246  uint16_t us_tx_list_size;
248  uint16_t us_tx_head;
250  uint16_t us_tx_tail;
251 
254 } emac_device_t;
255 
262 static inline void emac_network_control(Emac* p_emac, uint32_t ul_ncr)
263 {
264  p_emac->EMAC_NCR = ul_ncr;
265 }
266 
273 static inline uint32_t emac_get_network_control(Emac* p_emac)
274 {
275  return p_emac->EMAC_NCR;
276 }
277 
284 static inline void emac_enable_receive(Emac* p_emac, uint8_t uc_enable)
285 {
286  if (uc_enable) {
287  p_emac->EMAC_NCR |= EMAC_NCR_RE;
288  } else {
289  p_emac->EMAC_NCR &= ~EMAC_NCR_RE;
290  }
291 }
292 
299 static inline void emac_enable_transmit(Emac* p_emac, uint8_t uc_enable)
300 {
301  if (uc_enable) {
302  p_emac->EMAC_NCR |= EMAC_NCR_TE;
303  } else {
304  p_emac->EMAC_NCR &= ~EMAC_NCR_TE;
305  }
306 }
307 
314 static inline void emac_enable_management(Emac* p_emac, uint8_t uc_enable)
315 {
316  if (uc_enable) {
317  p_emac->EMAC_NCR |= EMAC_NCR_MPE;
318  } else {
319  p_emac->EMAC_NCR &= ~EMAC_NCR_MPE;
320  }
321 }
322 
328 static inline void emac_clear_statistics(Emac* p_emac)
329 {
330  p_emac->EMAC_NCR |= EMAC_NCR_CLRSTAT;
331 }
332 
338 static inline void emac_increase_statistics(Emac* p_emac)
339 {
340  p_emac->EMAC_NCR |= EMAC_NCR_INCSTAT;
341 }
342 
349 static inline void emac_enable_statistics_write(Emac* p_emac,
350  uint8_t uc_enable)
351 {
352  if (uc_enable) {
353  p_emac->EMAC_NCR |= EMAC_NCR_WESTAT;
354  } else {
355  p_emac->EMAC_NCR &= ~EMAC_NCR_WESTAT;
356  }
357 }
358 
365 static inline void emac_enable_back_pressure(Emac* p_emac, uint8_t uc_enable)
366 {
367  if (uc_enable) {
368  p_emac->EMAC_NCR |= EMAC_NCR_BP;
369  } else {
370  p_emac->EMAC_NCR &= ~EMAC_NCR_BP;
371  }
372 }
373 
379 static inline void emac_start_transmission(Emac* p_emac)
380 {
381  p_emac->EMAC_NCR |= EMAC_NCR_TSTART;
382 }
383 
389 static inline void emac_halt_transmission(Emac* p_emac)
390 {
391  p_emac->EMAC_NCR |= EMAC_NCR_THALT;
392 }
393 
400 static inline void emac_set_configure(Emac* p_emac, uint32_t ul_cfg)
401 {
402  p_emac->EMAC_NCFGR = ul_cfg;
403 }
404 
412 static inline uint32_t emac_get_configure(Emac* p_emac)
413 {
414  return p_emac->EMAC_NCFGR;
415 }
416 
423 static inline void emac_set_speed(Emac* p_emac, uint8_t uc_speed)
424 {
425  if (uc_speed) {
426  p_emac->EMAC_NCFGR |= EMAC_NCFGR_SPD;
427  } else {
428  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_SPD;
429  }
430 }
431 
438 static inline void emac_enable_full_duplex(Emac* p_emac, uint8_t uc_enable)
439 {
440  if (uc_enable) {
441  p_emac->EMAC_NCFGR |= EMAC_NCFGR_FD;
442  } else {
443  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_FD;
444  }
445 }
446 
453 static inline void emac_enable_copy_all(Emac* p_emac, uint8_t uc_enable)
454 {
455  if (uc_enable) {
456  p_emac->EMAC_NCFGR |= EMAC_NCFGR_CAF;
457  } else {
458  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_CAF;
459  }
460 }
461 
468 static inline void emac_enable_jumbo_frames(Emac* p_emac, uint8_t uc_enable)
469 {
470  if (uc_enable) {
471  p_emac->EMAC_NCFGR |= EMAC_NCFGR_JFRAME;
472  } else {
473  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_JFRAME;
474  }
475 }
476 
483 static inline void emac_disable_broadcast(Emac* p_emac, uint8_t uc_enable)
484 {
485  if (uc_enable) {
486  p_emac->EMAC_NCFGR |= EMAC_NCFGR_NBC;
487  } else {
488  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_NBC;
489  }
490 }
491 
498 static inline void emac_enable_multicast_hash(Emac* p_emac, uint8_t uc_enable)
499 {
500  if (uc_enable) {
501  p_emac->EMAC_NCFGR |= EMAC_NCFGR_UNI;
502  } else {
503  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_UNI;
504  }
505 }
506 
513 static inline void emac_enable_big_frame(Emac* p_emac, uint8_t uc_enable)
514 {
515  if (uc_enable) {
516  p_emac->EMAC_NCFGR |= EMAC_NCFGR_BIG;
517  } else {
518  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_BIG;
519  }
520 }
521 
530 static inline uint8_t emac_set_clock(Emac* p_emac, uint32_t ul_mck)
531 {
532  uint32_t ul_clk;
533 
534  if (ul_mck > EMAC_CLOCK_SPEED_160MHZ) {
535  return EMAC_INVALID;
536  } else if (ul_mck > EMAC_CLOCK_SPEED_80MHZ) {
537  ul_clk = EMAC_NCFGR_CLK_MCK_64;
538  } else if (ul_mck > EMAC_CLOCK_SPEED_40MHZ) {
539  ul_clk = EMAC_NCFGR_CLK_MCK_32;
540  } else if (ul_mck > EMAC_CLOCK_SPEED_20MHZ) {
541  ul_clk = EMAC_NCFGR_CLK_MCK_16;
542  } else {
543  ul_clk = EMAC_NCFGR_CLK_MCK_8;
544  }
545 
546  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_CLK_Msk;
547  p_emac->EMAC_NCFGR |= ul_clk;
548 
549  return EMAC_OK;
550 }
551 
558 static inline void emac_enable_retry_test(Emac* p_emac, uint8_t uc_enable)
559 {
560  if (uc_enable) {
561  p_emac->EMAC_NCFGR |= EMAC_NCFGR_RTY;
562  } else {
563  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_RTY;
564  }
565 }
566 
573 static inline void emac_enable_pause_frame(Emac* p_emac, uint8_t uc_enable)
574 {
575  if (uc_enable) {
576  p_emac->EMAC_NCFGR |= EMAC_NCFGR_PAE;
577  } else {
578  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_PAE;
579  }
580 }
581 
587 static inline void emac_set_rx_buffer_offset(Emac* p_emac, uint8_t uc_offset)
588 {
589  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_RBOF_Msk;
590  p_emac->EMAC_NCFGR |=
591  (EMAC_NCFGR_RBOF_Msk & ((uc_offset) << EMAC_NCFGR_RBOF_Pos));
592 }
593 
600 static inline void emac_enable_rx_length_check(Emac* p_emac, uint8_t uc_enable)
601 {
602  if (uc_enable) {
603  p_emac->EMAC_NCFGR |= EMAC_NCFGR_RLCE;
604  } else {
605  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_RLCE;
606  }
607 }
608 
615 static inline void emac_enable_discard_fcs(Emac* p_emac, uint8_t uc_enable)
616 {
617  if (uc_enable) {
618  p_emac->EMAC_NCFGR |= EMAC_NCFGR_DRFCS;
619  } else {
620  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_DRFCS;
621  }
622 }
623 
624 
632 static inline void emac_enable_efrhd(Emac* p_emac, uint8_t uc_enable)
633 {
634  if (uc_enable) {
635  p_emac->EMAC_NCFGR |= EMAC_NCFGR_EFRHD;
636  } else {
637  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_EFRHD;
638  }
639 }
640 
647 static inline void emac_enable_ignore_rx_fcs(Emac* p_emac, uint8_t uc_enable)
648 {
649  if (uc_enable) {
650  p_emac->EMAC_NCFGR |= EMAC_NCFGR_IRXFCS;
651  } else {
652  p_emac->EMAC_NCFGR &= ~EMAC_NCFGR_IRXFCS;
653  }
654 }
655 
663 static inline uint32_t emac_get_status(Emac* p_emac)
664 {
665  return p_emac->EMAC_NSR;
666 }
667 
675 static inline uint8_t emac_get_MDIO(Emac* p_emac)
676 {
677  return ((p_emac->EMAC_NSR & EMAC_NSR_MDIO) > 0);
678 }
679 
687 static inline uint8_t emac_is_phy_idle(Emac* p_emac)
688 {
689  return ((p_emac->EMAC_NSR & EMAC_NSR_IDLE) > 0);
690 }
691 
699 static inline uint32_t emac_get_tx_status(Emac* p_emac)
700 {
701  return p_emac->EMAC_TSR;
702 }
703 
710 static inline void emac_clear_tx_status(Emac* p_emac, uint32_t ul_status)
711 {
712  p_emac->EMAC_TSR = ul_status;
713 }
714 
720 static inline uint32_t emac_get_rx_status(Emac* p_emac)
721 {
722  return p_emac->EMAC_RSR;
723 }
724 
731 static inline void emac_clear_rx_status(Emac* p_emac, uint32_t ul_status)
732 {
733  p_emac->EMAC_RSR = ul_status;
734 }
735 
742 static inline void emac_set_rx_queue(Emac* p_emac, uint32_t ul_addr)
743 {
744  p_emac->EMAC_RBQP = EMAC_RBQP_ADDR_Msk & ul_addr;
745 }
746 
754 static inline uint32_t emac_get_rx_queue(Emac* p_emac)
755 {
756  return p_emac->EMAC_RBQP;
757 }
758 
765 static inline void emac_set_tx_queue(Emac* p_emac, uint32_t ul_addr)
766 {
767  p_emac->EMAC_TBQP = EMAC_TBQP_ADDR_Msk & ul_addr;
768 }
769 
777 static inline uint32_t emac_get_tx_queue(Emac* p_emac)
778 {
779  return p_emac->EMAC_TBQP;
780 }
781 
788 static inline void emac_enable_interrupt(Emac* p_emac, uint32_t ul_source)
789 {
790  p_emac->EMAC_IER = ul_source;
791 }
792 
799 static inline void emac_disable_interrupt(Emac* p_emac, uint32_t ul_source)
800 {
801  p_emac->EMAC_IDR = ul_source;
802 }
803 
811 static inline uint32_t emac_get_interrupt_status(Emac* p_emac)
812 {
813  return p_emac->EMAC_ISR;
814 }
815 
823 static inline uint32_t emac_get_interrupt_mask(Emac* p_emac)
824 {
825  return p_emac->EMAC_IMR;
826 }
827 
837 static inline void emac_maintain_phy(Emac* p_emac,
838  uint8_t uc_phy_addr, uint8_t uc_reg_addr, uint8_t uc_rw,
839  uint16_t us_data)
840 {
841  /* Wait until bus idle */
842  while ((p_emac->EMAC_NSR & EMAC_NSR_IDLE) == 0);
843  /* Write maintain register */
844  p_emac->EMAC_MAN = EMAC_MAN_CODE(EMAC_MAN_CODE_VALUE)
845  | EMAC_MAN_SOF(EMAC_MAN_SOF_VALUE)
846  | EMAC_MAN_PHYA(uc_phy_addr)
847  | EMAC_MAN_REGA(uc_reg_addr)
848  | EMAC_MAN_RW((uc_rw ? EMAC_MAN_RW_TYPE : EMAC_MAN_READ_ONLY))
849  | EMAC_MAN_DATA(us_data);
850 }
851 
859 static inline uint16_t emac_get_phy_data(Emac* p_emac)
860 {
861  /* Wait until bus idle */
862  while ((p_emac->EMAC_NSR & EMAC_NSR_IDLE) == 0);
863  /* Return data */
864  return (uint16_t) (p_emac->EMAC_MAN & EMAC_MAN_DATA_Msk);
865 }
866 
873 static inline void emac_set_pause_time(Emac* p_emac, uint16_t us_pause_time)
874 {
875  p_emac->EMAC_PTR = us_pause_time;
876 }
877 
885 static inline void emac_set_hash(Emac* p_emac, uint32_t ul_hash_top,
886  uint32_t ul_hash_bottom)
887 {
888  p_emac->EMAC_HRB = ul_hash_bottom;
889  p_emac->EMAC_HRT = ul_hash_top;
890 }
891 
898 static inline void emac_set_hash64(Emac* p_emac, uint64_t ull_hash)
899 {
900  p_emac->EMAC_HRB = (uint32_t) ull_hash;
901  p_emac->EMAC_HRT = (uint32_t) (ull_hash >> 32);
902 }
903 
911 static inline void emac_set_address(Emac* p_emac, uint8_t uc_index,
912  uint8_t* p_mac_addr)
913 {
914  p_emac->EMAC_SA[uc_index].EMAC_SAxB = (p_mac_addr[3] << 24)
915  | (p_mac_addr[2] << 16)
916  | (p_mac_addr[1] << 8)
917  | (p_mac_addr[0]);
918  p_emac->EMAC_SA[uc_index].EMAC_SAxT = (p_mac_addr[5] << 8)
919  | (p_mac_addr[4]);
920 }
921 
930 static inline void emac_set_address32(Emac* p_emac, uint8_t uc_index,
931  uint32_t ul_mac_top, uint32_t ul_mac_bottom)
932 {
933  p_emac->EMAC_SA[uc_index].EMAC_SAxB = ul_mac_bottom;
934  p_emac->EMAC_SA[uc_index].EMAC_SAxT = ul_mac_top;
935 }
936 
944 static inline void emac_set_address64(Emac* p_emac, uint8_t uc_index,
945  uint64_t ull_mac)
946 {
947  p_emac->EMAC_SA[uc_index].EMAC_SAxB = (uint32_t) ull_mac;
948  p_emac->EMAC_SA[uc_index].EMAC_SAxT = (uint32_t) (ull_mac >> 32);
949 }
950 
957 static inline void emac_set_type_id(Emac* p_emac, uint16_t us_type_id)
958 {
959  p_emac->EMAC_TID = EMAC_TID_TID(us_type_id);
960 }
961 
969 static inline uint16_t emac_get_type_id(Emac* p_emac)
970 {
971  return (p_emac->EMAC_TID & EMAC_TID_TID_Msk);
972 }
973 
980 static inline void emac_enable_rmii(Emac* p_emac, uint8_t uc_enable)
981 {
982  if (uc_enable) {
983  p_emac->EMAC_USRIO |= EMAC_USRIO_RMII;
984  } else {
985  p_emac->EMAC_USRIO &= ~EMAC_USRIO_RMII;
986  }
987 }
988 
995 static inline void emac_enable_transceiver_clock(Emac* p_emac,
996  uint8_t uc_enable)
997 {
998  if (uc_enable) {
999  p_emac->EMAC_USRIO |= EMAC_USRIO_CLKEN;
1000  } else {
1001  p_emac->EMAC_USRIO &= ~EMAC_USRIO_CLKEN;
1002  }
1003 }
1004 
1005 uint8_t emac_phy_read(Emac* p_emac, uint8_t uc_phy_address, uint8_t uc_address,
1006  uint32_t* p_value);
1007 uint8_t emac_phy_write(Emac* p_emac, uint8_t uc_phy_address,
1008  uint8_t uc_address, uint32_t ul_value);
1009 void emac_dev_init(Emac* p_emac, emac_device_t* p_emac_dev,
1010  emac_options_t* p_opt);
1011 uint32_t emac_dev_read(emac_device_t* p_emac_dev, uint8_t* p_frame,
1012  uint32_t ul_frame_size, uint32_t* p_rcv_size);
1013 uint32_t emac_dev_write(emac_device_t* p_emac_dev, void *p_buffer,
1014  uint32_t ul_size, emac_dev_tx_cb_t func_tx_cb);
1015 uint32_t emac_dev_get_tx_load(emac_device_t* p_emac_dev);
1016 void emac_dev_set_rx_callback(emac_device_t* p_emac_dev,
1017  emac_dev_tx_cb_t func_rx_cb);
1018 uint8_t emac_dev_set_tx_wakeup_callback(emac_device_t* p_emac_dev,
1019  emac_dev_wakeup_cb_t func_wakeup, uint8_t uc_threshold);
1020 void emac_dev_reset(emac_device_t* p_emac_dev);
1021 void emac_handler(emac_device_t* p_emac_dev);
1022 
1024 
1025 #ifdef __cplusplus
1026 }
1027 #endif
1028 
1029 
1225 #endif /* EMAC_H_INCLUDED */
emac_status_t
Return codes for EMAC APIs.
Definition: emac.h:123
emac_dev_tx_cb_t * func_tx_cb_list
Definition: emac.h:240
#define EMAC_NCFGR_CLK_Msk
(EMAC_NCFGR) MDC clock divider
Definition: component_emac.h:113
Definition: emac.h:130
RwReg EMAC_RBQP
(Emac Offset: 0x18) Receive Buffer Queue Pointer Register
Definition: component_emac.h:53
RwReg EMAC_SAxB
(EmacSa Offset: 0x0) Specific Address 1 Bottom Register
Definition: component_emac.h:42
Input parameters when initializing the emac module mode.
Definition: emac.h:200
#define EMAC_TID_TID_Msk
(EMAC_TID) Type ID checking
Definition: component_emac.h:326
#define EMAC_MAN_CODE_VALUE
Definition: emac.h:106
RoReg EMAC_IMR
(Emac Offset: 0x30) Interrupt Mask Register
Definition: component_emac.h:59
void(* emac_dev_wakeup_cb_t)(void)
Definition: emac.h:212
Emac * p_hw
Definition: emac.h:220
uint16_t us_tx_head
Definition: emac.h:248
#define EMAC_NCFGR_BIG
(EMAC_NCFGR) Receive 1536 bytes frames
Definition: component_emac.h:111
Definition: emac.h:139
union emac_rx_descriptor::emac_rx_addr addr
#define EMAC_NCR_MPE
(EMAC_NCR) Management port enable
Definition: component_emac.h:96
#define EMAC_CLOCK_SPEED_160MHZ
Definition: emac.h:100
RwReg EMAC_ISR
(Emac Offset: 0x24) Interrupt Status Register
Definition: component_emac.h:56
#define EMAC_NCFGR_CLK_MCK_32
(EMAC_NCFGR) MCK divided by 32 (MCK up to 80 MHz).
Definition: component_emac.h:116
RwReg EMAC_MAN
(Emac Offset: 0x34) Phy Maintenance Register
Definition: component_emac.h:60
uint16_t us_tx_list_size
Definition: emac.h:246
#define EMAC_NCR_CLRSTAT
(EMAC_NCR) Clear statistics registers
Definition: component_emac.h:97
#define EMAC_NSR_IDLE
(EMAC_NSR)
Definition: component_emac.h:132
struct emac_options emac_options_t
Input parameters when initializing the emac module mode.
#define EMAC_ADDR_LENGTH
Definition: emac.h:118
struct emac_rx_descriptor __attribute__((packed, aligned(8))) emac_rx_descriptor_t
#define EMAC_MAN_RW_TYPE
Definition: emac.h:112
Definition: emac.h:129
RwReg EMAC_HRT
(Emac Offset: 0x94) Hash Register Top [63:32] Register
Definition: component_emac.h:84
#define EMAC_NCR_BP
(EMAC_NCR) Back pressure
Definition: component_emac.h:100
#define EMAC_RBQP_ADDR_Msk
(EMAC_RBQP) Receive buffer queue pointer address
Definition: component_emac.h:143
#define EMAC_NCFGR_CLK_MCK_64
(EMAC_NCFGR) MCK divided by 64 (MCK up to 160 MHz).
Definition: component_emac.h:117
struct emac_device emac_device_t
#define EMAC_USRIO_RMII
(EMAC_USRIO) Reduce MII
Definition: component_emac.h:329
#define EMAC_NCR_INCSTAT
(EMAC_NCR) Increment statistics registers
Definition: component_emac.h:98
#define EMAC_NSR_MDIO
(EMAC_NSR)
Definition: component_emac.h:131
Definition: emac.h:128
#define EMAC_NCR_WESTAT
(EMAC_NCR) Write enable for statistics registers
Definition: component_emac.h:99
void(* emac_dev_tx_cb_t)(uint32_t ul_status)
Definition: emac.h:210
Definition: emac.h:217
#define EMAC_NCFGR_CLK_MCK_8
(EMAC_NCFGR) MCK divided by 8 (MCK up to 20 MHz).
Definition: component_emac.h:114
RwReg EMAC_TBQP
(Emac Offset: 0x1C) Transmit Buffer Queue Pointer Register
Definition: component_emac.h:54
uint8_t * p_rx_buffer
Definition: emac.h:230
WoReg EMAC_IDR
(Emac Offset: 0x2C) Interrupt Disable Register
Definition: component_emac.h:58
#define EMAC_NCR_RE
(EMAC_NCR) Receive enable
Definition: component_emac.h:94
RwReg EMAC_HRB
(Emac Offset: 0x90) Hash Register Bottom [31:0] Register
Definition: component_emac.h:83
#define EMAC_NCR_TSTART
(EMAC_NCR) Start transmission
Definition: component_emac.h:101
uint8_t uc_wakeup_threshold
Definition: emac.h:253
#define EMAC_MAN_DATA_Msk
(EMAC_MAN)
Definition: component_emac.h:207
RoReg EMAC_NSR
(Emac Offset: 0x08) Network Status Register
Definition: component_emac.h:50
#define EMAC_NCFGR_JFRAME
(EMAC_NCFGR) Jumbo Frames
Definition: component_emac.h:106
#define EMAC_NCFGR_CLK_MCK_16
(EMAC_NCFGR) MCK divided by 16 (MCK up to 40 MHz).
Definition: component_emac.h:115
RwReg EMAC_USRIO
(Emac Offset: 0xC0) User Input/Output Register
Definition: component_emac.h:88
#define EMAC_NCFGR_RLCE
(EMAC_NCFGR) Receive Length field Checking Enable
Definition: component_emac.h:126
#define EMAC_USRIO_CLKEN
(EMAC_USRIO) Clock Enable
Definition: component_emac.h:330
#define EMAC_NCFGR_SPD
(EMAC_NCFGR) Speed
Definition: component_emac.h:104
RwReg EMAC_SAxT
(EmacSa Offset: 0x4) Specific Address 1 Top Register
Definition: component_emac.h:43
Definition: emac.h:174
uint16_t us_tx_tail
Definition: emac.h:250
emac_dev_wakeup_cb_t func_wakeup_cb
Definition: emac.h:238
RwReg EMAC_TSR
(Emac Offset: 0x14) Transmit Status Register
Definition: component_emac.h:52
#define EMAC_NCFGR_IRXFCS
(EMAC_NCFGR) Ignore RX FCS
Definition: component_emac.h:129
RwReg EMAC_TID
(Emac Offset: 0xB8) Type ID Checking Register
Definition: component_emac.h:86
EmacSa EMAC_SA[EMACSA_NUMBER]
(Emac Offset: 0x98) sa = 1 .. 4
Definition: component_emac.h:85
emac_dev_tx_cb_t func_rx_cb
Definition: emac.h:236
RwReg EMAC_PTR
(Emac Offset: 0x38) Pause Time Register
Definition: component_emac.h:61
#define EMAC_NCR_TE
(EMAC_NCR) Transmit enable
Definition: component_emac.h:95
#define EMAC_MAN_SOF_VALUE
Definition: emac.h:109
#define EMAC_NCFGR_UNI
(EMAC_NCFGR) Unicast Hash Enable
Definition: component_emac.h:110
#define EMAC_MAN_READ_ONLY
Definition: emac.h:115
Definition: emac.h:140
#define EMAC_NCR_THALT
(EMAC_NCR) Transmit halt
Definition: component_emac.h:102
Definition: emac.h:126
#define EMAC_NCFGR_FD
(EMAC_NCFGR) Full Duplex
Definition: component_emac.h:105
#define EMAC_NCFGR_RTY
(EMAC_NCFGR) Retry test
Definition: component_emac.h:118
uint16_t us_rx_list_size
Definition: emac.h:242
Definition: emac.h:125
Definition: component_emac.h:47
#define EMAC_NCFGR_NBC
(EMAC_NCFGR) No Broadcast
Definition: component_emac.h:108
#define EMAC_NCFGR_RBOF_Msk
(EMAC_NCFGR) Receive Buffer Offset
Definition: component_emac.h:121
RwReg EMAC_NCR
(Emac Offset: 0x00) Network Control Register
Definition: component_emac.h:48
uint16_t us_rx_idx
Definition: emac.h:244
uint32_t b_ownership
Definition: emac.h:143
WoReg EMAC_IER
(Emac Offset: 0x28) Interrupt Enable Register
Definition: component_emac.h:57
RwReg EMAC_RSR
(Emac Offset: 0x20) Receive Status Register
Definition: component_emac.h:55
#define EMAC_TBQP_ADDR_Msk
(EMAC_TBQP) Transmit buffer queue pointer address
Definition: component_emac.h:147
#define EMAC_NCFGR_CAF
(EMAC_NCFGR) Copy All Frames
Definition: component_emac.h:107
RwReg EMAC_NCFGR
(Emac Offset: 0x04) Network Configuration Register
Definition: component_emac.h:49
emac_tx_descriptor_t * p_tx_dscr
Definition: emac.h:234
#define EMAC_NCFGR_PAE
(EMAC_NCFGR) Pause Enable
Definition: component_emac.h:119
Definition: emac.h:127
uint8_t * p_tx_buffer
Definition: emac.h:228
emac_rx_descriptor_t * p_rx_dscr
Definition: emac.h:232
#define EMAC_NCFGR_EFRHD
(EMAC_NCFGR)
Definition: component_emac.h:128
#define EMAC_NCFGR_DRFCS
(EMAC_NCFGR) Discard Receive FCS
Definition: component_emac.h:127