EE445M RTOS
Taken at the University of Texas Spring 2015
Emac_api

Data Structures

union  tEMACDES3
 
struct  tEMACDMADescriptor
 A structure defining a single Ethernet DMA buffer descriptor. More...
 
struct  tEMACWakeUpFrameFilter
 

Macros

#define VALID_CONFIG_FLAGS
 
#define VALID_FRMFILTER_FLAGS
 
#define EMAC_MASKABLE_INTS
 
#define EMAC_NORMAL_INTS
 
#define EMAC_ABNORMAL_INTS
 
#define EMAC_NON_MASKED_INTS
 
#define NUM_MAC_ADDR   4
 
#define MAC_ADDR_OFFSET   (EMAC_O_ADDR1L - EMAC_O_ADDR0L)
 
#define EMAC_O_ADDRL(n)   (EMAC_O_ADDR0L + (MAC_ADDR_OFFSET * (n)))
 
#define EMAC_O_ADDRH(n)   (EMAC_O_ADDR0H + (MAC_ADDR_OFFSET * (n)))
 
#define NUM_CLOCK_DIVISORS
 
#define EMAC_PHY_ADDR   0
 
#define htonl(a)
 
#define ntohl(a)   htonl((a))
 
#define htons(a)
 
#define ntohs(a)   htons((a))
 
#define DES0_TX_CTRL_OWN   0x80000000
 
#define DES0_TX_CTRL_INTERRUPT   0x40000000
 
#define DES0_TX_CTRL_LAST_SEG   0x20000000
 
#define DES0_TX_CTRL_FIRST_SEG   0x10000000
 
#define DES0_TX_CTRL_DISABLE_CRC   0x08000000
 
#define DES0_TX_CTRL_DISABLE_PADDING   0x04000000
 
#define DES0_TX_CTRL_ENABLE_TS   0x02000000
 
#define DES0_TX_CTRL_REPLACE_CRC   0x01000000
 
#define DES0_TX_CTRL_CHKSUM_M   0x00C00000
 
#define DES0_TX_CTRL_NO_CHKSUM   0x00000000
 
#define DES0_TX_CTRL_IP_HDR_CHKSUM   0x00400000
 
#define DES0_TX_CTRL_IP_HDR_PAY_CHKSUM   0x00800000
 
#define DES0_TX_CTRL_IP_ALL_CKHSUMS   0x00C00000
 
#define DES0_TX_CTRL_END_OF_RING   0x00200000
 
#define DES0_TX_CTRL_CHAINED   0x00100000
 
#define DES0_TX_CTRL_VLAN_M   0x000C0000
 
#define DES0_TX_CTRL_VLAN_NONE   0x00000000
 
#define DES0_TX_CTRL_VLAN_REMOVE   0x00040000
 
#define DES0_TX_CTRL_VLAN_INSERT   0x00080000
 
#define DES0_TX_CTRL_VLAN_REPLACE   0x000C0000
 
#define DES0_TX_STAT_TS_CAPTURED   0x00020000
 
#define DES0_TX_STAT_IPH_ERR   0x00010000
 
#define DES0_TX_STAT_ERR   0x00008000
 
#define DES0_TX_STAT_JABBER_TO   0x00004000
 
#define DES0_TX_STAT_FLUSHED   0x00002000
 
#define DES0_TX_STAT_PAYLOAD_ERR   0x00001000
 
#define DES0_TX_STAT_CARRIER_LOST   0x00000800
 
#define DES0_TX_STAT_NO_CARRIER   0x00000400
 
#define DES0_TX_STAT_TX_L_COLLISION   0x00000200
 
#define DES0_TX_STAT_E_COLLISION   0x00000100
 
#define DES0_TX_STAT_VLAN_FRAME   0x00000080
 
#define DES0_TX_STAT_COL_COUNT_M   0x00000078
 
#define DES0_TX_STAT_COL_COUNT_S   3
 
#define DES0_TX_STAT_E_DEFERRAL   0x00000004
 
#define DES0_TX_STAT_UNDERFLOW   0x00000002
 
#define DES0_TX_STAT_DEFERRED   0x00000001
 
#define DES1_TX_CTRL_SADDR_MAC1   0x80000000
 
#define DES1_TX_CTRL_SADDR_M   0x60000000
 
#define DES1_TX_CTRL_SADDR_NONE   0x00000000
 
#define DES1_TX_CTRL_SADDR_INSERT   0x20000000
 
#define DES1_TX_CTRL_SADDR_REPLACE   0x40000000
 
#define DES1_TX_CTRL_BUFF2_SIZE_M   0x1FFF0000
 
#define DES1_TX_CTRL_BUFF1_SIZE_M   0x00001FFF
 
#define DES1_TX_CTRL_BUFF2_SIZE_S   16
 
#define DES1_TX_CTRL_BUFF1_SIZE_S   0
 
#define DES0_RX_CTRL_OWN   0x80000000
 
#define DES0_RX_STAT_DEST_ADDR_FAIL   0x40000000
 
#define DES0_RX_STAT_FRAME_LENGTH_M   0x3FFF0000
 
#define DES0_RX_STAT_FRAME_LENGTH_S   16
 
#define DES0_RX_STAT_ERR   0x00008000
 
#define DES0_RX_STAT_DESCRIPTOR_ERR   0x00004000
 
#define DES0_RX_STAT_SRC_ADDR_FAIL   0x00002000
 
#define DES0_RX_STAT_LENGTH_ERR   0x00001000
 
#define DES0_RX_STAT_OVERFLOW   0x00000800
 
#define DES0_RX_STAT_VLAN_TAG   0x00000400
 
#define DES0_RX_STAT_FIRST_DESC   0x00000200
 
#define DES0_RX_STAT_LAST_DESC   0x00000100
 
#define DES0_RX_STAT_TS_AVAILABLE   0x00000080
 
#define DES0_RX_STAT_RX_L_COLLISION   0x00000040
 
#define DES0_RX_STAT_FRAME_TYPE   0x00000020
 
#define DES0_RX_STAT_WDOG_TIMEOUT   0x00000010
 
#define DES0_RX_STAT_RX_ERR   0x00000008
 
#define DES0_RX_STAT_DRIBBLE_ERR   0x00000004
 
#define DES0_RX_STAT_CRC_ERR   0x00000002
 
#define DES0_RX_STAT_MAC_ADDR   0x00000001
 
#define DES0_RX_STAT_EXT_AVAILABLE   0x00000001
 
#define DES1_RX_CTRL_DISABLE_INT   0x80000000
 
#define DES1_RX_CTRL_BUFF2_SIZE_M   0x1FFF0000
 
#define DES1_RX_CTRL_BUFF2_SIZE_S   16
 
#define DES1_RX_CTRL_END_OF_RING   0x00008000
 
#define DES1_RX_CTRL_CHAINED   0x00004000
 
#define DES1_RX_CTRL_BUFF1_SIZE_M   0x00001FFF
 
#define DES1_RX_CTRL_BUFF1_SIZE_S   0
 
#define DES4_RX_STAT_TS_DROPPED   0x00004000
 
#define DES4_RX_STAT_PTP_VERSION2   0x00002000
 
#define DES4_RX_STAT_PTP_TYPE_ETH   0x00001000
 
#define DES4_RX_STAT_PTP_TYPE_UDP   0x00000000
 
#define DES4_RX_STAT_PTP_MT_M   0x00000F00
 
#define DES4_RX_STAT_PTP_MT_NONE   0x00000000
 
#define DES4_RX_STAT_PTP_MT_SYNC   0x00000100
 
#define DES4_RX_STAT_PTP_MT_FOLLOW_UP   0x00000200
 
#define DES4_RX_STAT_PTP_MT_DELAY_REQ   0x00000300
 
#define DES4_RX_STAT_PTP_MT_DELAY_RESP   0x00000400
 
#define DES4_RX_STAT_PTP_MT_PDELAY_REQ   0x00000500
 
#define DES4_RX_STAT_PTP_MT_PDELAY_RESP   0x00000600
 
#define DES4_RX_STAT_PTP_MT_PDELAY_RFU   0x00000700
 
#define DES4_RX_STAT_PTP_MT_ANNOUNCE   0x00000800
 
#define DES4_RX_STAT_PTP_MT_SIGNALLING   0x00000A00
 
#define DES4_RX_STAT_PTP_MT_RESERVED   0x00000F00
 
#define DES4_RX_STAT_IPV6   0x00000080
 
#define DES4_RX_STAT_IPV4   0x00000040
 
#define DES4_RX_STAT_IP_CHK_BYPASSED   0x00000020
 
#define DES4_RX_STAT_IP_PAYLOAD_ERR   0x00000010
 
#define DES4_RX_STAT_IP_HEADER_ERR   0x00000008
 
#define DES4_RX_STAT_PAYLOAD_M   0x00000007
 
#define DES4_RX_STAT_PAYLOAD_UNKNOWN   0x00000000
 
#define DES4_RX_STAT_PAYLOAD_UDP   0x00000001
 
#define DES4_RX_STAT_PAYLOAD_TCP   0x00000002
 
#define DES4_RX_STAT_PAYLOAD_ICMP   0x00000003
 
#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_M   0x30000000
 
#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_1   0x00000000
 
#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_2   0x10000000
 
#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_3   0x20000000
 
#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_4   0x30000000
 
#define EMAC_BCONFIG_TX_PRIORITY   0x08000000
 
#define EMAC_BCONFIG_ADDR_ALIGNED   0x02000000
 
#define EMAC_BCONFIG_PRIORITY_M   0x0000C000
 
#define EMAC_BCONFIG_PRIORITY_1_1   (0 << 14)
 
#define EMAC_BCONFIG_PRIORITY_2_1   (1 << 14)
 
#define EMAC_BCONFIG_PRIORITY_3_1   (2 << 14)
 
#define EMAC_BCONFIG_PRIORITY_4_1   (3 << 14)
 
#define EMAC_BCONFIG_PRIORITY_FIXED   0x00000002
 
#define EMAC_BCONFIG_FIXED_BURST   0x00010000
 
#define EMAC_BCONFIG_MIXED_BURST   0x04000000
 
#define EMAC_PHY_TYPE_INTERNAL   0x00000000
 
#define EMAC_PHY_TYPE_EXTERNAL_MII   0x80000000
 
#define EMAC_PHY_TYPE_EXTERNAL_RMII   0xC0000000
 
#define EMAC_PHY_INT_NIB_TXERR_DET_DIS   0x01000000
 
#define EMAC_PHY_INT_RX_ER_DURING_IDLE   0x00800000
 
#define EMAC_PHY_INT_ISOLATE_MII_LLOSS   0x00400000
 
#define EMAC_PHY_INT_LINK_LOSS_RECOVERY   0x00200000
 
#define EMAC_PHY_INT_TDRRUN   0x00100000
 
#define EMAC_PHY_INT_LD_ON_RX_ERR_COUNT   0x00040000
 
#define EMAC_PHY_INT_LD_ON_MTL3_ERR_COUNT   0x00020000
 
#define EMAC_PHY_INT_LD_ON_LOW_SNR   0x00010000
 
#define EMAC_PHY_INT_LD_ON_SIGNAL_ENERGY   0x00008000
 
#define EMAC_PHY_INT_POLARITY_SWAP   0x00004000
 
#define EMAC_PHY_INT_MDI_SWAP   0x00002000
 
#define EMAC_PHY_INT_ROBUST_MDIX   0x00001000
 
#define EMAC_PHY_INT_FAST_MDIX   0x00000800
 
#define EMAC_PHY_INT_MDIX_EN   0x00000400
 
#define EMAC_PHY_INT_FAST_RXDV_DETECT   0x00000200
 
#define EMAC_PHY_INT_FAST_L_UP_DETECT   0x00000100
 
#define EMAC_PHY_INT_EXT_FULL_DUPLEX   0x00000080
 
#define EMAC_PHY_INT_FAST_AN_80_50_35   0x00000040
 
#define EMAC_PHY_INT_FAST_AN_120_75_50   0x00000050
 
#define EMAC_PHY_INT_FAST_AN_140_150_100   0x00000060
 
#define EMAC_PHY_FORCE_10B_T_HALF_DUPLEX   0x00000000
 
#define EMAC_PHY_FORCE_10B_T_FULL_DUPLEX   0x00000002
 
#define EMAC_PHY_FORCE_100B_T_HALF_DUPLEX   0x00000004
 
#define EMAC_PHY_FORCE_100B_T_FULL_DUPLEX   0x00000006
 
#define EMAC_PHY_AN_10B_T_HALF_DUPLEX   0x00000008
 
#define EMAC_PHY_AN_10B_T_FULL_DUPLEX   0x0000000A
 
#define EMAC_PHY_AN_100B_T_HALF_DUPLEX   0x0000000C
 
#define EMAC_PHY_AN_100B_T_FULL_DUPLEX   0x0000000E
 
#define EMAC_PHY_INT_HOLD   0x00000001
 
#define EMAC_PHY_TYPE_MASK   0xC0000000
 
#define EMAC_CONFIG_USE_MACADDR1   0x40000000
 
#define EMAC_CONFIG_USE_MACADDR0   0x00000000
 
#define EMAC_CONFIG_SA_FROM_DESCRIPTOR   0x00000000
 
#define EMAC_CONFIG_SA_INSERT   0x20000000
 
#define EMAC_CONFIG_SA_REPLACE   0x30000000
 
#define EMAC_CONFIG_2K_PACKETS   0x08000000
 
#define EMAC_CONFIG_STRIP_CRC   0x02000000
 
#define EMAC_CONFIG_JABBER_DISABLE   0x00400000
 
#define EMAC_CONFIG_JUMBO_ENABLE   0x00100000
 
#define EMAC_CONFIG_IF_GAP_MASK   0x000E0000
 
#define EMAC_CONFIG_IF_GAP_96BITS   (0x0 << 17)
 
#define EMAC_CONFIG_IF_GAP_88BITS   (0x1 << 17)
 
#define EMAC_CONFIG_IF_GAP_80BITS   (0x2 << 17)
 
#define EMAC_CONFIG_IF_GAP_72BITS   (0x3 << 17)
 
#define EMAC_CONFIG_IF_GAP_64BITS   (0x4 << 17)
 
#define EMAC_CONFIG_IF_GAP_56BITS   (0x5 << 17)
 
#define EMAC_CONFIG_IF_GAP_48BITS   (0x6 << 17)
 
#define EMAC_CONFIG_IF_GAP_40BITS   (0x7 << 17)
 
#define EMAC_CONFIG_CS_DISABLE   0x00010000
 
#define EMAC_CONFIG_100MBPS   0x00004000
 
#define EMAC_CONFIG_10MBPS   0x00000000
 
#define EMAC_CONFIG_RX_OWN_DISABLE   0x00002000
 
#define EMAC_CONFIG_LOOPBACK   0x00001000
 
#define EMAC_CONFIG_FULL_DUPLEX   0x00000800
 
#define EMAC_CONFIG_HALF_DUPLEX   0x00000000
 
#define EMAC_CONFIG_CHECKSUM_OFFLOAD   0x00000400
 
#define EMAC_CONFIG_RETRY_DISABLE   0x00000200
 
#define EMAC_CONFIG_AUTO_CRC_STRIPPING   0x00000080
 
#define EMAC_CONFIG_BO_MASK   0x00000060
 
#define EMAC_CONFIG_BO_LIMIT_1024   (0x0 << 5)
 
#define EMAC_CONFIG_BO_LIMIT_256   (0x1 << 5)
 
#define EMAC_CONFIG_BO_LIMIT_16   (0x2 << 5)
 
#define EMAC_CONFIG_BO_LIMIT_2   (0x3 << 5)
 
#define EMAC_CONFIG_DEFERRAL_CHK_ENABLE   0x00000010
 
#define EMAC_CONFIG_PREAMBLE_MASK   0x00000003
 
#define EMAC_CONFIG_7BYTE_PREAMBLE   0x00000000
 
#define EMAC_CONFIG_5BYTE_PREAMBLE   0x00000001
 
#define EMAC_CONFIG_3BYTE_PREAMBLE   0x00000002
 
#define EMAC_MODE_KEEP_BAD_CRC   0x04000000
 
#define EMAC_MODE_RX_STORE_FORWARD   0x02000000
 
#define EMAC_MODE_RX_FLUSH_DISABLE   0x01000000
 
#define EMAC_MODE_TX_STORE_FORWARD   0x00200000
 
#define EMAC_MODE_TX_THRESHOLD_16_BYTES   (7 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_24_BYTES   (6 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_32_BYTES   (5 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_40_BYTES   (4 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_64_BYTES   (0 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_128_BYTES   (1 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_192_BYTES   (2 << 14)
 
#define EMAC_MODE_TX_THRESHOLD_256_BYTES   (3 << 14)
 
#define EMAC_MODE_RX_ERROR_FRAMES   0x00000080
 
#define EMAC_MODE_RX_UNDERSIZED_FRAMES   0x00000040
 
#define EMAC_MODE_RX_THRESHOLD_64_BYTES   (0 << 3)
 
#define EMAC_MODE_RX_THRESHOLD_32_BYTES   (1 << 3)
 
#define EMAC_MODE_RX_THRESHOLD_96_BYTES   (2 << 3)
 
#define EMAC_MODE_RX_THRESHOLD_128_BYTES   (3 << 3)
 
#define EMAC_MODE_OPERATE_2ND_FRAME   0x00000002
 
#define EMAC_CONFIG_TX_ENABLED   0x00000008
 
#define EMAC_CONFIG_RX_ENABLED   0x00000004
 
#define EMAC_MODE_TX_DMA_ENABLED   0x00002000
 
#define EMAC_MODE_RX_DMA_ENABLED   0x00000002
 
#define EMAC_FRMFILTER_RX_ALL   0x80000000
 
#define EMAC_FRMFILTER_VLAN   0x00010000
 
#define EMAC_FRMFILTER_HASH_AND_PERFECT   0x00000400
 
#define EMAC_FRMFILTER_SADDR   0x00000200
 
#define EMAC_FRMFILTER_INV_SADDR   0x00000100
 
#define EMAC_FRMFILTER_PASS_MASK   (0x03 << 6)
 
#define EMAC_FRMFILTER_PASS_NO_CTRL   (0x00 << 6)
 
#define EMAC_FRMFILTER_PASS_NO_PAUSE   (0x01 << 6)
 
#define EMAC_FRMFILTER_PASS_ALL_CTRL   (0x02 << 6)
 
#define EMAC_FRMFILTER_PASS_ADDR_CTRL   (0x03 << 6)
 
#define EMAC_FRMFILTER_BROADCAST   0x00000020
 
#define EMAC_FRMFILTER_PASS_MULTICAST   0x00000010
 
#define EMAC_FRMFILTER_INV_DADDR   0x00000008
 
#define EMAC_FRMFILTER_HASH_MULTICAST   0x00000004
 
#define EMAC_FRMFILTER_HASH_UNICAST   0x00000002
 
#define EMAC_FRMFILTER_PROMISCUOUS   0x00000001
 
#define EMAC_STATUS_TX_NOT_EMPTY   0x01000000
 
#define EMAC_STATUS_TX_WRITING_FIFO   0x00400000
 
#define EMAC_STATUS_TRC_STATE_MASK   0x00300000
 
#define EMAC_STATUS_TRC_STATE_IDLE   (0x00 << 20)
 
#define EMAC_STATUS_TRC_STATE_READING   (0x01 << 20)
 
#define EMAC_STATUS_TRC_STATE_WAITING   (0x02 << 20)
 
#define EMAC_STATUS_TRC_STATE_STATUS   (0x03 << 20)
 
#define EMAC_STATUS_TX_PAUSED   0x00080000
 
#define EMAC_STATUS_TFC_STATE_MASK   0x00060000
 
#define EMAC_STATUS_TFC_STATE_IDLE   (0x00 << 17)
 
#define EMAC_STATUS_TFC_STATE_WAITING   (0x01 << 17)
 
#define EMAC_STATUS_TFC_STATE_PAUSING   (0x02 << 17)
 
#define EMAC_STATUS_TFC_STATE_WRITING   (0x03 << 17)
 
#define EMAC_STATUS_MAC_NOT_IDLE   0x00010000
 
#define EMAC_STATUS_RX_FIFO_LEVEL_MASK   0x00000300
 
#define EMAC_STATUS_RX_FIFO_EMPTY   (0x00 << 8)
 
#define EMAC_STATUS_RX_FIFO_BELOW   (0x01 << 8)
 
#define EMAC_STATUS_RX_FIFO_ABOVE   (0x02 << 8)
 
#define EMAC_STATUS_RX_FIFO_FULL   (0x03 << 8)
 
#define EMAC_STATUS_RX_FIFO_STATE_MASK   0x00000060
 
#define EMAC_STATUS_RX_FIFO_IDLE   (0x00 << 5)
 
#define EMAC_STATUS_RX_FIFO_READING   (0x01 << 5)
 
#define EMAC_STATUS_RX_FIFO_STATUS   (0x02 << 5)
 
#define EMAC_STATUS_RX_FIFO_FLUSHING   (0x03 << 5)
 
#define EMAC_STATUS_RWC_ACTIVE   0x00000010
 
#define EMAC_STATUS_RPE_ACTIVE   0x00000001
 
#define EMAC_DMA_TXSTAT_MASK   (0x07 << 20)
 
#define EMAC_DMA_TXSTAT_STOPPED   (0x00 << 20)
 
#define EMAC_DMA_TXSTAT_RUN_FETCH_DESC   (0x01 << 20)
 
#define EMAC_DMA_TXSTAT_RUN_WAIT_STATUS   (0x02 << 20)
 
#define EMAC_DMA_TXSTAT_RUN_READING   (0x03 << 20)
 
#define EMAC_DMA_TXSTAT_RUN_CLOSE_DESC   (0x07 << 20)
 
#define EMAC_DMA_TXSTAT_TS_WRITE   (0x04 << 20)
 
#define EMAC_DMA_TXSTAT_SUSPENDED   (0x06 << 20)
 
#define EMAC_DMA_RXSTAT_MASK   (0x07 << 17)
 
#define EMAC_DMA_RXSTAT_STOPPED   (0x00 << 17)
 
#define EMAC_DMA_RXSTAT_RUN_FETCH_DESC   (0x01 << 17)
 
#define EMAC_DMA_RXSTAT_RUN_WAIT_PACKET   (0x03 << 17)
 
#define EMAC_DMA_RXSTAT_SUSPENDED   (0x04 << 17)
 
#define EMAC_DMA_RXSTAT_RUN_CLOSE_DESC   (0x05 << 17)
 
#define EMAC_DMA_RXSTAT_TS_WRITE   (0x06 << 17)
 
#define EMAC_DMA_RXSTAT_RUN_RECEIVING   (0x07 << 17)
 
#define EMAC_TX_DMA_STATE(x)   ((x) & EMAC_DMA_TXSTAT_MASK)
 
#define EMAC_RX_DMA_STATE(x)   ((x) & EMAC_DMA_RXSTAT_MASK)
 
#define EMAC_DMA_ERROR   0x00002000
 
#define EMAC_DMA_ERR_MASK   0x03800000
 
#define EMAC_DMA_ERR_RX_DATA_WRITE   0x00000000
 
#define EMAC_DMA_ERR_TX_DATA_READ   0x01800000
 
#define EMAC_DMA_ERR_RX_DESC_WRITE   0x02000000
 
#define EMAC_DMA_ERR_TX_DESC_WRITE   0x02800000
 
#define EMAC_DMA_ERR_RX_DESC_READ   0x03000000
 
#define EMAC_DMA_ERR_TX_DESC_READ   0x03800000
 
#define EMAC_FILTER_ADDR_ENABLE   0x80000000
 
#define EMAC_FILTER_SOURCE_ADDR   0x40000000
 
#define EMAC_FILTER_MASK_BYTE_6   0x20000000
 
#define EMAC_FILTER_MASK_BYTE_5   0x10000000
 
#define EMAC_FILTER_MASK_BYTE_4   0x08000000
 
#define EMAC_FILTER_MASK_BYTE_3   0x04000000
 
#define EMAC_FILTER_MASK_BYTE_2   0x03000000
 
#define EMAC_FILTER_MASK_BYTE_1   0x01000000
 
#define EMAC_FILTER_BYTE_MASK_M   0x3F000000
 
#define EMAC_FILTER_BYTE_MASK_S   24
 
#define EMAC_TS_MAC_FILTER_ENABLE   0x00040000
 
#define EMAC_TS_MAC_FILTER_DISABLE   0x00000000
 
#define EMAC_TS_SYNC_FOLLOW_DREQ_DRESP   0x00000000
 
#define EMAC_TS_SYNC_ONLY   0x00004000
 
#define EMAC_TS_DELAYREQ_ONLY   0x0000C000
 
#define EMAC_TS_ALL   0x00010000
 
#define EMAC_TS_SYNC_PDREQ_PDRESP   0x00014000
 
#define EMAC_TS_DREQ_PDREQ_PDRESP   0x0001C000
 
#define EMAC_TS_SYNC_DELAYREQ   0x00020000
 
#define EMAC_TS_PDREQ_PDRESP   0x00030000
 
#define EMAC_TS_PROCESS_IPV4_UDP   0x00002000
 
#define EMAC_TS_PROCESS_IPV6_UDP   0x00001000
 
#define EMAC_TS_PROCESS_ETHERNET   0x00000800
 
#define EMAC_TS_PTP_VERSION_2   0x00000400
 
#define EMAC_TS_PTP_VERSION_1   0x00000000
 
#define EMAC_TS_DIGITAL_ROLLOVER   0x00000200
 
#define EMAC_TS_BINARY_ROLLOVER   0x00000000
 
#define EMAC_TS_ALL_RX_FRAMES   0x00000100
 
#define EMAC_TS_UPDATE_FINE   0x00000002
 
#define EMAC_TS_UPDATE_COARSE   0x00000000
 
#define EPHY_SCR_INPOL_EXT   0x00000008
 
#define EPHY_SCR_TINT_EXT   0x00000004
 
#define EPHY_SCR_INTEN_EXT   0x00000002
 
#define EPHY_SCR_INTOE_EXT   0x00000001
 
#define EMAC_INT_PHY   0x80000000
 
#define EMAC_INT_EARLY_RECEIVE   0x00004000
 
#define EMAC_INT_BUS_ERROR   0x00002000
 
#define EMAC_INT_EARLY_TRANSMIT   0x00000400
 
#define EMAC_INT_RX_WATCHDOG   0x00000200
 
#define EMAC_INT_RX_STOPPED   0x00000100
 
#define EMAC_INT_RX_NO_BUFFER   0x00000080
 
#define EMAC_INT_RECEIVE   0x00000040
 
#define EMAC_INT_TX_UNDERFLOW   0x00000020
 
#define EMAC_INT_RX_OVERFLOW   0x00000010
 
#define EMAC_INT_TX_JABBER   0x00000008
 
#define EMAC_INT_TX_NO_BUFFER   0x00000004
 
#define EMAC_INT_TX_STOPPED   0x00000002
 
#define EMAC_INT_TRANSMIT   0x00000001
 
#define EMAC_INT_NORMAL_INT   0x00010000
 
#define EMAC_INT_ABNORMAL_INT   0x00008000
 
#define EMAC_INT_TIMESTAMP   0x20000000
 
#define EMAC_TS_INT_TARGET_REACHED   0x00000002
 
#define EMAC_TS_INT_TS_SEC_OVERFLOW   0x00000001
 
#define EMAC_INT_POWER_MGMNT   0x10000000
 
#define EMAC_PPS_SINGLE_PULSE   0x00000000
 
#define EMAC_PPS_1HZ   0x00000001
 
#define EMAC_PPS_2HZ   0x00000002
 
#define EMAC_PPS_4HZ   0x00000003
 
#define EMAC_PPS_8HZ   0x00000004
 
#define EMAC_PPS_16HZ   0x00000005
 
#define EMAC_PPS_32HZ   0x00000006
 
#define EMAC_PPS_64HZ   0x00000007
 
#define EMAC_PPS_128HZ   0x00000008
 
#define EMAC_PPS_256HZ   0x00000009
 
#define EMAC_PPS_512HZ   0x0000000A
 
#define EMAC_PPS_1024HZ   0x0000000B
 
#define EMAC_PPS_2048HZ   0x0000000C
 
#define EMAC_PPS_4096HZ   0x0000000D
 
#define EMAC_PPS_8192HZ   0x0000000E
 
#define EMAC_PPS_16384HZ   0x0000000F
 
#define EMAC_PPS_32768HZ   0x00000010
 
#define EMAC_PPS_TARGET_INT   0x00000000
 
#define EMAC_PPS_TARGET_PPS   0x00000060
 
#define EMAC_PPS_TARGET_BOTH   0x00000040
 
#define EMAC_PPS_COMMAND_NONE   0x00
 
#define EMAC_PPS_COMMAND_START_SINGLE   0x01
 
#define EMAC_PPS_COMMAND_START_TRAIN   0x02
 
#define EMAC_PPS_COMMAND_CANCEL_START   0x03
 
#define EMAC_PPS_COMMAND_STOP_AT_TIME   0x04
 
#define EMAC_PPS_COMMAND_STOP_NOW   0x05
 
#define EMAC_PPS_COMMAND_CANCEL_STOP   0x06
 
#define EMAC_VLAN_RX_HASH_ENABLE   0x00080000
 
#define EMAC_VLAN_RX_HASH_DISABLE   0x00000000
 
#define EMAC_VLAN_RX_SVLAN_ENABLE   0x00040000
 
#define EMAC_VLAN_RX_SVLAN_DISABLE   0x00000000
 
#define EMAC_VLAN_RX_NORMAL_MATCH   0x00000000
 
#define EMAC_VLAN_RX_INVERSE_MATCH   0x00020000
 
#define EMAC_VLAN_RX_12BIT_TAG   0x00010000
 
#define EMAC_VLAN_RX_16BIT_TAG   0x00000000
 
#define EMAC_VLAN_TX_CVLAN   0x00000000
 
#define EMAC_VLAN_TX_SVLAN   0x00080000
 
#define EMAC_VLAN_TX_USE_VLC   0x00040000
 
#define EMAC_VLAN_TX_VLC_NONE   0x00000000
 
#define EMAC_VLAN_TX_VLC_DELETE   0x00010000
 
#define EMAC_VLAN_TX_VLC_INSERT   0x00020000
 
#define EMAC_VLAN_TX_VLC_REPLACE   0x00030000
 
#define EMAC_VLAN_TX_VLC_MASK   0x00030000
 
#define EMAC_RWU_FILTER_ENABLE   1
 
#define EMAC_RWU_FILTER_DISABLE   0
 
#define EMAC_RWU_FILTER_MULTICAST   8
 
#define EMAC_RWU_FILTER_UNICAST   0
 
#define EMAC_PMT_GLOBAL_UNICAST_ENABLE   0x00000200
 
#define EMAC_PMT_WAKEUP_PACKET_ENABLE   0x00000004
 
#define EMAC_PMT_MAGIC_PACKET_ENABLE   0x00000002
 
#define EMAC_PMT_POWER_DOWN   0x00000001
 
#define EMAC_PMT_WAKEUP_PACKET_RECEIVED   0x00000040
 
#define EMAC_PMT_MAGIC_PACKET_RECEIVED   0x00000020
 

Typedefs

typedef struct tEMACDMADescriptor tEMACDMADescriptor
 

Functions

void EMACInit (uint32_t ui32Base, uint32_t ui32SysClk, uint32_t ui32BusConfig, uint32_t ui32RxBurst, uint32_t ui32TxBurst, uint32_t ui32DescSkipSize)
 
void EMACReset (uint32_t ui32Base)
 
void EMACPHYConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void EMACConfigSet (uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32ModeFlags, uint32_t ui32RxMaxFrameSize)
 
void EMACConfigGet (uint32_t ui32Base, uint32_t *pui32Config, uint32_t *pui32Mode, uint32_t *pui32RxMaxFrameSize)
 
void EMACAddrSet (uint32_t ui32Base, uint32_t ui32Index, const uint8_t *pui8MACAddr)
 
void EMACAddrGet (uint32_t ui32Base, uint32_t ui32Index, uint8_t *pui8MACAddr)
 
uint32_t EMACNumAddrGet (uint32_t ui32Base)
 
void EMACAddrFilterSet (uint32_t ui32Base, uint32_t ui32Index, uint32_t ui32Config)
 
uint32_t EMACAddrFilterGet (uint32_t ui32Base, uint32_t ui32Index)
 
void EMACFrameFilterSet (uint32_t ui32Base, uint32_t ui32FilterOpts)
 
uint32_t EMACFrameFilterGet (uint32_t ui32Base)
 
void EMACHashFilterSet (uint32_t ui32Base, uint32_t ui32HashHi, uint32_t ui32HashLo)
 
void EMACHashFilterGet (uint32_t ui32Base, uint32_t *pui32HashHi, uint32_t *pui32HashLo)
 
uint32_t EMACHashFilterBitCalculate (uint8_t *pui8MACAddr)
 
void EMACRxWatchdogTimerSet (uint32_t ui32Base, uint8_t ui8Timeout)
 
uint32_t EMACStatusGet (uint32_t ui32Base)
 
void EMACTxDMAPollDemand (uint32_t ui32Base)
 
void EMACRxDMAPollDemand (uint32_t ui32Base)
 
void EMACRxDMADescriptorListSet (uint32_t ui32Base, tEMACDMADescriptor *pDescriptor)
 
tEMACDMADescriptorEMACRxDMADescriptorListGet (uint32_t ui32Base)
 
tEMACDMADescriptorEMACRxDMACurrentDescriptorGet (uint32_t ui32Base)
 
uint8_t * EMACRxDMACurrentBufferGet (uint32_t ui32Base)
 
void EMACTxDMADescriptorListSet (uint32_t ui32Base, tEMACDMADescriptor *pDescriptor)
 
tEMACDMADescriptorEMACTxDMADescriptorListGet (uint32_t ui32Base)
 
tEMACDMADescriptorEMACTxDMACurrentDescriptorGet (uint32_t ui32Base)
 
uint8_t * EMACTxDMACurrentBufferGet (uint32_t ui32Base)
 
uint32_t EMACDMAStateGet (uint32_t ui32Base)
 
void EMACTxFlush (uint32_t ui32Base)
 
void EMACTxEnable (uint32_t ui32Base)
 
void EMACTxDisable (uint32_t ui32Base)
 
void EMACRxEnable (uint32_t ui32Base)
 
void EMACRxDisable (uint32_t ui32Base)
 
void EMACIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void EMACIntUnregister (uint32_t ui32Base)
 
void EMACIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void EMACIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
uint32_t EMACIntStatus (uint32_t ui32Base, bool bMasked)
 
void EMACIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void EMACPHYWrite (uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr, uint16_t ui16Data)
 
uint16_t EMACPHYRead (uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr)
 
uint16_t EMACPHYExtendedRead (uint32_t ui32Base, uint8_t ui8PhyAddr, uint16_t ui16RegAddr)
 
void EMACPHYExtendedWrite (uint32_t ui32Base, uint8_t ui8PhyAddr, uint16_t ui16RegAddr, uint16_t ui16Value)
 
void EMACPHYPowerOff (uint32_t ui32Base, uint8_t ui8PhyAddr)
 
void EMACPHYPowerOn (uint32_t ui32Base, uint8_t ui8PhyAddr)
 
void EMACTimestampConfigSet (uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32SubSecondInc)
 
uint32_t EMACTimestampConfigGet (uint32_t ui32Base, uint32_t *pui32SubSecondInc)
 
void EMACTimestampEnable (uint32_t ui32Base)
 
void EMACTimestampDisable (uint32_t ui32Base)
 
void EMACTimestampSysTimeSet (uint32_t ui32Base, uint32_t ui32Seconds, uint32_t ui32SubSeconds)
 
void EMACTimestampSysTimeGet (uint32_t ui32Base, uint32_t *pui32Seconds, uint32_t *pui32SubSeconds)
 
void EMACTimestampSysTimeUpdate (uint32_t ui32Base, uint32_t ui32Seconds, uint32_t ui32SubSeconds, bool bInc)
 
void EMACTimestampAddendSet (uint32_t ui32Base, uint32_t ui32Increment)
 
void EMACTimestampTargetSet (uint32_t ui32Base, uint32_t ui32Seconds, uint32_t ui32SubSeconds)
 
void EMACTimestampTargetIntEnable (uint32_t ui32Base)
 
void EMACTimestampTargetIntDisable (uint32_t ui32Base)
 
uint32_t EMACTimestampIntStatus (uint32_t ui32Base)
 
void EMACTimestampPPSSimpleModeSet (uint32_t ui32Base, uint32_t ui32FreqConfig)
 
void EMACTimestampPPSCommandModeSet (uint32_t ui32Base, uint32_t ui32Config)
 Configures the Ethernet MAC PPS output in command mode. More...
 
void EMACTimestampPPSCommand (uint32_t ui32Base, uint8_t ui8Cmd)
 
void EMACTimestampPPSPeriodSet (uint32_t ui32Base, uint32_t ui32Period, uint32_t ui32Width)
 
void EMACVLANRxConfigSet (uint32_t ui32Base, uint16_t ui16Tag, uint32_t ui32Config)
 
uint32_t EMACVLANRxConfigGet (uint32_t ui32Base, uint16_t *pui16Tag)
 
void EMACVLANTxConfigSet (uint32_t ui32Base, uint16_t ui16Tag, uint32_t ui32Config)
 
uint32_t EMACVLANTxConfigGet (uint32_t ui32Base, uint16_t *pui16Tag)
 
uint32_t EMACVLANHashFilterBitCalculate (uint16_t ui16Tag)
 
void EMACVLANHashFilterSet (uint32_t ui32Base, uint32_t ui32Hash)
 
uint32_t EMACVLANHashFilterGet (uint32_t ui32Base)
 
void EMACRemoteWakeUpFrameFilterSet (uint32_t ui32Base, const tEMACWakeUpFrameFilter *pFilter)
 
void EMACRemoteWakeUpFrameFilterGet (uint32_t ui32Base, tEMACWakeUpFrameFilter *pFilter)
 
void EMACPowerManagementControlSet (uint32_t ui32Base, uint32_t ui32Flags)
 
uint32_t EMACPowerManagementControlGet (uint32_t ui32Base)
 
uint32_t EMACPowerManagementStatusGet (uint32_t ui32Base)
 

Variables

struct {
   uint32_t   ui32SysClockMax
 
   uint32_t   ui32Divisor
 
g_pi16MIIClockDiv []
 

Detailed Description

Macro Definition Documentation

#define DES0_RX_CTRL_OWN   0x80000000

Definition at line 288 of file emac.h.

#define DES0_RX_STAT_CRC_ERR   0x00000002

Definition at line 306 of file emac.h.

#define DES0_RX_STAT_DESCRIPTOR_ERR   0x00004000

Definition at line 293 of file emac.h.

#define DES0_RX_STAT_DEST_ADDR_FAIL   0x40000000

Definition at line 289 of file emac.h.

#define DES0_RX_STAT_DRIBBLE_ERR   0x00000004

Definition at line 305 of file emac.h.

#define DES0_RX_STAT_ERR   0x00008000

Definition at line 292 of file emac.h.

#define DES0_RX_STAT_EXT_AVAILABLE   0x00000001

Definition at line 308 of file emac.h.

#define DES0_RX_STAT_FIRST_DESC   0x00000200

Definition at line 298 of file emac.h.

#define DES0_RX_STAT_FRAME_LENGTH_M   0x3FFF0000

Definition at line 290 of file emac.h.

#define DES0_RX_STAT_FRAME_LENGTH_S   16

Definition at line 291 of file emac.h.

#define DES0_RX_STAT_FRAME_TYPE   0x00000020

Definition at line 302 of file emac.h.

#define DES0_RX_STAT_LAST_DESC   0x00000100

Definition at line 299 of file emac.h.

#define DES0_RX_STAT_LENGTH_ERR   0x00001000

Definition at line 295 of file emac.h.

#define DES0_RX_STAT_MAC_ADDR   0x00000001

Definition at line 307 of file emac.h.

#define DES0_RX_STAT_OVERFLOW   0x00000800

Definition at line 296 of file emac.h.

#define DES0_RX_STAT_RX_ERR   0x00000008

Definition at line 304 of file emac.h.

#define DES0_RX_STAT_RX_L_COLLISION   0x00000040

Definition at line 301 of file emac.h.

#define DES0_RX_STAT_SRC_ADDR_FAIL   0x00002000

Definition at line 294 of file emac.h.

#define DES0_RX_STAT_TS_AVAILABLE   0x00000080

Definition at line 300 of file emac.h.

#define DES0_RX_STAT_VLAN_TAG   0x00000400

Definition at line 297 of file emac.h.

#define DES0_RX_STAT_WDOG_TIMEOUT   0x00000010

Definition at line 303 of file emac.h.

#define DES0_TX_CTRL_CHAINED   0x00100000

Definition at line 243 of file emac.h.

#define DES0_TX_CTRL_CHKSUM_M   0x00C00000

Definition at line 237 of file emac.h.

#define DES0_TX_CTRL_DISABLE_CRC   0x08000000

Definition at line 227 of file emac.h.

#define DES0_TX_CTRL_DISABLE_PADDING   0x04000000

Definition at line 228 of file emac.h.

#define DES0_TX_CTRL_ENABLE_TS   0x02000000

Definition at line 229 of file emac.h.

#define DES0_TX_CTRL_END_OF_RING   0x00200000

Definition at line 242 of file emac.h.

#define DES0_TX_CTRL_FIRST_SEG   0x10000000

Definition at line 214 of file emac.h.

#define DES0_TX_CTRL_INTERRUPT   0x40000000

Definition at line 212 of file emac.h.

#define DES0_TX_CTRL_IP_ALL_CKHSUMS   0x00C00000

Definition at line 241 of file emac.h.

#define DES0_TX_CTRL_IP_HDR_CHKSUM   0x00400000

Definition at line 239 of file emac.h.

#define DES0_TX_CTRL_IP_HDR_PAY_CHKSUM   0x00800000

Definition at line 240 of file emac.h.

#define DES0_TX_CTRL_LAST_SEG   0x20000000

Definition at line 213 of file emac.h.

#define DES0_TX_CTRL_NO_CHKSUM   0x00000000

Definition at line 238 of file emac.h.

#define DES0_TX_CTRL_OWN   0x80000000

Definition at line 211 of file emac.h.

#define DES0_TX_CTRL_REPLACE_CRC   0x01000000

Definition at line 236 of file emac.h.

#define DES0_TX_CTRL_VLAN_INSERT   0x00080000

Definition at line 247 of file emac.h.

#define DES0_TX_CTRL_VLAN_M   0x000C0000

Definition at line 244 of file emac.h.

#define DES0_TX_CTRL_VLAN_NONE   0x00000000

Definition at line 245 of file emac.h.

#define DES0_TX_CTRL_VLAN_REMOVE   0x00040000

Definition at line 246 of file emac.h.

#define DES0_TX_CTRL_VLAN_REPLACE   0x000C0000

Definition at line 248 of file emac.h.

#define DES0_TX_STAT_CARRIER_LOST   0x00000800

Definition at line 255 of file emac.h.

#define DES0_TX_STAT_COL_COUNT_M   0x00000078

Definition at line 260 of file emac.h.

#define DES0_TX_STAT_COL_COUNT_S   3

Definition at line 261 of file emac.h.

#define DES0_TX_STAT_DEFERRED   0x00000001

Definition at line 264 of file emac.h.

#define DES0_TX_STAT_E_COLLISION   0x00000100

Definition at line 258 of file emac.h.

#define DES0_TX_STAT_E_DEFERRAL   0x00000004

Definition at line 262 of file emac.h.

#define DES0_TX_STAT_ERR   0x00008000

Definition at line 251 of file emac.h.

#define DES0_TX_STAT_FLUSHED   0x00002000

Definition at line 253 of file emac.h.

#define DES0_TX_STAT_IPH_ERR   0x00010000

Definition at line 250 of file emac.h.

#define DES0_TX_STAT_JABBER_TO   0x00004000

Definition at line 252 of file emac.h.

#define DES0_TX_STAT_NO_CARRIER   0x00000400

Definition at line 256 of file emac.h.

#define DES0_TX_STAT_PAYLOAD_ERR   0x00001000

Definition at line 254 of file emac.h.

#define DES0_TX_STAT_TS_CAPTURED   0x00020000

Definition at line 249 of file emac.h.

#define DES0_TX_STAT_TX_L_COLLISION   0x00000200

Definition at line 257 of file emac.h.

#define DES0_TX_STAT_UNDERFLOW   0x00000002

Definition at line 263 of file emac.h.

#define DES0_TX_STAT_VLAN_FRAME   0x00000080

Definition at line 259 of file emac.h.

#define DES1_RX_CTRL_BUFF1_SIZE_M   0x00001FFF

Definition at line 321 of file emac.h.

#define DES1_RX_CTRL_BUFF1_SIZE_S   0

Definition at line 322 of file emac.h.

#define DES1_RX_CTRL_BUFF2_SIZE_M   0x1FFF0000

Definition at line 317 of file emac.h.

#define DES1_RX_CTRL_BUFF2_SIZE_S   16

Definition at line 318 of file emac.h.

#define DES1_RX_CTRL_CHAINED   0x00004000

Definition at line 320 of file emac.h.

#define DES1_RX_CTRL_DISABLE_INT   0x80000000

Definition at line 316 of file emac.h.

#define DES1_RX_CTRL_END_OF_RING   0x00008000

Definition at line 319 of file emac.h.

#define DES1_TX_CTRL_BUFF1_SIZE_M   0x00001FFF

Definition at line 278 of file emac.h.

#define DES1_TX_CTRL_BUFF1_SIZE_S   0

Definition at line 280 of file emac.h.

#define DES1_TX_CTRL_BUFF2_SIZE_M   0x1FFF0000

Definition at line 277 of file emac.h.

#define DES1_TX_CTRL_BUFF2_SIZE_S   16

Definition at line 279 of file emac.h.

#define DES1_TX_CTRL_SADDR_INSERT   0x20000000

Definition at line 275 of file emac.h.

#define DES1_TX_CTRL_SADDR_M   0x60000000

Definition at line 273 of file emac.h.

#define DES1_TX_CTRL_SADDR_MAC1   0x80000000

Definition at line 272 of file emac.h.

#define DES1_TX_CTRL_SADDR_NONE   0x00000000

Definition at line 274 of file emac.h.

#define DES1_TX_CTRL_SADDR_REPLACE   0x40000000

Definition at line 276 of file emac.h.

#define DES4_RX_STAT_IP_CHK_BYPASSED   0x00000020

Definition at line 348 of file emac.h.

#define DES4_RX_STAT_IP_HEADER_ERR   0x00000008

Definition at line 350 of file emac.h.

#define DES4_RX_STAT_IP_PAYLOAD_ERR   0x00000010

Definition at line 349 of file emac.h.

#define DES4_RX_STAT_IPV4   0x00000040

Definition at line 347 of file emac.h.

#define DES4_RX_STAT_IPV6   0x00000080

Definition at line 346 of file emac.h.

#define DES4_RX_STAT_PAYLOAD_ICMP   0x00000003

Definition at line 355 of file emac.h.

#define DES4_RX_STAT_PAYLOAD_M   0x00000007

Definition at line 351 of file emac.h.

#define DES4_RX_STAT_PAYLOAD_TCP   0x00000002

Definition at line 354 of file emac.h.

#define DES4_RX_STAT_PAYLOAD_UDP   0x00000001

Definition at line 353 of file emac.h.

#define DES4_RX_STAT_PAYLOAD_UNKNOWN   0x00000000

Definition at line 352 of file emac.h.

#define DES4_RX_STAT_PTP_MT_ANNOUNCE   0x00000800

Definition at line 343 of file emac.h.

#define DES4_RX_STAT_PTP_MT_DELAY_REQ   0x00000300

Definition at line 338 of file emac.h.

#define DES4_RX_STAT_PTP_MT_DELAY_RESP   0x00000400

Definition at line 339 of file emac.h.

#define DES4_RX_STAT_PTP_MT_FOLLOW_UP   0x00000200

Definition at line 337 of file emac.h.

#define DES4_RX_STAT_PTP_MT_M   0x00000F00

Definition at line 334 of file emac.h.

#define DES4_RX_STAT_PTP_MT_NONE   0x00000000

Definition at line 335 of file emac.h.

#define DES4_RX_STAT_PTP_MT_PDELAY_REQ   0x00000500

Definition at line 340 of file emac.h.

#define DES4_RX_STAT_PTP_MT_PDELAY_RESP   0x00000600

Definition at line 341 of file emac.h.

#define DES4_RX_STAT_PTP_MT_PDELAY_RFU   0x00000700

Definition at line 342 of file emac.h.

#define DES4_RX_STAT_PTP_MT_RESERVED   0x00000F00

Definition at line 345 of file emac.h.

#define DES4_RX_STAT_PTP_MT_SIGNALLING   0x00000A00

Definition at line 344 of file emac.h.

#define DES4_RX_STAT_PTP_MT_SYNC   0x00000100

Definition at line 336 of file emac.h.

#define DES4_RX_STAT_PTP_TYPE_ETH   0x00001000

Definition at line 332 of file emac.h.

#define DES4_RX_STAT_PTP_TYPE_UDP   0x00000000

Definition at line 333 of file emac.h.

#define DES4_RX_STAT_PTP_VERSION2   0x00002000

Definition at line 331 of file emac.h.

#define DES4_RX_STAT_TS_DROPPED   0x00004000

Definition at line 330 of file emac.h.

#define EMAC_ABNORMAL_INTS
Value:
#define EMAC_INT_RX_STOPPED
Definition: emac.h:682
#define EMAC_INT_RX_NO_BUFFER
Definition: emac.h:683
#define EMAC_INT_TX_JABBER
Definition: emac.h:687
#define EMAC_INT_EARLY_TRANSMIT
Definition: emac.h:680
#define EMAC_INT_RX_WATCHDOG
Definition: emac.h:681
#define EMAC_INT_TX_STOPPED
Definition: emac.h:689
#define EMAC_INT_TX_UNDERFLOW
Definition: emac.h:685
#define EMAC_INT_RX_OVERFLOW
Definition: emac.h:686
#define EMAC_INT_BUS_ERROR
Definition: emac.h:679

Definition at line 148 of file emac.c.

Referenced by EMACIntClear(), EMACIntDisable(), and EMACIntEnable().

#define EMAC_BCONFIG_ADDR_ALIGNED   0x02000000

Definition at line 368 of file emac.h.

#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_1   0x00000000

Definition at line 363 of file emac.h.

#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_2   0x10000000

Definition at line 364 of file emac.h.

#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_3   0x20000000

Definition at line 365 of file emac.h.

#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_4   0x30000000

Definition at line 366 of file emac.h.

#define EMAC_BCONFIG_DMA_PRIO_WEIGHT_M   0x30000000

Definition at line 362 of file emac.h.

#define EMAC_BCONFIG_FIXED_BURST   0x00010000

Definition at line 375 of file emac.h.

#define EMAC_BCONFIG_MIXED_BURST   0x04000000

Definition at line 376 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_1_1   (0 << 14)

Definition at line 370 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_2_1   (1 << 14)

Definition at line 371 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_3_1   (2 << 14)

Definition at line 372 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_4_1   (3 << 14)

Definition at line 373 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_FIXED   0x00000002

Definition at line 374 of file emac.h.

#define EMAC_BCONFIG_PRIORITY_M   0x0000C000

Definition at line 369 of file emac.h.

#define EMAC_BCONFIG_TX_PRIORITY   0x08000000

Definition at line 367 of file emac.h.

#define EMAC_CONFIG_100MBPS   0x00004000

Definition at line 442 of file emac.h.

#define EMAC_CONFIG_10MBPS   0x00000000

Definition at line 443 of file emac.h.

#define EMAC_CONFIG_2K_PACKETS   0x08000000

Definition at line 428 of file emac.h.

#define EMAC_CONFIG_3BYTE_PREAMBLE   0x00000002

Definition at line 460 of file emac.h.

#define EMAC_CONFIG_5BYTE_PREAMBLE   0x00000001

Definition at line 459 of file emac.h.

#define EMAC_CONFIG_7BYTE_PREAMBLE   0x00000000

Definition at line 458 of file emac.h.

#define EMAC_CONFIG_AUTO_CRC_STRIPPING   0x00000080

Definition at line 450 of file emac.h.

#define EMAC_CONFIG_BO_LIMIT_1024   (0x0 << 5)

Definition at line 452 of file emac.h.

#define EMAC_CONFIG_BO_LIMIT_16   (0x2 << 5)

Definition at line 454 of file emac.h.

#define EMAC_CONFIG_BO_LIMIT_2   (0x3 << 5)

Definition at line 455 of file emac.h.

#define EMAC_CONFIG_BO_LIMIT_256   (0x1 << 5)

Definition at line 453 of file emac.h.

#define EMAC_CONFIG_BO_MASK   0x00000060

Definition at line 451 of file emac.h.

#define EMAC_CONFIG_CHECKSUM_OFFLOAD   0x00000400

Definition at line 448 of file emac.h.

#define EMAC_CONFIG_CS_DISABLE   0x00010000

Definition at line 441 of file emac.h.

#define EMAC_CONFIG_DEFERRAL_CHK_ENABLE   0x00000010

Definition at line 456 of file emac.h.

#define EMAC_CONFIG_FULL_DUPLEX   0x00000800

Definition at line 446 of file emac.h.

#define EMAC_CONFIG_HALF_DUPLEX   0x00000000

Definition at line 447 of file emac.h.

#define EMAC_CONFIG_IF_GAP_40BITS   (0x7 << 17)

Definition at line 440 of file emac.h.

#define EMAC_CONFIG_IF_GAP_48BITS   (0x6 << 17)

Definition at line 439 of file emac.h.

#define EMAC_CONFIG_IF_GAP_56BITS   (0x5 << 17)

Definition at line 438 of file emac.h.

#define EMAC_CONFIG_IF_GAP_64BITS   (0x4 << 17)

Definition at line 437 of file emac.h.

#define EMAC_CONFIG_IF_GAP_72BITS   (0x3 << 17)

Definition at line 436 of file emac.h.

#define EMAC_CONFIG_IF_GAP_80BITS   (0x2 << 17)

Definition at line 435 of file emac.h.

#define EMAC_CONFIG_IF_GAP_88BITS   (0x1 << 17)

Definition at line 434 of file emac.h.

#define EMAC_CONFIG_IF_GAP_96BITS   (0x0 << 17)

Definition at line 433 of file emac.h.

#define EMAC_CONFIG_IF_GAP_MASK   0x000E0000

Definition at line 432 of file emac.h.

#define EMAC_CONFIG_JABBER_DISABLE   0x00400000

Definition at line 430 of file emac.h.

#define EMAC_CONFIG_JUMBO_ENABLE   0x00100000

Definition at line 431 of file emac.h.

#define EMAC_CONFIG_LOOPBACK   0x00001000

Definition at line 445 of file emac.h.

#define EMAC_CONFIG_PREAMBLE_MASK   0x00000003

Definition at line 457 of file emac.h.

#define EMAC_CONFIG_RETRY_DISABLE   0x00000200

Definition at line 449 of file emac.h.

#define EMAC_CONFIG_RX_ENABLED   0x00000004

Definition at line 496 of file emac.h.

Referenced by EMACConfigGet(), and EMACConfigSet().

#define EMAC_CONFIG_RX_OWN_DISABLE   0x00002000

Definition at line 444 of file emac.h.

#define EMAC_CONFIG_SA_FROM_DESCRIPTOR   0x00000000

Definition at line 425 of file emac.h.

#define EMAC_CONFIG_SA_INSERT   0x20000000

Definition at line 426 of file emac.h.

#define EMAC_CONFIG_SA_REPLACE   0x30000000

Definition at line 427 of file emac.h.

#define EMAC_CONFIG_STRIP_CRC   0x02000000

Definition at line 429 of file emac.h.

#define EMAC_CONFIG_TX_ENABLED   0x00000008

Definition at line 495 of file emac.h.

Referenced by EMACConfigGet(), and EMACConfigSet().

#define EMAC_CONFIG_USE_MACADDR0   0x00000000

Definition at line 424 of file emac.h.

#define EMAC_CONFIG_USE_MACADDR1   0x40000000

Definition at line 423 of file emac.h.

#define EMAC_DMA_ERR_MASK   0x03800000

Definition at line 591 of file emac.h.

#define EMAC_DMA_ERR_RX_DATA_WRITE   0x00000000

Definition at line 592 of file emac.h.

#define EMAC_DMA_ERR_RX_DESC_READ   0x03000000

Definition at line 596 of file emac.h.

#define EMAC_DMA_ERR_RX_DESC_WRITE   0x02000000

Definition at line 594 of file emac.h.

#define EMAC_DMA_ERR_TX_DATA_READ   0x01800000

Definition at line 593 of file emac.h.

#define EMAC_DMA_ERR_TX_DESC_READ   0x03800000

Definition at line 597 of file emac.h.

#define EMAC_DMA_ERR_TX_DESC_WRITE   0x02800000

Definition at line 595 of file emac.h.

#define EMAC_DMA_ERROR   0x00002000

Definition at line 590 of file emac.h.

#define EMAC_DMA_RXSTAT_MASK   (0x07 << 17)

Definition at line 578 of file emac.h.

#define EMAC_DMA_RXSTAT_RUN_CLOSE_DESC   (0x05 << 17)

Definition at line 583 of file emac.h.

#define EMAC_DMA_RXSTAT_RUN_FETCH_DESC   (0x01 << 17)

Definition at line 580 of file emac.h.

#define EMAC_DMA_RXSTAT_RUN_RECEIVING   (0x07 << 17)

Definition at line 585 of file emac.h.

#define EMAC_DMA_RXSTAT_RUN_WAIT_PACKET   (0x03 << 17)

Definition at line 581 of file emac.h.

#define EMAC_DMA_RXSTAT_STOPPED   (0x00 << 17)

Definition at line 579 of file emac.h.

#define EMAC_DMA_RXSTAT_SUSPENDED   (0x04 << 17)

Definition at line 582 of file emac.h.

#define EMAC_DMA_RXSTAT_TS_WRITE   (0x06 << 17)

Definition at line 584 of file emac.h.

#define EMAC_DMA_TXSTAT_MASK   (0x07 << 20)

Definition at line 569 of file emac.h.

#define EMAC_DMA_TXSTAT_RUN_CLOSE_DESC   (0x07 << 20)

Definition at line 574 of file emac.h.

#define EMAC_DMA_TXSTAT_RUN_FETCH_DESC   (0x01 << 20)

Definition at line 571 of file emac.h.

#define EMAC_DMA_TXSTAT_RUN_READING   (0x03 << 20)

Definition at line 573 of file emac.h.

#define EMAC_DMA_TXSTAT_RUN_WAIT_STATUS   (0x02 << 20)

Definition at line 572 of file emac.h.

#define EMAC_DMA_TXSTAT_STOPPED   (0x00 << 20)

Definition at line 570 of file emac.h.

#define EMAC_DMA_TXSTAT_SUSPENDED   (0x06 << 20)

Definition at line 576 of file emac.h.

#define EMAC_DMA_TXSTAT_TS_WRITE   (0x04 << 20)

Definition at line 575 of file emac.h.

#define EMAC_FILTER_ADDR_ENABLE   0x80000000

Definition at line 605 of file emac.h.

Referenced by EMACAddrFilterGet(), and EMACAddrFilterSet().

#define EMAC_FILTER_BYTE_MASK_M   0x3F000000

Definition at line 614 of file emac.h.

Referenced by EMACAddrFilterGet(), and EMACAddrFilterSet().

#define EMAC_FILTER_BYTE_MASK_S   24

Definition at line 615 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_1   0x01000000

Definition at line 612 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_2   0x03000000

Definition at line 611 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_3   0x04000000

Definition at line 610 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_4   0x08000000

Definition at line 609 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_5   0x10000000

Definition at line 608 of file emac.h.

#define EMAC_FILTER_MASK_BYTE_6   0x20000000

Definition at line 607 of file emac.h.

#define EMAC_FILTER_SOURCE_ADDR   0x40000000

Definition at line 606 of file emac.h.

Referenced by EMACAddrFilterGet(), and EMACAddrFilterSet().

#define EMAC_FRMFILTER_BROADCAST   0x00000020

Definition at line 525 of file emac.h.

#define EMAC_FRMFILTER_HASH_AND_PERFECT   0x00000400

Definition at line 517 of file emac.h.

#define EMAC_FRMFILTER_HASH_MULTICAST   0x00000004

Definition at line 528 of file emac.h.

#define EMAC_FRMFILTER_HASH_UNICAST   0x00000002

Definition at line 529 of file emac.h.

#define EMAC_FRMFILTER_INV_DADDR   0x00000008

Definition at line 527 of file emac.h.

#define EMAC_FRMFILTER_INV_SADDR   0x00000100

Definition at line 519 of file emac.h.

#define EMAC_FRMFILTER_PASS_ADDR_CTRL   (0x03 << 6)

Definition at line 524 of file emac.h.

#define EMAC_FRMFILTER_PASS_ALL_CTRL   (0x02 << 6)

Definition at line 523 of file emac.h.

#define EMAC_FRMFILTER_PASS_MASK   (0x03 << 6)

Definition at line 520 of file emac.h.

#define EMAC_FRMFILTER_PASS_MULTICAST   0x00000010

Definition at line 526 of file emac.h.

#define EMAC_FRMFILTER_PASS_NO_CTRL   (0x00 << 6)

Definition at line 521 of file emac.h.

#define EMAC_FRMFILTER_PASS_NO_PAUSE   (0x01 << 6)

Definition at line 522 of file emac.h.

#define EMAC_FRMFILTER_PROMISCUOUS   0x00000001

Definition at line 530 of file emac.h.

#define EMAC_FRMFILTER_RX_ALL   0x80000000

Definition at line 515 of file emac.h.

#define EMAC_FRMFILTER_SADDR   0x00000200

Definition at line 518 of file emac.h.

#define EMAC_FRMFILTER_VLAN   0x00010000

Definition at line 516 of file emac.h.

#define EMAC_INT_ABNORMAL_INT   0x00008000

Definition at line 709 of file emac.h.

Referenced by EMACIntClear(), EMACIntDisable(), and EMACIntEnable().

#define EMAC_INT_BUS_ERROR   0x00002000

Definition at line 679 of file emac.h.

#define EMAC_INT_EARLY_RECEIVE   0x00004000

Definition at line 678 of file emac.h.

#define EMAC_INT_EARLY_TRANSMIT   0x00000400

Definition at line 680 of file emac.h.

#define EMAC_INT_NORMAL_INT   0x00010000

Definition at line 708 of file emac.h.

Referenced by EMACIntClear(), EMACIntDisable(), and EMACIntEnable().

#define EMAC_INT_PHY   0x80000000

Definition at line 677 of file emac.h.

Referenced by EMACIntClear(), EMACIntDisable(), EMACIntEnable(), and EMACIntStatus().

#define EMAC_INT_POWER_MGMNT   0x10000000

Definition at line 727 of file emac.h.

#define EMAC_INT_RECEIVE   0x00000040

Definition at line 684 of file emac.h.

#define EMAC_INT_RX_NO_BUFFER   0x00000080

Definition at line 683 of file emac.h.

#define EMAC_INT_RX_OVERFLOW   0x00000010

Definition at line 686 of file emac.h.

#define EMAC_INT_RX_STOPPED   0x00000100

Definition at line 682 of file emac.h.

#define EMAC_INT_RX_WATCHDOG   0x00000200

Definition at line 681 of file emac.h.

#define EMAC_INT_TIMESTAMP   0x20000000

Definition at line 715 of file emac.h.

#define EMAC_INT_TRANSMIT   0x00000001

Definition at line 690 of file emac.h.

#define EMAC_INT_TX_JABBER   0x00000008

Definition at line 687 of file emac.h.

#define EMAC_INT_TX_NO_BUFFER   0x00000004

Definition at line 688 of file emac.h.

#define EMAC_INT_TX_STOPPED   0x00000002

Definition at line 689 of file emac.h.

#define EMAC_INT_TX_UNDERFLOW   0x00000020

Definition at line 685 of file emac.h.

#define EMAC_MASKABLE_INTS
Value:
#define EMAC_INT_RX_STOPPED
Definition: emac.h:682
#define EMAC_INT_EARLY_RECEIVE
Definition: emac.h:678
#define EMAC_INT_PHY
Definition: emac.h:677
#define EMAC_INT_RECEIVE
Definition: emac.h:684
#define EMAC_INT_TRANSMIT
Definition: emac.h:690
#define EMAC_INT_TX_NO_BUFFER
Definition: emac.h:688
#define EMAC_INT_RX_NO_BUFFER
Definition: emac.h:683
#define EMAC_INT_TX_JABBER
Definition: emac.h:687
#define EMAC_INT_EARLY_TRANSMIT
Definition: emac.h:680
#define EMAC_INT_RX_WATCHDOG
Definition: emac.h:681
#define EMAC_INT_ABNORMAL_INT
Definition: emac.h:709
#define EMAC_INT_TX_STOPPED
Definition: emac.h:689
#define EMAC_INT_TX_UNDERFLOW
Definition: emac.h:685
#define EMAC_INT_RX_OVERFLOW
Definition: emac.h:686
#define EMAC_INT_NORMAL_INT
Definition: emac.h:708
#define EMAC_INT_BUS_ERROR
Definition: emac.h:679

Definition at line 116 of file emac.c.

Referenced by EMACIntDisable(), and EMACIntEnable().

#define EMAC_MODE_KEEP_BAD_CRC   0x04000000

Definition at line 467 of file emac.h.

#define EMAC_MODE_OPERATE_2ND_FRAME   0x00000002

Definition at line 485 of file emac.h.

#define EMAC_MODE_RX_DMA_ENABLED   0x00000002

Definition at line 507 of file emac.h.

#define EMAC_MODE_RX_ERROR_FRAMES   0x00000080

Definition at line 479 of file emac.h.

#define EMAC_MODE_RX_FLUSH_DISABLE   0x01000000

Definition at line 469 of file emac.h.

#define EMAC_MODE_RX_STORE_FORWARD   0x02000000

Definition at line 468 of file emac.h.

#define EMAC_MODE_RX_THRESHOLD_128_BYTES   (3 << 3)

Definition at line 484 of file emac.h.

#define EMAC_MODE_RX_THRESHOLD_32_BYTES   (1 << 3)

Definition at line 482 of file emac.h.

#define EMAC_MODE_RX_THRESHOLD_64_BYTES   (0 << 3)

Definition at line 481 of file emac.h.

#define EMAC_MODE_RX_THRESHOLD_96_BYTES   (2 << 3)

Definition at line 483 of file emac.h.

#define EMAC_MODE_RX_UNDERSIZED_FRAMES   0x00000040

Definition at line 480 of file emac.h.

#define EMAC_MODE_TX_DMA_ENABLED   0x00002000

Definition at line 506 of file emac.h.

#define EMAC_MODE_TX_STORE_FORWARD   0x00200000

Definition at line 470 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_128_BYTES   (1 << 14)

Definition at line 476 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_16_BYTES   (7 << 14)

Definition at line 471 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_192_BYTES   (2 << 14)

Definition at line 477 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_24_BYTES   (6 << 14)

Definition at line 472 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_256_BYTES   (3 << 14)

Definition at line 478 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_32_BYTES   (5 << 14)

Definition at line 473 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_40_BYTES   (4 << 14)

Definition at line 474 of file emac.h.

#define EMAC_MODE_TX_THRESHOLD_64_BYTES   (0 << 14)

Definition at line 475 of file emac.h.

#define EMAC_NON_MASKED_INTS
Value:
#define EMAC_DMARIS_MMC
Definition: hw_emac.h:1045
#define EMAC_DMARIS_TT
Definition: hw_emac.h:1042
#define EMAC_DMARIS_PMT
Definition: hw_emac.h:1044

Definition at line 164 of file emac.c.

Referenced by EMACIntStatus().

#define EMAC_NORMAL_INTS
Value:
#define EMAC_INT_EARLY_RECEIVE
Definition: emac.h:678
#define EMAC_INT_RECEIVE
Definition: emac.h:684
#define EMAC_INT_TRANSMIT
Definition: emac.h:690
#define EMAC_INT_TX_NO_BUFFER
Definition: emac.h:688

Definition at line 138 of file emac.c.

Referenced by EMACIntClear(), EMACIntDisable(), and EMACIntEnable().

#define EMAC_O_ADDRH (   n)    (EMAC_O_ADDR0H + (MAC_ADDR_OFFSET * (n)))

Definition at line 182 of file emac.c.

Referenced by EMACAddrFilterGet(), EMACAddrFilterSet(), EMACAddrGet(), and EMACAddrSet().

#define EMAC_O_ADDRL (   n)    (EMAC_O_ADDR0L + (MAC_ADDR_OFFSET * (n)))

Definition at line 181 of file emac.c.

Referenced by EMACAddrFilterSet(), EMACAddrGet(), and EMACAddrSet().

#define EMAC_PHY_ADDR   0

Definition at line 67 of file emac.h.

#define EMAC_PHY_AN_100B_T_FULL_DUPLEX   0x0000000E

Definition at line 413 of file emac.h.

#define EMAC_PHY_AN_100B_T_HALF_DUPLEX   0x0000000C

Definition at line 412 of file emac.h.

#define EMAC_PHY_AN_10B_T_FULL_DUPLEX   0x0000000A

Definition at line 411 of file emac.h.

#define EMAC_PHY_AN_10B_T_HALF_DUPLEX   0x00000008

Definition at line 410 of file emac.h.

#define EMAC_PHY_FORCE_100B_T_FULL_DUPLEX   0x00000006

Definition at line 409 of file emac.h.

#define EMAC_PHY_FORCE_100B_T_HALF_DUPLEX   0x00000004

Definition at line 408 of file emac.h.

#define EMAC_PHY_FORCE_10B_T_FULL_DUPLEX   0x00000002

Definition at line 407 of file emac.h.

#define EMAC_PHY_FORCE_10B_T_HALF_DUPLEX   0x00000000

Definition at line 406 of file emac.h.

#define EMAC_PHY_INT_EXT_FULL_DUPLEX   0x00000080

Definition at line 402 of file emac.h.

#define EMAC_PHY_INT_FAST_AN_120_75_50   0x00000050

Definition at line 404 of file emac.h.

#define EMAC_PHY_INT_FAST_AN_140_150_100   0x00000060

Definition at line 405 of file emac.h.

#define EMAC_PHY_INT_FAST_AN_80_50_35   0x00000040

Definition at line 403 of file emac.h.

#define EMAC_PHY_INT_FAST_L_UP_DETECT   0x00000100

Definition at line 401 of file emac.h.

#define EMAC_PHY_INT_FAST_MDIX   0x00000800

Definition at line 398 of file emac.h.

#define EMAC_PHY_INT_FAST_RXDV_DETECT   0x00000200

Definition at line 400 of file emac.h.

#define EMAC_PHY_INT_HOLD   0x00000001

Definition at line 414 of file emac.h.

#define EMAC_PHY_INT_ISOLATE_MII_LLOSS   0x00400000

Definition at line 388 of file emac.h.

#define EMAC_PHY_INT_LD_ON_LOW_SNR   0x00010000

Definition at line 393 of file emac.h.

#define EMAC_PHY_INT_LD_ON_MTL3_ERR_COUNT   0x00020000

Definition at line 392 of file emac.h.

#define EMAC_PHY_INT_LD_ON_RX_ERR_COUNT   0x00040000

Definition at line 391 of file emac.h.

#define EMAC_PHY_INT_LD_ON_SIGNAL_ENERGY   0x00008000

Definition at line 394 of file emac.h.

#define EMAC_PHY_INT_LINK_LOSS_RECOVERY   0x00200000

Definition at line 389 of file emac.h.

#define EMAC_PHY_INT_MDI_SWAP   0x00002000

Definition at line 396 of file emac.h.

#define EMAC_PHY_INT_MDIX_EN   0x00000400

Definition at line 399 of file emac.h.

#define EMAC_PHY_INT_NIB_TXERR_DET_DIS   0x01000000

Definition at line 386 of file emac.h.

#define EMAC_PHY_INT_POLARITY_SWAP   0x00004000

Definition at line 395 of file emac.h.

#define EMAC_PHY_INT_ROBUST_MDIX   0x00001000

Definition at line 397 of file emac.h.

#define EMAC_PHY_INT_RX_ER_DURING_IDLE   0x00800000

Definition at line 387 of file emac.h.

#define EMAC_PHY_INT_TDRRUN   0x00100000

Definition at line 390 of file emac.h.

#define EMAC_PHY_TYPE_EXTERNAL_MII   0x80000000

Definition at line 384 of file emac.h.

#define EMAC_PHY_TYPE_EXTERNAL_RMII   0xC0000000

Definition at line 385 of file emac.h.

Referenced by EMACPHYConfigSet().

#define EMAC_PHY_TYPE_INTERNAL   0x00000000

Definition at line 383 of file emac.h.

Referenced by EMACPHYConfigSet().

#define EMAC_PHY_TYPE_MASK   0xC0000000

Definition at line 416 of file emac.h.

Referenced by EMACPHYConfigSet().

#define EMAC_PMT_GLOBAL_UNICAST_ENABLE   0x00000200

Definition at line 885 of file emac.h.

Referenced by EMACPowerManagementControlSet().

#define EMAC_PMT_MAGIC_PACKET_ENABLE   0x00000002

Definition at line 887 of file emac.h.

Referenced by EMACPowerManagementControlSet().

#define EMAC_PMT_MAGIC_PACKET_RECEIVED   0x00000020

Definition at line 898 of file emac.h.

#define EMAC_PMT_POWER_DOWN   0x00000001

Definition at line 888 of file emac.h.

Referenced by EMACPowerManagementControlSet().

#define EMAC_PMT_WAKEUP_PACKET_ENABLE   0x00000004

Definition at line 886 of file emac.h.

Referenced by EMACPowerManagementControlSet().

#define EMAC_PMT_WAKEUP_PACKET_RECEIVED   0x00000040

Definition at line 897 of file emac.h.

#define EMAC_PPS_1024HZ   0x0000000B

Definition at line 746 of file emac.h.

#define EMAC_PPS_128HZ   0x00000008

Definition at line 743 of file emac.h.

#define EMAC_PPS_16384HZ   0x0000000F

Definition at line 750 of file emac.h.

#define EMAC_PPS_16HZ   0x00000005

Definition at line 740 of file emac.h.

#define EMAC_PPS_1HZ   0x00000001

Definition at line 736 of file emac.h.

Referenced by EMACTimestampPPSSimpleModeSet().

#define EMAC_PPS_2048HZ   0x0000000C

Definition at line 747 of file emac.h.

#define EMAC_PPS_256HZ   0x00000009

Definition at line 744 of file emac.h.

#define EMAC_PPS_2HZ   0x00000002

Definition at line 737 of file emac.h.

#define EMAC_PPS_32768HZ   0x00000010

Definition at line 751 of file emac.h.

Referenced by EMACTimestampPPSSimpleModeSet().

#define EMAC_PPS_32HZ   0x00000006

Definition at line 741 of file emac.h.

#define EMAC_PPS_4096HZ   0x0000000D

Definition at line 748 of file emac.h.

#define EMAC_PPS_4HZ   0x00000003

Definition at line 738 of file emac.h.

#define EMAC_PPS_512HZ   0x0000000A

Definition at line 745 of file emac.h.

#define EMAC_PPS_64HZ   0x00000007

Definition at line 742 of file emac.h.

#define EMAC_PPS_8192HZ   0x0000000E

Definition at line 749 of file emac.h.

#define EMAC_PPS_8HZ   0x00000004

Definition at line 739 of file emac.h.

#define EMAC_PPS_COMMAND_CANCEL_START   0x03

Definition at line 771 of file emac.h.

#define EMAC_PPS_COMMAND_CANCEL_STOP   0x06

Definition at line 774 of file emac.h.

#define EMAC_PPS_COMMAND_NONE   0x00

Definition at line 768 of file emac.h.

#define EMAC_PPS_COMMAND_START_SINGLE   0x01

Definition at line 769 of file emac.h.

#define EMAC_PPS_COMMAND_START_TRAIN   0x02

Definition at line 770 of file emac.h.

#define EMAC_PPS_COMMAND_STOP_AT_TIME   0x04

Definition at line 772 of file emac.h.

#define EMAC_PPS_COMMAND_STOP_NOW   0x05

Definition at line 773 of file emac.h.

#define EMAC_PPS_SINGLE_PULSE   0x00000000

Definition at line 735 of file emac.h.

Referenced by EMACTimestampPPSSimpleModeSet().

#define EMAC_PPS_TARGET_BOTH   0x00000040

Definition at line 761 of file emac.h.

Referenced by EMACTimestampPPSCommandModeSet().

#define EMAC_PPS_TARGET_INT   0x00000000

Definition at line 759 of file emac.h.

Referenced by EMACTimestampPPSCommandModeSet().

#define EMAC_PPS_TARGET_PPS   0x00000060

Definition at line 760 of file emac.h.

Referenced by EMACTimestampPPSCommandModeSet().

#define EMAC_RWU_FILTER_DISABLE   0

Definition at line 808 of file emac.h.

#define EMAC_RWU_FILTER_ENABLE   1

Definition at line 807 of file emac.h.

#define EMAC_RWU_FILTER_MULTICAST   8

Definition at line 809 of file emac.h.

#define EMAC_RWU_FILTER_UNICAST   0

Definition at line 810 of file emac.h.

#define EMAC_RX_DMA_STATE (   x)    ((x) & EMAC_DMA_RXSTAT_MASK)

Definition at line 588 of file emac.h.

#define EMAC_STATUS_MAC_NOT_IDLE   0x00010000

Definition at line 550 of file emac.h.

#define EMAC_STATUS_RPE_ACTIVE   0x00000001

Definition at line 562 of file emac.h.

#define EMAC_STATUS_RWC_ACTIVE   0x00000010

Definition at line 561 of file emac.h.

#define EMAC_STATUS_RX_FIFO_ABOVE   (0x02 << 8)

Definition at line 554 of file emac.h.

#define EMAC_STATUS_RX_FIFO_BELOW   (0x01 << 8)

Definition at line 553 of file emac.h.

#define EMAC_STATUS_RX_FIFO_EMPTY   (0x00 << 8)

Definition at line 552 of file emac.h.

#define EMAC_STATUS_RX_FIFO_FLUSHING   (0x03 << 5)

Definition at line 560 of file emac.h.

#define EMAC_STATUS_RX_FIFO_FULL   (0x03 << 8)

Definition at line 555 of file emac.h.

#define EMAC_STATUS_RX_FIFO_IDLE   (0x00 << 5)

Definition at line 557 of file emac.h.

#define EMAC_STATUS_RX_FIFO_LEVEL_MASK   0x00000300

Definition at line 551 of file emac.h.

#define EMAC_STATUS_RX_FIFO_READING   (0x01 << 5)

Definition at line 558 of file emac.h.

#define EMAC_STATUS_RX_FIFO_STATE_MASK   0x00000060

Definition at line 556 of file emac.h.

#define EMAC_STATUS_RX_FIFO_STATUS   (0x02 << 5)

Definition at line 559 of file emac.h.

#define EMAC_STATUS_TFC_STATE_IDLE   (0x00 << 17)

Definition at line 546 of file emac.h.

#define EMAC_STATUS_TFC_STATE_MASK   0x00060000

Definition at line 545 of file emac.h.

#define EMAC_STATUS_TFC_STATE_PAUSING   (0x02 << 17)

Definition at line 548 of file emac.h.

#define EMAC_STATUS_TFC_STATE_WAITING   (0x01 << 17)

Definition at line 547 of file emac.h.

#define EMAC_STATUS_TFC_STATE_WRITING   (0x03 << 17)

Definition at line 549 of file emac.h.

#define EMAC_STATUS_TRC_STATE_IDLE   (0x00 << 20)

Definition at line 540 of file emac.h.

#define EMAC_STATUS_TRC_STATE_MASK   0x00300000

Definition at line 539 of file emac.h.

#define EMAC_STATUS_TRC_STATE_READING   (0x01 << 20)

Definition at line 541 of file emac.h.

#define EMAC_STATUS_TRC_STATE_STATUS   (0x03 << 20)

Definition at line 543 of file emac.h.

#define EMAC_STATUS_TRC_STATE_WAITING   (0x02 << 20)

Definition at line 542 of file emac.h.

#define EMAC_STATUS_TX_NOT_EMPTY   0x01000000

Definition at line 537 of file emac.h.

#define EMAC_STATUS_TX_PAUSED   0x00080000

Definition at line 544 of file emac.h.

#define EMAC_STATUS_TX_WRITING_FIFO   0x00400000

Definition at line 538 of file emac.h.

#define EMAC_TS_ALL   0x00010000

Definition at line 628 of file emac.h.

#define EMAC_TS_ALL_RX_FRAMES   0x00000100

Definition at line 640 of file emac.h.

#define EMAC_TS_BINARY_ROLLOVER   0x00000000

Definition at line 639 of file emac.h.

#define EMAC_TS_DELAYREQ_ONLY   0x0000C000

Definition at line 627 of file emac.h.

#define EMAC_TS_DIGITAL_ROLLOVER   0x00000200

Definition at line 638 of file emac.h.

Referenced by EMACTimestampPPSSimpleModeSet().

#define EMAC_TS_DREQ_PDREQ_PDRESP   0x0001C000

Definition at line 630 of file emac.h.

#define EMAC_TS_INT_TARGET_REACHED   0x00000002

Definition at line 720 of file emac.h.

#define EMAC_TS_INT_TS_SEC_OVERFLOW   0x00000001

Definition at line 721 of file emac.h.

#define EMAC_TS_MAC_FILTER_DISABLE   0x00000000

Definition at line 624 of file emac.h.

#define EMAC_TS_MAC_FILTER_ENABLE   0x00040000

Definition at line 623 of file emac.h.

#define EMAC_TS_PDREQ_PDRESP   0x00030000

Definition at line 632 of file emac.h.

#define EMAC_TS_PROCESS_ETHERNET   0x00000800

Definition at line 635 of file emac.h.

#define EMAC_TS_PROCESS_IPV4_UDP   0x00002000

Definition at line 633 of file emac.h.

#define EMAC_TS_PROCESS_IPV6_UDP   0x00001000

Definition at line 634 of file emac.h.

#define EMAC_TS_PTP_VERSION_1   0x00000000

Definition at line 637 of file emac.h.

#define EMAC_TS_PTP_VERSION_2   0x00000400

Definition at line 636 of file emac.h.

#define EMAC_TS_SYNC_DELAYREQ   0x00020000

Definition at line 631 of file emac.h.

#define EMAC_TS_SYNC_FOLLOW_DREQ_DRESP   0x00000000

Definition at line 625 of file emac.h.

#define EMAC_TS_SYNC_ONLY   0x00004000

Definition at line 626 of file emac.h.

#define EMAC_TS_SYNC_PDREQ_PDRESP   0x00014000

Definition at line 629 of file emac.h.

#define EMAC_TS_UPDATE_COARSE   0x00000000

Definition at line 642 of file emac.h.

#define EMAC_TS_UPDATE_FINE   0x00000002

Definition at line 641 of file emac.h.

#define EMAC_TX_DMA_STATE (   x)    ((x) & EMAC_DMA_TXSTAT_MASK)

Definition at line 587 of file emac.h.

#define EMAC_VLAN_RX_12BIT_TAG   0x00010000

Definition at line 788 of file emac.h.

#define EMAC_VLAN_RX_16BIT_TAG   0x00000000

Definition at line 789 of file emac.h.

#define EMAC_VLAN_RX_HASH_DISABLE   0x00000000

Definition at line 783 of file emac.h.

#define EMAC_VLAN_RX_HASH_ENABLE   0x00080000

Definition at line 782 of file emac.h.

#define EMAC_VLAN_RX_INVERSE_MATCH   0x00020000

Definition at line 787 of file emac.h.

#define EMAC_VLAN_RX_NORMAL_MATCH   0x00000000

Definition at line 786 of file emac.h.

#define EMAC_VLAN_RX_SVLAN_DISABLE   0x00000000

Definition at line 785 of file emac.h.

#define EMAC_VLAN_RX_SVLAN_ENABLE   0x00040000

Definition at line 784 of file emac.h.

#define EMAC_VLAN_TX_CVLAN   0x00000000

Definition at line 797 of file emac.h.

#define EMAC_VLAN_TX_SVLAN   0x00080000

Definition at line 798 of file emac.h.

#define EMAC_VLAN_TX_USE_VLC   0x00040000

Definition at line 799 of file emac.h.

#define EMAC_VLAN_TX_VLC_DELETE   0x00010000

Definition at line 801 of file emac.h.

#define EMAC_VLAN_TX_VLC_INSERT   0x00020000

Definition at line 802 of file emac.h.

#define EMAC_VLAN_TX_VLC_MASK   0x00030000

Definition at line 805 of file emac.h.

#define EMAC_VLAN_TX_VLC_NONE   0x00000000

Definition at line 800 of file emac.h.

#define EMAC_VLAN_TX_VLC_REPLACE   0x00030000

Definition at line 803 of file emac.h.

#define EPHY_SCR_INPOL_EXT   0x00000008

Definition at line 651 of file emac.h.

#define EPHY_SCR_INTEN_EXT   0x00000002

Definition at line 653 of file emac.h.

#define EPHY_SCR_INTOE_EXT   0x00000001

Definition at line 654 of file emac.h.

#define EPHY_SCR_TINT_EXT   0x00000004

Definition at line 652 of file emac.h.

#define htonl (   a)
Value:
((((a) >> 24) & 0x000000ff) | \
(((a) >> 8) & 0x0000ff00) | \
(((a) << 8) & 0x00ff0000) | \
(((a) << 24) & 0xff000000))

Definition at line 80 of file emac.h.

#define htons (   a)
Value:
((((a) >> 8) & 0x00ff) | \
(((a) << 8) & 0xff00))

Definition at line 98 of file emac.h.

#define MAC_ADDR_OFFSET   (EMAC_O_ADDR1L - EMAC_O_ADDR0L)

Definition at line 180 of file emac.c.

#define ntohl (   a)    htonl((a))

Definition at line 88 of file emac.h.

#define ntohs (   a)    htons((a))

Definition at line 104 of file emac.h.

#define NUM_CLOCK_DIVISORS
Value:
(sizeof(g_pi16MIIClockDiv) / \
sizeof(g_pi16MIIClockDiv[0]))
static const struct @0 g_pi16MIIClockDiv[]

Definition at line 207 of file emac.c.

Referenced by EMACInit().

#define NUM_MAC_ADDR   4
#define VALID_CONFIG_FLAGS
Value:
#define EMAC_CONFIG_STRIP_CRC
Definition: emac.h:429
#define EMAC_CONFIG_IF_GAP_MASK
Definition: emac.h:432
#define EMAC_CONFIG_SA_REPLACE
Definition: emac.h:427
#define EMAC_CONFIG_BO_MASK
Definition: emac.h:451
#define EMAC_CONFIG_LOOPBACK
Definition: emac.h:445
#define EMAC_CONFIG_SA_INSERT
Definition: emac.h:426
#define EMAC_CONFIG_USE_MACADDR1
Definition: emac.h:423
#define EMAC_CONFIG_AUTO_CRC_STRIPPING
Definition: emac.h:450
#define EMAC_CONFIG_RX_OWN_DISABLE
Definition: emac.h:444
#define EMAC_CONFIG_PREAMBLE_MASK
Definition: emac.h:457
#define EMAC_CONFIG_CHECKSUM_OFFLOAD
Definition: emac.h:448
#define EMAC_CONFIG_RETRY_DISABLE
Definition: emac.h:449
#define EMAC_CONFIG_2K_PACKETS
Definition: emac.h:428
#define EMAC_CONFIG_100MBPS
Definition: emac.h:442
#define EMAC_CONFIG_DEFERRAL_CHK_ENABLE
Definition: emac.h:456
#define EMAC_CONFIG_FULL_DUPLEX
Definition: emac.h:446
#define EMAC_CONFIG_CS_DISABLE
Definition: emac.h:441
#define EMAC_CONFIG_JUMBO_ENABLE
Definition: emac.h:431
#define EMAC_CONFIG_JABBER_DISABLE
Definition: emac.h:430

Definition at line 71 of file emac.c.

Referenced by EMACConfigGet(), and EMACConfigSet().

#define VALID_FRMFILTER_FLAGS
Value:
#define EMAC_FRMFILTER_VLAN
Definition: emac.h:516
#define EMAC_FRMFILTER_RX_ALL
Definition: emac.h:515
#define EMAC_FRMFILTER_PROMISCUOUS
Definition: emac.h:530
#define EMAC_FRMFILTER_PASS_ALL_CTRL
Definition: emac.h:523
#define EMAC_FRMFILTER_HASH_MULTICAST
Definition: emac.h:528
#define EMAC_FRMFILTER_INV_SADDR
Definition: emac.h:519
#define EMAC_FRMFILTER_HASH_AND_PERFECT
Definition: emac.h:517
#define EMAC_FRMFILTER_SADDR
Definition: emac.h:518
#define EMAC_FRMFILTER_HASH_UNICAST
Definition: emac.h:529
#define EMAC_FRMFILTER_PASS_MULTICAST
Definition: emac.h:526
#define EMAC_FRMFILTER_INV_DADDR
Definition: emac.h:527
#define EMAC_FRMFILTER_PASS_NO_PAUSE
Definition: emac.h:522
#define EMAC_FRMFILTER_BROADCAST
Definition: emac.h:525
#define EMAC_FRMFILTER_PASS_ADDR_CTRL
Definition: emac.h:524

Definition at line 96 of file emac.c.

Referenced by EMACFrameFilterGet(), and EMACFrameFilterSet().

Typedef Documentation

Definition at line 112 of file emac.h.

Function Documentation

uint32_t EMACAddrFilterGet ( uint32_t  ui32Base,
uint32_t  ui32Index 
)

Gets filtering parameters associated with one of the configured MAC addresses.

Parameters
ui32Baseis the base address of the controller.
ui32Indexis the index of the MAC address slot for which the filter is to be queried.

This function returns filtering parameters associated with one of the MAC address slots that the controller supports. This configuration is used when perfect filtering (rather than hash table filtering) is selected.

Valid values for ui32Index are from 1 to (number of MAC address slots - 1). The number of supported MAC address slots may be found by calling EMACNumAddrGet(). MAC index 0 is the local MAC address and does not have filtering parameters associated with it.

Returns
Returns the filter configuration as the logical OR of the following labels:
  • EMAC_FILTER_ADDR_ENABLE indicates that this MAC address is enabled and is used when performing perfect filtering. If this flag is absent, the MAC address at the given index is disabled and is not used in filtering.
  • EMAC_FILTER_SOURCE_ADDR indicates that the MAC address at the given index is compared to the source address of incoming frames while performing perfect filtering. If absent, the MAC address is compared against the destination address.
  • EMAC_FILTER_MASK_BYTE_6 indicates that the MAC ignores the sixth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_5 indicates that the MAC ignores the fifth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_4 indicates that the MAC ignores the fourth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_3 indicates that the MAC ignores the third byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_2 indicates that the MAC ignores the second byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_1 indicates that the MAC ignores the first byte of the source or destination address when filtering.

Definition at line 1394 of file emac.c.

References ASSERT, EMAC_FILTER_ADDR_ENABLE, EMAC_FILTER_BYTE_MASK_M, EMAC_FILTER_SOURCE_ADDR, EMAC_O_ADDRH, HWREG, and NUM_MAC_ADDR.

1395 {
1396  //
1397  // Parameter sanity check.
1398  //
1399  ASSERT(ui32Index < NUM_MAC_ADDR);
1400  ASSERT(ui32Index);
1401 
1402  //
1403  // Read and return the filter settings for the requested MAC address slot.
1404  //
1405  return(HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) &
1408 }
#define EMAC_FILTER_ADDR_ENABLE
Definition: emac.h:605
#define EMAC_FILTER_SOURCE_ADDR
Definition: emac.h:606
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define NUM_MAC_ADDR
Definition: emac.c:173
#define EMAC_FILTER_BYTE_MASK_M
Definition: emac.h:614
#define EMAC_O_ADDRH(n)
Definition: emac.c:182
void EMACAddrFilterSet ( uint32_t  ui32Base,
uint32_t  ui32Index,
uint32_t  ui32Config 
)

Sets filtering parameters associated with one of the configured MAC addresses.

Parameters
ui32Baseis the base address of the controller.
ui32Indexis the index of the MAC address slot for which the filter is to be set.
ui32Configsets the filter parameters for the given MAC address.

This function sets filtering parameters associated with one of the MAC address slots that the controller supports. This configuration is used when perfect filtering (rather than hash table filtering) is selected.

Valid values for ui32Index are from 1 to (number of MAC address slots - 1). The number of supported MAC address slots may be found by calling EMACNumAddrGet(). MAC index 0 is the local MAC address and does not have filtering parameters associated with it.

The ui32Config parameter determines how the given MAC address is used when filtering incoming Ethernet frames. It is comprised of a logical OR of the fields:

  • EMAC_FILTER_ADDR_ENABLE indicates that this MAC address is enabled and should be used when performing perfect filtering. If this flag is absent, the MAC address at the given index is disabled and is not used in filtering.
  • EMAC_FILTER_SOURCE_ADDR indicates that the MAC address at the given index is compared to the source address of incoming frames while performing perfect filtering. If absent, the MAC address is compared against the destination address.
  • EMAC_FILTER_MASK_BYTE_6 indicates that the MAC should ignore the sixth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_5 indicates that the MAC should ignore the fifth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_4 indicates that the MAC should ignore the fourth byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_3 indicates that the MAC should ignore the third byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_2 indicates that the MAC should ignore the second byte of the source or destination address when filtering.
  • EMAC_FILTER_MASK_BYTE_1 indicates that the MAC should ignore the first byte of the source or destination address when filtering.
Returns
None.

Definition at line 1323 of file emac.c.

References ASSERT, EMAC_FILTER_ADDR_ENABLE, EMAC_FILTER_BYTE_MASK_M, EMAC_FILTER_SOURCE_ADDR, EMAC_O_ADDRH, EMAC_O_ADDRL, HWREG, and NUM_MAC_ADDR.

1324 {
1325  uint32_t ui32Val;
1326 
1327  //
1328  // Parameter sanity check.
1329  //
1330  ASSERT(ui32Index < NUM_MAC_ADDR);
1331  ASSERT((ui32Config & ~(EMAC_FILTER_BYTE_MASK_M |
1333  EMAC_FILTER_SOURCE_ADDR)) == 0);
1334  ASSERT(ui32Index);
1335 
1336  //
1337  // Set the filter configuration for a particular MAC address.
1338  //
1339  HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) =
1340  (HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) & 0xFFFF) | ui32Config;
1341 
1342  //
1343  // Read and rewrite the low half of the MAC address register to ensure
1344  // that the upper half's data is latched.
1345  //
1346  ui32Val = HWREG(ui32Base + EMAC_O_ADDRL(ui32Index));
1347  HWREG(ui32Base + EMAC_O_ADDRL(ui32Index)) = ui32Val;
1348 }
#define EMAC_FILTER_ADDR_ENABLE
Definition: emac.h:605
#define EMAC_FILTER_SOURCE_ADDR
Definition: emac.h:606
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define NUM_MAC_ADDR
Definition: emac.c:173
#define EMAC_FILTER_BYTE_MASK_M
Definition: emac.h:614
#define EMAC_O_ADDRH(n)
Definition: emac.c:182
#define EMAC_O_ADDRL(n)
Definition: emac.c:181
void EMACAddrGet ( uint32_t  ui32Base,
uint32_t  ui32Index,
uint8_t *  pui8MACAddr 
)

Gets one of the MAC addresses stored in the Ethernet controller.

Parameters
ui32Baseis the base address of the controller.
ui32Indexis the zero-based index of the MAC address to return.
pui8MACAddris the pointer to the location in which to store the array of MAC-48 address octets.

This function reads the currently programmed MAC address into the pui8MACAddr buffer. The ui32Index parameter defines which of the hardware's MAC addresses to return. The number of MAC addresses supported by the controller may be queried using a call to EMACNumAddrGet(). Index 0 refers to the MAC address of the local node. Other indices are used to define MAC addresses when filtering incoming packets.

The address is written to the pui8MACAddr array ordered with the first byte to be transmitted in the first array entry. For example, if the address is written in its usual form with the Organizationally Unique Identifier (OUI) shown first as:

AC-DE-48-00-00-80

the data is returned with 0xAC in the first byte of the array, 0xDE in the second, 0x48 in the third and so on.

Returns
None.

Definition at line 1226 of file emac.c.

References ASSERT, EMAC_O_ADDRH, EMAC_O_ADDRL, HWREG, and NUM_MAC_ADDR.

1227 {
1228  uint32_t ui32Val;
1229 
1230  //
1231  // Parameter sanity check.
1232  //
1233  ASSERT(ui32Index < NUM_MAC_ADDR);
1234  ASSERT(pui8MACAddr);
1235 
1236  //
1237  // Get the first 4 bytes of the MAC address.
1238  //
1239  ui32Val = HWREG(ui32Base + EMAC_O_ADDRL(ui32Index));
1240  pui8MACAddr[0] = ui32Val & 0xFF;
1241  pui8MACAddr[1] = (ui32Val >> 8) & 0xFF;
1242  pui8MACAddr[2] = (ui32Val >> 16) & 0xFF;
1243  pui8MACAddr[3] = (ui32Val >> 24) & 0xFF;
1244 
1245  //
1246  // Get the last 2 bytes of the MAC address.
1247  //
1248  ui32Val = HWREG(ui32Base + EMAC_O_ADDRH(ui32Index));
1249  pui8MACAddr[4] = ui32Val & 0xFF;
1250  pui8MACAddr[5] = (ui32Val >> 8) & 0xFF;
1251 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define NUM_MAC_ADDR
Definition: emac.c:173
#define EMAC_O_ADDRH(n)
Definition: emac.c:182
#define EMAC_O_ADDRL(n)
Definition: emac.c:181
void EMACAddrSet ( uint32_t  ui32Base,
uint32_t  ui32Index,
const uint8_t *  pui8MACAddr 
)

Sets the MAC address of the Ethernet controller.

Parameters
ui32Baseis the base address of the Ethernet controller.
ui32Indexis the zero-based index of the MAC address to set.
pui8MACAddris the pointer to the array of MAC-48 address octets.

This function programs the IEEE-defined MAC-48 address specified in pui8MACAddr into the Ethernet controller. This address is used by the Ethernet controller for hardware-level filtering of incoming Ethernet packets (when promiscuous mode is not enabled). Index 0 is used to hold the local node's MAC address which is inserted into all transmitted packets.

The controller may support several Ethernet MAC address slots, each of which may be programmed independently and used to filter incoming packets. The number of MAC addresses that the hardware supports may be queried using a call to EMACNumAddrGet(). The value of the ui32Index parameter must lie in the range from 0 to (number of MAC addresses - 1) inclusive.

The MAC-48 address is defined as 6 octets, illustrated by the following example address. The numbers are shown in hexadecimal format.

    AC-DE-48-00-00-80

In this representation, the first three octets (AC-DE-48) are the Organizationally Unique Identifier (OUI). This is a number assigned by the IEEE to an organization that requests a block of MAC addresses. The last three octets (00-00-80) are a 24-bit number managed by the OUI owner to uniquely identify a piece of hardware within that organization that is to be connected to the Ethernet.

In this representation, the octets are transmitted from left to right, with the AC'' octet being transmitted first and the80'' octet being transmitted last. Within an octet, the bits are transmitted LSB to MSB. For this address, the first bit to be transmitted would be 0'', the LSB ofAC'', and the last bit to be transmitted would be 1'', the MSB of 80''.

The address passed to this function in the pui8MACAddr array is ordered with the first byte to be transmitted in the first array entry. For example, the address given above could be represented using the following array:

uint8_t g_pui8MACAddr[] = { 0xAC, 0xDE, 0x48, 0x00, 0x00, 0x80 };

If the MAC address set by this function is currently enabled, it remains enabled following this call. Similarly, any filter configured for the MAC address remains unaffected by a change in the address.

Returns
None.

Definition at line 1171 of file emac.c.

References ASSERT, EMAC_O_ADDRH, EMAC_O_ADDRL, HWREG, and NUM_MAC_ADDR.

1172 {
1173  //
1174  // Parameter sanity check.
1175  //
1176  ASSERT(ui32Index < NUM_MAC_ADDR);
1177  ASSERT(pui8MACAddr);
1178 
1179  //
1180  // Set the high 2 bytes of the MAC address. Note that we must set the
1181  // registers in this order since the address is latched internally
1182  // on the write to EMAC_O_ADDRL.
1183  //
1184  HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) =
1185  ((HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) & 0xFFFF0000) |
1186  pui8MACAddr[4] | (pui8MACAddr[5] << 8));
1187 
1188  //
1189  // Set the first 4 bytes of the MAC address
1190  //
1191  HWREG(ui32Base + EMAC_O_ADDRL(ui32Index)) =
1192  (pui8MACAddr[0] | (pui8MACAddr[1] << 8) | (pui8MACAddr[2] << 16) |
1193  (pui8MACAddr[3] << 24));
1194 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define NUM_MAC_ADDR
Definition: emac.c:173
#define EMAC_O_ADDRH(n)
Definition: emac.c:182
#define EMAC_O_ADDRL(n)
Definition: emac.c:181
void EMACConfigGet ( uint32_t  ui32Base,
uint32_t *  pui32Config,
uint32_t *  pui32Mode,
uint32_t *  pui32RxMaxFrameSize 
)

Returns the Ethernet MAC's current basic configuration parameters.

Parameters
ui32Baseis the base address of the Ethernet controller.
pui32Configpoints to storage that is written with Ethernet MAC configuration.
pui32Modepoints to storage that is written with Ethernet MAC mode information.
pui32RxMaxFrameSizepoints to storage that is written with the maximum receive frame size.

This function is called to query the basic operating parameters for the MAC and its DMA engines.

The pui32Config parameter is written with the logical OR of various fields and flags. The first field describes which MAC address is used during insertion or replacement for all transmitted frames. Valid options are

  • EMAC_CONFIG_USE_MACADDR1
  • EMAC_CONFIG_USE_MACADDR0

The interframe gap between transmitted frames is given using one of the following values:

  • EMAC_CONFIG_IF_GAP_96BITS
  • EMAC_CONFIG_IF_GAP_88BITS
  • EMAC_CONFIG_IF_GAP_80BITS
  • EMAC_CONFIG_IF_GAP_72BITS
  • EMAC_CONFIG_IF_GAP_64BITS
  • EMAC_CONFIG_IF_GAP_56BITS
  • EMAC_CONFIG_IF_GAP_48BITS
  • EMAC_CONFIG_IF_GAP_40BITS

The number of bytes of preamble added to the beginning of every transmitted frame is described using one of the following values:

  • EMAC_CONFIG_7BYTE_PREAMBLE
  • EMAC_CONFIG_5BYTE_PREAMBLE
  • EMAC_CONFIG_3BYTE_PREAMBLE

The back-off limit determines the range of the random time that the MAC delays after a collision and before attempting to retransmit a frame. One of the following values provides the currently selected limit. In each case the retransmission delay in terms of 512 bit time slots, is the lower of (2 ** N) and a random number between 0 and the reported backoff-limit.

  • EMAC_CONFIG_BO_LIMIT_1024
  • EMAC_CONFIG_BO_LIMIT_256
  • EMAC_CONFIG_BO_LIMIT_16
  • EMAC_CONFIG_BO_LIMIT_2

Handling of insertion or replacement of the source address in all transmitted frames is described by one of the following fields:

  • EMAC_CONFIG_SA_INSERT causes the MAC address (0 or 1 depending on whether EMAC_CONFIG_USE_MACADDR0 or EMAC_CONFIG_USE_MACADDR1 was specified) to be inserted into all transmitted frames.
  • EMAC_CONFIG_SA_REPLACE causes the MAC address to be replaced with the selected address in all transmitted frames.
  • EMAC_CONFIG_SA_FROM_DESCRIPTOR causes control of source address insertion or deletion to be controlled by fields in the DMA transmit descriptor, allowing control on a frame-by-frame basis.

Whether the interface attempts to operate in full- or half-duplex mode is reported by one of the following flags:

  • EMAC_CONFIG_FULL_DUPLEX
  • EMAC_CONFIG_HALF_DUPLEX

The following additional flags may also be included:

  • EMAC_CONFIG_2K_PACKETS indicates that IEEE802.3as support for 2K packets is enabled. When present, the MAC considers all frames up to 2000 bytes in length as normal packets. When EMAC_CONFIG_JUMBO_ENABLE is not reported, all frames larger than 2000 bytes are treated as Giant frames. The value of this flag should be ignored if EMAC_CONFIG_JUMBO_ENABLE is also reported.
  • EMAC_CONFIG_STRIP_CRC indicates that the 4-byte CRC of all Ethernet type frames is being stripped and dropped before the frame is forwarded to the application.
  • EMAC_CONFIG_JABBER_DISABLE indicates that the the jabber timer on the transmitter is disabled, allowing frames of up to 16384 bytes to be transmitted. If this flag is absent, the MAC does not allow more than 2048 (or 10240 if EMAC_CONFIG_JUMBO_ENABLE is reported) bytes to be sent in any one frame.
  • EMAC_CONFIG_JUMBO_ENABLE indicates that Jumbo Frames of up to 9018 (or 9022 if using VLAN tagging) are enabled.
  • EMAC_CONFIG_CS_DISABLE indicates that Carrier Sense is disabled during transmission when operating in half-duplex mode.
  • EMAC_CONFIG_100MBPS indicates that the MAC is using 100Mbps signaling to communicate with the PHY.
  • EMAC_CONFIG_RX_OWN_DISABLE indicates that reception of transmitted frames is disabled when operating in half-duplex mode.
  • EMAC_CONFIG_LOOPBACK indicates that internal loopback is enabled.
  • EMAC_CONFIG_CHECKSUM_OFFLOAD indicates that IPv4 header checksum checking and IPv4 or IPv6 TCP, UPD or ICMP payload checksum checking is enabled. The results of the checksum calculations are reported via status fields in the DMA receive descriptors.
  • EMAC_CONFIG_RETRY_DISABLE indicates that retransmission is disabled in cases where half-duplex mode is in use and a collision occurs. This condition causes the current frame to be ignored and a frame abort to be reported in the transmit frame status.
  • EMAC_CONFIG_AUTO_CRC_STRIPPING indicates that the last 4 bytes (frame check sequence) from all Ether type frames are being stripped before frames are forwarded to the application.
  • EMAC_CONFIG_DEFERRAL_CHK_ENABLE indicates that transmit deferral checking is disabled in half-duplex mode. When enabled, the transmitter reports an error if it is unable to transmit a frame for more than 24288 bit times (or 155680 bit times in Jumbo frame mode) due to an active carrier sense signal on the MII.
  • EMAC_CONFIG_TX_ENABLED indicates that the MAC transmitter is currently enabled.
  • EMAC_CONFIG_RX_ENABLED indicates that the MAC receiver is currently enabled.

The pui32ModeFlags parameter is written with operating parameters related to the internal MAC FIFOs. It comprises a logical OR of the following fields. The first field reports the transmit FIFO threshold. Transmission of a frame begins when this amount of data or a full frame exists in the transmit FIFO. This field should be ignored if EMAC_MODE_TX_STORE_FORWARD is also reported. One of the following values is reported:

  • EMAC_MODE_TX_THRESHOLD_16_BYTES
  • EMAC_MODE_TX_THRESHOLD_24_BYTES
  • EMAC_MODE_TX_THRESHOLD_32_BYTES
  • EMAC_MODE_TX_THRESHOLD_40_BYTES
  • EMAC_MODE_TX_THRESHOLD_64_BYTES
  • EMAC_MODE_TX_THRESHOLD_128_BYTES
  • EMAC_MODE_TX_THRESHOLD_192_BYTES
  • EMAC_MODE_TX_THRESHOLD_256_BYTES

The second field reports the receive FIFO threshold. DMA transfers of received data begin either when the receive FIFO contains a full frame or this number of bytes. This field should be ignored if EMAC_MODE_RX_STORE_FORWARD is included. One of the following values is reported:

  • EMAC_MODE_RX_THRESHOLD_64_BYTES
  • EMAC_MODE_RX_THRESHOLD_32_BYTES
  • EMAC_MODE_RX_THRESHOLD_96_BYTES
  • EMAC_MODE_RX_THRESHOLD_128_BYTES

The following additional flags may be included:

  • EMAC_MODE_KEEP_BAD_CRC indicates that frames with TCP/IP checksum errors are being forwarded to the application if those frames do not have any errors (including FCS errors) in the Ethernet framing. In these cases, the frames have errors only in the payload. If this flag is not reported, all frames with any detected error are discarded unless EMAC_MODE_RX_ERROR_FRAMES is also reported.
  • EMAC_MODE_RX_STORE_FORWARD indicates that the receive DMA is configured to read frames from the FIFO only after the complete frame has been written to it. If this mode is enabled, the receive threshold is ignored.
  • EMAC_MODE_RX_FLUSH_DISABLE indicates that the flushing of received frames is disabled in cases where receive descriptors or buffers are unavailable.
  • EMAC_MODE_TX_STORE_FORWARD indicates that the transmitter is configured to transmit a frame only after the whole frame has been written to the transmit FIFO. If this mode is enabled, the transmit threshold is ignored.
  • EMAC_MODE_RX_ERROR_FRAMES indicates that all frames other than runt error frames are being forwarded to the receive DMA regardless of any errors detected in the frames.
  • EMAC_MODE_RX_UNDERSIZED_FRAMES indicates that undersized frames (frames shorter than 64 bytes but with no errors) are being forwarded to the application. If this option is not reported, all undersized frames are dropped by the receiver unless it has already started transferring them to the receive FIFO due to the receive threshold setting.
  • EMAC_MODE_OPERATE_2ND_FRAME indicates that the transmit DMA is configured to operate on a second frame while waiting for the previous frame to be transmitted and associated status and timestamps to be reported. If absent, the transmit DMA works on a single frame at any one time, waiting for that frame to be transmitted and its status to be received before moving on to the next frame.
  • EMAC_MODE_TX_DMA_ENABLED indicates that the transmit DMA engine is currently enabled.
  • EMAC_MODE_RX_DMA_ENABLED indicates that the receive DMA engine is currently enabled.

The pui32RxMaxFrameSize is written with the currently configured maximum receive packet size. Packets larger than this are flagged as being in error.

Returns
None.

Definition at line 1054 of file emac.c.

References ASSERT, EMAC_CFG_JFEN, EMAC_CONFIG_RX_ENABLED, EMAC_CONFIG_TX_ENABLED, EMAC_O_CFG, EMAC_O_DMAOPMODE, EMAC_O_WDOGTO, EMAC_WDOGTO_PWE, EMAC_WDOGTO_WTO_M, HWREG, and VALID_CONFIG_FLAGS.

1056 {
1057  uint32_t ui32Value;
1058 
1059  //
1060  // Parameter sanity check.
1061  //
1062  ASSERT(pui32Mode);
1063  ASSERT(pui32Config);
1064  ASSERT(pui32RxMaxFrameSize);
1065 
1066  //
1067  // Return the mode information from the operation mode register.
1068  //
1069  *pui32Mode = HWREG(ui32Base + EMAC_O_DMAOPMODE);
1070 
1071  //
1072  // Return the current configuration flags from the EMAC_O_CFG register.
1073  //
1074  *pui32Config = (HWREG(ui32Base + EMAC_O_CFG) &
1077 
1078  //
1079  // Get the receive packet size watchdog value.
1080  //
1081  ui32Value = HWREG(ui32Base + EMAC_O_WDOGTO);
1082  if(ui32Value & EMAC_WDOGTO_PWE)
1083  {
1084  //
1085  // The watchdog is enables so the maximum packet length can be read
1086  // from the watchdog timeout register.
1087  //
1088  *pui32RxMaxFrameSize = ui32Value & EMAC_WDOGTO_WTO_M;
1089  }
1090  else
1091  {
1092  //
1093  // The maximum packet size override found in the watchdog timer
1094  // register is not enabled so the maximum packet size is determined
1095  // by whether or not jumbo frame mode is enabled.
1096  //
1097  if(HWREG(ui32Base + EMAC_O_CFG) & EMAC_CFG_JFEN)
1098  {
1099  //
1100  // Jumbo frames are enabled so the watchdog kicks in at 10240
1101  // bytes.
1102  //
1103  *pui32RxMaxFrameSize = 10240;
1104  }
1105  else
1106  {
1107  //
1108  // Jumbo frames are not enabled so the watchdog kicks in at
1109  // 2048 bytes.
1110  //
1111  *pui32RxMaxFrameSize = 2048;
1112  }
1113  }
1114 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define VALID_CONFIG_FLAGS
Definition: emac.c:71
#define EMAC_CONFIG_TX_ENABLED
Definition: emac.h:495
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CONFIG_RX_ENABLED
Definition: emac.h:496
#define EMAC_WDOGTO_PWE
Definition: hw_emac.h:522
#define EMAC_WDOGTO_WTO_M
Definition: hw_emac.h:523
#define EMAC_O_WDOGTO
Definition: hw_emac.h:73
#define EMAC_CFG_JFEN
Definition: hw_emac.h:171
void EMACConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config,
uint32_t  ui32ModeFlags,
uint32_t  ui32RxMaxFrameSize 
)

Configures basic Ethernet MAC operation parameters.

Parameters
ui32Baseis the base address of the Ethernet controller.
ui32Configprovides various flags and values configuring the MAC.
ui32ModeFlagsprovides configuration relating to the transmit and receive DMA engines.
ui32RxMaxFrameSizesets the maximum receive frame size above which an error is reported.

This function is called to configure basic operating parameters for the MAC and its DMA engines.

The ui32Config parameter is the logical OR of various fields and flags. The first field determines which MAC address is used during insertion or replacement for all transmitted frames. Valid options are

  • EMAC_CONFIG_USE_MACADDR1 and
  • EMAC_CONFIG_USE_MACADDR0

The interframe gap between transmitted frames is controlled using one of the following values:

  • EMAC_CONFIG_IF_GAP_96BITS
  • EMAC_CONFIG_IF_GAP_88BITS
  • EMAC_CONFIG_IF_GAP_80BITS
  • EMAC_CONFIG_IF_GAP_72BITS
  • EMAC_CONFIG_IF_GAP_64BITS
  • EMAC_CONFIG_IF_GAP_56BITS
  • EMAC_CONFIG_IF_GAP_48BITS
  • EMAC_CONFIG_IF_GAP_40BITS

The number of bytes of preamble added to the beginning of every transmitted frame is selected using one of the following values:

  • EMAC_CONFIG_7BYTE_PREAMBLE
  • EMAC_CONFIG_5BYTE_PREAMBLE
  • EMAC_CONFIG_3BYTE_PREAMBLE

The back-off limit determines the range of the random time that the MAC delays after a collision and before attempting to retransmit a frame. One of the following values must be used to select this limit. In each case, the retransmission delay in terms of 512 bit time slots, is the lower of (2 ** N) and a random number between 0 and the selected backoff-limit.

  • EMAC_CONFIG_BO_LIMIT_1024
  • EMAC_CONFIG_BO_LIMIT_256
  • EMAC_CONFIG_BO_LIMIT_16
  • EMAC_CONFIG_BO_LIMIT_2

Control over insertion or replacement of the source address in all transmitted frames is provided by using one of the following fields:

  • EMAC_CONFIG_SA_INSERT causes the MAC address (0 or 1 depending on whether EMAC_CONFIG_USE_MACADDR0 or EMAC_CONFIG_USE_MACADDR1 was specified) to be inserted into all transmitted frames.
  • EMAC_CONFIG_SA_REPLACE causes the MAC address to be replaced with the selected address in all transmitted frames.
  • EMAC_CONFIG_SA_FROM_DESCRIPTOR causes control of source address insertion or deletion to be controlled by fields in the DMA transmit descriptor, allowing control on a frame-by-frame basis.

Whether the interface attempts to operate in full- or half-duplex mode is controlled by one of the following flags:

  • EMAC_CONFIG_FULL_DUPLEX
  • EMAC_CONFIG_HALF_DUPLEX

The following additional flags may also be specified:

  • EMAC_CONFIG_2K_PACKETS enables IEEE802.3as support for 2K packets. When specified, the MAC considers all frames up to 2000 bytes in length as normal packets. When EMAC_CONFIG_JUMBO_ENABLE is not specified, all frames larger than 2000 bytes are treated as Giant frames. This flag is ignored if EMAC_CONFIG_JUMBO_ENABLE is specified.
  • EMAC_CONFIG_STRIP_CRC causes the 4-byte CRC of all Ethernet type frames to be stripped and dropped before the frame is forwarded to the application.
  • EMAC_CONFIG_JABBER_DISABLE disables the jabber timer on the transmitter and enables frames of up to 16384 bytes to be transmitted. If this flag is absent, the MAC does not allow more than 2048 (or 10240 if EMAC_CONFIG_JUMBO_ENABLE is specified) bytes to be sent in any one frame.
  • EMAC_CONFIG_JUMBO_ENABLE enables Jumbo Frames, allowing frames of up to 9018 (or 9022 if using VLAN tagging) to be handled without reporting giant frame errors.
  • EMAC_CONFIG_100MBPS forces the MAC to communicate with the PHY using 100Mbps signaling. If this option is not specified, the MAC uses 10Mbps signaling. This speed setting is important when using an external RMII PHY where the selected rate must match the PHY's setting which may have been made as a result of auto-negotiation. When using the internal PHY or an external MII PHY, the signaling rate is controlled by the PHY- provided transmit and receive clocks.
  • EMAC_CONFIG_CS_DISABLE disables Carrier Sense during transmission when operating in half-duplex mode.
  • EMAC_CONFIG_RX_OWN_DISABLE disables reception of transmitted frames when operating in half-duplex mode.
  • EMAC_CONFIG_LOOPBACK enables internal loopback.
  • EMAC_CONFIG_CHECKSUM_OFFLOAD enables IPv4 header checksum checking and IPv4 or IPv6 TCP, UPD or ICMP payload checksum checking. The results of the checksum calculations are reported via status fields in the DMA receive descriptors.
  • EMAC_CONFIG_RETRY_DISABLE disables retransmission in cases where half-duplex mode is in use and a collision occurs. This condition causes the current frame to be ignored and a frame abort to be reported in the transmit frame status.
  • EMAC_CONFIG_AUTO_CRC_STRIPPING strips the last 4 bytes (frame check sequence) from all Ether type frames before forwarding the frames to the application.
  • EMAC_CONFIG_DEFERRAL_CHK_ENABLE enables transmit deferral checking in half-duplex mode. When enabled, the transmitter reports an error if it is unable to transmit a frame for more than 24288 bit times (or 155680 bit times in Jumbo frame mode) due to an active carrier sense signal on the MII.

The ui32ModeFlags parameter sets operating parameters related to the internal MAC FIFOs. It comprises a logical OR of the following fields. The first selects the transmit FIFO threshold. Transmission of a frame begins when this amount of data or a full frame exists in the transmit FIFO. This field is ignored if EMAC_MODE_TX_STORE_FORWARD is included. One of the following must be specified:

  • EMAC_MODE_TX_THRESHOLD_16_BYTES
  • EMAC_MODE_TX_THRESHOLD_24_BYTES
  • EMAC_MODE_TX_THRESHOLD_32_BYTES
  • EMAC_MODE_TX_THRESHOLD_40_BYTES
  • EMAC_MODE_TX_THRESHOLD_64_BYTES
  • EMAC_MODE_TX_THRESHOLD_128_BYTES
  • EMAC_MODE_TX_THRESHOLD_192_BYTES
  • EMAC_MODE_TX_THRESHOLD_256_BYTES

The second field controls the receive FIFO threshold. DMA transfers of received data begin either when the receive FIFO contains a full frame or this number of bytes. This field is ignored if EMAC_MODE_RX_STORE_FORWARD is included. One of the following must be specified:

  • EMAC_MODE_RX_THRESHOLD_64_BYTES
  • EMAC_MODE_RX_THRESHOLD_32_BYTES
  • EMAC_MODE_RX_THRESHOLD_96_BYTES
  • EMAC_MODE_RX_THRESHOLD_128_BYTES

The following additional flags may be specified:

  • EMAC_MODE_KEEP_BAD_CRC causes frames with TCP/IP checksum errors to be forwarded to the application if those frames do not have any errors (including FCS errors) in the Ethernet framing. In these cases, the frames have errors only in the payload. If this flag is not specified, all frames with any detected error are discarded unless EMAC_MODE_RX_ERROR_FRAMES is also specified.
  • EMAC_MODE_RX_STORE_FORWARD causes the receive DMA to read frames from the FIFO only after the complete frame has been written to it. If this mode is enabled, the receive threshold is ignored.
  • EMAC_MODE_RX_FLUSH_DISABLE disables the flushing of received frames in cases where receive descriptors or buffers are unavailable.
  • EMAC_MODE_TX_STORE_FORWARD causes the transmitter to start transmitting a frame only after the whole frame has been written to the transmit FIFO. If this mode is enabled, the transmit threshold is ignored.
  • EMAC_MODE_RX_ERROR_FRAMES causes all frames other than runt error frames to be forwarded to the receive DMA regardless of any errors detected in the frames.
  • EMAC_MODE_RX_UNDERSIZED_FRAMES causes undersized frames (frames shorter than 64 bytes but with no errors) to the application. If this option is not selected, all undersized frames are dropped by the receiver unless it has already started transferring them to the receive FIFO due to the receive threshold setting.
  • EMAC_MODE_OPERATE_2ND_FRAME enables the transmit DMA to operate on a second frame while waiting for the previous frame to be transmitted and associated status and timestamps to be reported. If absent, the transmit DMA works on a single frame at any one time, waiting for that frame to be transmitted and its status to be received before moving on to the next frame.

The ui32RxMaxFrameSize parameter may be used to override the default setting for the maximum number of bytes that can be received in a frame before that frame is flagged as being in error. If the parameter is set to 0, the default hardware settings are applied. If non-zero, any frame received which is longer than the ui32RxMaxFrameSize, regardless of whether the MAC is configured for normal or Jumbo frame operation, is flagged as an error.

Returns
None.

Definition at line 819 of file emac.c.

References ASSERT, EMAC_CFG_PS, EMAC_CONFIG_RX_ENABLED, EMAC_CONFIG_TX_ENABLED, EMAC_O_CFG, EMAC_O_DMAOPMODE, EMAC_O_WDOGTO, EMAC_WDOGTO_PWE, HWREG, and VALID_CONFIG_FLAGS.

821 {
822  //
823  // Parameter sanity check. Note that we allow TX_ENABLED and RX_ENABLED
824  // here because we'll mask them off before writing the value and this
825  // makes back-to-back EMACConfigGet/EMACConfigSet calls work without the
826  // caller needing to explicitly remove these bits from the parameter.
827  //
829  EMAC_CONFIG_RX_ENABLED)) == 0);
830  ASSERT(!ui32RxMaxFrameSize || ((ui32RxMaxFrameSize < 0x4000) &&
831  (ui32RxMaxFrameSize > 1522)));
832 
833  //
834  // Set the configuration flags as specified. Note that we unconditionally
835  // OR in the EMAC_CFG_PS bit here since this implementation supports only
836  // MII and RMII interfaces to the PHYs.
837  //
838  HWREG(ui32Base + EMAC_O_CFG) =
839  ((HWREG(ui32Base + EMAC_O_CFG) & ~VALID_CONFIG_FLAGS) | ui32Config |
840  EMAC_CFG_PS);
841 
842  //
843  // Set the maximum receive frame size. If 0 is passed, this implies
844  // that the default maximum frame size should be used so just turn off
845  // the override.
846  //
847  if(ui32RxMaxFrameSize)
848  {
849  HWREG(ui32Base + EMAC_O_WDOGTO) = ui32RxMaxFrameSize | EMAC_WDOGTO_PWE;
850  }
851  else
852  {
853  HWREG(ui32Base + EMAC_O_WDOGTO) &= ~EMAC_WDOGTO_PWE;
854  }
855 
856  //
857  // Set the operating mode register.
858  //
859  HWREG(ui32Base + EMAC_O_DMAOPMODE) = ui32ModeFlags;
860 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define VALID_CONFIG_FLAGS
Definition: emac.c:71
#define EMAC_CONFIG_TX_ENABLED
Definition: emac.h:495
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CONFIG_RX_ENABLED
Definition: emac.h:496
#define EMAC_CFG_PS
Definition: hw_emac.h:183
#define EMAC_WDOGTO_PWE
Definition: hw_emac.h:522
#define EMAC_O_WDOGTO
Definition: hw_emac.h:73
uint32_t EMACDMAStateGet ( uint32_t  ui32Base)

Returns the current states of the Ethernet MAC transmit and receive DMA engines.

Parameters
ui32Baseis the base address of the controller.

This function may be used to query the current states of the transmit and receive DMA engines. The return value contains two fields, one providing the transmit state and the other the receive state. Macros EMAC_TX_DMA_STATE() and EMAC_RX_DMA_STATE() may be used to extract these fields from the returned value. Alternatively, masks EMAC_DMA_TXSTAT_MASK and EMAC_DMA_RXSTAT_MASK may be used directly to mask out the individual states from the returned value.

Returns
Returns the states of the transmit and receive DMA engines. These states are ORed together into a single word containing one of:
  • EMAC_DMA_TXSTAT_STOPPED indicating that the transmit engine is stopped.
  • EMAC_DMA_TXSTAT_RUN_FETCH_DESC indicating that the transmit engine is fetching the next descriptor.
  • EMAC_DMA_TXSTAT_RUN_WAIT_STATUS indicating that the transmit engine is waiting for status from the MAC.
  • EMAC_DMA_TXSTAT_RUN_READING indicating that the transmit engine is currently transferring data from memory to the MAC transmit FIFO.
  • EMAC_DMA_TXSTAT_RUN_CLOSE_DESC indicating that the transmit engine is closing the descriptor after transmission of the buffer data.
  • EMAC_DMA_TXSTAT_TS_WRITE indicating that the transmit engine is currently writing timestamp information to the descriptor.
  • EMAC_DMA_TXSTAT_SUSPENDED indicating that the transmit engine is suspended due to the next descriptor being unavailable (owned by the host) or a transmit buffer underflow.

and one of:

  • EMAC_DMA_RXSTAT_STOPPED indicating that the receive engine is stopped.
  • EMAC_DMA_RXSTAT_RUN_FETCH_DESC indicating that the receive engine is fetching the next descriptor.
  • EMAC_DMA_RXSTAT_RUN_WAIT_PACKET indicating that the receive engine is waiting for the next packet.
  • EMAC_DMA_RXSTAT_SUSPENDED indicating that the receive engine is suspended due to the next descriptor being unavailable.
  • EMAC_DMA_RXSTAT_RUN_CLOSE_DESC indicating that the receive engine is closing the descriptor after receiving a buffer of data.
  • EMAC_DMA_RXSTAT_TS_WRITE indicating that the transmit engine is currently writing timestamp information to the descriptor.
  • EMAC_DMA_RXSTAT_RUN_RECEIVING indicating that the receive engine is currently transferring data from the MAC receive FIFO to memory.

Additionally, a DMA bus error may be signaled using EMAC_DMA_ERROR. If this flag is present, the source of the error is identified using one of the following values which may be extracted from the return value using EMAC_DMA_ERR_MASK:

  • EMAC_DMA_ERR_RX_DATA_WRITE indicates that an error occurred when writing received data to memory.
  • EMAC_DMA_ERR_TX_DATA_READ indicates that an error occurred when reading data from memory for transmission.
  • EMAC_DMA_ERR_RX_DESC_WRITE indicates that an error occurred when writing to the receive descriptor.
  • EMAC_DMA_ERR_TX_DESC_WRITE indicates that an error occurred when writing to the transmit descriptor.
  • EMAC_DMA_ERR_RX_DESC_READ indicates that an error occurred when reading the receive descriptor.
  • EMAC_DMA_ERR_TX_DESC_READ indicates that an error occurred when reading the transmit descriptor.

Definition at line 2173 of file emac.c.

References EMAC_DMARIS_AE_M, EMAC_DMARIS_FBI, EMAC_DMARIS_RS_M, EMAC_DMARIS_TS_M, EMAC_O_DMARIS, and HWREG.

2174 {
2175  //
2176  // Return the status of the DMA channels.
2177  //
2178  return(HWREG(ui32Base + EMAC_O_DMARIS) &
2180  EMAC_DMARIS_TS_M));
2181 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_DMARIS
Definition: hw_emac.h:133
#define EMAC_DMARIS_AE_M
Definition: hw_emac.h:1046
#define EMAC_DMARIS_FBI
Definition: hw_emac.h:1092
#define EMAC_DMARIS_TS_M
Definition: hw_emac.h:1059
#define EMAC_DMARIS_RS_M
Definition: hw_emac.h:1074
uint32_t EMACFrameFilterGet ( uint32_t  ui32Base)

Returns the current Ethernet frame filtering settings.

Parameters
ui32Baseis the base address of the controller.

This function may be called to retrieve the frame filtering configuration set using a prior call to EMACFrameFilterSet().

Returns
Returns a value comprising the logical OR of various flags indicating the frame filtering options in use. Possible flags are:
  • EMAC_FRMFILTER_RX_ALL indicates that the MAC to is configured to pass all received frames regardless of whether or not they pass any address filter that is configured. The receive status word in the relevant DMA descriptor is updated to indicate whether the configured filter passed or failed for the frame.
  • EMAC_FRMFILTER_VLAN indicates that the MAC is configured to drop any frames which do not pass the VLAN tag comparison.
  • EMAC_FRMFILTER_HASH_AND_PERFECT indicates that the MAC is configured to pass frames if they match either the hash filter or the perfect filter. If this flag is absent, frames passing based on the result of a single filter, the perfect filter if EMAC_FRMFILTER_HASH_MULTICAST or EMAC_FRMFILTER_HASH_UNICAST are clear or the hash filter otherwise.
  • EMAC_FRMFILTER_SADDR indicates that the MAC is configured to drop received frames when the source address field in the frame does not match the values programmed into the enabled SA registers.
  • EMAC_FRMFILTER_INV_SADDR enables inverse source address filtering. When this option is specified, frames for which the SA does not match the SA registers are marked as passing the source address filter.
  • EMAC_FRMFILTER_BROADCAST indicates that the MAC is configured to discard all incoming broadcast frames.
  • EMAC_FRMFILTER_PASS_MULTICAST indicates that the MAC is configured to pass all incoming frames with multicast destinations addresses.
  • EMAC_FRMFILTER_INV_DADDR indicates that the sense of the destination address filtering for both unicast and multicast frames is inverted.
  • EMAC_FRMFILTER_HASH_MULTICAST indicates that destination address filtering of received multicast frames is enabled using the hash table. If absent, perfect destination address filtering is used. If used in conjunction with EMAC_FRMFILTER_HASH_AND_PERFECT, this flag indicates that the hash filter should be used for incoming multicast packets along with the perfect filter.
  • EMAC_FRMFILTER_HASH_UNICAST indicates that destination address filtering of received unicast frames is enabled using the hash table. If absent, perfect destination address filtering is used. If used in conjunction with EMAC_FRMFILTER_HASH_AND_PERFECT, this flag indicates that the hash filter should be used for incoming unicast packets along with the perfect filter.
  • EMAC_FRMFILTER_PROMISCUOUS indicates that the MAC is configured to operate in promiscuous mode where all received frames are passed to the application and the SA and DA filter status bits of the descriptor receive status word are always cleared.

Control frame filtering configuration is indicated by one of the following values which may be extracted from the returned value using the mask EMAC_FRMFILTER_PASS_MASK:

  • EMAC_FRMFILTER_PASS_NO_CTRL prevents any control frame from reaching the application.
  • EMAC_FRMFILTER_PASS_NO_PAUSE passes all control frames other than PAUSE even if they fail the configured address filter.
  • EMAC_FRMFILTER_PASS_ALL_CTRL passes all control frames, including PAUSE even if they fail the configured address filter.
  • EMAC_FRMFILTER_PASS_ADDR_CTRL passes all control frames only if they pass the configured address filter.

Definition at line 1564 of file emac.c.

References EMAC_O_FRAMEFLTR, HWREG, and VALID_FRMFILTER_FLAGS.

1565 {
1566  //
1567  // Return the current MAC frame filter setting.
1568  //
1569  return(HWREG(ui32Base + EMAC_O_FRAMEFLTR) & VALID_FRMFILTER_FLAGS);
1570 }
#define VALID_FRMFILTER_FLAGS
Definition: emac.c:96
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_FRAMEFLTR
Definition: hw_emac.h:49
void EMACFrameFilterSet ( uint32_t  ui32Base,
uint32_t  ui32FilterOpts 
)

Sets options related to Ethernet frame filtering.

Parameters
ui32Baseis the base address of the controller.
ui32FilterOptsis a logical OR of flags defining the required MAC address filtering options.

This function allows various filtering options to be defined and allows an application to control which frames are received based on various criteria related to the frame source and destination MAC addresses or VLAN tagging.

The ui32FilterOpts parameter is a logical OR of any of the following flags:

  • EMAC_FRMFILTER_RX_ALL configures the MAC to pass all received frames regardless of whether or not they pass any address filter that is configured. The receive status word in the relevant DMA descriptor is updated to indicate whether the configured filter passed or failed for the frame.
  • EMAC_FRMFILTER_VLAN configures the MAC to drop any frames that do not pass the VLAN tag comparison.
  • EMAC_FRMFILTER_HASH_AND_PERFECT configures the MAC to filter frames based on both any perfect filters set and the hash filter if enabled using EMAC_FRMFILTER_HASH_UNICAST or EMAC_FRMFILTER_HASH_MULTICAST. In this case, only if both filters fail is the packet rejected. If this option is absent, only one of the filter types is used, as controlled by EMAC_FRMFILTER_HASH_UNICAST and EMAC_FRMFILTER_HASH_MULTICAST for unicast and multicast frames respectively.
  • EMAC_FRMFILTER_SADDR configures the MAC to drop received frames when the source address field in the frame does not match the values programmed into the enabled SA registers.
  • EMAC_FRMFILTER_INV_SADDR enables inverse source address filtering. When this option is specified, frames for which the SA does not match the SA registers are marked as passing the source address filter.
  • EMAC_FRMFILTER_BROADCAST configures the MAC to discard all incoming broadcast frames.
  • EMAC_FRMFILTER_PASS_MULTICAST configures the MAC to pass all incoming frames with multicast destinations addresses.
  • EMAC_FRMFILTER_INV_DADDR inverts the sense of the destination address filtering for both unicast and multicast frames.
  • EMAC_FRMFILTER_HASH_MULTICAST enables destination address filtering of received multicast frames using the hash table. If absent, perfect destination address filtering is used. If used in conjunction with EMAC_FRMFILTER_HASH_AND_PERFECT, this flag indicates that the hash filter should be used for incoming multicast packets along with the perfect filter.
  • EMAC_FRMFILTER_HASH_UNICAST enables destination address filtering of received unicast frames using the hash table. If absent, perfect destination address filtering is used. If used in conjunction with EMAC_FRMFILTER_HASH_AND_PERFECT, this flag indicates that the hash filter should be used for incoming unicast packets along with the perfect filter.
  • EMAC_FRMFILTER_PROMISCUOUS configures the MAC to operate in promiscuous mode where all received frames are passed to the application and the SA and DA filter status bits of the descriptor receive status word are always cleared.

Control frame filtering may be configured by ORing one of the following values into ui32FilterOpts:

  • EMAC_FRMFILTER_PASS_NO_CTRL prevents any control frame from reaching the application.
  • EMAC_FRMFILTER_PASS_NO_PAUSE passes all control frames other than PAUSE even if they fail the configured address filter.
  • EMAC_FRMFILTER_PASS_ALL_CTRL passes all control frames, including PAUSE even if they fail the configured address filter.
  • EMAC_FRMFILTER_PASS_ADDR_CTRL passes all control frames only if they pass the configured address filter.
Returns
None.

Definition at line 1484 of file emac.c.

References ASSERT, EMAC_O_FRAMEFLTR, HWREG, and VALID_FRMFILTER_FLAGS.

1485 {
1486  ASSERT((ui32FilterOpts & ~VALID_FRMFILTER_FLAGS) == 0);
1487 
1488  //
1489  // Set the Ethernet MAC frame filter according to the flags passed.
1490  //
1491  HWREG(ui32Base + EMAC_O_FRAMEFLTR) =
1492  ((HWREG(ui32Base + EMAC_O_FRAMEFLTR) & ~VALID_FRMFILTER_FLAGS) |
1493  ui32FilterOpts);
1494 }
#define VALID_FRMFILTER_FLAGS
Definition: emac.c:96
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_FRAMEFLTR
Definition: hw_emac.h:49
uint32_t EMACHashFilterBitCalculate ( uint8_t *  pui8MACAddr)

Returns the bit number to set in the MAC hash filter corresponding to a given MAC address.

Parameters
pui8MACAddrpoints to a buffer containing the 6-byte MAC address for which the hash filter bit is to be determined.

This function may be used to determine which bit in the MAC address hash filter to set to describe a given 6-byte MAC address. The returned value is a 6-bit number where bit 5 indicates which of the two hash table words is affected and the bottom 5 bits indicate the bit number to set within that word. For example, if 0x22 (100010b) is returned, this indicates that bit 2 of word 1 (ui32HashHi as passed to EMACHashFilterSet()) must be set to describe the passed MAC address.

Returns
Returns the bit number to set in the MAC hash table to describe the passed MAC address.

Definition at line 1672 of file emac.c.

References ASSERT, and Crc32().

1673 {
1674  uint32_t ui32CRC, ui32Mask, ui32Loop;
1675 
1676  //
1677  // Parameter sanity check.
1678  //
1679  ASSERT(pui8MACAddr);
1680 
1681  //
1682  // Calculate the CRC for the MAC address.
1683  //
1684  ui32CRC = Crc32(0xFFFFFFFF, pui8MACAddr, 6);
1685  ui32CRC ^= 0xFFFFFFFF;
1686 
1687  //
1688  // Determine the hash bit to use from the calculated CRC. This is the
1689  // top 6 bits of the reversed CRC (or the bottom 6 bits of the calculated
1690  // CRC with the bit order of those 6 bits reversed).
1691  //
1692  ui32Mask = 0;
1693 
1694  //
1695  // Reverse the order of the bottom 6 bits of the calculated CRC.
1696  //
1697  for(ui32Loop = 0; ui32Loop < 6; ui32Loop++)
1698  {
1699  ui32Mask <<= 1;
1700  ui32Mask |= (ui32CRC & 1);
1701  ui32CRC >>= 1;
1702  }
1703 
1704  //
1705  // Return the final hash table bit index.
1706  //
1707  return(ui32Mask);
1708 }
#define ASSERT(expr)
Definition: debug.h:67
uint32_t Crc32(uint32_t ui32Crc, const uint8_t *pui8Data, uint32_t ui32Count)
Definition: sw_crc.c:654

Here is the call graph for this function:

void EMACHashFilterGet ( uint32_t  ui32Base,
uint32_t *  pui32HashHi,
uint32_t *  pui32HashLo 
)

Returns the current MAC address hash filter table.

Parameters
ui32Baseis the base address of the controller.
pui32HashHipoints to storage to be written with the upper 32 bits of the current 64-bit hash filter table.
pui32HashLopoints to storage to be written with the lower 32 bits of the current 64-bit hash filter table.

This function may be used to retrieve the current 64-bit hash filter table from the MAC prior to making changes and setting the new hash filter via a call to EMACHashFilterSet().

Hash table filtering allows many different MAC addresses to be filtered simultaneously at the cost of some false-positive results in the form of packets passing the filter when their MAC address was not one of those required. A CRC of the packet source or destination MAC address is calculated and the bottom 6 bits are used as a bit index into the 64-bit hash filter table. If the bit in the hash table is set, the filter is considered to have passed. If the bit is clear, the filter fails and the packet is rejected (assuming normal rather than inverse filtering is configured).

Returns
None.

Definition at line 1638 of file emac.c.

References ASSERT, EMAC_O_HASHTBLH, EMAC_O_HASHTBLL, and HWREG.

1640 {
1641  ASSERT(pui32HashHi);
1642  ASSERT(pui32HashLo);
1643 
1644  //
1645  // Get the current hash table values.
1646  //
1647  *pui32HashLo = HWREG(ui32Base + EMAC_O_HASHTBLL);
1648  *pui32HashHi = HWREG(ui32Base + EMAC_O_HASHTBLH);
1649 }
#define EMAC_O_HASHTBLH
Definition: hw_emac.h:50
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_HASHTBLL
Definition: hw_emac.h:51
void EMACHashFilterSet ( uint32_t  ui32Base,
uint32_t  ui32HashHi,
uint32_t  ui32HashLo 
)

Sets the MAC address hash filter table.

Parameters
ui32Baseis the base address of the controller.
ui32HashHiis the upper 32 bits of the current 64-bit hash filter table to set.
ui32HashLois the lower 32 bits of the current 64-bit hash filter table to set.

This function may be used to set the current 64-bit hash filter table used by the MAC to filter incoming packets when hash filtering is enabled. Hash filtering is enabled by passing EMAC_FRMFILTER_HASH_UNICAST and/or EMAC_FRMFILTER_HASH_MULTICAST in the ui32FilterOpts parameter to EMACFrameFilterSet(). The current hash filter may be retrieved by calling EMACHashFilterGet().

Hash table filtering allows many different MAC addresses to be filtered simultaneously at the cost of some false-positive results (in the form of packets passing the filter when their MAC address was not one of those required). A CRC of the packet source or destination MAC address is calculated and the bottom 6 bits are used as a bit index into the 64-bit hash filter table. If the bit in the hash table is set, the filter is considered to have passed. If the bit is clear, the filter fails and the packet is rejected (assuming normal rather than inverse filtering is configured).

Returns
None.

Definition at line 1603 of file emac.c.

References EMAC_O_HASHTBLH, EMAC_O_HASHTBLL, and HWREG.

1604 {
1605  // Set the hash table with the values provided.
1606  HWREG(ui32Base + EMAC_O_HASHTBLL) = ui32HashLo;
1607  HWREG(ui32Base + EMAC_O_HASHTBLH) = ui32HashHi;
1608 }
#define EMAC_O_HASHTBLH
Definition: hw_emac.h:50
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_HASHTBLL
Definition: hw_emac.h:51
void EMACInit ( uint32_t  ui32Base,
uint32_t  ui32SysClk,
uint32_t  ui32BusConfig,
uint32_t  ui32RxBurst,
uint32_t  ui32TxBurst,
uint32_t  ui32DescSkipSize 
)

Initializes the Ethernet MAC and sets bus-related DMA parameters.

Parameters
ui32Baseis the base address of the Ethernet controller.
ui32SysClkis the current system clock frequency in Hertz.
ui32BusConfigdefines the bus operating mode for the Ethernet MAC DMA controller.
ui32RxBurstis the maximum receive burst size in words.
ui32TxBurstis the maximum transmit burst size in words.
ui32DescSkipSizeis the number of 32-bit words to skip between two unchained DMA descriptors. Values in the range 0 to 31 are valid.

This function sets bus-related parameters for the Ethernet MAC DMA engines. It must be called after EMACPHYConfigSet() and called again after any subsequent call to EMACPHYConfigSet().

The ui32BusConfig parameter is the logical OR of various fields. The first sets the DMA channel priority weight:

  • EMAC_BCONFIG_DMA_PRIO_WEIGHT_1
  • EMAC_BCONFIG_DMA_PRIO_WEIGHT_2
  • EMAC_BCONFIG_DMA_PRIO_WEIGHT_3
  • EMAC_BCONFIG_DMA_PRIO_WEIGHT_4

The second field sets the receive and transmit priorities used when arbitrating between the Rx and Tx DMA. The priorities are Rx:Tx unless EMAC_BCONFIG_TX_PRIORITY is also specified, in which case they become Tx:Rx. The priority provided here is ignored if EMAC_BCONFIG_PRIORITY_FIXED is specified.

  • EMAC_BCONFIG_PRIORITY_1_1
  • EMAC_BCONFIG_PRIORITY_2_1
  • EMAC_BCONFIG_PRIORITY_3_1
  • EMAC_BCONFIG_PRIORITY_4_1

The following additional flags may also be defined:

  • EMAC_BCONFIG_TX_PRIORITY indicates that the transmit DMA should be higher priority in all arbitration for the system-side bus. If this is not defined, the receive DMA has higher priority.
  • EMAC_BCONFIG_ADDR_ALIGNED works in tandem with EMAC_BCONFIG_FIXED_BURST to control address alignment of AHB bursts. When both flags are specified, all bursts are aligned to the start address least significant bits. If EMAC_BCONFIG_FIXED_BURST is not specified, the first burst is unaligned but subsequent bursts are aligned to the address.
  • EMAC_BCONFIG_ALT_DESCRIPTORS indicates that the DMA engine should use the alternate descriptor format as defined in type tEMACDMADescriptor. If absent, the basic descriptor type is used. Alternate descriptors are required if using IEEE 1588-2008 advanced timestamping, VLAN or TCP/UDP/ICMP CRC insertion features. Note that, for clarity, emac.h does not contain type definitions for the basic descriptor type. Please see the part datasheet for information on basic descriptor structures.
  • EMAC_BCONFIG_PRIORITY_FIXED indicates that a fixed priority scheme should be employed when arbitrating between the transmit and receive DMA for system-side bus access. In this case, the receive channel always has priority unless EMAC_BCONFIG_TX_PRIORITY is set, in which case the transmit channel has priority. If EMAC_BCONFIG_PRIORITY_FIXED is not specified, a weighted round-robin arbitration scheme is used with the weighting defined using EMAC_BCONFIG_PRIORITY_1_1, EMAC_BCONFIG_PRIORITY_2_1, EMAC_BCONFIG_PRIORITY_3_1 or EMAC_BCONFIG_PRIORITY_4_1, and EMAC_BCONFIG_TX_PRIORITY.
  • EMAC_BCONFIG_FIXED_BURST indicates that fixed burst transfers should be used.
  • EMAC_BCONFIG_MIXED_BURST indicates that the DMA engine should use mixed burst types depending on the length of data to be transferred across the system bus.

The ui32RxBurst and ui32TxBurst parameters indicate the maximum number of words that the relevant DMA should transfer in a single transaction. Valid values are 1, 2, 4, 8, 16 and 32. Any other value results in undefined behavior.

The ui32DescSkipSize parameter is used when the descriptor lists are using ring mode (where descriptors are contiguous in memory with the last descriptor marked with the END_OF_RING flag) rather than chained mode (where each descriptor includes a field that points to the next descriptor in the list). In ring mode, the hardware uses the ui32DescSkipSize to skip past any application-defined fields after the end of the hardware- defined descriptor fields. The parameter value indicates the number of 32-bit words to skip after the last field of the hardware-defined descriptor to get to the first field of the next descriptor. When using arrays of either the tEMACDMADescriptor or tEMACAltDMADescriptor types defined for this driver, ui32DescSkipSize must be set to 1 to skip the pvNext pointer added to the end of each of these structures. Applications may modify these structure definitions to include their own application-specific data and modify ui32DescSkipSize appropriately if desired.

Returns
None.

Definition at line 305 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_DMABUSMOD_8XPBL, EMAC_DMABUSMOD_ATDS, EMAC_DMABUSMOD_DSL_S, EMAC_DMABUSMOD_PBL_S, EMAC_DMABUSMOD_RPBL_S, EMAC_DMABUSMOD_SWR, EMAC_DMABUSMOD_USP, EMAC_MIIADDR_CR_M, EMAC_O_DMABUSMOD, EMAC_O_MIIADDR, EMAC_O_MMCRXIM, EMAC_O_MMCTXIM, g_pi16MIIClockDiv, HWREG, NUM_CLOCK_DIVISORS, and ui32SysClockMax.

307 {
308  uint32_t ui32Val, ui32Div;
309 
310  //
311  // Parameter sanity checks.
312  //
313  ASSERT(ui32DescSkipSize < 32);
314  ASSERT(ui32TxBurst < (32 * 8));
315  ASSERT(ui32RxBurst < (32 * 8));
316 
317  //
318  // Make sure that the DMA software reset is clear before continuing.
319  //
321  {
322  }
323 
324  //
325  // Set common flags. Note that this driver assumes we are always using
326  // 8 word descriptors so we need to OR in EMAC_DMABUSMOD_ATDS here.
327  //
328  ui32Val = (ui32BusConfig | (ui32DescSkipSize << EMAC_DMABUSMOD_DSL_S) |
330 
331  //
332  // Do we need to use the 8X burst length multiplier?
333  //
334  if((ui32TxBurst > 32) || (ui32RxBurst > 32))
335  {
336  //
337  // Divide both burst lengths by 8 and set the 8X burst length
338  // multiplier.
339  //
340  ui32Val |= EMAC_DMABUSMOD_8XPBL;
341  ui32TxBurst >>= 3;
342  ui32RxBurst >>= 3;
343 
344  //
345  // Sanity check - neither burst length should have become zero. If
346  // they did, this indicates that the values passed are invalid.
347  //
348  ASSERT(ui32RxBurst);
349  ASSERT(ui32TxBurst);
350  }
351 
352  //
353  // Are the receive and transmit burst lengths the same?
354  //
355  if(ui32RxBurst == ui32TxBurst)
356  {
357  //
358  // Yes - set up to use a single burst length.
359  //
360  ui32Val |= (ui32TxBurst << EMAC_DMABUSMOD_PBL_S);
361  }
362  else
363  {
364  //
365  // No - we need to use separate burst lengths for each.
366  //
367  ui32Val |= (EMAC_DMABUSMOD_USP |
368  (ui32TxBurst << EMAC_DMABUSMOD_PBL_S) |
369  (ui32RxBurst << EMAC_DMABUSMOD_RPBL_S));
370  }
371 
372  //
373  // Finally, write the bus mode register.
374  //
375  HWREG(ui32Base + EMAC_O_DMABUSMOD) = ui32Val;
376 
377  //
378  // Default the MII CSR clock divider based on the fastest system clock.
379  //
380  ui32Div = g_pi16MIIClockDiv[NUM_CLOCK_DIVISORS - 1].ui32Divisor;
381 
382  //
383  // Find the MII CSR clock divider to use based on the current system clock.
384  //
385  for(ui32Val = 0; ui32Val < NUM_CLOCK_DIVISORS; ui32Val++)
386  {
387  if(ui32SysClk <= g_pi16MIIClockDiv[ui32Val].ui32SysClockMax)
388  {
389  ui32Div = g_pi16MIIClockDiv[ui32Val].ui32Divisor;
390  break;
391  }
392  }
393 
394  //
395  // Set the MII CSR clock speed.
396  //
397  HWREG(ui32Base + EMAC_O_MIIADDR) = ((HWREG(ui32Base + EMAC_O_MIIADDR) &
398  ~EMAC_MIIADDR_CR_M) | ui32Div);
399 
400  //
401  // Disable all the MMC interrupts as these are enabled by default at reset.
402  //
403  HWREG(ui32Base + EMAC_O_MMCRXIM) = 0xFFFFFFFF;
404  HWREG(ui32Base + EMAC_O_MMCTXIM) = 0xFFFFFFFF;
405 }
static const struct @0 g_pi16MIIClockDiv[]
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_DMABUSMOD_RPBL_S
Definition: hw_emac.h:993
#define EMAC_O_MMCTXIM
Definition: hw_emac.h:81
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_DMABUSMOD_USP
Definition: hw_emac.h:982
#define EMAC_MIIADDR_CR_M
Definition: hw_emac.h:263
#define EMAC_DMABUSMOD_PBL_S
Definition: hw_emac.h:995
#define EMAC_O_MMCRXIM
Definition: hw_emac.h:79
uint32_t ui32SysClockMax
Definition: emac.c:192
#define EMAC_DMABUSMOD_DSL_S
Definition: hw_emac.h:996
#define EMAC_DMABUSMOD_ATDS
Definition: hw_emac.h:989
#define EMAC_O_MIIADDR
Definition: hw_emac.h:52
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define NUM_CLOCK_DIVISORS
Definition: emac.c:207
#define EMAC_DMABUSMOD_8XPBL
Definition: hw_emac.h:980
#define EMAC_DMABUSMOD_SWR
Definition: hw_emac.h:992
#define EMAC_O_DMABUSMOD
Definition: hw_emac.h:125
void EMACIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears individual Ethernet MAC interrupt sources.

Parameters
ui32Baseis the base address of the Ethernet MAC.
ui32IntFlagsis the bit mask of the interrupt sources to be cleared.

This function disables the indicated Ethernet MAC interrupt sources.

The ui32IntFlags parameter is the logical OR of any of the following:

  • EMAC_INT_PHY indicates that the PHY has signaled a change of state. Software must read and write the appropriate PHY registers to enable, disable and clear particular notifications.
  • EMAC_INT_EARLY_RECEIVE indicates that the DMA engine has filled the first data buffer of a packet.
  • EMAC_INT_BUS_ERROR indicates that a fatal bus error has occurred and that the DMA engine has been disabled.
  • EMAC_INT_EARLY_TRANSMIT indicates that a frame to be transmitted has been fully written from memory into the MAC transmit FIFO.
  • EMAC_INT_RX_WATCHDOG indicates that a frame with length greater than 2048 bytes (of 10240 bytes in Jumbo Frame mode) was received.
  • EMAC_INT_RX_STOPPED indicates that the receive process has entered the stopped state.
  • EMAC_INT_RX_NO_BUFFER indicates that the host owns the next buffer in the DMA's receive descriptor list and the DMA cannot, therefore, acquire a buffer. The receive process is suspended and can be resumed by changing the descriptor ownership and calling EMACRxDMAPollDemand().
  • EMAC_INT_RECEIVE indicates that reception of a frame has completed and all requested status has been written to the appropriate DMA receive descriptor.
  • EMAC_INT_TX_UNDERFLOW indicates that the transmitter experienced an underflow during transmission. The transmit process is suspended.
  • EMAC_INT_RX_OVERFLOW indicates that an overflow was experienced during reception.
  • EMAC_INT_TX_JABBER indicates that the transmit jabber timer expired. This condition occurs when the frame size exceeds 2048 bytes (or 10240 bytes in Jumbo Frame mode) and causes the transmit process to abort and enter the Stopped state.
  • EMAC_INT_TX_NO_BUFFER indicates that the host owns the next buffer in the DMA's transmit descriptor list and that the DMA cannot, therefore, acquire a buffer. Transmission is suspended and can be resumed by changing the descriptor ownership and calling EMACTxDMAPollDemand().
  • EMAC_INT_TX_STOPPED indicates that the transmit process has stopped.
  • EMAC_INT_TRANSMIT indicates that transmission of a frame has completed and that all requested status has been updated in the descriptor.

Summary interrupt bits EMAC_INT_NORMAL_INT and EMAC_INT_ABNORMAL_INT are cleared automatically by the driver if any of their constituent sources are cleared. Applications do not need to explicitly clear these bits.

Returns
None.

Definition at line 2781 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_ABNORMAL_INTS, EMAC_EPHYMISC_INT, EMAC_INT_ABNORMAL_INT, EMAC_INT_NORMAL_INT, EMAC_INT_PHY, EMAC_NORMAL_INTS, EMAC_O_DMARIS, EMAC_O_EPHYMISC, and HWREG.

2782 {
2783  //
2784  // Parameter sanity check.
2785  //
2786  ASSERT(ui32Base == EMAC0_BASE);
2787 
2788  //
2789  // Mask in the normal interrupt if one of the sources it relates to is
2790  // specified.
2791  //
2792  if(ui32IntFlags & EMAC_NORMAL_INTS)
2793  {
2794  ui32IntFlags |= EMAC_INT_NORMAL_INT;
2795  }
2796 
2797  //
2798  // Similarly, mask in the abnormal interrupt if one of the sources it
2799  // relates to is specified.
2800  //
2801  if(ui32IntFlags & EMAC_ABNORMAL_INTS)
2802  {
2803  ui32IntFlags |= EMAC_INT_ABNORMAL_INT;
2804  }
2805 
2806  //
2807  // Clear the maskable interrupt sources. We write exactly the value passed
2808  // (with the summary sources added if necessary) but remember that only
2809  // the bottom 17 bits of the register are actually clearable. Only do
2810  // this if some bits are actually set that refer to the DMA interrupt
2811  // sources.
2812  //
2813  if(ui32IntFlags & ~EMAC_INT_PHY)
2814  {
2815  HWREG(ui32Base + EMAC_O_DMARIS) = (ui32IntFlags & ~EMAC_INT_PHY);
2816  }
2817 
2818  //
2819  // Clear the PHY interrupt if we've been asked to do this.
2820  //
2821  if(ui32IntFlags & EMAC_INT_PHY)
2822  {
2823  HWREG(ui32Base + EMAC_O_EPHYMISC) |= EMAC_EPHYMISC_INT;
2824  }
2825 }
#define EMAC_ABNORMAL_INTS
Definition: emac.c:148
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_DMARIS
Definition: hw_emac.h:133
#define EMAC_EPHYMISC_INT
Definition: hw_emac.h:1319
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_INT_PHY
Definition: emac.h:677
#define EMAC_O_EPHYMISC
Definition: hw_emac.h:159
#define EMAC_INT_ABNORMAL_INT
Definition: emac.h:709
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_INT_NORMAL_INT
Definition: emac.h:708
#define EMAC_NORMAL_INTS
Definition: emac.c:138
void EMACIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual Ethernet MAC interrupt sources.

Parameters
ui32Baseis the base address of the Ethernet MAC.
ui32IntFlagsis the bit mask of the interrupt sources to be disabled.

This function disables the indicated Ethernet MAC interrupt sources.

The ui32IntFlags parameter is the logical OR of any of the following:

  • EMAC_INT_PHY indicates that the PHY has signaled a change of state. Software must read and write the appropriate PHY registers to enable and disable particular notifications.
  • EMAC_INT_EARLY_RECEIVE indicates that the DMA engine has filled the first data buffer of a packet.
  • EMAC_INT_BUS_ERROR indicates that a fatal bus error has occurred and that the DMA engine has been disabled.
  • EMAC_INT_EARLY_TRANSMIT indicates that a frame to be transmitted has been fully written from memory into the MAC transmit FIFO.
  • EMAC_INT_RX_WATCHDOG indicates that a frame with length greater than 2048 bytes (of 10240 bytes in Jumbo Frame mode) was received.
  • EMAC_INT_RX_STOPPED indicates that the receive process has entered the stopped state.
  • EMAC_INT_RX_NO_BUFFER indicates that the host owns the next buffer in the DMA's receive descriptor list and the DMA cannot, therefore, acquire a buffer. The receive process is suspended and can be resumed by changing the descriptor ownership and calling EMACRxDMAPollDemand().
  • EMAC_INT_RECEIVE indicates that reception of a frame has completed and all requested status has been written to the appropriate DMA receive descriptor.
  • EMAC_INT_TX_UNDERFLOW indicates that the transmitter experienced an underflow during transmission. The transmit process is suspended.
  • EMAC_INT_RX_OVERFLOW indicates that an overflow was experienced during reception.
  • EMAC_INT_TX_JABBER indicates that the transmit jabber timer expired. This condition occurs when the frame size exceeds 2048 bytes (or 10240 bytes in Jumbo Frame mode) and causes the transmit process to abort and enter the Stopped state.
  • EMAC_INT_TX_NO_BUFFER indicates that the host owns the next buffer in the DMA's transmit descriptor list and that the DMA cannot, therefore, acquire a buffer. Transmission is suspended and can be resumed by changing the descriptor ownership and calling EMACTxDMAPollDemand().
  • EMAC_INT_TX_STOPPED indicates that the transmit process has stopped.
  • EMAC_INT_TRANSMIT indicates that transmission of a frame has completed and that all requested status has been updated in the descriptor.
  • EMAC_INT_TIMESTAMP indicates that an interrupt from the timestamp module has occurred. This precise source of the interrupt can be determined by calling EMACTimestampIntStatus(), which also clears this bit.

Summary interrupt bits EMAC_INT_NORMAL_INT and EMAC_INT_ABNORMAL_INT are disabled automatically by the driver if none of their constituent sources are enabled. Applications do not need to explicitly disable these bits.

Note
Timestamp-related interrupts from the IEEE 1588 module must be disabled independently by using a call to EMACTimestampTargetIntDisable().
Returns
None.

Definition at line 2561 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_ABNORMAL_INTS, EMAC_EPHYIM_INT, EMAC_INT_ABNORMAL_INT, EMAC_INT_NORMAL_INT, EMAC_INT_PHY, EMAC_MASKABLE_INTS, EMAC_NORMAL_INTS, EMAC_O_DMAIM, EMAC_O_EPHYIM, and HWREG.

2562 {
2563  uint32_t ui32Mask;
2564 
2565  //
2566  // Parameter sanity check.
2567  //
2568  ASSERT(ui32Base == EMAC0_BASE);
2569  ASSERT((ui32IntFlags & ~EMAC_MASKABLE_INTS) == 0);
2570 
2571  //
2572  // Get the current interrupt mask.
2573  //
2574  ui32Mask = HWREG(ui32Base + EMAC_O_DMAIM);
2575 
2576  //
2577  // Clear the requested bits.
2578  //
2579  ui32Mask &= ~(ui32IntFlags & ~EMAC_INT_PHY);
2580 
2581  //
2582  // If none of the normal interrupt sources are enabled, disable the
2583  // normal interrupt.
2584  //
2585  if(!(ui32Mask & EMAC_NORMAL_INTS))
2586  {
2587  ui32Mask &= ~EMAC_INT_NORMAL_INT;
2588  }
2589 
2590  //
2591  // Similarly, if none of the abnormal interrupt sources are enabled,
2592  // disable the abnormal interrupt.
2593  //
2594  if(!(ui32Mask & EMAC_ABNORMAL_INTS))
2595  {
2596  ui32Mask &= ~EMAC_INT_ABNORMAL_INT;
2597  }
2598 
2599  //
2600  // Write the new mask back to the hardware.
2601  //
2602  HWREG(ui32Base + EMAC_O_DMAIM) = ui32Mask;
2603 
2604  //
2605  // Disable the PHY interrupt if we've been asked to do this.
2606  //
2607  if(ui32IntFlags & EMAC_INT_PHY)
2608  {
2609  HWREG(ui32Base + EMAC_O_EPHYIM) &= ~EMAC_EPHYIM_INT;
2610  }
2611 }
#define EMAC_ABNORMAL_INTS
Definition: emac.c:148
#define EMAC_EPHYIM_INT
Definition: hw_emac.h:1311
#define EMAC_O_EPHYIM
Definition: hw_emac.h:158
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_INT_PHY
Definition: emac.h:677
#define EMAC_MASKABLE_INTS
Definition: emac.c:116
#define EMAC_INT_ABNORMAL_INT
Definition: emac.h:709
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_DMAIM
Definition: hw_emac.h:136
#define EMAC_INT_NORMAL_INT
Definition: emac.h:708
#define EMAC_NORMAL_INTS
Definition: emac.c:138
void EMACIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual Ethernet MAC interrupt sources.

Parameters
ui32Baseis the base address of the Ethernet MAC.
ui32IntFlagsis the bit mask of the interrupt sources to be enabled.

This function enables the indicated Ethernet MAC interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter is the logical OR of any of the following:

  • EMAC_INT_PHY indicates that the PHY has signaled a change of state. Software must read and write the appropriate PHY registers to enable and disable particular notifications.
  • EMAC_INT_EARLY_RECEIVE indicates that the DMA engine has filled the first data buffer of a packet.
  • EMAC_INT_BUS_ERROR indicates that a fatal bus error has occurred and that the DMA engine has been disabled.
  • EMAC_INT_EARLY_TRANSMIT indicates that a frame to be transmitted has been fully written from memory into the MAC transmit FIFO.
  • EMAC_INT_RX_WATCHDOG indicates that a frame with length greater than 2048 bytes (of 10240 bytes in Jumbo Frame mode) was received.
  • EMAC_INT_RX_STOPPED indicates that the receive process has entered the stopped state.
  • EMAC_INT_RX_NO_BUFFER indicates that the host owns the next buffer in the DMA's receive descriptor list and the DMA cannot, therefore, acquire a buffer. The receive process is suspended and can be resumed by changing the descriptor ownership and calling EMACRxDMAPollDemand().
  • EMAC_INT_RECEIVE indicates that reception of a frame has completed and all requested status has been written to the appropriate DMA receive descriptor.
  • EMAC_INT_TX_UNDERFLOW indicates that the transmitter experienced an underflow during transmission. The transmit process is suspended.
  • EMAC_INT_RX_OVERFLOW indicates that an overflow was experienced during reception.
  • EMAC_INT_TX_JABBER indicates that the transmit jabber timer expired. This condition occurs when the frame size exceeds 2048 bytes (or 10240 bytes in Jumbo Frame mode) and causes the transmit process to abort and enter the Stopped state.
  • EMAC_INT_TX_NO_BUFFER indicates that the host owns the next buffer in the DMA's transmit descriptor list and that the DMA cannot, therefore, acquire a buffer. Transmission is suspended and can be resumed by changing the descriptor ownership and calling EMACTxDMAPollDemand().
  • EMAC_INT_TX_STOPPED indicates that the transmit process has stopped.
  • EMAC_INT_TRANSMIT indicates that transmission of a frame has completed and that all requested status has been updated in the descriptor.

Summary interrupt bits EMAC_INT_NORMAL_INT and EMAC_INT_ABNORMAL_INT are enabled automatically by the driver if any of their constituent sources are enabled. Applications do not need to explicitly enable these bits.

Note
Timestamp-related interrupts from the IEEE 1588 module must be enabled independently by using a call to EMACTimestampTargetIntEnable().
Returns
None.

Definition at line 2455 of file emac.c.

References ASSERT, EMAC_ABNORMAL_INTS, EMAC_EPHYIM_INT, EMAC_INT_ABNORMAL_INT, EMAC_INT_NORMAL_INT, EMAC_INT_PHY, EMAC_MASKABLE_INTS, EMAC_NORMAL_INTS, EMAC_O_DMAIM, EMAC_O_EPHYIM, and HWREG.

2456 {
2457  //
2458  // Parameter sanity check.
2459  //
2460  ASSERT((ui32IntFlags & ~EMAC_MASKABLE_INTS) == 0);
2461 
2462  //
2463  // Enable the normal interrupt if any of its individual sources are
2464  // enabled.
2465  //
2466  if(ui32IntFlags & EMAC_NORMAL_INTS)
2467  {
2468  ui32IntFlags |= EMAC_INT_NORMAL_INT;
2469  }
2470 
2471  //
2472  // Similarly, enable the abnormal interrupt if any of its individual
2473  // sources are enabled.
2474  //
2475  if(ui32IntFlags & EMAC_ABNORMAL_INTS)
2476  {
2477  ui32IntFlags |= EMAC_INT_ABNORMAL_INT;
2478  }
2479 
2480  //
2481  // Set the MAC DMA interrupt mask appropriately if any of the sources
2482  // we've been asked to enable are found in that register.
2483  //
2484  if(ui32IntFlags & ~EMAC_INT_PHY)
2485  {
2486  HWREG(ui32Base + EMAC_O_DMAIM) |= ui32IntFlags & ~EMAC_INT_PHY;
2487  }
2488 
2489  //
2490  // Enable the PHY interrupt if we've been asked to do this.
2491  //
2492  if(ui32IntFlags & EMAC_INT_PHY)
2493  {
2494  HWREG(ui32Base + EMAC_O_EPHYIM) |= EMAC_EPHYIM_INT;
2495  }
2496 }
#define EMAC_ABNORMAL_INTS
Definition: emac.c:148
#define EMAC_EPHYIM_INT
Definition: hw_emac.h:1311
#define EMAC_O_EPHYIM
Definition: hw_emac.h:158
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_INT_PHY
Definition: emac.h:677
#define EMAC_MASKABLE_INTS
Definition: emac.c:116
#define EMAC_INT_ABNORMAL_INT
Definition: emac.h:709
#define EMAC_O_DMAIM
Definition: hw_emac.h:136
#define EMAC_INT_NORMAL_INT
Definition: emac.h:708
#define EMAC_NORMAL_INTS
Definition: emac.c:138
void EMACIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for an Ethernet interrupt.

Parameters
ui32Baseis the base address of the controller.
pfnHandleris a pointer to the function to be called when the enabled Ethernet interrupts occur.

This function sets the handler to be called when the Ethernet interrupt occurs. This function enables the global interrupt in the interrupt controller; specific Ethernet interrupts must be enabled via EMACIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 2346 of file emac.c.

References ASSERT, INT_EMAC0_TM4C129, IntEnable(), and IntRegister().

2347 {
2348  //
2349  // Check the arguments.
2350  //
2351  ASSERT(pfnHandler != 0);
2352 
2353  //
2354  // Register the interrupt handler.
2355  //
2356  IntRegister(INT_EMAC0_TM4C129, pfnHandler);
2357 
2358  //
2359  // Enable the Ethernet interrupt.
2360  //
2362 }
#define INT_EMAC0_TM4C129
Definition: hw_ints.h:216
#define ASSERT(expr)
Definition: debug.h:67
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

uint32_t EMACIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current Ethernet MAC interrupt status.

Parameters
ui32Baseis the base address of the Ethernet MAC.
bMaskedis true to return the masked interrupt status or false to return the unmasked status.

This function returns the interrupt status for the Ethernet MAC. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
Returns the current interrupt status as the logical OR of any of the following:
  • EMAC_INT_PHY indicates that the PHY interrupt has occurred. Software must read the relevant PHY interrupt status register to determine the cause.
  • EMAC_INT_EARLY_RECEIVE indicates that the DMA engine has filled the first data buffer of a packet.
  • EMAC_INT_BUS_ERROR indicates that a fatal bus error has occurred and that the DMA engine has been disabled. The cause of the error can be determined by calling EMACDMAStateGet().
  • EMAC_INT_EARLY_TRANSMIT indicates that a frame to be transmitted has been fully written from memory into the MAC transmit FIFO.
  • EMAC_INT_RX_WATCHDOG indicates that a frame with length greater than 2048 bytes (of 10240 bytes in Jumbo Frame mode) was received.
  • EMAC_INT_RX_STOPPED indicates that the receive process has entered the stopped state.
  • EMAC_INT_RX_NO_BUFFER indicates that the host owns the next buffer in the DMA's receive descriptor list and the DMA cannot, therefore, acquire a buffer. The receive process is suspended and can be resumed by changing the descriptor ownership and calling EMACRxDMAPollDemand().
  • EMAC_INT_RECEIVE indicates that reception of a frame has completed and all requested status has been written to the appropriate DMA receive descriptor.
  • EMAC_INT_TX_UNDERFLOW indicates that the transmitter experienced an underflow during transmission. The transmit process is suspended.
  • EMAC_INT_RX_OVERFLOW indicates that an overflow was experienced during reception.
  • EMAC_INT_TX_JABBER indicates that the transmit jabber timer expired. This condition occurs when the frame size exceeds 2048 bytes (or 10240 bytes in Jumbo Frame mode) and causes the transmit process to abort and enter the Stopped state.
  • EMAC_INT_TX_NO_BUFFER indicates that the host owns the next buffer in the DMA's transmit descriptor list and that the DMA cannot, therefore, acquire a buffer. Transmission is suspended and can be resumed by changing the descriptor ownership and calling EMACTxDMAPollDemand().
  • EMAC_INT_TX_STOPPED indicates that the transmit process has stopped.
  • EMAC_INT_TRANSMIT indicates that transmission of a frame has completed and that all requested status has been updated in the descriptor.
  • EMAC_INT_NORMAL_INT is a summary interrupt comprising the logical OR of the masked state of EMAC_INT_TRANSMIT, EMAC_INT_RECEIVE, EMAC_INT_TX_NO_BUFFER and EMAC_INT_EARLY_RECEIVE.
  • EMAC_INT_ABNORMAL_INT is a summary interrupt comprising the logical OR of the masked state of EMAC_INT_TX_STOPPED, EMAC_INT_TX_JABBER, EMAC_INT_RX_OVERFLOW, EMAC_INT_TX_UNDERFLOW, EMAC_INT_RX_NO_BUFFER, EMAC_INT_RX_STOPPED, EMAC_INT_RX_WATCHDOG, EMAC_INT_EARLY_TRANSMIT and EMAC_INT_BUS_ERROR.

Definition at line 2676 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_DMARIS_AE_M, EMAC_DMARIS_RS_M, EMAC_DMARIS_TS_M, EMAC_EPHYMISC_INT, EMAC_INT_PHY, EMAC_NON_MASKED_INTS, EMAC_O_DMAIM, EMAC_O_DMARIS, EMAC_O_EPHYMISC, EMAC_O_EPHYRIS, and HWREG.

2677 {
2678  uint32_t ui32Val, ui32PHYStat;
2679 
2680  //
2681  // Parameter sanity check.
2682  //
2683  ASSERT(ui32Base == EMAC0_BASE);
2684 
2685  //
2686  // Get the unmasked interrupt status and clear any unwanted status fields.
2687  //
2688  ui32Val = HWREG(ui32Base + EMAC_O_DMARIS);
2690 
2691  //
2692  // This peripheral doesn't have a masked interrupt status register
2693  // so perform the masking manually. Note that only the bottom 16 bits
2694  // of the register can be masked so make sure we take this into account.
2695  //
2696  if(bMasked)
2697  {
2698  ui32Val &= (EMAC_NON_MASKED_INTS | HWREG(ui32Base + EMAC_O_DMAIM));
2699  }
2700 
2701  //
2702  // Read the PHY interrupt status.
2703  //
2704  if(bMasked)
2705  {
2706  ui32PHYStat = HWREG(ui32Base + EMAC_O_EPHYMISC);
2707  }
2708  else
2709  {
2710  ui32PHYStat = HWREG(ui32Base + EMAC_O_EPHYRIS);
2711  }
2712 
2713  //
2714  // If the PHY interrupt is reported, add the appropriate flag to the
2715  // return value.
2716  //
2717  if(ui32PHYStat & EMAC_EPHYMISC_INT)
2718  {
2719  ui32Val |= EMAC_INT_PHY;
2720  }
2721 
2722  return(ui32Val);
2723 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_DMARIS
Definition: hw_emac.h:133
#define EMAC_DMARIS_AE_M
Definition: hw_emac.h:1046
#define EMAC_EPHYMISC_INT
Definition: hw_emac.h:1319
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_INT_PHY
Definition: emac.h:677
#define EMAC_DMARIS_TS_M
Definition: hw_emac.h:1059
#define EMAC_O_EPHYMISC
Definition: hw_emac.h:159
#define EMAC_DMARIS_RS_M
Definition: hw_emac.h:1074
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_DMAIM
Definition: hw_emac.h:136
#define EMAC_O_EPHYRIS
Definition: hw_emac.h:156
#define EMAC_NON_MASKED_INTS
Definition: emac.c:164
void EMACIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for an Ethernet interrupt.

Parameters
ui32Baseis the base address of the controller.

This function unregisters the interrupt handler. This function disables the global interrupt in the interrupt controller so that the interrupt handler is no longer called.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 2381 of file emac.c.

References INT_EMAC0_TM4C129, IntDisable(), and IntUnregister().

2382 {
2383  //
2384  // Disable the interrupt.
2385  //
2387 
2388  //
2389  // Unregister the interrupt handler.
2390  //
2392 }
#define INT_EMAC0_TM4C129
Definition: hw_ints.h:216
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

uint32_t EMACNumAddrGet ( uint32_t  ui32Base)

Returns the number of MAC addresses supported by the Ethernet controller.

Parameters
ui32Baseis the base address of the Ethernet controller.

This function may be used to determine the number of MAC addresses that the given controller supports. MAC address slots may be used when performing perfect (rather than hash table) filtering of packets.

Returns
Returns the number of supported MAC addresses.

Definition at line 1267 of file emac.c.

References NUM_MAC_ADDR.

1268 {
1269  //
1270  // The only Ethernet controller on Snowflake supports 4 MAC addresses.
1271  //
1272  return(NUM_MAC_ADDR);
1273 }
#define NUM_MAC_ADDR
Definition: emac.c:173
void EMACPHYConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Selects the Ethernet PHY in use.

Parameters
ui32Baseis the base address of the Ethernet controller.
ui32Configselects the PHY in use and, when using the internal PHY, allows various various PHY parameters to be configured.

This function must be called prior to EMACInit() and EMACConfigSet() to select the Ethernet PHY to be used. If the internal PHY is selected, the function also allows configuration of various PHY parameters. Note that the Ethernet MAC is reset during this function call because parameters used by this function are latched by the hardware only on a MAC reset. The call sequence to select and configure the PHY, therefore, must be as follows:

//!     // Enable and reset the MAC.
//!     SysCtlPeripheralEnable(SYSCTL_PERIPH_EMAC0);
//!     SysCtlPeripheralReset(SYSCTL_PERIPH_EMAC0);
//!     if(<using internal PHY>)
//!     {
//!         // Enable and reset the internal PHY.
//!         SysCtlPeripheralEnable(SYSCTL_PERIPH_EPHY0);
//!         SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);
//!     }
//!
//!     // Ensure the MAC is completed its reset.
//!     while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_EMAC0))
//!     {
//!     }
//!
//!     // Set the PHY type and configuration options.
//!     EMACPHYConfigSet(EMAC0_BASE, <config>);
//!
//!     // Initialize and configure the MAC.
//!     EMACInit(EMAC0_BASE, <system clock rate>, <bus config>,
//!              <Rx burst size>, <Tx burst size>, <desc skip>);
//!     EMACConfigSet(EMAC0_BASE, <parameters>);
//! 
The \e ui32Config parameter must specify one of the following values:

- \b EMAC_PHY_TYPE_INTERNAL selects the internal Ethernet PHY.
- \b EMAC_PHY_TYPE_EXTERNAL_MII selects an external PHY connected via the
MII interface.
- \b EMAC_PHY_TYPE_EXTERNAL_RMII selects an external PHY connected via the
RMII interface.

If \b EMAC_PHY_TYPE_INTERNAL is selected, the following flags may be ORed
into \e ui32Config to control various PHY features and modes.  These flags 
are ignored if an external PHY is selected.

- \b EMAC_PHY_INT_NIB_TXERR_DET_DIS disables odd nibble transmit error
detection (sets the default value of PHY register MR10, bit 1).
- \b EMAC_PHY_INT_RX_ER_DURING_IDLE enables receive error detection during
idle  (sets the default value of PHY register MR10, bit 2).
- \b EMAC_PHY_INT_ISOLATE_MII_LLOSS ties the MII outputs low if no link is
established in 100B-T and full duplex modes (sets the default value of PHY
register MR10, bit 3).
- \b EMAC_PHY_INT_LINK_LOSS_RECOVERY enables link loss recovery (sets the
default value of PHY register MR9, bit 7).
- \b EMAC_PHY_INT_TDRRUN enables execution of the TDR procedure after a link
down event (sets the default value of PHY register MR9, bit 8).
- \b EMAC_PHY_INT_LD_ON_RX_ERR_COUNT enables link down if the receiver
error count reaches 32 within a 10-us interval (sets the default value of
PHY register MR11 bit 3).
- \b EMAC_PHY_INT_LD_ON_MTL3_ERR_COUNT enables link down if the MTL3 error
count reaches 20 in a 10 us-interval (sets the default value of PHY register
MR11 bit 2).
- \b EMAC_PHY_INT_LD_ON_LOW_SNR enables link down if the low SNR threshold
is crossed 20 times in a 10 us-interval (sets the default value of PHY
register MR11 bit 1).
- \b EMAC_PHY_INT_LD_ON_SIGNAL_ENERGY enables link down if energy detector
indicates Energy Loss (sets the default value of PHY register MR11 bit 0).
- \b EMAC_PHY_INT_POLARITY_SWAP inverts the polarity on both TPTD and TPRD
pairs (sets the default value of PHY register MR11 bit 5).
- \b EMAC_PHY_INT_MDI_SWAP swaps the MDI pairs putting receive on the TPTD
pair and transmit on TPRD (sets the default value of PHY register MR11 bit
6).
- \b EMAC_PHY_INT_ROBUST_MDIX enables robust auto MDI-X resolution (sets the
default value of PHY register MR9 bit 5).
- \b EMAC_PHY_INT_FAST_MDIX enables fast auto-MDI/MDIX resolution (sets the
default value of PHY register MR9 bit 6).
- \b EMAC_PHY_INT_MDIX_EN enables auto-MDI/MDIX crossover (sets the
default value of PHY register MR9 bit 14).
- \b EMAC_PHY_INT_FAST_RXDV_DETECT enables fast RXDV detection (set the
default value of PHY register MR9 bit 1).
- \b EMAC_PHY_INT_FAST_L_UP_DETECT enables fast link-up time during parallel
detection (sets the default value of PHY register MR10 bit 6)
- \b EMAC_PHY_INT_EXT_FULL_DUPLEX forces full-duplex while working with a
link partner in forced 100B-TX (sets the default value of PHY register
MR10 bit 5).
- \b EMAC_PHY_INT_FAST_AN_80_50_35 enables fast auto-negotiation using
break link, link fail inhibit and wait timers set to 80, 50 and 35
respectively (sets the default value of PHY register MR9 bits [4:2] to
3b100).
- \b EMAC_PHY_INT_FAST_AN_120_75_50 enables fast auto-negotiation using
break link, link fail inhibit and wait timers set to 120, 75 and 50
respectively (sets the default value of PHY register MR9 bits [4:2] to
3b101).
- \b EMAC_PHY_INT_FAST_AN_140_150_100 enables fast auto-negotiation using
break link, link fail inhibit and wait timers set to 140, 150 and 100
respectively (sets the default value of PHY register MR9 bits [4:2] to
3b110).
- \b EMAC_PHY_FORCE_10B_T_HALF_DUPLEX disables auto-negotiation and forces
operation in 10Base-T, half duplex mode (sets the default value of PHY
register MR9 bits [13:11] to 3b000).
- \b EMAC_PHY_FORCE_10B_T_FULL_DUPLEX disables auto-negotiation and forces
operation in 10Base-T, full duplex mode (sets the default value of PHY
register MR9 bits [13:11] to 3b001).
- \b EMAC_PHY_FORCE_100B_T_HALF_DUPLEX disables auto-negotiation and forces
operation in 100Base-T, half duplex mode (sets the default value of PHY
register MR9 bits [13:11] to 3b010).
- \b EMAC_PHY_FORCE_100B_T_FULL_DUPLEX disables auto-negotiation and forces
operation in 100Base-T, full duplex mode (sets the default value of PHY
register MR9 bits [13:11] to 3b011).
- \b EMAC_PHY_AN_10B_T_HALF_DUPLEX enables auto-negotiation and advertises
10Base-T, half duplex mode (sets the default value of PHY register MR9 bits
[13:11] to 3b100).
- \b EMAC_PHY_AN_10B_T_FULL_DUPLEX enables auto-negotiation and advertises
10Base-T half or full duplex modes (sets the default value of PHY register
MR9 bits [13:11] to 3b101).
- \b EMAC_PHY_AN_100B_T_HALF_DUPLEX enables auto-negotiation and advertises
10Base-T half or full duplex, and 100Base-T half duplex modes (sets the
default value of PHY register MR9 bits [13:11] to 3b110).
- \b EMAC_PHY_AN_100B_T_FULL_DUPLEX enables auto-negotiation and advertises
10Base-T half or full duplex, and 100Base-T half or full duplex modes (sets
the default value of PHY register MR9 bits [13:11] to 3b111).
- \b EMAC_PHY_INT_HOLD prevents the PHY from transmitting energy on the
line.

As a side effect of this function, the Ethernet MAC is reset so any
previous MAC configuration is lost.

\return None.  

Definition at line 578 of file emac.c.

References EMAC0_BASE, EMAC_CC_CLKEN, EMAC_O_CC, EMAC_O_PC, EMAC_PHY_TYPE_EXTERNAL_RMII, EMAC_PHY_TYPE_INTERNAL, EMAC_PHY_TYPE_MASK, EMACReset(), HWREG, SYSCTL_PERIPH_EPHY0, SysCtlDelay(), SysCtlPeripheralReady(), and SysCtlPeripheralReset().

579 {
580  //
581  // Write the Ethernet PHY configuration to the peripheral configuration
582  // register.
583  //
584  HWREG(ui32Base + EMAC_O_PC) = ui32Config;
585 
586  //
587  // If using the internal PHY, reset it to ensure that new configuration is
588  // latched there.
589  //
590  if((ui32Config & EMAC_PHY_TYPE_MASK) == EMAC_PHY_TYPE_INTERNAL)
591  {
594  {
595  //
596  // Wait for the PHY reset to complete.
597  //
598  }
599 
600  //
601  // Delay a bit longer to ensure that the PHY reset has completed.
602  //
603  SysCtlDelay(10000);
604  }
605 
606  //
607  // If using an external RMII PHY, we must set 2 bits in the Ethernet MAC
608  // Clock Configuration Register.
609  //
610  if((ui32Config & EMAC_PHY_TYPE_MASK) == EMAC_PHY_TYPE_EXTERNAL_RMII)
611  {
612  //
613  // Select and enable the external clock from the RMII PHY.
614  //
616  }
617  else
618  {
619  //
620  // Disable the external clock.
621  //
623  }
624 
625  //
626  // Reset the MAC regardless of whether the PHY connection changed or not.
627  //
629 
630  SysCtlDelay(1000);
631 }
#define HWREG(x)
Definition: hw_types.h:48
void EMACReset(uint32_t ui32Base)
Definition: emac.c:425
bool SysCtlPeripheralReady(uint32_t ui32Peripheral)
Definition: sysctl.c:632
#define EMAC_CC_CLKEN
Definition: hw_emac.h:1296
void SysCtlDelay(uint32_t ui32Count)
#define EMAC_PHY_TYPE_MASK
Definition: emac.h:416
#define EMAC_PHY_TYPE_EXTERNAL_RMII
Definition: emac.h:385
void SysCtlPeripheralReset(uint32_t ui32Peripheral)
Definition: sysctl.c:762
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_CC
Definition: hw_emac.h:154
#define EMAC_PHY_TYPE_INTERNAL
Definition: emac.h:383
#define EMAC_O_PC
Definition: hw_emac.h:152
#define SYSCTL_PERIPH_EPHY0
Definition: sysctl.h:69

Here is the call graph for this function:

uint16_t EMACPHYExtendedRead ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr,
uint16_t  ui16RegAddr 
)

Reads from an extended PHY register.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to access.
ui16RegAddris the address of the PHY extended register to be accessed.

When using the internal PHY or when connected to an external PHY supporting extended registers, this function returns the contents of the extended PHY register specified by ui16RegAddr.

Returns
Returns the 16-bit value read from the PHY.

Definition at line 2953 of file emac.c.

References ASSERT, EMAC0_BASE, EMACPHYRead(), EMACPHYWrite(), EPHY_ADDAR, and EPHY_REGCTL.

2955 {
2956  //
2957  // Parameter sanity check.
2958  //
2959  ASSERT(ui8PhyAddr < 32);
2960  ASSERT(ui32Base == EMAC0_BASE);
2961 
2962  //
2963  // Set the address of the register we're about to read.
2964  //
2965  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_REGCTL, 0x001F);
2966  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_ADDAR, ui16RegAddr);
2967 
2968  //
2969  // Read the extended register value.
2970  //
2971  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_REGCTL, 0x401F);
2972  return(EMACPHYRead(EMAC0_BASE, ui8PhyAddr, EPHY_ADDAR));
2973 }
uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr)
Definition: emac.c:2900
void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr, uint16_t ui16Data)
Definition: emac.c:2843
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EPHY_REGCTL
Definition: hw_emac.h:1346
#define EPHY_ADDAR
Definition: hw_emac.h:1347

Here is the call graph for this function:

void EMACPHYExtendedWrite ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr,
uint16_t  ui16RegAddr,
uint16_t  ui16Value 
)

Writes a value to an extended PHY register.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to access.
ui16RegAddris the address of the PHY extended register to be accessed.
ui16Valueis the value to write to the register.

When using the internal PHY or when connected to an external PHY supporting extended registers, this function allows a value to be written to the extended PHY register specified by ui16RegAddr.

Returns
None.

Definition at line 2993 of file emac.c.

References ASSERT, EMAC0_BASE, EMACPHYWrite(), EPHY_ADDAR, and EPHY_REGCTL.

2995 {
2996  //
2997  // Parameter sanity check.
2998  //
2999  ASSERT(ui8PhyAddr < 32);
3000  ASSERT(ui32Base == EMAC0_BASE);
3001 
3002  //
3003  // Set the address of the register we're about to write.
3004  //
3005  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_REGCTL, 0x001F);
3006  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_ADDAR, ui16RegAddr);
3007 
3008  //
3009  // Write the extended register.
3010  //
3011  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_REGCTL, 0x401F);
3012  EMACPHYWrite(EMAC0_BASE, ui8PhyAddr, EPHY_ADDAR, ui16Value);
3013 }
void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr, uint16_t ui16Data)
Definition: emac.c:2843
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EPHY_REGCTL
Definition: hw_emac.h:1346
#define EPHY_ADDAR
Definition: hw_emac.h:1347

Here is the call graph for this function:

void EMACPHYPowerOff ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr 
)

Powers off the Ethernet PHY.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to power down.

This function powers off the Ethernet PHY, reducing the current consumption of the device. While in the powered-off state, the Ethernet controller is unable to connect to Ethernet.

Returns
None.

Definition at line 3030 of file emac.c.

References EMACPHYRead(), EMACPHYWrite(), EPHY_BMCR, EPHY_BMCR_ANEN, and EPHY_BMCR_PWRDWN.

3031 {
3032  //
3033  // Set the PWRDN bit and clear the ANEN bit in the PHY, putting it into
3034  // its low power mode.
3035  //
3036  EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_BMCR,
3037  (EMACPHYRead(ui32Base, ui8PhyAddr, EPHY_BMCR) &
3039 }
uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr)
Definition: emac.c:2900
void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr, uint16_t ui16Data)
Definition: emac.c:2843
#define EPHY_BMCR
Definition: hw_emac.h:1327
#define EPHY_BMCR_PWRDWN
Definition: hw_emac.h:1380
#define EPHY_BMCR_ANEN
Definition: hw_emac.h:1379

Here is the call graph for this function:

void EMACPHYPowerOn ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr 
)

Powers on the Ethernet PHY.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to power up.

This function powers on the Ethernet PHY, enabling it return to normal operation. By default, the PHY is powered on, so this function is only called if EMACPHYPowerOff() has previously been called.

Returns
None.

Definition at line 3056 of file emac.c.

References EMACPHYRead(), EMACPHYWrite(), EPHY_BMCR, EPHY_BMCR_ANEN, and EPHY_BMCR_PWRDWN.

3057 {
3058  //
3059  // Clear the PWRDN bit and set the ANEGEN bit in the PHY, putting it into
3060  // normal operating mode.
3061  //
3062  EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_BMCR,
3063  (EMACPHYRead(ui32Base, ui8PhyAddr, EPHY_BMCR) &
3065 }
uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr)
Definition: emac.c:2900
void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr, uint16_t ui16Data)
Definition: emac.c:2843
#define EPHY_BMCR
Definition: hw_emac.h:1327
#define EPHY_BMCR_PWRDWN
Definition: hw_emac.h:1380
#define EPHY_BMCR_ANEN
Definition: hw_emac.h:1379

Here is the call graph for this function:

uint16_t EMACPHYRead ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr,
uint8_t  ui8RegAddr 
)

Reads from a PHY register.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to access.
ui8RegAddris the address of the PHY register to be accessed.

This function returns the contents of the PHY register specified by ui8RegAddr.

Returns
Returns the 16-bit value read from the PHY.

Definition at line 2900 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_MIIADDR_CR_M, EMAC_MIIADDR_MII_S, EMAC_MIIADDR_MIIB, EMAC_MIIADDR_PLA_S, EMAC_MIIDATA_DATA_M, EMAC_O_MIIADDR, EMAC_O_MIIDATA, and HWREG.

Referenced by EMACPHYExtendedRead(), EMACPHYPowerOff(), and EMACPHYPowerOn().

2901 {
2902  //
2903  // Parameter sanity check.
2904  //
2905  ASSERT(ui8PhyAddr < 32);
2906  ASSERT(ui32Base == EMAC0_BASE);
2907 
2908  //
2909  // Make sure the MII is idle.
2910  //
2911  while(HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_MIIB)
2912  {
2913  }
2914 
2915  //
2916  // Tell the MAC to read the given PHY register.
2917  //
2918  HWREG(ui32Base + EMAC_O_MIIADDR) =
2919  ((HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_CR_M) |
2920  (ui8RegAddr << EMAC_MIIADDR_MII_S) |
2921  (ui8PhyAddr << EMAC_MIIADDR_PLA_S) | EMAC_MIIADDR_MIIB);
2922 
2923  //
2924  // Wait for the read to complete.
2925  //
2926  while(HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_MIIB)
2927  {
2928  }
2929 
2930  //
2931  // Return the result.
2932  //
2933  return(HWREG(ui32Base + EMAC_O_MIIDATA) & EMAC_MIIDATA_DATA_M);
2934 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_MIIDATA_DATA_M
Definition: hw_emac.h:288
#define EMAC_O_MIIDATA
Definition: hw_emac.h:53
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_MIIADDR_CR_M
Definition: hw_emac.h:263
#define EMAC_MIIADDR_PLA_S
Definition: hw_emac.h:280
#define EMAC_MIIADDR_MII_S
Definition: hw_emac.h:281
#define EMAC_O_MIIADDR
Definition: hw_emac.h:52
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_MIIADDR_MIIB
Definition: hw_emac.h:279

Here is the caller graph for this function:

void EMACPHYWrite ( uint32_t  ui32Base,
uint8_t  ui8PhyAddr,
uint8_t  ui8RegAddr,
uint16_t  ui16Data 
)

Writes to the PHY register.

Parameters
ui32Baseis the base address of the controller.
ui8PhyAddris the physical address of the PHY to access.
ui8RegAddris the address of the PHY register to be accessed.
ui16Datais the data to be written to the PHY register.

This function writes the ui16Data value to the PHY register specified by ui8RegAddr.

Returns
None.

Definition at line 2843 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_MIIADDR_CR_M, EMAC_MIIADDR_MII_S, EMAC_MIIADDR_MIIB, EMAC_MIIADDR_MIIW, EMAC_MIIADDR_PLA_S, EMAC_O_MIIADDR, EMAC_O_MIIDATA, and HWREG.

Referenced by EMACPHYExtendedRead(), EMACPHYExtendedWrite(), EMACPHYPowerOff(), and EMACPHYPowerOn().

2845 {
2846  //
2847  // Parameter sanity check.
2848  //
2849  ASSERT(ui32Base == EMAC0_BASE);
2850 
2851  //
2852  // Parameter sanity check.
2853  //
2854  ASSERT(ui8PhyAddr < 32);
2855 
2856  //
2857  // Make sure the MII is idle.
2858  //
2859  while(HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_MIIB)
2860  {
2861  }
2862 
2863  //
2864  // Write the value provided.
2865  //
2866  HWREG(ui32Base + EMAC_O_MIIDATA) = ui16Data;
2867 
2868  //
2869  // Tell the MAC to write the given PHY register.
2870  //
2871  HWREG(ui32Base + EMAC_O_MIIADDR) =
2872  ((HWREG(ui32Base + EMAC_O_MIIADDR) &
2873  EMAC_MIIADDR_CR_M) | (ui8RegAddr << EMAC_MIIADDR_MII_S) |
2874  (ui8PhyAddr << EMAC_MIIADDR_PLA_S) | EMAC_MIIADDR_MIIW |
2875  EMAC_MIIADDR_MIIB);
2876 
2877  //
2878  // Wait for the write to complete.
2879  //
2880  while(HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_MIIB)
2881  {
2882  }
2883 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_MIIDATA
Definition: hw_emac.h:53
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_MIIADDR_CR_M
Definition: hw_emac.h:263
#define EMAC_MIIADDR_PLA_S
Definition: hw_emac.h:280
#define EMAC_MIIADDR_MII_S
Definition: hw_emac.h:281
#define EMAC_O_MIIADDR
Definition: hw_emac.h:52
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_MIIADDR_MIIB
Definition: hw_emac.h:279
#define EMAC_MIIADDR_MIIW
Definition: hw_emac.h:278

Here is the caller graph for this function:

uint32_t EMACPowerManagementControlGet ( uint32_t  ui32Base)

Queries the current Ethernet MAC remote wake-up configuration.

Parameters
ui32Baseis the base address of the controller.

This function allows the MAC's remote wake-up settings to be queried. These settings determine which types of frame should trigger a remote wake-up event

Returns
Returns a logical OR of the following flags:
  • EMAC_PMT_GLOBAL_UNICAST_ENABLE indicates that the MAC wakes up when any unicast frame matching the MAC destination address filter is received.
  • EMAC_PMT_WAKEUP_PACKET_ENABLE indicates that the MAC wakes up when any received frame matches the remote wake-up filter configured via a call to EMACRemoteWakeUpFrameFilterSet().
  • EMAC_PMT_MAGIC_PACKET_ENABLE indicates that the MAC wakes up when a standard Wake-on-LAN "magic packet" is received. The magic packet contains 6 bytes of 0xFF followed immediately by 16 repetitions of the destination MAC address.
  • EMAC_PMT_POWER_DOWN indicates that the MAC is currently in power-down mode and is waiting for an incoming frame matching the remote wake-up frames as described by other returned flags and via the remote wake-up filter.

Definition at line 4628 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PMTCTLSTAT, EMAC_PMTCTLSTAT_GLBLUCAST, EMAC_PMTCTLSTAT_MGKPKTEN, EMAC_PMTCTLSTAT_PWRDWN, EMAC_PMTCTLSTAT_WUPFREN, and HWREG.

4629 {
4630  //
4631  // Parameter sanity check.
4632  //
4633  ASSERT(ui32Base == EMAC0_BASE);
4634 
4635  //
4636  // Read the control/status register and mask off the control bits to return
4637  // them to the caller.
4638  //
4639  return(HWREG(ui32Base + EMAC_O_PMTCTLSTAT) &
4642 }
#define EMAC_O_PMTCTLSTAT
Definition: hw_emac.h:59
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PMTCTLSTAT_PWRDWN
Definition: hw_emac.h:417
#define EMAC_PMTCTLSTAT_GLBLUCAST
Definition: hw_emac.h:410
#define EMAC_PMTCTLSTAT_MGKPKTEN
Definition: hw_emac.h:415
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_PMTCTLSTAT_WUPFREN
Definition: hw_emac.h:414
void EMACPowerManagementControlSet ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Sets the Ethernet MAC remote wake-up configuration.

Parameters
ui32Baseis the base address of the controller.
ui32Flagsdefines which types of frame should trigger a remote wake-up and allows the MAC to be put into power-down mode.

This function allows the MAC's remote wake-up features to be configured, determining which types of frame should trigger a wake-up event and allowing an application to place the MAC in power-down mode. In this mode, the MAC ignores all received frames until one matching a configured remote wake-up frame is received, at which point the MAC automatically exits power-down mode and continues to receive frames.

The ui32Flags parameter is a logical OR of the following flags:

  • EMAC_PMT_GLOBAL_UNICAST_ENABLE instructs the MAC to wake up when any unicast frame matching the MAC destination address filter is received.
  • EMAC_PMT_WAKEUP_PACKET_ENABLE instructs the MAC to wake up when any received frame matches the remote wake-up filter configured via a call to EMACRemoteWakeUpFrameFilterSet().
  • EMAC_PMT_MAGIC_PACKET_ENABLE instructs the MAC to wake up when a standard Wake-on-LAN "magic packet" is received. The magic packet contains 6 bytes of 0xFF followed immediately by 16 repetitions of the destination MAC address.
  • EMAC_PMT_POWER_DOWN instructs the MAC to enter power-down mode and wait for an incoming frame matching the remote wake-up frames as described by other flags and via the remote wake-up filter. This flag should only set set if at least one other flag is specified to configure a wake-up frame type.

When the MAC is in power-down mode, software may exit the mode by calling this function with the EMAC_PMT_POWER_DOWN flag absent from ui32Flags. If a configured wake-up frame is received while in power-down mode, the EMAC_INT_POWER_MGMNT interrupt is signaled and may be cleared by reading the status using EMACPowerManagementStatusGet().

Note
While it is possible to gate the clock to the MAC while it is in power-down mode, doing so prevents the reading of the registers required to determine the interrupt status and also prevents power-down mode from exiting via another call to this function.
Returns
None.

Definition at line 4576 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PMTCTLSTAT, EMAC_PMT_GLOBAL_UNICAST_ENABLE, EMAC_PMT_MAGIC_PACKET_ENABLE, EMAC_PMT_POWER_DOWN, EMAC_PMT_WAKEUP_PACKET_ENABLE, EMAC_PMTCTLSTAT_GLBLUCAST, EMAC_PMTCTLSTAT_MGKPKTEN, EMAC_PMTCTLSTAT_PWRDWN, EMAC_PMTCTLSTAT_WUPFREN, and HWREG.

4577 {
4578  uint32_t ui32Value;
4579 
4580  //
4581  // Parameter sanity check.
4582  //
4583  ASSERT(ui32Base == EMAC0_BASE);
4584  ASSERT(~(ui32Flags & ~(EMAC_PMT_GLOBAL_UNICAST_ENABLE |
4588 
4589  //
4590  // Read the control/status register, clear all the bits we can set, mask
4591  // in the new values then rewrite the new register value.
4592  //
4593  ui32Value = HWREG(ui32Base + EMAC_O_PMTCTLSTAT);
4596  ui32Value |= ui32Flags;
4597  HWREG(ui32Base + EMAC_O_PMTCTLSTAT) = ui32Value;
4598 }
#define EMAC_O_PMTCTLSTAT
Definition: hw_emac.h:59
#define EMAC_PMT_GLOBAL_UNICAST_ENABLE
Definition: emac.h:885
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PMT_MAGIC_PACKET_ENABLE
Definition: emac.h:887
#define EMAC_PMTCTLSTAT_PWRDWN
Definition: hw_emac.h:417
#define EMAC_PMTCTLSTAT_GLBLUCAST
Definition: hw_emac.h:410
#define EMAC_PMTCTLSTAT_MGKPKTEN
Definition: hw_emac.h:415
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_PMT_POWER_DOWN
Definition: emac.h:888
#define EMAC_PMT_WAKEUP_PACKET_ENABLE
Definition: emac.h:886
#define EMAC_PMTCTLSTAT_WUPFREN
Definition: hw_emac.h:414
uint32_t EMACPowerManagementStatusGet ( uint32_t  ui32Base)

Queries the current Ethernet MAC remote wake-up status.

Parameters
ui32Baseis the base address of the controller.

This function returns information on the remote wake-up state of the Ethernet MAC. If the MAC has been woken up since the last call, the returned value indicates the type of received frame that caused the MAC to exit power-down state.

Returns
Returns a logical OR of the following flags:
  • EMAC_PMT_POWER_DOWN indicates that the MAC is currently in power-down mode.
  • EMAC_PMT_WAKEUP_PACKET_RECEIVED indicates that the MAC exited power-down mode due to a remote wake-up frame being received. This function call clears this flag.
  • EMAC_PMT_MAGIC_PACKET_RECEIVED indicates that the MAC exited power-down mode due to a wake-on-LAN magic packet being received. This function call clears this flag.

Definition at line 4668 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PMTCTLSTAT, EMAC_PMTCTLSTAT_MGKPRX, EMAC_PMTCTLSTAT_PWRDWN, EMAC_PMTCTLSTAT_WUPRX, and HWREG.

4669 {
4670  //
4671  // Parameter sanity check.
4672  //
4673  ASSERT(ui32Base == EMAC0_BASE);
4674 
4675  //
4676  // Read the control/status register and mask off the status bits to return
4677  // them to the caller.
4678  //
4679  return(HWREG(ui32Base + EMAC_O_PMTCTLSTAT) &
4682 }
#define EMAC_O_PMTCTLSTAT
Definition: hw_emac.h:59
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_PMTCTLSTAT_WUPRX
Definition: hw_emac.h:412
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PMTCTLSTAT_PWRDWN
Definition: hw_emac.h:417
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_PMTCTLSTAT_MGKPRX
Definition: hw_emac.h:413
void EMACRemoteWakeUpFrameFilterGet ( uint32_t  ui32Base,
tEMACWakeUpFrameFilter pFilter 
)

Returns the current remote wake-up frame filter configuration.

Parameters
ui32Baseis the base address of the controller.
pFilterpoints to the structure that is written with the current remote wake-up frame filter information.

This function may be used to read the current wake-up frame filter settings. The data returned by the function describes wake-up frames in terms of a CRC calculated on up to 31 payload bytes in the frame. The actual bytes used in the CRC calculation are defined by means of a bit mask where a 1'' indicates that a byte in the frame should contribute to the CRC calculation and a0'' indicates that the byte should be skipped, and an offset from the start of the frame to the payload byte that represents the first byte in the 31-byte CRC-checked sequence.

The pFilter parameter points to storage that is written with a structure containing the information defining the frame filters. This structure contains the following fields, each of which is replicated 4 times, once for each possible wake-up frame:

  • pui32ByteMask defines whether a given byte in the chosen 31-byte sequence within the frame should contribute to the CRC calculation or not. A 1 indicates that the byte should contribute to the calculation, a 0 causes the byte to be skipped.
  • pui8Command contains flags defining whether this filter is enabled and, if so, whether it refers to unicast or multicast packets. Valid values are one of EMAC_RWU_FILTER_MULTICAST or EMAC_RWU_FILTER_UNICAST ORed with one of EMAC_RWU_FILTER_ENABLE or EMAC_RWU_FILTER_DISABLE.
  • pui8Offset defines the zero-based index of the byte within the frame at which CRC checking defined by pui32ByteMask begins. Alternatively, this value can be thought of as the number of bytes in the frame that the MAC skips before accumulating the CRC based on the pattern in pui32ByteMask.
  • pui16CRC provides the value of the calculated CRC for a valid remote wake-up frame. If the incoming frame is processed according to the filter values provided and the final CRC calculation equals this value, the frame is considered to be a valid remote wake-up frame.

Note that this filter uses CRC16 rather than CRC32 as used in frame checksums.

Returns
None.

Definition at line 4494 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PMTCTLSTAT, EMAC_O_RWUFF, EMAC_PMTCTLSTAT_WUPFRRST, and HWREG.

4496 {
4497  uint32_t *pui32Data;
4498  uint32_t ui32Loop;
4499 
4500  //
4501  // Parameter sanity check.
4502  //
4503  ASSERT(ui32Base == EMAC0_BASE);
4504  ASSERT(pFilter);
4505 
4506  //
4507  // Make sure that the internal register counter for the frame filter
4508  // is reset. This bit automatically resets after 1 clock cycle.
4509  //
4511 
4512  //
4513  // Get a word pointer to the supplied structure.
4514  //
4515  pui32Data = (uint32_t *)pFilter;
4516 
4517  //
4518  // Read the 8 words of the wake-up filter definition from the hardware.
4519  //
4520  for(ui32Loop = 0; ui32Loop < 8; ui32Loop++)
4521  {
4522  //
4523  // Read a word of the filter definition.
4524  //
4525  pui32Data[ui32Loop] = HWREG(ui32Base + EMAC_O_RWUFF);
4526  }
4527 }
#define EMAC_O_PMTCTLSTAT
Definition: hw_emac.h:59
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PMTCTLSTAT_WUPFRRST
Definition: hw_emac.h:405
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_RWUFF
Definition: hw_emac.h:57
void EMACRemoteWakeUpFrameFilterSet ( uint32_t  ui32Base,
const tEMACWakeUpFrameFilter pFilter 
)

Sets values defining up to four frames used to trigger a remote wake-up.

Parameters
ui32Baseis the base address of the controller.
pFilterpoints to the structure containing remote wake-up frame filter information.

This function may be used to define up to four different frames that are considered by the Ethernet MAC to be remote wake-up signals. The data passed to the function describes a wake-up frame in terms of a CRC calculated on up to 31 payload bytes in the frame. The actual bytes used in the CRC calculation are defined by means of a bit mask where a ``1'' indicates that a byte in the frame should contribute to the CRC calculation and a ``0'' indicates that the byte should be skipped, as well as an offset from the start of the frame to the payload byte that represents the first byte in the 31-byte CRC-checked sequence.

The pFilter parameter points to a structure containing the information necessary to set up the filters. This structure contains the following fields, each of which is replicated 4 times, once for each possible wake-up frame:

  • pui32ByteMask defines whether a given byte in the chosen 31-byte sequence within the frame should contribute to the CRC calculation or not. A 1 indicates that the byte should contribute to the calculation, a 0 causes the byte to be skipped.
  • pui8Command contains flags defining whether this filter is enabled and, if so, whether it refers to unicast or multicast packets. Valid values are one of EMAC_RWU_FILTER_MULTICAST or EMAC_RWU_FILTER_UNICAST ORed with one of EMAC_RWU_FILTER_ENABLE or EMAC_RWU_FILTER_DISABLE.
  • pui8Offset defines the zero-based index of the byte within the frame at which CRC checking defined by pui32ByteMask begins. Alternatively, this value can be thought of as the number of bytes in the frame that the MAC skips before accumulating the CRC based on the pattern in pui32ByteMask.
  • pui16CRC provides the value of the calculated CRC for a valid remote wake-up frame. If the incoming frame is processed according to the filter values provided and the final CRC calculation equals this value, the frame is considered to be a valid remote wake-up frame.

Note that this filter uses CRC16 rather than CRC32 as used in frame checksums. The required CRC uses a direct algorithm with polynomial 0x8005, initial seed value 0xFFFF, no final XOR and reversed data order. CRCs for use in this function may be determined using the online calculator found at http://www.zorc.breitbandkatze.de/crc.html.

Returns
None.

Definition at line 4411 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PMTCTLSTAT, EMAC_O_RWUFF, EMAC_PMTCTLSTAT_WUPFRRST, and HWREG.

4413 {
4414  uint32_t *pui32Data;
4415  uint32_t ui32Loop;
4416 
4417  //
4418  // Parameter sanity check.
4419  //
4420  ASSERT(ui32Base == EMAC0_BASE);
4421  ASSERT(pFilter);
4422 
4423  //
4424  // Make sure that the internal register counter for the frame filter
4425  // is reset. This bit automatically resets after 1 clock cycle.
4426  //
4428 
4429  //
4430  // Get a word pointer to the supplied structure.
4431  //
4432  pui32Data = (uint32_t *)pFilter;
4433 
4434  //
4435  // Write the 8 words of the wake-up filter definition to the hardware.
4436  //
4437  for(ui32Loop = 0; ui32Loop < 8; ui32Loop++)
4438  {
4439  //
4440  // Write a word of the filter definition.
4441  //
4442  HWREG(ui32Base + EMAC_O_RWUFF) = pui32Data[ui32Loop];
4443  }
4444 }
#define EMAC_O_PMTCTLSTAT
Definition: hw_emac.h:59
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PMTCTLSTAT_WUPFRRST
Definition: hw_emac.h:405
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_RWUFF
Definition: hw_emac.h:57
void EMACReset ( uint32_t  ui32Base)

Resets the Ethernet MAC.

Parameters
ui32Baseis the base address of the Ethernet controller.

This function performs a reset of the Ethernet MAC by resetting all logic and returning all registers to their default values. The function returns only after the hardware indicates that the reset has completed.

Note
To ensure that the reset completes, the selected PHY clock must be enabled when this function is called. If the PHY clock is absent, this function does not return.
Returns
None.

Definition at line 425 of file emac.c.

References EMAC_DMABUSMOD_SWR, EMAC_O_DMABUSMOD, and HWREG.

Referenced by EMACPHYConfigSet().

426 {
427  //
428  // Reset the Ethernet MAC.
429  //
431 
432  //
433  // Wait for the reset to complete.
434  //
435  while(HWREG(ui32Base + EMAC_O_DMABUSMOD) & EMAC_DMABUSMOD_SWR)
436  {
437  }
438 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_DMABUSMOD_SWR
Definition: hw_emac.h:992
#define EMAC_O_DMABUSMOD
Definition: hw_emac.h:125

Here is the caller graph for this function:

void EMACRxDisable ( uint32_t  ui32Base)

Disables the Ethernet controller receiver.

Parameters
ui32Baseis the base address of the controller.

When terminating operations on the Ethernet interface, this function should be called. This function disables the receiver.

Returns
None.

Definition at line 2312 of file emac.c.

References EMAC_CFG_RE, EMAC_DMAOPMODE_SR, EMAC_O_CFG, EMAC_O_DMAOPMODE, and HWREG.

2313 {
2314  //
2315  // Disable reception in the MAC configuration register.
2316  //
2317  HWREG(ui32Base + EMAC_O_CFG) &= ~EMAC_CFG_RE;
2318 
2319  //
2320  // Disable the MAC receive path.
2321  //
2322  HWREG(ui32Base + EMAC_O_DMAOPMODE) &= ~EMAC_DMAOPMODE_SR;
2323 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_DMAOPMODE_SR
Definition: hw_emac.h:1138
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CFG_RE
Definition: hw_emac.h:198
uint8_t* EMACRxDMACurrentBufferGet ( uint32_t  ui32Base)

Returns the current DMA receive buffer pointer.

Parameters
ui32Baseis the base address of the controller.

This function may be called to determine which buffer the receive DMA engine is currently writing to.

Returns
Returns the receive buffer address currently being written by the DMA engine.

Definition at line 1974 of file emac.c.

References EMAC_O_HOSRXBA, and HWREG.

1975 {
1976  //
1977  // Return the receive buffer address currently being written by the DMA.
1978  //
1979  return((uint8_t *)HWREG(ui32Base + EMAC_O_HOSRXBA));
1980 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_HOSRXBA
Definition: hw_emac.h:148
tEMACDMADescriptor* EMACRxDMACurrentDescriptorGet ( uint32_t  ui32Base)

Returns the current DMA receive descriptor pointer.

Parameters
ui32Baseis the base address of the controller.

This function returns a pointer to the current Ethernet receive descriptor read by the DMA.

Returns
Returns a pointer to the start of the current receive DMA descriptor.

Definition at line 1952 of file emac.c.

References EMAC_O_HOSRXDESC, and HWREG.

1953 {
1954  //
1955  // Return the address of the current receive descriptor written by the DMA.
1956  //
1957  return((tEMACDMADescriptor *)HWREG(ui32Base + EMAC_O_HOSRXDESC));
1958 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_HOSRXDESC
Definition: hw_emac.h:144
A structure defining a single Ethernet DMA buffer descriptor.
Definition: emac.h:142
tEMACDMADescriptor* EMACRxDMADescriptorListGet ( uint32_t  ui32Base)

Returns a pointer to the start of the DMA receive descriptor list.

Parameters
ui32Baseis the base address of the controller.

This function returns a pointer to the head of the Ethernet MAC's receive DMA descriptor list. This value corresponds to the pointer originally set using a call to EMACRxDMADescriptorListSet().

Returns
Returns a pointer to the start of the DMA receive descriptor list.

Definition at line 1930 of file emac.c.

References EMAC_O_RXDLADDR, and HWREG.

1931 {
1932  //
1933  // Return the current receive DMA descriptor list pointer.
1934  //
1935  return((tEMACDMADescriptor *)HWREG(ui32Base + EMAC_O_RXDLADDR));
1936 }
#define HWREG(x)
Definition: hw_types.h:48
A structure defining a single Ethernet DMA buffer descriptor.
Definition: emac.h:142
#define EMAC_O_RXDLADDR
Definition: hw_emac.h:129
void EMACRxDMADescriptorListSet ( uint32_t  ui32Base,
tEMACDMADescriptor pDescriptor 
)

Sets the DMA receive descriptor list pointer.

Parameters
ui32Baseis the base address of the controller.
pDescriptorpoints to the first DMA descriptor in the list to be passed to the receive DMA engine.

This function sets the Ethernet MAC's receive DMA descriptor list pointer. The pDescriptor pointer must point to one or more descriptor structures.

When multiple descriptors are provided, they can be either chained or unchained. Chained descriptors are indicated by setting the DES0_TX_CTRL_CHAINED or DES1_RX_CTRL_CHAINED bit in the relevant word of the transmit or receive descriptor. If this bit is clear, unchained descriptors are assumed.

Chained descriptors use a link pointer in each descriptor to point to the next descriptor in the chain.

Unchained descriptors are assumed to be contiguous in memory with a consistent offset between the start of one descriptor and the next. If unchained descriptors are used, the pvLink field in the descriptor becomes available to store a second buffer pointer, allowing each descriptor to point to two buffers rather than one. In this case, the ui32DescSkipSize parameter to EMACInit() must previously have been set to the number of words between the end of one descriptor and the start of the next. This value must be 0 in cases where a packed array of tEMACDMADescriptor structures is used. If the application wishes to add new state fields to the end of the descriptor structure, the skip size should be set to accommodate the newly sized structure.

Applications are responsible for initializing all descriptor fields appropriately before passing the descriptor list to the hardware.

Returns
None.

Definition at line 1902 of file emac.c.

References ASSERT, EMAC_O_RXDLADDR, and HWREG.

1903 {
1904  //
1905  // Parameter sanity check.
1906  //
1907  ASSERT(pDescriptor);
1908  ASSERT(((uint32_t)pDescriptor & 3) == 0);
1909 
1910  //
1911  // Write the supplied address to the MACRXDLADDR register.
1912  //
1913  HWREG(ui32Base + EMAC_O_RXDLADDR) = (uint32_t)pDescriptor;
1914 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_RXDLADDR
Definition: hw_emac.h:129
void EMACRxDMAPollDemand ( uint32_t  ui32Base)

Orders the MAC DMA controller to attempt to acquire the next receive descriptor.

Parameters
ui32Baseis the base address of the Ethernet controller.

This function must be called to restart the receiver if it has been suspended due to the current receive DMA descriptor being owned by the host. Once the application reads any data from the descriptor and marks it as being owned by the MAC DMA, this function causes the hardware to attempt to acquire the descriptor before writing the next received packet into its buffer(s).

Returns
None.

Definition at line 1853 of file emac.c.

References EMAC_O_RXPOLLD, and HWREG.

1854 {
1855  //
1856  // Any write to the MACRXPOLLD register causes the receive DMA to attempt
1857  // to resume.
1858  //
1859  HWREG(ui32Base + EMAC_O_RXPOLLD) = 0;
1860 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_RXPOLLD
Definition: hw_emac.h:128
void EMACRxEnable ( uint32_t  ui32Base)

Enables the Ethernet controller receiver.

Parameters
ui32Baseis the base address of the controller.

When starting operations on the Ethernet interface, this function should be called to enable the receiver after all configuration has been completed.

Returns
None.

Definition at line 2286 of file emac.c.

References EMAC_CFG_RE, EMAC_DMAOPMODE_SR, EMAC_O_CFG, EMAC_O_DMAOPMODE, and HWREG.

2287 {
2288  //
2289  // Enable the MAC receive path.
2290  //
2291  HWREG(ui32Base + EMAC_O_DMAOPMODE) |= EMAC_DMAOPMODE_SR;
2292 
2293  //
2294  // Enable receive in the MAC configuration register.
2295  //
2296  HWREG(ui32Base + EMAC_O_CFG) |= EMAC_CFG_RE;
2297 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_DMAOPMODE_SR
Definition: hw_emac.h:1138
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CFG_RE
Definition: hw_emac.h:198
void EMACRxWatchdogTimerSet ( uint32_t  ui32Base,
uint8_t  ui8Timeout 
)

Sets the receive interrupt watchdog timer period.

Parameters
ui32Baseis the base address of the Ethernet controller.
ui8Timeoutis the desired timeout expressed as a number of 256 system clock periods.

This function configures the receive interrupt watchdog timer. The uiTimeout parameter specifies the number of 256 system clock periods that elapse before the timer expires. In cases where the DMA has transferred a frame using a descriptor that has DES1_RX_CTRL_DISABLE_INT set, the watchdog causes a receive interrupt to be generated when it times out. The watchdog timer is reset whenever a packet is transferred to memory using a DMA descriptor that does not disable the receive interrupt.

To disable the receive interrupt watchdog function, set ui8Timeout to 0.

Returns
None.

Definition at line 1733 of file emac.c.

References EMAC_O_RXINTWDT, and HWREG.

1734 {
1735  //
1736  // Set the receive interrupt watchdog timeout period.
1737  //
1738  HWREG(ui32Base + EMAC_O_RXINTWDT) = (uint32_t)ui8Timeout;
1739 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_RXINTWDT
Definition: hw_emac.h:140
uint32_t EMACStatusGet ( uint32_t  ui32Base)

Returns the current Ethernet MAC status.

Parameters
ui32Baseis the base address of the Ethernet controller.

This function returns information on the current status of all the main modules in the MAC transmit and receive data paths.

Returns
Returns the current MAC status as a logical OR of any of the following flags:
  • EMAC_STATUS_TX_NOT_EMPTY
  • EMAC_STATUS_TX_WRITING_FIFO
  • EMAC_STATUS_TX_PAUSED
  • EMAC_STATUS_MAC_NOT_IDLE
  • EMAC_STATUS_RWC_ACTIVE
  • EMAC_STATUS_RPE_ACTIVE

The transmit frame controller status can be extracted from the returned value by ANDing with EMAC_STATUS_TFC_STATE_MASK and is one of the following:

  • EMAC_STATUS_TFC_STATE_IDLE
  • EMAC_STATUS_TFC_STATE_WAITING
  • EMAC_STATUS_TFC_STATE_PAUSING
  • EMAC_STATUS_TFC_STATE_WRITING

The transmit FIFO read controller status can be extracted from the returned value by ANDing with EMAC_STATUS_TRC_STATE_MASK and is one of the following:

  • EMAC_STATUS_TRC_STATE_IDLE
  • EMAC_STATUS_TRC_STATE_READING
  • EMAC_STATUS_TRC_STATE_WAITING
  • EMAC_STATUS_TRC_STATE_STATUS

The current receive FIFO levels can be extracted from the returned value by ANDing with EMAC_STATUS_RX_FIFO_LEVEL_MASK and is one of the following:

  • EMAC_STATUS_RX_FIFO_EMPTY indicating that the FIFO is empty.
  • EMAC_STATUS_RX_FIFO_BELOW indicating that the FIFO fill level is below the flow-control deactivate threshold.
  • EMAC_STATUS_RX_FIFO_ABOVE indicating that the FIFO fill level is above the flow-control activate threshold.
  • EMAC_STATUS_RX_FIFO_FULL indicating that the FIFO is full.

The current receive FIFO state can be extracted from the returned value by ANDing with EMAC_STATUS_RX_FIFO_STATE_MASK and is one of the following:

  • EMAC_STATUS_RX_FIFO_IDLE
  • EMAC_STATUS_RX_FIFO_READING
  • EMAC_STATUS_RX_FIFO_STATUS
  • EMAC_STATUS_RX_FIFO_FLUSHING

Definition at line 1800 of file emac.c.

References EMAC_O_STATUS, and HWREG.

1801 {
1802  //
1803  // Read and return the MAC status register content.
1804  //
1805  return(HWREG(ui32Base + EMAC_O_STATUS));
1806 }
#define EMAC_O_STATUS
Definition: hw_emac.h:56
#define HWREG(x)
Definition: hw_types.h:48
void EMACTimestampAddendSet ( uint32_t  ui32Base,
uint32_t  ui32Increment 
)

Adjusts the system time update rate when using the fine correction method.

Parameters
ui32Baseis the base address of the controller.
ui32Incrementis the number to add to the accumulator register on each tick of the 25-MHz main oscillator.

This function is used to control the rate of update of the system time when in fine update mode. Fine correction mode is selected if EMAC_TS_UPDATE_FINE is supplied in the ui32Config parameter passed to a previous call to EMACTimestampConfigSet(). Fine update mode is typically used when synchronizing the local clock to the IEEE 1588 master clock. The subsecond counter is incremented by the number passed to EMACTimestampConfigSet() in the ui32SubSecondInc parameter each time a 32-bit accumulator register generates a carry. The accumulator register is incremented by the "addend" value on each main oscillator tick, and this addend value is modified to allow fine control over the rate of change of the timestamp counter. The addend value is calculated using the ratio of the main oscillator clock rate and the desired IEEE 1588 clock rate and the ui32SubSecondInc value is set to correspond to the desired IEEE 1588 clock rate.

As an example, using digital rollover mode and a 25-MHz main oscillator clock with a desired IEEE 1588 clock accuracy of 12.5 MHz, and having made a previous call to EMACTimestampConfigSet() with ui32SubSecondInc set to the 12.5-MHz clock period of 80 ns, the initial ui32Increment value would be set to 0x80000000 to generate a carry on every second main oscillator tick. Because the system time updates each time the accumulator overflows, small changes in the ui32Increment value can be used to very finely control the system time rate.

Returns
None.
See also
EMACTimestampConfigSet()

Definition at line 3555 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMADD, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_ADDREGUP, and HWREG.

3556 {
3557  //
3558  // Parameter sanity check.
3559  //
3560  ASSERT(ui32Base == EMAC0_BASE);
3561 
3562  HWREG(ui32Base + EMAC_O_TIMADD) = ui32Increment;
3563 
3564  //
3565  // Wait for any previous update to complete.
3566  //
3567  while(HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_ADDREGUP)
3568  {
3569  //
3570  // Spin for a while.
3571  //
3572  }
3573 
3574  //
3575  // Force the system clock to update by the value provided.
3576  //
3578 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_O_TIMADD
Definition: hw_emac.h:115
#define EMAC_TIMSTCTRL_ADDREGUP
Definition: hw_emac.h:753
uint32_t EMACTimestampConfigGet ( uint32_t  ui32Base,
uint32_t *  pui32SubSecondInc 
)

Returns the current IEEE 1588 timestamping configuration.

Parameters
ui32Baseis the base address of the controller.
pui32SubSecondIncpoints to storage that is written with the current subsecond increment value for the IEEE 1588 clock.

This function may be used to retreive the current MAC timestamping configuration.

See also
EMACTimestampConfigSet()
Returns
Returns the current timestamping configuration as a logical OR of the following flags:
  • EMAC_TS_PTP_VERSION_2 indicates that the MAC is processing PTP version 2 messages. If this flag is absent, PTP version 1 messages are expected.
  • EMAC_TS_DIGITAL_ROLLOVER causes the clock's subsecond value to roll over at 0x3BA9C9FF (999999999 decimal). In this mode, it can be considered as a nanosecond counter with each digit representing 1 ns. If this flag is absent, the subsecond value rolls over at 0x7FFFFFFF, effectively counting increments of 0.465 ns.
  • EMAC_TS_MAC_FILTER_ENABLE indicates that incoming PTP messages are filtered using any of the configured MAC addresses. Messages with a destination address programmed into the MAC address filter are passed, others are discarded. If this flag is absent, the MAC address is ignored.
  • EMAC_TS_UPDATE_FINE implements the fine update method that causes the IEEE 1588 clock to advance by the the value returned in the *pui32SubSecondInc parameter each time a carry is generated from the addend accumulator register. If this flag is absent, the coarse update method is in use and the clock is advanced by the *pui32SubSecondInc value on each system clock tick.
  • EMAC_TS_SYNC_ONLY indicates that timestamps are only generated for SYNC messages.
  • EMAC_TS_DELAYREQ_ONLY indicates that timestamps are only generated for Delay_Req messages.
  • EMAC_TS_ALL indicates that timestamps are generated for all IEEE 1588 messages.
  • EMAC_TS_SYNC_PDREQ_PDRESP timestamps only SYNC, Pdelay_Req and Pdelay_Resp messages.
  • EMAC_TS_DREQ_PDREQ_PDRESP indicates that timestamps are only generated for Delay_Req, Pdelay_Req and Pdelay_Resp messages.
  • EMAC_TS_SYNC_DELAYREQ indicates that timestamps are only generated for Delay_Req messages.
  • EMAC_TS_PDREQ_PDRESP indicates that timestamps are only generated for Pdelay_Req and Pdelay_Resp messages.
  • EMAC_TS_PROCESS_IPV4_UDP indicates that PTP packets encapsulated in UDP over IPv4 packets are being processed. If absent, the MAC ignores these frames.
  • EMAC_TS_PROCESS_IPV6_UDP indicates that PTP packets encapsulated in UDP over IPv6 packets are being processed. If absent, the MAC ignores these frames.
  • EMAC_TS_PROCESS_ETHERNET indicates that PTP packets encapsulated directly in Ethernet frames are being processd. If absent, the MAC ignores these frames.
  • EMAC_TS_ALL_RX_FRAMES indicates that timestamping is enabled for all frames received by the MAC, regardless of type.

If EMAC_TS_ALL_RX_FRAMES and none of the options specifying subsets of PTP packets to timestamp are set, the MAC is configured to timestamp SYNC, Follow_Up, Delay_Req and Delay_Resp messages only.

Definition at line 3282 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_SUBSECINC, EMAC_O_TIMSTCTRL, EMAC_SUBSECINC_SSINC_M, EMAC_SUBSECINC_SSINC_S, and HWREG.

3283 {
3284  //
3285  // Parameter sanity check.
3286  //
3287  ASSERT(ui32Base == EMAC0_BASE);
3288  ASSERT(pui32SubSecondInc);
3289 
3290  //
3291  // Read the current subsecond increment value.
3292  //
3293  *pui32SubSecondInc = (HWREG(ui32Base + EMAC_O_SUBSECINC) &
3295 
3296  //
3297  // Return the current timestamp configuration.
3298  //
3299  return(HWREG(ui32Base + EMAC_O_TIMSTCTRL));
3300 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_SUBSECINC
Definition: hw_emac.h:105
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_SUBSECINC_SSINC_M
Definition: hw_emac.h:768
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_SUBSECINC_SSINC_S
Definition: hw_emac.h:769
void EMACTimestampConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config,
uint32_t  ui32SubSecondInc 
)

Configures the Ethernet MAC's IEEE 1588 timestamping options.

Parameters
ui32Baseis the base address of the controller.
ui32Configcontains flags selecting particular configuration options.
ui32SubSecondIncis the number that the IEEE 1588 subsecond clock should increment on each tick.

This function is used to configure the operation of the Ethernet MAC's internal timestamping clock. This clock is used to timestamp incoming and outgoing packets and as an accurate system time reference when IEEE 1588 Precision Time Protocol is in use.

The ui32Config parameter contains a collection of flags selecting the desired options. Valid flags are:

One of the following to determine whether IEEE 1588 version 1 or version 2 packet format is to be processed:

  • EMAC_TS_PTP_VERSION_2
  • EMAC_TS_PTP_VERSION_1

One of the following to determine how the IEEE 1588 clock's subsecond value should be interpreted and handled:

  • EMAC_TS_DIGITAL_ROLLOVER causes the clock's subsecond value to roll over at 0x3BA9C9FF (999999999 decimal). In this mode, it can be considered as a nanosecond counter with each digit representing 1 ns.
  • EMAC_TS_BINARY_ROLLOVER causes the clock's subsecond value to roll over at 0x7FFFFFFF. In this mode, the subsecond value counts 0.465 ns periods.

One of the following to enable or disable MAC address filtering. When enabled, PTP frames are filtered unless the destination MAC address matches any of the currently programmed MAC addresses.

  • EMAC_TS_MAC_FILTER_ENABLE
  • EMAC_TS_MAC_FILTER_DISABLE

One of the following to determine how the clock is updated:

  • EMAC_TS_UPDATE_COARSE causes the IEEE 1588 clock to advance by the value supplied in the ui32SubSecondInc parameter on each main oscillator clock cycle.
  • EMAC_TS_UPDATE_FINE selects the fine update method which causes the IEEE 1588 clock to advance by the the value supplied in the ui32SubSecondInc parameter each time a carry is generated from the addend accumulator register.

One of the following to determine which IEEE 1588 messages are timestamped:

  • EMAC_TS_SYNC_FOLLOW_DREQ_DRESP timestamps SYNC, Follow_Up, Delay_Req and Delay_Resp messages.
  • EMAC_TS_SYNC_ONLY timestamps only SYNC messages.
  • EMAC_TS_DELAYREQ_ONLY timestamps only Delay_Req messages.
  • EMAC_TS_ALL timestamps all IEEE 1588 messages.
  • EMAC_TS_SYNC_PDREQ_PDRESP timestamps only SYNC, Pdelay_Req and Pdelay_Resp messages.
  • EMAC_TS_DREQ_PDREQ_PDRESP timestamps only Delay_Req, Pdelay_Req and Pdelay_Resp messages.
  • EMAC_TS_SYNC_DELAYREQ timestamps only Delay_Req messages.
  • EMAC_TS_PDREQ_PDRESP timestamps only Pdelay_Req and Pdelay_Resp messages.

Optional, additional flags are:

  • EMAC_TS_PROCESS_IPV4_UDP processes PTP packets encapsulated in UDP over IPv4 packets. If absent, the MAC ignores these frames.
  • EMAC_TS_PROCESS_IPV6_UDP processes PTP packets encapsulated in UDP over IPv6 packets. If absent, the MAC ignores these frames.
  • EMAC_TS_PROCESS_ETHERNET processes PTP packets encapsulated directly in Ethernet frames. If absent, the MAC ignores these frames.
  • EMAC_TS_ALL_RX_FRAMES enables timestamping for all frames received by the MAC, regardless of type.

The ui32SubSecondInc controls the rate at which the timestamp clock's subsecond count increments. Its meaning depends on which of EMAC_TS_DIGITAL_ROLLOVER or EMAC_TS_BINARY_ROLLOVER and EMAC_TS_UPDATE_FINE or EMAC_TS_UPDATE_COARSE were included in ui32Config.

The timestamp second counter is incremented each time the subsecond counter rolls over. In digital rollover mode, the subsecond counter acts as a simple 31-bit counter, rolling over to 0 after reaching 0x7FFFFFFF. In this case, each lsb of the subsecond counter represents 0.465 ns (assuming the definition of 1 second resolution for the seconds counter). When binary rollover mode is selected, the subsecond counter acts as a nanosecond counter and rolls over to 0 after reaching 999,999,999 making each lsb represent 1 nanosecond.

In coarse update mode, the timestamp subsecond counter is incremented by ui32SubSecondInc on each main oscillator clock tick. Setting ui32SubSecondInc to the main oscillator clock period in either 1 ns or 0.465 ns units ensures that the time stamp, read as seconds and subseconds, increments at the same rate as the main oscillator clock. For example, if the main oscillator is 25 MHz, ui32SubSecondInc is set to 40 if digital rollover mode is selected or (40 / 0.465) = 86 in binary rollover mode.

In fine update mode, the subsecond increment value must be set according to the desired accuracy of the recovered IEEE 1588 clock which must be lower than the system clock rate. Fine update mode is typically used when synchronizing the local clock to the IEEE 1588 master clock. The subsecond counter is incremented by ui32SubSecondInc counts each time a 32-bit accumulator register generates a carry. The accumulator register is incremented by the addend value on each main oscillator tick and this addend value is modified to allow fine control over the rate of change of the timestamp counter. The addend value is calculated using the ratio of the main oscillator clock rate and the desired IEEE 1588 clock rate and the ui32SubSecondInc value is set to correspond to the desired IEEE 1588 clock rate. As an example, using digital rollover mode and a 25-MHz main oscillator clock with a desired IEEE 1588 clock accuracy of 12.5 MHz, we would set ui32SubSecondInc to the 12.5-MHz clock period of 80 ns and set the initial addend value to 0x80000000 to generate a carry on every second system clock.

See also
EMACTimestampAddendSet()
Returns
None.

Definition at line 3190 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_CC_PTPCEN, EMAC_O_CC, EMAC_O_SUBSECINC, EMAC_O_TIMSTCTRL, EMAC_SUBSECINC_SSINC_M, EMAC_SUBSECINC_SSINC_S, and HWREG.

3192 {
3193  //
3194  // Parameter sanity check.
3195  //
3196  ASSERT(ui32Base == EMAC0_BASE);
3197 
3198  //
3199  // Ensure that the PTP module clock is enabled.
3200  //
3201  HWREG(ui32Base + EMAC_O_CC) |= EMAC_CC_PTPCEN;
3202 
3203  //
3204  // Write the subsecond increment value.
3205  //
3206  HWREG(ui32Base + EMAC_O_SUBSECINC) = ((ui32SubSecondInc <<
3209 
3210  //
3211  // Set the timestamp configuration.
3212  //
3213  HWREG(ui32Base + EMAC_O_TIMSTCTRL) = ui32Config;
3214 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_CC_PTPCEN
Definition: hw_emac.h:1294
#define EMAC_O_SUBSECINC
Definition: hw_emac.h:105
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_SUBSECINC_SSINC_M
Definition: hw_emac.h:768
#define EMAC_O_CC
Definition: hw_emac.h:154
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_SUBSECINC_SSINC_S
Definition: hw_emac.h:769
void EMACTimestampDisable ( uint32_t  ui32Base)

Disables packet timestamping and stops the system clock.

Parameters
ui32Baseis the base address of the controller.

This function is used to stop the system clock used to timestamp Ethernet frames and to disable timestamping.

Returns
None.

Definition at line 3351 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_TSEN, and HWREG.

3352 {
3353  //
3354  // Parameter sanity check.
3355  //
3356  ASSERT(ui32Base == EMAC0_BASE);
3357 
3358  //
3359  // Disable IEEE 1588 timestamping.
3360  //
3361  HWREG(ui32Base + EMAC_O_TIMSTCTRL) &= ~EMAC_TIMSTCTRL_TSEN;
3362 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_TIMSTCTRL_TSEN
Definition: hw_emac.h:759
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
void EMACTimestampEnable ( uint32_t  ui32Base)

Enables packet timestamping and starts the system clock running.

Parameters
ui32Baseis the base address of the controller.

This function is used to enable the system clock used to timestamp Ethernet frames and to enable that timestamping.

Returns
None.

Definition at line 3315 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_TSEN, EMAC_TIMSTCTRL_TSINIT, and HWREG.

3316 {
3317  //
3318  // Parameter sanity check.
3319  //
3320  ASSERT(ui32Base == EMAC0_BASE);
3321 
3322  //
3323  // Enable IEEE 1588 timestamping.
3324  //
3326 
3327  //
3328  // If necessary, initialize the timestamping system. This bit self-clears
3329  // once the system time is loaded. Only do this if initialization is not
3330  // currently ongoing.
3331  //
3332  if(!(HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_TSINIT))
3333  {
3335  }
3336 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_TIMSTCTRL_TSEN
Definition: hw_emac.h:759
#define EMAC_TIMSTCTRL_TSINIT
Definition: hw_emac.h:757
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
uint32_t EMACTimestampIntStatus ( uint32_t  ui32Base)

Reads the status of the Ethernet system time interrupt.

Parameters
ui32Baseis the base address of the controller.

When an Ethernet interrupt occurs and EMAC_INT_TIMESTAMP is reported bu EMACIntStatus(), this function must be called to read and clear the timer interrupt status.

Returns
The return value is the logical OR of the values EMAC_TS_INT_TS_SEC_OVERFLOW and EMAC_TS_INT_TARGET_REACHED.
  • EMAC_TS_INT_TS_SEC_OVERFLOW indicates that the second counter in the hardware timer has rolled over.
  • EMAC_TS_INT_TARGET_REACHED indicates that the system time incremented past the value set in an earlier call to EMACTimestampTargetSet(). When this occurs, a new target time may be set and the interrupt re-enabled using calls to EMACTimestampTargetSet() and EMACTimestampTargetIntEnable().

Definition at line 3713 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMSTAT, and HWREG.

3714 {
3715  //
3716  // Parameter sanity check.
3717  //
3718  ASSERT(ui32Base == EMAC0_BASE);
3719 
3720  //
3721  // Return the current interrupt status from the timestamp module.
3722  //
3723  return(HWREG(ui32Base + EMAC_O_TIMSTAT));
3724 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_TIMSTAT
Definition: hw_emac.h:121
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
void EMACTimestampPPSCommand ( uint32_t  ui32Base,
uint8_t  ui8Cmd 
)

Sends a command to control the PPS output from the Ethernet MAC.

Parameters
ui32Baseis the base address of the controller.
ui8Cmdidentifies the command to be sent.

This function may be used to send a command to the MAC PPS (Pulse Per Second) controller when it is operating in command mode. Command mode is selected by calling EMACTimestampPPSCommandModeSet(). Valid commands are as follow:

  • EMAC_PPS_COMMAND_NONE indicates no command.
  • EMAC_PPS_COMMAND_START_SINGLE indicates that a single high pulse should be generated when the system time reaches the current target time.
  • EMAC_PPS_COMMAND_START_TRAIN indicates that a train of pulses should be started when the system time reaches the current target time.
  • EMAC_PPS_COMMAND_CANCEL_START cancels any pending start command if the system time has not yet reached the programmed target time.
  • EMAC_PPS_COMMAND_STOP_AT_TIME indicates that the current pulse train should be stopped when the system time reaches the current target time.
  • EMAC_PPS_COMMAND_STOP_NOW indicates that the current pulse train should be stopped immediately.
  • EMAC_PPS_COMMAND_CANCEL_STOP cancels any pending stop command if the system time has not yet reached the programmed target time.

In all cases, the width of the pulses generated is governed by the ui32Width parameter passed to EMACTimestampPPSPeriodSet(). If a command starts a train of pulses, the period of the pulses is governed by the ui32Period parameter passed to the same function. Target times associated with PPS commands are set by calling EMACTimestampTargetSet().

Returns
None.

Definition at line 3919 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PPSCTRL, EMAC_PPSCTRL_PPSCTRL_M, EMAC_PPSCTRL_PPSEN0, and HWREG.

3920 {
3921  //
3922  // Parameter sanity check.
3923  //
3924  ASSERT(ui32Base == EMAC0_BASE);
3925 
3926  //
3927  // Wait for any previous command write to complete.
3928  //
3929  while(HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M)
3930  {
3931  //
3932  // Wait a bit.
3933  //
3934  }
3935 
3936  //
3937  // Write the command to the PPS control register.
3938  //
3939  HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui8Cmd);
3940 }
#define EMAC_PPSCTRL_PPSEN0
Definition: hw_emac.h:874
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PPSCTRL_PPSCTRL_M
Definition: hw_emac.h:875
#define EMAC_O_PPSCTRL
Definition: hw_emac.h:122
#define EMAC0_BASE
Definition: hw_memmap.h:132
void EMACTimestampPPSCommandModeSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the Ethernet MAC PPS output in command mode.

Parameters
ui32Baseis the base address of the controller.
ui32Configdetermines how the system target time is used.

The simple mode of operation offered by the PPS (Pulse Per Second) engine may be too restrictive for some applications. The second mode, however, allows complex pulse trains to be generated using commands that tell the engine to send individual pulses or start and stop trains if pulses. In this mode, the pulse width and period may be set arbitrarily based on ticks of the clock used to update the system time. Commands are triggered at specific times using the target time last set using a call to EMACTimestampTargetSet().

The ui32Config parameter may be used to control whether the target time is used to trigger commands only or can also generate an interrupt to the CPU. Valid values are:

  • EMAC_PPS_TARGET_INT configures the target time to only raise an interrupt and not to trigger any pending PPS command.
  • EMAC_PPS_TARGET_PPS configures the target time to trigger a pending PPS command but not raise an interrupt.
  • EMAC_PPS_TARGET_BOTH configures the target time to trigger any pending PPS command and also raise an interrupt.

To use command mode, an application must call this function to enable the mode, then call:

Returns
None.

Definition at line 3854 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PPSCTRL, EMAC_PPS_TARGET_BOTH, EMAC_PPS_TARGET_INT, EMAC_PPS_TARGET_PPS, EMAC_PPSCTRL_PPSCTRL_M, EMAC_PPSCTRL_PPSEN0, and HWREG.

3855 {
3856  //
3857  // Parameter sanity check.
3858  //
3859  ASSERT(ui32Base == EMAC0_BASE);
3860  ASSERT(!(ui32Config & (EMAC_PPS_TARGET_INT | EMAC_PPS_TARGET_PPS |
3862 
3863  //
3864  // Wait for any previous command write to complete.
3865  //
3866  while(HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M)
3867  {
3868  //
3869  // Wait a bit.
3870  //
3871  }
3872 
3873  //
3874  // Write the configuration value to the PPS control register, setting the
3875  // PPSEN0 bit to ensure that the PPS engine is in command mode and
3876  // clearing the command in the PPSCTRL field.
3877  //
3878  HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui32Config);
3879 }
#define EMAC_PPSCTRL_PPSEN0
Definition: hw_emac.h:874
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PPSCTRL_PPSCTRL_M
Definition: hw_emac.h:875
#define EMAC_PPS_TARGET_PPS
Definition: emac.h:760
#define EMAC_O_PPSCTRL
Definition: hw_emac.h:122
#define EMAC_PPS_TARGET_INT
Definition: emac.h:759
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_PPS_TARGET_BOTH
Definition: emac.h:761
void EMACTimestampPPSPeriodSet ( uint32_t  ui32Base,
uint32_t  ui32Period,
uint32_t  ui32Width 
)

Sets the period and width of the pulses on the Ethernet MAC PPS output.

Parameters
ui32Baseis the base address of the controller.
ui32Periodis the period of the PPS output expressed in terms of system time update ticks.
ui32Widthis the width of the high portion of the PPS output expressed in terms of system time update ticks.

This function may be used to control the period and duty cycle of the signal output on the Ethernet MAC PPS pin when the PPS generator is operating in command mode and a command to send one or more pulses has been executed. Command mode is selected by calling EMACTimestampPPSCommandModeSet().

In simple mode, the PPS output signal frequency is controlled by the ui32FreqConfig parameter passed to EMACTimestampPPSSimpleModeSet().

The ui32Period and ui32Width parameters are expressed in terms of system time update ticks. When the system time is operating in coarse update mode, each tick is equivalent to the system clock. In fine update mode, a tick occurs every time the 32-bit system time accumulator overflows and this, in turn, is determined by the value passed to the function EMACTimestampAddendSet(). Regardless of the tick source, each tick increments the actual system time, queried using EMACTimestampSysTimeGet() by the subsecond increment value passed in the ui32SubSecondInc to EMACTimestampConfigSet().

Returns
None.

Definition at line 3975 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PPS0INTVL, EMAC_O_PPS0WIDTH, and HWREG.

3977 {
3978  //
3979  // Parameter sanity check.
3980  //
3981  ASSERT(ui32Base == EMAC0_BASE);
3982 
3983  //
3984  // Write the desired PPS period and pulse width.
3985  //
3986  HWREG(ui32Base + EMAC_O_PPS0INTVL) = ui32Period;
3987  HWREG(ui32Base + EMAC_O_PPS0WIDTH) = ui32Width;
3988 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_PPS0INTVL
Definition: hw_emac.h:123
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_PPS0WIDTH
Definition: hw_emac.h:124
void EMACTimestampPPSSimpleModeSet ( uint32_t  ui32Base,
uint32_t  ui32FreqConfig 
)

Configures the Ethernet MAC PPS output in simple mode.

Parameters
ui32Baseis the base address of the controller.
ui32FreqConfigdetermines the frequency of the output generated on the PPS pin.

This function configures the Ethernet MAC PPS (Pulse Per Second) engine to operate in its simple mode which allows the generation of a few, fixed frequencies and pulse widths on the PPS pin. If more complex pulse train generation is required, the MAC also provides a command-based PPS control mode that can be selected by calling EMACTimestampPPSCommandModeSet().

The ui32FreqConfig parameter may take one of the following values:

  • EMAC_PPS_SINGLE_PULSE generates a single high pulse on the PPS output once per second. The pulse width is the same as the system clock period.
  • EMAC_PPS_1HZ generates a 1Hz signal on the PPS output. This option is not available if the system time subsecond counter is currently configured to operate in binary rollover mode.
  • EMAC_PPS_2HZ, EMAC_PPS_4HZ, EMAC_PPS_8HZ, EMAC_PPS_16HZ, EMAC_PPS_32HZ, EMAC_PPS_64HZ, EMAC_PPS_128HZ, EMAC_PPS_256HZ, EMAC_PPS_512HZ, EMAC_PPS_1024HZ, EMAC_PPS_2048HZ, EMAC_PPS_4096HZ, EMAC_PPS_8192HZ, EMAC_PPS_16384HZ generate the requested frequency on the PPS output in both binary and digital rollover modes.
  • EMAC_PPS_32768HZ generates a 32KHz signal on the PPS output. This option is not available if the system time subsecond counter is currently configured to operate in digital rollover mode.

Except when EMAC_PPS_SINGLE_PULSE is specified, the signal generated on PPS has a duty cycle of 50% when binary rollover mode is used for the system time subsecond count. In digital mode, the output frequency averages the value requested and is resynchronized each second. For example, if EMAC_PPS_4HZ is selected in digital rollover mode, the output generates three clocks with 50 percent duty cycle and 268 ms period followed by a fourth clock of 195 ms period, 134 ms low and 61 ms high.

Returns
None.

Definition at line 3771 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_PPSCTRL, EMAC_O_TIMSTCTRL, EMAC_PPS_1HZ, EMAC_PPS_32768HZ, EMAC_PPS_SINGLE_PULSE, EMAC_TS_DIGITAL_ROLLOVER, and HWREG.

3772 {
3773  bool bDigital;
3774 
3775  //
3776  // Parameter sanity check.
3777  //
3778  ASSERT(ui32Base == EMAC0_BASE);
3779 
3780  //
3781  // Are we currently running the clock in digital or binary rollover mode?
3782  //
3783  bDigital = (HWREG(ui32Base + EMAC_O_TIMSTCTRL) &
3784  EMAC_TS_DIGITAL_ROLLOVER) ? true : false;
3785 
3786  //
3787  // Weed out some unsupported frequencies. The hardware can't produce a
3788  // 1Hz output when we are in binary rollover mode and can't produce a
3789  // 32KHz output when we are digital rollover mode.
3790  //
3791  ASSERT(bDigital || (ui32FreqConfig != EMAC_PPS_1HZ));
3792  ASSERT(!bDigital || (ui32FreqConfig != EMAC_PPS_32768HZ));
3793 
3794  //
3795  // Adjust the supplied frequency if we are currently in binary update mode
3796  // where the control value generates an output that is twice as fast as
3797  // in digital mode.
3798  //
3799  if((ui32FreqConfig != EMAC_PPS_SINGLE_PULSE) && !bDigital)
3800  {
3801  ui32FreqConfig--;
3802  }
3803 
3804  //
3805  // Write the frequency control value to the PPS control register, clearing
3806  // the PPSEN0 bit to ensure that the PPS engine is in simple mode and not
3807  // waiting for a command. We also clear the TRGMODS0 field to revert to
3808  // the default operation of the target time registers.
3809  //
3810  HWREG(ui32Base + EMAC_O_PPSCTRL) = ui32FreqConfig;
3811 }
#define EMAC_TS_DIGITAL_ROLLOVER
Definition: emac.h:638
#define EMAC_PPS_1HZ
Definition: emac.h:736
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_PPS_32768HZ
Definition: emac.h:751
#define EMAC_O_PPSCTRL
Definition: hw_emac.h:122
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_PPS_SINGLE_PULSE
Definition: emac.h:735
void EMACTimestampSysTimeGet ( uint32_t  ui32Base,
uint32_t *  pui32Seconds,
uint32_t *  pui32SubSeconds 
)

Gets the current system time.

Parameters
ui32Baseis the base address of the controller.
pui32Secondspoints to storage for the current seconds value.
pui32SubSecondspoints to storage for the current subseconds value.

This function may be used to get the current system time.

The meaning of ui32SubSeconds depends on the current system time configuration. If EMACTimestampConfigSet() was previously called with the EMAC_TS_DIGITAL_ROLLOVER configuration option, each bit in the ui32SubSeconds value represents 1 ns. If EMAC_TS_BINARY_ROLLOVER was specified instead, a ui32SubSeconds bit represents 0.46 ns.

Returns
None.

Definition at line 3437 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMNANO, EMAC_O_TIMSEC, and HWREG.

3439 {
3440  //
3441  // Parameter sanity check.
3442  //
3443  ASSERT(ui32Base == EMAC0_BASE);
3444  ASSERT(pui32Seconds);
3445  ASSERT(pui32SubSeconds);
3446 
3447  //
3448  // Read the two-part system time from the seconds and nanoseconds
3449  // registers. We do this in a way that should guard against us reading
3450  // the registers across a nanosecond wrap.
3451  //
3452  do
3453  {
3454  *pui32Seconds = HWREG(ui32Base + EMAC_O_TIMSEC);
3455  *pui32SubSeconds = HWREG(ui32Base + EMAC_O_TIMNANO);
3456  }
3457  while(*pui32SubSeconds > HWREG(ui32Base + EMAC_O_TIMNANO));
3458 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMNANO
Definition: hw_emac.h:109
#define EMAC_O_TIMSEC
Definition: hw_emac.h:107
void EMACTimestampSysTimeSet ( uint32_t  ui32Base,
uint32_t  ui32Seconds,
uint32_t  ui32SubSeconds 
)

Sets the current system time.

Parameters
ui32Baseis the base address of the controller.
ui32Secondsis the seconds value of the new system clock setting.
ui32SubSecondsis the subseconds value of the new system clock setting.

This function may be used to set the current system time. The system clock is set to the value passed in the ui32Seconds and ui32SubSeconds parameters.

The meaning of ui32SubSeconds depends on the current system time configuration. If EMACTimestampConfigSet() was previously called with the EMAC_TS_DIGITAL_ROLLOVER configuration option, each bit in the ui32SubSeconds value represents 1 ns. If EMAC_TS_BINARY_ROLLOVER was specified instead, a ui32SubSeconds bit represents 0.46 ns.

Returns
None.

Definition at line 3387 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMNANOU, EMAC_O_TIMSECU, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_TSINIT, and HWREG.

3389 {
3390  //
3391  // Parameter sanity check.
3392  //
3393  ASSERT(ui32Base == EMAC0_BASE);
3394 
3395  //
3396  // Write the new time to the system time update registers.
3397  //
3398  HWREG(ui32Base + EMAC_O_TIMSECU) = ui32Seconds;
3399  HWREG(ui32Base + EMAC_O_TIMNANOU) = ui32SubSeconds;
3400 
3401  //
3402  // Wait for any previous update to complete.
3403  //
3404  while(HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_TSINIT)
3405  {
3406  //
3407  // Spin for a while.
3408  //
3409  }
3410 
3411  //
3412  // Force the system clock to reset.
3413  //
3415 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_TIMSTCTRL_TSINIT
Definition: hw_emac.h:757
#define EMAC_O_TIMSECU
Definition: hw_emac.h:111
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_O_TIMNANOU
Definition: hw_emac.h:113
void EMACTimestampSysTimeUpdate ( uint32_t  ui32Base,
uint32_t  ui32Seconds,
uint32_t  ui32SubSeconds,
bool  bInc 
)

Adjusts the current system time upwards or downwards by a given amount.

Parameters
ui32Baseis the base address of the controller.
ui32Secondsis the seconds value of the time update to apply.
ui32SubSecondsis the subseconds value of the time update to apply.
bIncdefines the direction of the update.

This function may be used to adjust the current system time either upwards or downwards by a given amount. The size of the adjustment is given by the ui32Seconds and ui32SubSeconds parameter and the direction by the bInc parameter. When bInc is true, the system time is advanced by the interval given. When it is false, the time is retarded by the interval.

The meaning of ui32SubSeconds depends on the current system time configuration. If EMACTimestampConfigSet() was previously called with the EMAC_TS_DIGITAL_ROLLOVER configuration option, each bit in the subsecond value represents 1 ns. If EMAC_TS_BINARY_ROLLOVER was specified instead, a subsecond bit represents 0.46 ns.

Returns
None.

Definition at line 3486 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMNANOU, EMAC_O_TIMSECU, EMAC_O_TIMSTCTRL, EMAC_TIMNANOU_ADDSUB, EMAC_TIMSTCTRL_TSUPDT, and HWREG.

3488 {
3489  //
3490  // Parameter sanity check.
3491  //
3492  ASSERT(ui32Base == EMAC0_BASE);
3493 
3494  //
3495  // Write the new time to the system time update registers.
3496  //
3497  HWREG(ui32Base + EMAC_O_TIMSECU) = ui32Seconds;
3498  HWREG(ui32Base + EMAC_O_TIMNANOU) = ui32SubSeconds |
3499  (bInc ? 0 : EMAC_TIMNANOU_ADDSUB);
3500 
3501  //
3502  // Wait for any previous update to complete.
3503  //
3504  while(HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_TSUPDT)
3505  {
3506  //
3507  // Spin for a while.
3508  //
3509  }
3510 
3511  //
3512  // Force the system clock to update by the value provided.
3513  //
3515 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_TIMNANOU_ADDSUB
Definition: hw_emac.h:801
#define EMAC_O_TIMSECU
Definition: hw_emac.h:111
#define EMAC_TIMSTCTRL_TSUPDT
Definition: hw_emac.h:756
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
#define EMAC_O_TIMNANOU
Definition: hw_emac.h:113
void EMACTimestampTargetIntDisable ( uint32_t  ui32Base)

Disables the Ethernet system time interrupt.

Parameters
ui32Baseis the base address of the controller.

This function may be used to disable any pending Ethernet system time interrupt previously scheduled using calls to EMACTimestampTargetSet() and EMACTimestampTargetIntEnable().

Returns
None.

Definition at line 3675 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_INTTRIG, and HWREG.

3676 {
3677  //
3678  // Parameter sanity check.
3679  //
3680  ASSERT(ui32Base == EMAC0_BASE);
3681 
3682  //
3683  // Clear the bit to disable the timestamp target interrupt. This bit
3684  // clears automatically when the interrupt fires, so it only must be
3685  // disabled if you want to cancel a previously-set interrupt.
3686  //
3688 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_TIMSTCTRL_INTTRIG
Definition: hw_emac.h:754
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
void EMACTimestampTargetIntEnable ( uint32_t  ui32Base)

Enables the Ethernet system time interrupt.

Parameters
ui32Baseis the base address of the controller.

This function may be used after EMACTimestampTargetSet() to schedule an interrupt at some future time. The time reference for the function is the IEEE 1588 time as returned by EMACTimestampSysTimeGet(). To generate an interrupt when the system time exceeds a given value, call this function to set the desired time, then EMACTimestampTargetIntEnable() to enable the interrupt. When the system time increments past the target time, an Ethernet interrupt with status EMAC_INT_TIMESTAMP is generated.

Returns
None.

Definition at line 3646 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TIMSTCTRL, EMAC_TIMSTCTRL_INTTRIG, and HWREG.

3647 {
3648  //
3649  // Parameter sanity check.
3650  //
3651  ASSERT(ui32Base == EMAC0_BASE);
3652 
3653  //
3654  // Set the bit to enable the timestamp target interrupt. This bit clears
3655  // automatically when the interrupt fires after which point, you must
3656  // set a new target time and re-enable the interrupts.
3657  //
3659 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_TIMSTCTRL_INTTRIG
Definition: hw_emac.h:754
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TIMSTCTRL
Definition: hw_emac.h:104
void EMACTimestampTargetSet ( uint32_t  ui32Base,
uint32_t  ui32Seconds,
uint32_t  ui32SubSeconds 
)

Sets the target system time at which the next Ethernet timer interrupt is generated.

Parameters
ui32Baseis the base address of the controller.
ui32Secondsis the second value of the desired target time.
ui32SubSecondsis the subseconds value of the desired target time.

This function may be used to schedule an interrupt at some future time. The time reference for the function is the IEEE 1588 time as returned by EMACTimestampSysTimeGet(). To generate an interrupt when the system time exceeds a given value, call this function to set the desired time, then EMACTimestampTargetIntEnable() to enable the interrupt. When the system time increments past the target time, an Ethernet interrupt with status EMAC_INT_TIMESTAMP is generated.

The accuracy of the interrupt timing depends on the Ethernet timer update frequency and the subsecond increment value currently in use. The interrupt is generated on the first timer increment that causes the system time to be greater than or equal to the target time set.

Returns
None.

Definition at line 3606 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_TARGNANO, EMAC_O_TARGSEC, EMAC_TARGNANO_TRGTBUSY, and HWREG.

3608 {
3609  //
3610  // Parameter sanity check.
3611  //
3612  ASSERT(ui32Base == EMAC0_BASE);
3613 
3614  //
3615  // Wait for any previous write to complete.
3616  //
3617  while(HWREG(ui32Base + EMAC_O_TARGNANO) & EMAC_TARGNANO_TRGTBUSY)
3618  {
3619  }
3620 
3621  //
3622  // Write the new target time.
3623  //
3624  HWREG(ui32Base + EMAC_O_TARGSEC) = ui32Seconds;
3625  HWREG(ui32Base + EMAC_O_TARGNANO) = ui32SubSeconds;
3626 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_O_TARGNANO
Definition: hw_emac.h:117
#define EMAC_TARGNANO_TRGTBUSY
Definition: hw_emac.h:827
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_TARGSEC
Definition: hw_emac.h:116
void EMACTxDisable ( uint32_t  ui32Base)

Disables the Ethernet controller transmitter.

Parameters
ui32Baseis the base address of the controller.

When terminating operations on the Ethernet interface, this function should be called. This function disables the transmitter.

Returns
None.

Definition at line 2259 of file emac.c.

References EMAC_CFG_TE, EMAC_DMAOPMODE_ST, EMAC_O_CFG, EMAC_O_DMAOPMODE, and HWREG.

2260 {
2261  //
2262  // Disable transmission in the MAC configuration register.
2263  //
2264  HWREG(ui32Base + EMAC_O_CFG) &= ~EMAC_CFG_TE;
2265 
2266  //
2267  // Disable the MAC transmit path in the opmode register.
2268  //
2269  HWREG(ui32Base + EMAC_O_DMAOPMODE) &= ~EMAC_DMAOPMODE_ST;
2270 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_DMAOPMODE_ST
Definition: hw_emac.h:1127
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CFG_TE
Definition: hw_emac.h:197
uint8_t* EMACTxDMACurrentBufferGet ( uint32_t  ui32Base)

Returns the current DMA transmit buffer pointer.

Parameters
ui32Baseis the base address of the controller.

This function may be called to determine which buffer the transmit DMA engine is currently reading from.

Returns
Returns the transmit buffer address currently being read by the DMA engine.

Definition at line 2094 of file emac.c.

References EMAC_O_HOSTXBA, and HWREG.

2095 {
2096  //
2097  // Return the transmit buffer address currently being read by the DMA.
2098  //
2099  return((uint8_t *)HWREG(ui32Base + EMAC_O_HOSTXBA));
2100 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_HOSTXBA
Definition: hw_emac.h:146
tEMACDMADescriptor* EMACTxDMACurrentDescriptorGet ( uint32_t  ui32Base)

Returns the current DMA transmit descriptor pointer.

Parameters
ui32Baseis the base address of the controller.

This function returns a pointer to the current Ethernet transmit descriptor read by the DMA.

Returns
Returns a pointer to the start of the current transmit DMA descriptor.

Definition at line 2072 of file emac.c.

References EMAC_O_HOSTXDESC, and HWREG.

2073 {
2074  //
2075  // Return the address of the current transmit descriptor read by the DMA.
2076  //
2077  return((tEMACDMADescriptor *)HWREG(ui32Base + EMAC_O_HOSTXDESC));
2078 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_HOSTXDESC
Definition: hw_emac.h:142
A structure defining a single Ethernet DMA buffer descriptor.
Definition: emac.h:142
tEMACDMADescriptor* EMACTxDMADescriptorListGet ( uint32_t  ui32Base)

Returns a pointer to the start of the DMA transmit descriptor list.

Parameters
ui32Baseis the base address of the controller.

This function returns a pointer to the head of the Ethernet MAC's transmit DMA descriptor list. This value corresponds to the pointer originally set using a call to EMACTxDMADescriptorListSet().

Returns
Returns a pointer to the start of the DMA transmit descriptor list.

Definition at line 2050 of file emac.c.

References EMAC_O_TXDLADDR, and HWREG.

2051 {
2052  //
2053  // Return the current transmit DMA descriptor list pointer.
2054  //
2055  return((tEMACDMADescriptor *)HWREG(ui32Base + EMAC_O_TXDLADDR));
2056 }
#define EMAC_O_TXDLADDR
Definition: hw_emac.h:131
#define HWREG(x)
Definition: hw_types.h:48
A structure defining a single Ethernet DMA buffer descriptor.
Definition: emac.h:142
void EMACTxDMADescriptorListSet ( uint32_t  ui32Base,
tEMACDMADescriptor pDescriptor 
)

Sets the DMA transmit descriptor list pointer.

Parameters
ui32Baseis the base address of the controller.
pDescriptorpoints to the first DMA descriptor in the list to be passed to the transmit DMA engine.

This function sets the Ethernet MAC's transmit DMA descriptor list pointer. The pDescriptor pointer must point to one or more descriptor structures.

When multiple descriptors are provided, they can be either chained or unchained. Chained descriptors are indicated by setting the DES0_TX_CTRL_CHAINED or DES1_RX_CTRL_CHAINED bit in the relevant word of the transmit or receive descriptor. If this bit is clear, unchained descriptors are assumed.

Chained descriptors use a link pointer in each descriptor to point to the next descriptor in the chain.

Unchained descriptors are assumed to be contiguous in memory with a consistent offset between the start of one descriptor and the next. If unchained descriptors are used, the pvLink field in the descriptor becomes available to store a second buffer pointer, allowing each descriptor to point to two buffers rather than one. In this case, the ui32DescSkipSize parameter to EMACInit() must previously have been set to the number of words between the end of one descriptor and the start of the next. This value must be 0 in cases where a packed array of tEMACDMADescriptor structures is used. If the application wishes to add new state fields to the end of the descriptor structure, the skip size should be set to accommodate the newly sized structure.

Applications are responsible for initializing all descriptor fields appropriately before passing the descriptor list to the hardware.

Returns
None.

Definition at line 2022 of file emac.c.

References ASSERT, EMAC_O_TXDLADDR, and HWREG.

2023 {
2024  //
2025  // Parameter sanity check.
2026  //
2027  ASSERT(pDescriptor);
2028  ASSERT(((uint32_t)pDescriptor & 3) == 0);
2029 
2030  //
2031  // Write the supplied address to the MACTXDLADDR register.
2032  //
2033  HWREG(ui32Base + EMAC_O_TXDLADDR) = (uint32_t)pDescriptor;
2034 }
#define EMAC_O_TXDLADDR
Definition: hw_emac.h:131
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
void EMACTxDMAPollDemand ( uint32_t  ui32Base)

Orders the MAC DMA controller to attempt to acquire the next transmit descriptor.

Parameters
ui32Baseis the base address of the Ethernet controller.

This function must be called to restart the transmitter if it has been suspended due to the current transmit DMA descriptor being owned by the host. Once the application writes new values to the descriptor and marks it as being owned by the MAC DMA, this function causes the hardware to attempt to acquire the descriptor and start transmission of the new data.

Returns
None.

Definition at line 1826 of file emac.c.

References EMAC_O_TXPOLLD, and HWREG.

1827 {
1828  //
1829  // Any write to the MACTXPOLLD register causes the transmit DMA to attempt
1830  // to resume.
1831  //
1832  HWREG(ui32Base + EMAC_O_TXPOLLD) = 0;
1833 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_TXPOLLD
Definition: hw_emac.h:126
void EMACTxEnable ( uint32_t  ui32Base)

Enables the Ethernet controller transmitter.

Parameters
ui32Baseis the base address of the controller.

When starting operations on the Ethernet interface, this function should be called to enable the transmitter after all configuration has been completed.

Returns
None.

Definition at line 2233 of file emac.c.

References EMAC_CFG_TE, EMAC_DMAOPMODE_ST, EMAC_O_CFG, EMAC_O_DMAOPMODE, and HWREG.

2234 {
2235  //
2236  // Enable the MAC transmit path in the opmode register.
2237  //
2238  HWREG(ui32Base + EMAC_O_DMAOPMODE) |= EMAC_DMAOPMODE_ST;
2239 
2240  //
2241  // Enable transmission in the MAC configuration register.
2242  //
2243  HWREG(ui32Base + EMAC_O_CFG) |= EMAC_CFG_TE;
2244 }
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_CFG
Definition: hw_emac.h:48
#define EMAC_DMAOPMODE_ST
Definition: hw_emac.h:1127
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_CFG_TE
Definition: hw_emac.h:197
void EMACTxFlush ( uint32_t  ui32Base)

Flushes the Ethernet controller transmit FIFO.

Parameters
ui32Baseis the base address of the controller.

This function flushes any data currently held in the Ethernet transmit FIFO. Data that has already been passed to the MAC for transmission is transmitted, possibly resulting in a transmit underflow or runt frame transmission.

Returns
None.

Definition at line 2198 of file emac.c.

References EMAC_DMAOPMODE_FTF, EMAC_O_DMAOPMODE, EMAC_O_STATUS, EMAC_STATUS_TXFE, and HWREG.

2199 {
2200  //
2201  // Check to make sure that the FIFO is not already empty.
2202  //
2203  if(HWREG(ui32Base + EMAC_O_STATUS) & EMAC_STATUS_TXFE)
2204  {
2205  //
2206  // Flush the transmit FIFO since it is not currently empty.
2207  //
2208  HWREG(ui32Base + EMAC_O_DMAOPMODE) |= EMAC_DMAOPMODE_FTF;
2209 
2210  //
2211  // Wait for the flush to complete.
2212  //
2213  while(HWREG(ui32Base + EMAC_O_DMAOPMODE) & EMAC_DMAOPMODE_FTF)
2214  {
2215  }
2216  }
2217 }
#define EMAC_DMAOPMODE_FTF
Definition: hw_emac.h:1117
#define EMAC_O_STATUS
Definition: hw_emac.h:56
#define HWREG(x)
Definition: hw_types.h:48
#define EMAC_O_DMAOPMODE
Definition: hw_emac.h:135
#define EMAC_STATUS_TXFE
Definition: hw_emac.h:339
uint32_t EMACVLANHashFilterBitCalculate ( uint16_t  ui16Tag)

Returns the bit number to set in the VLAN hash filter corresponding to a given tag.

Parameters
ui16Tagis the VLAN tag for which the hash filter bit number is to be determined.

This function may be used to determine which bit in the VLAN hash filter to set to describe a given 12- or 16-bit VLAN tag. The returned value is a 4-bit value indicating the bit number to set within the 16-bit VLAN hash filter. For example, if 0x02 is returned, this indicates that bit 2 of the hash filter must be set to pass the supplied VLAN tag.

Returns
Returns the bit number to set in the VLAN hash filter to describe the passed tag.

Definition at line 4262 of file emac.c.

References Crc32().

4263 {
4264  uint32_t ui32CRC, ui32Mask, ui32Loop;
4265 
4266  //
4267  // Calculate the CRC for the MAC address.
4268  //
4269  ui32CRC = Crc32(0xFFFFFFFF, (uint8_t *)&ui16Tag, 2);
4270  ui32CRC ^= 0xFFFFFFFF;
4271 
4272  //
4273  // Determine the hash bit to use from the calculated CRC. This is the
4274  // top 4 bits of the reversed CRC (or the bottom 4 bits of the calculated
4275  // CRC with the bit order of those 4 bits reversed).
4276  //
4277  ui32Mask = 0;
4278 
4279  //
4280  // Reverse the order of the bottom 4 bits of the calculated CRC.
4281  //
4282  for(ui32Loop = 0; ui32Loop < 4; ui32Loop++)
4283  {
4284  ui32Mask <<= 1;
4285  ui32Mask |= (ui32CRC & 1);
4286  ui32CRC >>= 1;
4287  }
4288 
4289  //
4290  // Return the final hash filter bit index.
4291  //
4292  return(ui32Mask);
4293 }
uint32_t Crc32(uint32_t ui32Crc, const uint8_t *pui8Data, uint32_t ui32Count)
Definition: sw_crc.c:654

Here is the call graph for this function:

uint32_t EMACVLANHashFilterGet ( uint32_t  ui32Base)

Returns the current value of the hash filter used to control reception of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.

This function allows the current VLAN tag hash filter value to be returned. Additional VLAN tags may be added to this filter by setting the appropriate bits, determined by calling EMACVLANHashFilterBitCalculate(), and then calling EMACVLANHashFilterSet() to set the new filter value.

Returns
Returns the current value of the VLAN hash filter.

Definition at line 4346 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLANHASH, and HWREG.

4347 {
4348  //
4349  // Parameter sanity check.
4350  //
4351  ASSERT(ui32Base == EMAC0_BASE);
4352 
4353  //
4354  // Return the VLAN Hash Table register.
4355  //
4356  return(HWREG(ui32Base + EMAC_O_VLANHASH));
4357 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_VLANHASH
Definition: hw_emac.h:103
void EMACVLANHashFilterSet ( uint32_t  ui32Base,
uint32_t  ui32Hash 
)

Sets the hash filter used to control reception of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.
ui32Hashis the hash filter value to set.

This function allows the VLAG tag hash filter to be set. By using hash filtering, several different VLAN tags can be filtered very easily at the cost of some false positive results that must be removed by software.

The hash filter value passed in ui32Hash may be built up by calling EMACVLANHashFilterBitCalculate() for each VLAN tag that is to pass the filter and then set each of the bits for which the numbers are returned by that function. Care must be taken when clearing bits in the hash filter due to the fact that there is a many-to-one correspondence between VLAN tags and hash filter bits.

Returns
None

Definition at line 4317 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLANHASH, and HWREG.

4318 {
4319  //
4320  // Parameter sanity check.
4321  //
4322  ASSERT(ui32Base == EMAC0_BASE);
4323 
4324  //
4325  // Write the VLAN Hash Table register.
4326  //
4327  HWREG(ui32Base + EMAC_O_VLANHASH) = ui32Hash;
4328 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_VLANHASH
Definition: hw_emac.h:103
uint32_t EMACVLANRxConfigGet ( uint32_t  ui32Base,
uint16_t *  pui16Tag 
)

Returns the currently-set options related to reception of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.
pui16Tagpoints to storage which is written with the currently configured VLAN tag used for perfect filtering.

This function returns information on how the receiver is currently handling IEEE 802.1Q VLAN-tagged frames.

See also
EMACVLANRxConfigSet()
Returns
Returns flags defining how VLAN-tagged frames are handled. The value is a logical OR of the following flags:
  • EMAC_VLAN_RX_HASH_ENABLE indicates that hash filtering is enabled for VLAN tags. If this flag is absent, perfect filtering using the tag returned in *pui16Tag is performed.
  • EMAC_VLAN_RX_SVLAN_ENABLE indicates that the receiver recognizes S-VLAN (Type = 0x88A8) frames as valid VLAN-tagged frames. If absent, only frames with type 0x8100 are considered valid VLAN frames.
  • EMAC_VLAN_RX_INVERSE_MATCH indicates that the receiver passes all VLAN frames for which the tags do not match the *pui16Tag value. If this flag is absent, only tagged frames matching *pui16Tag are passed.
  • EMAC_VLAN_RX_12BIT_TAG indicates that the receiver is comparing only the bottom 12 bits of *pui16Tag when performing either perfect or hash filtering of VLAN frames. If this flag is absent, all 16 bits of the frame tag are examined when filtering. If this flag is set and *pui16Tag has all bottom 12 bits clear, the receiver passes all frames with types 0x8100 or 0x88A8 regardless of the tag values they contain.

Definition at line 4087 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLANTG, EMAC_VLANTG_VL_M, EMAC_VLANTG_VL_S, and HWREG.

4088 {
4089  uint32_t ui32Value;
4090 
4091  //
4092  // Parameter sanity check.
4093  //
4094  ASSERT(ui32Base == EMAC0_BASE);
4095  ASSERT(pui16Tag);
4096 
4097  //
4098  // Read the VLAN tag register.
4099  //
4100  ui32Value = HWREG(ui32Base + EMAC_O_VLANTG);
4101 
4102  //
4103  // Extract the VLAN tag from the register.
4104  //
4105  *pui16Tag = (ui32Value & EMAC_VLANTG_VL_M) >> EMAC_VLANTG_VL_S;
4106 
4107  //
4108  // Return the configuration flags.
4109  //
4110  return(ui32Value & ~EMAC_VLANTG_VL_M);
4111 }
#define EMAC_VLANTG_VL_M
Definition: hw_emac.h:328
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_VLANTG_VL_S
Definition: hw_emac.h:330
#define EMAC_O_VLANTG
Definition: hw_emac.h:55
#define EMAC0_BASE
Definition: hw_memmap.h:132
void EMACVLANRxConfigSet ( uint32_t  ui32Base,
uint16_t  ui16Tag,
uint32_t  ui32Config 
)

Sets options related to reception of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.
ui16Tagis the IEEE 802.1Q VLAN tag expected for incoming frames.
ui32Configdetermines how the receiver handles VLAN-tagged frames.

This function configures the receiver's handling of IEEE 802.1Q VLAN tagged frames. Incoming tagged frames are filtered using either a perfect filter or a hash filter. When hash filtering is disabled, VLAN frames tagged with the value of ui16Tag pass the filter and all others are rejected. The tag comparison may involve all 16 bits or only the 12-bit VLAN ID portion of the tag.

The ui32Config parameter is a logical OR of the following values:

  • EMAC_VLAN_RX_HASH_ENABLE enables hash filtering for VLAN tags. If this flag is absent, perfect filtering using the tag supplied in ui16Tag is performed. The hash filter may be set using EMACVLANHashFilterSet(), and EMACVLANHashFilterBitCalculate() may be used to determine which bits to set in the filter for given VLAN tags.
  • EMAC_VLAN_RX_SVLAN_ENABLE causes the receiver to recognize S-VLAN (Type = 0x88A8) frames as valid VLAN-tagged frames. If absent, only frames with type 0x8100 are considered valid VLAN frames.
  • EMAC_VLAN_RX_INVERSE_MATCH causes the receiver to pass all VLAN frames for which the tags do not match the supplied ui16Tag value. If this flag is absent, only tagged frames matching ui16Tag are passed.
  • EMAC_VLAN_RX_12BIT_TAG causes the receiver to compare only the bottom 12 bits of ui16Tag when performing either perfect or hash filtering of VLAN frames. If this flag is absent, all 16 bits of the frame tag are examined when filtering. If this flag is set and ui16Tag has all bottom 12 bits clear, the receiver passes all frames with types 0x8100 or 0x88A8 regardless of the tag values they contain.
Note
To ensure that VLAN frames that fail the tag filter are dropped by the MAC, EMACFrameFilterSet() must be called with the EMAC_FRMFILTER_VLAN flag set in the ui32FilterOpts parameter. If this flag is not set, failing VLAN packets are received by the application, but bit 10 of RDES0 (EMAC_FRMFILTER_VLAN) is clear indicating that the packet did not match the current VLAG tag filter.
See also
EMACVLANRxConfigGet()
Returns
None

Definition at line 4038 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLANTG, EMAC_VLANTG_VL_S, and HWREG.

4039 {
4040  //
4041  // Parameter sanity check.
4042  //
4043  ASSERT(ui32Base == EMAC0_BASE);
4044 
4045  //
4046  // Write the VLAN tag register.
4047  //
4048  HWREG(ui32Base + EMAC_O_VLANTG) =
4049  ui32Config | (((uint32_t)ui16Tag) << EMAC_VLANTG_VL_S);
4050 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC_VLANTG_VL_S
Definition: hw_emac.h:330
#define EMAC_O_VLANTG
Definition: hw_emac.h:55
#define EMAC0_BASE
Definition: hw_memmap.h:132
uint32_t EMACVLANTxConfigGet ( uint32_t  ui32Base,
uint16_t *  pui16Tag 
)

Returns currently-selected options related to transmission of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.
pui16Tagpoints to storage that is written with the VLAN tag currently being used for insertion or replacement.

This function returns information on the current settings related to VLAN tagging of transmitted frames.

See also
EMACVLANTxConfigSet()
Returns
Returns flags describing the current VLAN configuration relating to frame transmission. The return value is a logical OR of the following values:
  • EMAC_VLAN_TX_SVLAN indicates that the S-VLAN type (0x88A8) is being used when inserting or replacing tags in transmitted frames. If this label is absent, C-VLAN type (0x8100) is being used.
  • EMAC_VLAN_TX_USE_VLC indicates that the transmitter is processing VLAN frames according to the VLAN control (VLC) value returned here. If this tag is absent, VLAN handling is controlled by fields in the transmit descriptor.

If EMAC_VLAN_TX_USE_VLC is returned, one of the following four labels is also included to define the transmit VLAN tag handling. Note that this value may be extracted from the return value using the mask EMAC_VLAN_TX_VLC_MASK.

  • EMAC_VLAN_TX_VLC_NONE indicates that the transmitter is not performing VLAN tag insertion, deletion or replacement.
  • EMAC_VLAN_TX_VLC_DELETE indicates that the transmitter is removing VLAN tags from all transmitted frames which contain them.
  • EMAC_VLAN_TX_VLC_INSERT indicates that the transmitter is inserting a VLAN type and tag into all outgoing frames regardless of whether or not they already contain a VLAN tag.
  • EMAC_VLAN_TX_VLC_REPLACE indicates that the transmitter is replacing the VLAN tag in all transmitted frames of type 0x8100 or 0x88A8 with the value returned in *pui16Tag.

Definition at line 4216 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLNINCREP, EMAC_VLNINCREP_VLT_M, EMAC_VLNINCREP_VLT_S, and HWREG.

4217 {
4218  uint32_t ui32Value;
4219 
4220  //
4221  // Parameter sanity check.
4222  //
4223  ASSERT(ui32Base == EMAC0_BASE);
4224  ASSERT(pui16Tag);
4225 
4226  //
4227  // Read the VLAN Tag Inclusion or Replacement register.
4228  //
4229  ui32Value = HWREG(ui32Base + EMAC_O_VLNINCREP);
4230 
4231  //
4232  // Extract the tag.
4233  //
4234  *pui16Tag = (uint16_t)((ui32Value & EMAC_VLNINCREP_VLT_M) >>
4236 
4237  //
4238  // Return the configuration flags.
4239  //
4240  return(ui32Value & ~EMAC_VLNINCREP_VLT_M);
4241 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_VLNINCREP_VLT_M
Definition: hw_emac.h:716
#define EMAC_O_VLNINCREP
Definition: hw_emac.h:101
#define EMAC_VLNINCREP_VLT_S
Definition: hw_emac.h:717
void EMACVLANTxConfigSet ( uint32_t  ui32Base,
uint16_t  ui16Tag,
uint32_t  ui32Config 
)

Sets options related to transmission of VLAN-tagged frames.

Parameters
ui32Baseis the base address of the controller.
ui16Tagis the VLAN tag to be used when inserting or replacing tags in transmitted frames.
ui32Configdetermines the VLAN-related processing performed by the transmitter.

This function is used to configure transmitter options relating to IEEE 802.1Q VLAN tagging. The transmitter may be set to insert tagging into untagged frames or replace existing tags with new values.

The ui16Tag parameter contains the VLAN tag to be used in outgoing tagged frames. The ui32Config parameter is a logical OR of the following labels:

  • EMAC_VLAN_TX_SVLAN uses the S-VLAN type (0x88A8) when inserting or replacing tags in transmitted frames. If this label is absent, C-VLAN type (0x8100) is used.
  • EMAC_VLAN_TX_USE_VLC informs the transmitter that the VLAN tag handling should be defined by the VLAN control (VLC) value provided in this function call. If this tag is absent, VLAN handling is controlled by fields in the transmit descriptor.

If EMAC_VLAN_TX_USE_VLC is set, one of the following four labels must also be included to define the transmit VLAN tag handling:

  • EMAC_VLAN_TX_VLC_NONE instructs the transmitter to perform no VLAN tag insertion, deletion or replacement.
  • EMAC_VLAN_TX_VLC_DELETE instructs the transmitter to remove VLAN tags from all transmitted frames that contain them. As a result, bytes 13, 14, 15 and 16 are removed from all frames with types 0x8100 or 0x88A8.
  • EMAC_VLAN_TX_VLC_INSERT instructs the transmitter to insert a VLAN type and tag into all outgoing frames regardless of whether or not they already contain a VLAN tag.
  • EMAC_VLAN_TX_VLC_REPLACE instructs the transmitter to replace the VLAN tag in all frames of type 0x8100 or 0x88A8 with the value provided to this function in the ui16Tag parameter.
Returns
None

Definition at line 4158 of file emac.c.

References ASSERT, EMAC0_BASE, EMAC_O_VLNINCREP, EMAC_VLNINCREP_VLT_S, and HWREG.

4159 {
4160  //
4161  // Parameter sanity check.
4162  //
4163  ASSERT(ui32Base == EMAC0_BASE);
4164 
4165  //
4166  // Write the VLAN Tag Inclusion or Replacement register.
4167  //
4168  HWREG(ui32Base + EMAC_O_VLNINCREP) =
4169  ui32Config | ((uint32_t)ui16Tag << EMAC_VLNINCREP_VLT_S);
4170 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define EMAC0_BASE
Definition: hw_memmap.h:132
#define EMAC_O_VLNINCREP
Definition: hw_emac.h:101
#define EMAC_VLNINCREP_VLT_S
Definition: hw_emac.h:717

Variable Documentation

const { ... } g_pi16MIIClockDiv[]
Initial value:
=
{
{ 64000000, 0x0000000C },
{ 104000000, 0x00000000 },
{ 150000000, 0x00000004 }
}

Referenced by EMACInit().

uint32_t { ... } ui32Divisor

Definition at line 193 of file emac.c.

uint32_t { ... } ui32SysClockMax

Definition at line 192 of file emac.c.