diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-09-27 18:48:47 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-09-27 18:48:47 +0000 |
commit | c9bfcaa15ec3d03ee088ecfa5cf6cf82e718cb38 (patch) | |
tree | 0bcfd6b978bb7004587ce6f70ad17ed95bda13b8 /demos | |
parent | ee0d07151a144a8425d8cfd0740098d1b76711c2 (diff) | |
download | ChibiOS-c9bfcaa15ec3d03ee088ecfa5cf6cf82e718cb38.tar.gz ChibiOS-c9bfcaa15ec3d03ee088ecfa5cf6cf82e718cb38.tar.bz2 ChibiOS-c9bfcaa15ec3d03ee088ecfa5cf6cf82e718cb38.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1192 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
-rw-r--r-- | demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c | 130 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/Makefile | 6 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/board.c | 6 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/main.c | 2 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c | 32 |
5 files changed, 84 insertions, 92 deletions
diff --git a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c index 5716f6e58..ccd7bd67f 100644 --- a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c +++ b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c @@ -1,55 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -/* - **** This file incorporates work covered by the following copyright and **** - **** permission notice: **** - - Copyright (c) 2001-2004 Swedish Institute of Computer Science. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - OF SUCH DAMAGE. - - This file is part of the lwIP TCP/IP stack. - - Author: Adam Dunkels <adam@sics.se> -*/ - /** * @file * Ethernet Interface Skeleton @@ -57,6 +5,38 @@ */ /* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels <adam@sics.se> + * + */ + +/* * This file is a skeleton for developing Ethernet network interface * drivers for lwIP. Add code to the low_level functions and do a * search-and-replace for the word "ethernetif" to replace it with @@ -65,7 +45,7 @@ #include "lwip/opt.h" -#if 1 /* don't build, this is only a skeleton, see previous comment */ +#if 0 /* don't build, this is only a skeleton, see previous comment */ #include "lwip/def.h" #include "lwip/mem.h" @@ -105,23 +85,23 @@ static void low_level_init(struct netif *netif) { struct ethernetif *ethernetif = netif->state; - + /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ -////////// netif->hwaddr[0] = ; -////////// ... -////////// netif->hwaddr[5] = ; + netif->hwaddr[0] = ; + ... + netif->hwaddr[5] = ; /* maximum transfer unit */ netif->mtu = 1500; - + /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; - - /* Do whatever else is needed to initialize interface. */ + + /* Do whatever else is needed to initialize interface. */ } /** @@ -146,8 +126,8 @@ low_level_output(struct netif *netif, struct pbuf *p) struct ethernetif *ethernetif = netif->state; struct pbuf *q; -////////// initiate transfer(); - + initiate transfer(); + #if ETH_PAD_SIZE pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ #endif @@ -156,15 +136,15 @@ low_level_output(struct netif *netif, struct pbuf *p) /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len variable. */ -////////// send data from(q->payload, q->len); + send data from(q->payload, q->len); } -////////// signal that packet should be sent(); + signal that packet should be sent(); #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif - + LINK_STATS_INC(link.xmit); return ERR_OK; @@ -187,7 +167,7 @@ low_level_input(struct netif *netif) /* Obtain the size of the packet and put it into the "len" variable. */ -////////// len = ; + len = ; #if ETH_PAD_SIZE len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ @@ -195,7 +175,7 @@ low_level_input(struct netif *netif) /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); - + if (p != NULL) { #if ETH_PAD_SIZE @@ -208,9 +188,9 @@ low_level_input(struct netif *netif) /* Read enough bytes to fill this pbuf in the chain. The * available data in the pbuf is given by the q->len * variable. */ -////////// read data into(q->payload, q->len); + read data into(q->payload, q->len); } -////////// acknowledge that packet has been read(); + acknowledge that packet has been read(); #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ @@ -218,12 +198,12 @@ low_level_input(struct netif *netif) LINK_STATS_INC(link.recv); } else { -////////// drop packet(); + drop packet(); LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.drop); } - return p; + return p; } /** @@ -293,7 +273,7 @@ ethernetif_init(struct netif *netif) struct ethernetif *ethernetif; LWIP_ASSERT("netif != NULL", (netif != NULL)); - + ethernetif = mem_malloc(sizeof(struct ethernetif)); if (ethernetif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n")); @@ -310,7 +290,7 @@ ethernetif_init(struct netif *netif) * The last argument should be replaced with your link speed, in units * of bits per second. */ - NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, ???); + NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS); netif->state = ethernetif; netif->name[0] = IFNAME0; @@ -321,9 +301,9 @@ ethernetif_init(struct netif *netif) * is available...) */ netif->output = etharp_output; netif->linkoutput = low_level_output; - + ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); - + /* initialize the hardware */ low_level_init(netif); diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile index 9538d20d5..bb4c21c1a 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile @@ -65,13 +65,17 @@ CSRC = ${PORTSRC} \ ${USRC} \
${CHIBIOS}/os/io/pal.c \
${CHIBIOS}/os/io/serial.c \
+ ${CHIBIOS}/os/io/phy.c \
+ ${CHIBIOS}/os/io/mac.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/pal_lld.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/serial_lld.c \
- ${CHIBIOS}/os/io/platforms/AT91SAM7X/sam7x_emac.c \
+ ${CHIBIOS}/os/io/platforms/AT91SAM7X/phy_lld.c \
+ ${CHIBIOS}/os/io/platforms/AT91SAM7X/mac_lld.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/at91lib/aic.c \
${CHIBIOS}/os/various/evtimer.c \
web/webthread.c \
board.c main.c
+# ${CHIBIOS}/os/io/platforms/AT91SAM7X/sam7x_emac.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c index e57f8bcdc..39136b03e 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c @@ -20,7 +20,8 @@ #include <ch.h>
#include <pal.h>
#include <serial.h>
-#include <sam7x_emac.h>
+#include <mac.h>
+//#include <sam7x_emac.h>
#include "board.h"
#include "at91lib/aic.h"
@@ -178,7 +179,8 @@ void hwinit1(void) { /*
* EMAC driver initialization.
*/
- emac_init(AT91C_AIC_PRIOR_HIGHEST - 3);
+// emac_init(AT91C_AIC_PRIOR_HIGHEST - 3);
+ macInit();
/*
* ChibiOS/RT initialization.
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c index adfba225f..e2d3e8cd8 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c @@ -28,7 +28,7 @@ #include "web/webthread.h"
static WORKING_AREA(waWebThread, 512);
-static WORKING_AREA(waThread1, 64);
+static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c b/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c index d064e1ef3..521a40b04 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c @@ -21,7 +21,7 @@ #include <ch.h>
#include <evtimer.h>
-#include <sam7x_emac.h>
+#include <mac.h>
#include <uip.h>
#include <uip_arp.h>
@@ -47,11 +47,11 @@ static const struct uip_eth_addr macaddr = { */
static void network_device_send(void) {
int i;
- BufDescriptorEntry *bdep;
+ MACTransmitDescriptor *tdp;
for (i = 0; i < SEND_RETRY_MAX; i++) {
- if ((bdep = EMACGetTransmitBuffer()) != NULL) {
- uint8_t *bp = (uint8_t *)bdep->w1;
+ if ((tdp = macWaitTransmitDescriptor(&MAC1, uip_len, TIME_IMMEDIATE)) != NULL) {
+ uint8_t *bp = macGetTransmitBuffer(tdp);
if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN)
memcpy(bp, &uip_buf[0], uip_len);
@@ -61,7 +61,7 @@ static void network_device_send(void) { uip_appdata,
uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN));
}
- EMACTransmit(bdep, uip_len);
+ macReleaseTransmitDescriptor(&MAC1, tdp);
return;
}
chThdSleep(SEND_RETRY_INTERVAL);
@@ -73,10 +73,16 @@ static void network_device_send(void) { * uIP receive function wrapping the EMAC function.
*/
static size_t network_device_read(void) {
- size_t size = UIP_CONF_BUFFER_SIZE;
- if (EMACReceive(uip_buf, &size))
- return size;
- return 0;
+ MACReceiveDescriptor *rdp;
+ size_t size;
+ uint8_t *bp;
+
+ if ((rdp = macWaitReceiveDescriptor(&MAC1, &size, TIME_IMMEDIATE)) == NULL)
+ return 0;
+ bp = macGetReceiveBuffer(rdp);
+ memcpy(&uip_buf[0], bp, size);
+ macReleaseReceiveDescriptor(&MAC1, rdp);
+ return size;
}
void clock_init(void) {}
@@ -107,7 +113,7 @@ static void PeriodicTimerHandler(eventid_t id) { static void ARPTimerHandler(eventid_t id) {
uip_arp_timer();
- (void)EMACGetLinkStatus();
+ (void)macPollLinkStatus(&MAC1);
}
/*
@@ -150,7 +156,7 @@ msg_t WebThread(void *p) { /*
* Event sources setup.
*/
- chEvtRegister(&EMACFrameReceived, &el0, FRAME_RECEIVED_ID);
+ chEvtRegister(macGetReceiveEventSource(&MAC1), &el0, FRAME_RECEIVED_ID);
chEvtPend(EVENT_MASK(FRAME_RECEIVED_ID)); /* In case some frames are already buffered */
evtInit(&evt1, MS2ST(500));
@@ -164,8 +170,8 @@ msg_t WebThread(void *p) { /*
* EMAC settings.
*/
- EMACSetAddress(&macaddr.addr[0]);
- (void)EMACGetLinkStatus();
+ macSetAddress(&MAC1, &macaddr.addr[0]);
+ (void)macPollLinkStatus(&MAC1);
/*
* uIP initialization.
|