/*
 * network-device.c
 *
 *  Created on: Jan 29, 2012
 *      Author: RomanM
 */

#define UIP_DRIPADDR0   192
#define UIP_DRIPADDR1   168
#define UIP_DRIPADDR2   0
#define UIP_DRIPADDR3   1

#include "../uip.h"
#include "../uip_arp.h"
#include "network-device.h"
#include "drivers/Enc424j600/Enc424j600.h"

void network_device_init(void) {
	Enc424j600_Init();
	Enc424j600_ReadMacAddress((uint8_t*)(&uip_ethaddr));
}

unsigned char network_device_linked(void) {
	return Enc424j600_IsLinked();
}

unsigned int network_device_read(void) {
	uint16_t len = 0;
	len = Enc424j600_ReceivePacket(uip_buf);
	return len;
}

void network_device_send(void) {
	Enc424j600_SendPacket(uip_buf, uip_len);
}
