44 #ifndef EMAC_H_INCLUDED 45 #define EMAC_H_INCLUDED 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 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) 106 #define EMAC_MAN_CODE_VALUE (10) 109 #define EMAC_MAN_SOF_VALUE (1) 112 #define EMAC_MAN_RW_TYPE (2) 115 #define EMAC_MAN_READ_ONLY (1) 118 #define EMAC_ADDR_LENGTH (6) 133 #if defined __ICCARM__ 135 #define __attribute__(...) 157 b_priority_detected:1,
167 b_multi_hash_match:1,
168 b_boardcast_detect:1;
202 uint8_t uc_copy_all_frame;
204 uint8_t uc_no_boardcast;
262 static inline void emac_network_control(
Emac* p_emac, uint32_t ul_ncr)
273 static inline uint32_t emac_get_network_control(
Emac* p_emac)
284 static inline void emac_enable_receive(
Emac* p_emac, uint8_t uc_enable)
299 static inline void emac_enable_transmit(
Emac* p_emac, uint8_t uc_enable)
314 static inline void emac_enable_management(
Emac* p_emac, uint8_t uc_enable)
328 static inline void emac_clear_statistics(
Emac* p_emac)
338 static inline void emac_increase_statistics(
Emac* p_emac)
349 static inline void emac_enable_statistics_write(
Emac* p_emac,
365 static inline void emac_enable_back_pressure(
Emac* p_emac, uint8_t uc_enable)
379 static inline void emac_start_transmission(
Emac* p_emac)
389 static inline void emac_halt_transmission(
Emac* p_emac)
400 static inline void emac_set_configure(
Emac* p_emac, uint32_t ul_cfg)
412 static inline uint32_t emac_get_configure(
Emac* p_emac)
423 static inline void emac_set_speed(
Emac* p_emac, uint8_t uc_speed)
438 static inline void emac_enable_full_duplex(
Emac* p_emac, uint8_t uc_enable)
453 static inline void emac_enable_copy_all(
Emac* p_emac, uint8_t uc_enable)
468 static inline void emac_enable_jumbo_frames(
Emac* p_emac, uint8_t uc_enable)
483 static inline void emac_disable_broadcast(
Emac* p_emac, uint8_t uc_enable)
498 static inline void emac_enable_multicast_hash(
Emac* p_emac, uint8_t uc_enable)
513 static inline void emac_enable_big_frame(
Emac* p_emac, uint8_t uc_enable)
530 static inline uint8_t emac_set_clock(
Emac* p_emac, uint32_t ul_mck)
536 }
else if (ul_mck > EMAC_CLOCK_SPEED_80MHZ) {
538 }
else if (ul_mck > EMAC_CLOCK_SPEED_40MHZ) {
540 }
else if (ul_mck > EMAC_CLOCK_SPEED_20MHZ) {
558 static inline void emac_enable_retry_test(
Emac* p_emac, uint8_t uc_enable)
573 static inline void emac_enable_pause_frame(
Emac* p_emac, uint8_t uc_enable)
587 static inline void emac_set_rx_buffer_offset(
Emac* p_emac, uint8_t uc_offset)
600 static inline void emac_enable_rx_length_check(
Emac* p_emac, uint8_t uc_enable)
615 static inline void emac_enable_discard_fcs(
Emac* p_emac, uint8_t uc_enable)
632 static inline void emac_enable_efrhd(
Emac* p_emac, uint8_t uc_enable)
647 static inline void emac_enable_ignore_rx_fcs(
Emac* p_emac, uint8_t uc_enable)
663 static inline uint32_t emac_get_status(
Emac* p_emac)
675 static inline uint8_t emac_get_MDIO(
Emac* p_emac)
687 static inline uint8_t emac_is_phy_idle(
Emac* p_emac)
699 static inline uint32_t emac_get_tx_status(
Emac* p_emac)
710 static inline void emac_clear_tx_status(
Emac* p_emac, uint32_t ul_status)
720 static inline uint32_t emac_get_rx_status(
Emac* p_emac)
731 static inline void emac_clear_rx_status(
Emac* p_emac, uint32_t ul_status)
742 static inline void emac_set_rx_queue(
Emac* p_emac, uint32_t ul_addr)
754 static inline uint32_t emac_get_rx_queue(
Emac* p_emac)
765 static inline void emac_set_tx_queue(
Emac* p_emac, uint32_t ul_addr)
777 static inline uint32_t emac_get_tx_queue(
Emac* p_emac)
788 static inline void emac_enable_interrupt(
Emac* p_emac, uint32_t ul_source)
799 static inline void emac_disable_interrupt(
Emac* p_emac, uint32_t ul_source)
811 static inline uint32_t emac_get_interrupt_status(
Emac* p_emac)
823 static inline uint32_t emac_get_interrupt_mask(
Emac* p_emac)
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,
846 | EMAC_MAN_PHYA(uc_phy_addr)
847 | EMAC_MAN_REGA(uc_reg_addr)
849 | EMAC_MAN_DATA(us_data);
859 static inline uint16_t emac_get_phy_data(
Emac* p_emac)
873 static inline void emac_set_pause_time(
Emac* p_emac, uint16_t us_pause_time)
885 static inline void emac_set_hash(
Emac* p_emac, uint32_t ul_hash_top,
886 uint32_t ul_hash_bottom)
898 static inline void emac_set_hash64(
Emac* p_emac, uint64_t ull_hash)
900 p_emac->
EMAC_HRB = (uint32_t) ull_hash;
901 p_emac->
EMAC_HRT = (uint32_t) (ull_hash >> 32);
911 static inline void emac_set_address(
Emac* p_emac, uint8_t uc_index,
915 | (p_mac_addr[2] << 16)
916 | (p_mac_addr[1] << 8)
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)
944 static inline void emac_set_address64(
Emac* p_emac, uint8_t uc_index,
957 static inline void emac_set_type_id(
Emac* p_emac, uint16_t us_type_id)
959 p_emac->
EMAC_TID = EMAC_TID_TID(us_type_id);
969 static inline uint16_t emac_get_type_id(
Emac* p_emac)
980 static inline void emac_enable_rmii(
Emac* p_emac, uint8_t uc_enable)
995 static inline void emac_enable_transceiver_clock(
Emac* p_emac,
1005 uint8_t emac_phy_read(
Emac* p_emac, uint8_t uc_phy_address, uint8_t uc_address,
1007 uint8_t emac_phy_write(
Emac* p_emac, uint8_t uc_phy_address,
1008 uint8_t uc_address, uint32_t ul_value);
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,
1018 uint8_t emac_dev_set_tx_wakeup_callback(
emac_device_t* p_emac_dev,
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
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
uint32_t b_wrap
Definition: emac.h:143
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
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
uint32_t addr_dw
Definition: emac.h:143
#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
#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
#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
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
#define EMAC_NCR_THALT
(EMAC_NCR) Transmit halt
Definition: component_emac.h:102
#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: 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
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