GMAC example for SAM.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
Functions | |
static void | at24mac_get_mac_address (void) |
static void | configure_console (void) |
Configure UART console. More... | |
static void | gmac_display_ip_packet (p_ip_header_t p_ip_header, uint32_t ul_size) |
Display the IP packet. More... | |
void | GMAC_Handler (void) |
GMAC interrupt handler. More... | |
static uint16_t | gmac_icmp_checksum (uint16_t *p_buff, uint32_t ul_len) |
Process & return the ICMP checksum. More... | |
static void | gmac_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 | gmac_process_eth_packet (uint8_t *p_uc_data, uint32_t ul_size) |
Process the received GMAC packet. More... | |
static void | gmac_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) |
GMAC example entry point. More... | |
Variables | |
static gmac_device_t | gs_gmac_dev |
The GMAC driver instance. More... | |
static volatile uint8_t | gs_uc_eth_buffer [GMAC_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 |
References twihs_packet::addr, twihs_packet::addr_length, BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_PAGE_SIZE, BOARD_AT24MAC_TWIHS, BOARD_AT24MAC_TWIHS_CLK, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_options::master_clk, pmc_enable_periph_clk(), twihs_options::speed, sysclk_get_cpu_hz(), twihs_master_init(), and twihs_master_read().
Referenced by main().
|
static |
Configure UART console.
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, CONSOLE_UART_ID, 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 gmac_process_eth_packet().
void GMAC_Handler | ( | void | ) |
GMAC interrupt handler.
References gmac_handler(), and GMAC_QUE_0.
|
static |
Process & return the ICMP checksum.
p_buff | Pointer to the buffer. |
ul_len | The length of the buffered data. |
References SWAP16.
Referenced by gmac_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, ethernet_header::et_dest, ethernet_header::et_src, ETH_HEADER_SIZE, gmac_dev_write(), GMAC_OK, GMAC_QUE_0, and SWAP16.
Referenced by gmac_process_eth_packet().
|
static |
Process the received GMAC packet.
p_uc_data | The data to process. |
ul_size | The data size. |
References ethernet_header::et_protlen, ETH_HEADER_SIZE, ETH_PROT_ARP, ETH_PROT_IP, gmac_display_ip_packet(), gmac_process_arp_packet(), gmac_process_ip_packet(), 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, ethernet_header::et_dest, ethernet_header::et_src, ETH_HEADER_SIZE, ETH_IP_HEADER_SIZE, gmac_dev_write(), gmac_icmp_checksum(), GMAC_OK, GMAC_QUE_0, ICMP_ECHO_REPLY, ICMP_ECHO_REQUEST, _IPheader::ip_dst, _IPheader::ip_len, _IPheader::ip_p, IP_PROT_ICMP, _IPheader::ip_src, SWAP16, icmp_echo_header::type, and UNUSED.
Referenced by gmac_process_eth_packet().
int main | ( | void | ) |
GMAC example entry point.
References at24mac_get_mac_address(), BOARD_GMAC_PHY_ADDR, board_init(), configure_console(), ethernet_phy_auto_negotiate(), ethernet_phy_init(), ethernet_phy_set_link(), gmac_dev_init(), gmac_dev_read(), GMAC_OK, gmac_process_eth_packet(), GMAC_QUE_0, gmac_device::p_hw, pmc_enable_periph_clk(), STRING_HEADER, sysclk_get_cpu_hz(), sysclk_init(), gmac_options::uc_copy_all_frame, gmac_options::uc_mac_addr, and gmac_options::uc_no_boardcast.
|
static |
The GMAC driver instance.
|
static |
Buffer for ethernet packets.
|
static |
The IP address used for test (ping ...)
|
static |
The MAC address used for the test.