Atmel Software Framework

macb_example.c File Reference
#include <stdio.h>
#include <string.h>
#include <avr32/io.h>
#include "print_funcs.h"
#include "usart.h"
#include "board.h"
#include "macb.h"
#include "gpio.h"
#include "compiler.h"
#include "conf_eth.h"
#include "flashc.h"
#include "intc.h"
#include "power_clocks_lib.h"

Macros

#define MACB_EXAMPLE_CPU_HZ   60000000
 
#define MACB_EXAMPLE_PBA_HZ   60000000
 
#define SEQ_NUM_START   0x2546
 

Functions

static unsigned short in_cksum (unsigned short *addr, int len)
 Checksum routine for Internet Protocol family headers. More...
 
static void macb_example_receive_packet (macb_packet_t *pkt)
 callback to manage packets reception More...
 
static void macb_example_send_ARP_request (void)
 Send an ARP request to host. More...
 
static void macb_example_send_ping_response (macb_packet_t *pkt)
 function to send PING response to pkt->data->host More...
 
int main (void)
 main function : do init and loop (poll if configured so) More...
 

Variables

const unsigned char ARP_FRAME [42]
 
unsigned char data [ETHERNET_CONF_TX_BUFFER_SIZE]
 
unsigned char hwaddr [6] = { ETHERNET_CONF_ETHADDR0,ETHERNET_CONF_ETHADDR1,ETHERNET_CONF_ETHADDR2,ETHERNET_CONF_ETHADDR3,ETHERNET_CONF_ETHADDR4,ETHERNET_CONF_ETHADDR5 }
 
const unsigned char local_ipaddr [4] = {ETHERNET_CONF_IPADDR0,ETHERNET_CONF_IPADDR1,ETHERNET_CONF_IPADDR2,ETHERNET_CONF_IPADDR3}
 
unsigned short seqnum = SEQ_NUM_START
 

#define MACB_EXAMPLE_CPU_HZ   60000000

Referenced by main().

#define MACB_EXAMPLE_PBA_HZ   60000000

Referenced by main().

#define SEQ_NUM_START   0x2546

initial sequence number for ICMP request and reply

Referenced by macb_example_send_ping_response().

static unsigned short in_cksum ( unsigned short *  addr,
int  len 
)
static

Checksum routine for Internet Protocol family headers.

Parameters
addraddress of data to compute checksum
lenlength of data to compute checksum
Returns
unsigned short checksum computed

References w.

Referenced by macb_example_send_ping_response().

static void macb_example_receive_packet ( macb_packet_t pkt)
static

callback to manage packets reception

Parameters
pktpacket to manage

References macb_packet_t::data, hwaddr, macb_packet_t::len, lMACBSend(), local_ipaddr, macb_example_send_ping_response(), and print_dbg().

Referenced by main().

static void macb_example_send_ARP_request ( void  )
static

Send an ARP request to host.

References ARP_FRAME, data, macb_packet_t::data, macb_packet_t::len, lMACBSend(), and print_dbg().

Referenced by main().

static void macb_example_send_ping_response ( macb_packet_t pkt)
static

function to send PING response to pkt->data->host

Parameters
pktpacket to manage

References macb_packet_t::data, hwaddr, in_cksum(), macb_packet_t::len, lMACBSend(), LSB, MSB, SEQ_NUM_START, and seqnum.

Referenced by macb_example_receive_packet().

const unsigned char ARP_FRAME[42]
Initial value:
= {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x08,0x06,0x00,0x01,0x08,0x00,0x06,0x04,0x00,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,
}
#define ETHERNET_CONF_ETHADDR3
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:87
#define ETHERNET_CONF_GATEWAY_ADDR0
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:102
#define ETHERNET_CONF_ETHADDR2
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:86
#define ETHERNET_CONF_IPADDR0
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:94
#define ETHERNET_CONF_ETHADDR5
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:89
#define ETHERNET_CONF_GATEWAY_ADDR1
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:103
#define ETHERNET_CONF_GATEWAY_ADDR2
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:104
#define ETHERNET_CONF_GATEWAY_ADDR3
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:105
#define ETHERNET_CONF_ETHADDR1
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:85
#define ETHERNET_CONF_ETHADDR0
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:84
#define ETHERNET_CONF_IPADDR1
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:95
#define ETHERNET_CONF_IPADDR2
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:96
#define ETHERNET_CONF_IPADDR3
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:97
#define ETHERNET_CONF_ETHADDR4
Definition: thirdparty/hd/example/ports/avr32/conf/conf_eth.h:88

define the ARP global frame

Referenced by macb_example_send_ARP_request().

unsigned char data[ETHERNET_CONF_TX_BUFFER_SIZE]

buffer for sending packets

buffer for sending packets

Referenced by macb_example_receive_packet().

unsigned short seqnum = SEQ_NUM_START

sequence number for ICMP request and reply

Referenced by macb_example_send_ping_response().