Microchip® Advanced 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_GATEWAY_ADDR3
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:93
#define ETHERNET_CONF_IPADDR1
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:85
#define ETHERNET_CONF_GATEWAY_ADDR0
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:90
#define ETHERNET_CONF_GATEWAY_ADDR1
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:91
#define ETHERNET_CONF_GATEWAY_ADDR2
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:92
#define ETHERNET_CONF_IPADDR3
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:87
#define ETHERNET_CONF_ETHADDR3
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:79
#define ETHERNET_CONF_IPADDR0
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:84
#define ETHERNET_CONF_ETHADDR1
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:77
#define ETHERNET_CONF_ETHADDR2
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:78
#define ETHERNET_CONF_ETHADDR0
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:76
#define ETHERNET_CONF_ETHADDR5
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:81
#define ETHERNET_CONF_IPADDR2
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:86
#define ETHERNET_CONF_ETHADDR4
Definition: avr32/applications/evk1100-control-panel/conf_eth.h:80

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().