EMAC example for SAM.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
Functions | |
static void | configure_console (void) |
Configure UART console. More... | |
static void | emac_display_ip_packet (p_ip_header_t p_ip_header, uint32_t ul_size) |
Display the IP packet. More... | |
void | EMAC_Handler (void) |
EMAC interrupt handler. More... | |
static uint16_t | emac_icmp_checksum (uint16_t *p_buff, uint32_t ul_len) |
Process & return the ICMP checksum. More... | |
static void | emac_process_arp_packet (uint8_t *p_uc_data, uint32_t ul_size) |
Process the received ARP packet; change address and send it back. More... | |
static void | emac_process_eth_packet (uint8_t *p_uc_data, uint32_t ul_size) |
Process the received EMAC packet. More... | |
static void | emac_process_ip_packet (uint8_t *p_uc_data, uint32_t ul_size) |
Process the received IP packet; change address and send it back. More... | |
int | main (void) |
EMAC example entry point. More... | |
Variables | |
static emac_device_t | gs_emac_dev |
The EMAC driver instance. More... | |
static volatile uint8_t | gs_uc_eth_buffer [EMAC_FRAME_LENTGH_MAX] |
Buffer for ethernet packets. More... | |
static uint8_t | gs_uc_ip_address [] |
The IP address used for test (ping ...) More... | |
static uint8_t | gs_uc_mac_address [] |
The MAC address used for the test. More... | |
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
|
static |
Configure UART console.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Display the IP packet.
p_ip_header | Pointer to the IP header. |
ul_size | The data size. |
References _IPheader::ip_dst, _IPheader::ip_hl_v, _IPheader::ip_id, _IPheader::ip_len, _IPheader::ip_p, IP_PROT_ICMP, IP_PROT_IP, IP_PROT_TCP, IP_PROT_UDP, _IPheader::ip_src, _IPheader::ip_sum, and _IPheader::ip_tos.
Referenced by emac_process_eth_packet().
void EMAC_Handler | ( | void | ) |
EMAC interrupt handler.
References emac_handler().
|
static |
Process & return the ICMP checksum.
p_buff | Pointer to the buffer. |
ul_len | The length of the buffered data. |
References SWAP16.
Referenced by emac_process_ip_packet().
|
static |
Process the received ARP packet; change address and send it back.
p_uc_data | The data to process. |
ul_size | The data size. |
References arp_header::ar_op, arp_header::ar_sha, arp_header::ar_spa, arp_header::ar_tha, arp_header::ar_tpa, ARP_REPLY, ARP_REQUEST, emac_dev_write(), EMAC_OK, ethernet_header::et_dest, ethernet_header::et_src, ETH_HEADER_SIZE, NULL, and SWAP16.
Referenced by emac_process_eth_packet().
|
static |
Process the received EMAC packet.
p_uc_data | The data to process. |
ul_size | The data size. |
References emac_display_ip_packet(), emac_process_arp_packet(), emac_process_ip_packet(), ethernet_header::et_protlen, ETH_HEADER_SIZE, ETH_PROT_ARP, ETH_PROT_IP, and SWAP16.
Referenced by main().
|
static |
Process the received IP packet; change address and send it back.
p_uc_data | The data to process. |
ul_size | The data size. |
References icmp_echo_header::cksum, icmp_echo_header::code, emac_dev_write(), emac_icmp_checksum(), EMAC_OK, ethernet_header::et_dest, ethernet_header::et_src, ETH_HEADER_SIZE, ETH_IP_HEADER_SIZE, ICMP_ECHO_REPLY, ICMP_ECHO_REQUEST, _IPheader::ip_dst, _IPheader::ip_len, _IPheader::ip_p, IP_PROT_ICMP, _IPheader::ip_src, NULL, SWAP16, icmp_echo_header::type, and UNUSED.
Referenced by emac_process_eth_packet().
int main | ( | void | ) |
EMAC example entry point.
References board_init(), configure_console(), emac_dev_init(), emac_dev_read(), EMAC_OK, emac_process_eth_packet(), ethernet_phy_auto_negotiate(), ethernet_phy_init(), ethernet_phy_set_link(), emac_device::p_hw, pmc_enable_periph_clk(), rstc_get_status(), rstc_reset_extern(), rstc_set_external_reset(), STRING_HEADER, sysclk_get_cpu_hz(), sysclk_init(), emac_options::uc_copy_all_frame, emac_options::uc_mac_addr, and emac_options::uc_no_boardcast.
|
static |
The EMAC driver instance.
|
static |
Buffer for ethernet packets.
|
static |
The IP address used for test (ping ...)
|
static |
The MAC address used for the test.