diff options
| author | [email protected] <[email protected]> | 2011-08-23 14:48:10 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2011-08-23 14:48:10 +0000 |
| commit | da74af2347cfee577b202cf4e26c1af16c05f5b6 (patch) | |
| tree | 517b77d8357a0bd2be0b886bf4a81fd9acfc9321 /bsp | |
| parent | 1f1c6fb47e603039f81e2d94666a655603bdbb07 (diff) | |
AT91SAM9260 branch
1. Support Keil MDK development environment
2. Modify EMAC driver according to the changes of lwIP API in reversion 1668 and 1669
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1681 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp')
| -rwxr-xr-x | bsp/at91sam9260/application.c | 13 | ||||
| -rwxr-xr-x | bsp/at91sam9260/macb.c | 31 | ||||
| -rwxr-xr-x | bsp/at91sam9260/macb.h | 1 | ||||
| -rw-r--r-- | bsp/at91sam9260/mii.h | 2 | ||||
| -rwxr-xr-x | bsp/at91sam9260/startup.c | 13 |
5 files changed, 41 insertions, 19 deletions
diff --git a/bsp/at91sam9260/application.c b/bsp/at91sam9260/application.c index 9b229f57b3..97c413b45e 100755 --- a/bsp/at91sam9260/application.c +++ b/bsp/at91sam9260/application.c @@ -32,6 +32,16 @@ #endif
#endif
+#if defined(RT_USING_DFS_DEVFS)
+#include <devfs.h>
+#endif
+
+#ifdef RT_USING_LWIP
+#include <netif/ethernetif.h>
+#include <arch/sys_arch_init.h>
+#include "macb.h"
+#endif
+
#ifdef RT_USING_LED
#include "led.h"
#endif
@@ -90,6 +100,7 @@ void rt_init_thread_entry(void* parameter) rt_kprintf("UFFS File System initialzation failed!\n");
}
#endif
+
}
#endif
@@ -98,8 +109,6 @@ void rt_init_thread_entry(void* parameter) /* register ethernetif device */
eth_system_device_init();
rt_hw_macb_init();
- /* re-init device driver */
- rt_device_init_all();
/* init lwip system */
lwip_sys_init();
rt_kprintf("TCP/IP initialized!\n");
diff --git a/bsp/at91sam9260/macb.c b/bsp/at91sam9260/macb.c index 898a21d0d5..e29a504377 100755 --- a/bsp/at91sam9260/macb.c +++ b/bsp/at91sam9260/macb.c @@ -68,7 +68,7 @@ struct rt_macb_eth /* inherit from ethernet device */ struct eth_device parent; - void *regs; + unsigned int regs; unsigned int rx_tail; unsigned int tx_head; @@ -213,9 +213,9 @@ static rt_uint16_t macb_mdio_read(struct rt_macb_eth *macb, rt_uint8_t reg) static void macb_phy_reset(rt_device_t dev) { - struct rt_macb_eth *macb = dev->user_data;; int i; rt_uint16_t status, adv; + struct rt_macb_eth *macb = dev->user_data;; adv = ADVERTISE_CSMA | ADVERTISE_ALL; macb_mdio_write(macb, MII_ADVERTISE, adv); @@ -322,13 +322,15 @@ void macb_update_link(struct rt_macb_eth *macb) ? 100 : 10); macb->duplex = (media & ADVERTISE_FULL) ? 1 : 0; rt_kprintf("%s: link up (%dMbps/%s-duplex)\n", - dev->parent.name, macb->speed, - DUPLEX_FULL == macb->duplex ? "Full":"Half"); - netif_set_link_up(macb->parent.netif); + dev->parent.name, macb->speed, + DUPLEX_FULL == macb->duplex ? "Full":"Half"); + macb->parent.link_status = 1; } else { rt_kprintf("%s: link down\n", dev->parent.name); - netif_set_link_down(macb->parent.netif); + macb->parent.link_status = 0; } + + eth_device_linkchange(&macb->parent, RT_TRUE); } } @@ -458,13 +460,11 @@ static rt_err_t rt_macb_control(rt_device_t dev, rt_uint8_t cmd, void *args) /* transmit packet. */ rt_err_t rt_macb_tx( rt_device_t dev, struct pbuf* p) { - struct rt_macb_eth *macb = dev->user_data; struct pbuf* q; - rt_uint32_t len; rt_uint8_t* bufptr, *buf = RT_NULL; - unsigned long paddr, ctrl; + unsigned long ctrl; + struct rt_macb_eth *macb = dev->user_data; unsigned int tx_head = macb->tx_head; - int i; /* lock macb device */ rt_sem_take(&sem_lock, RT_WAITING_FOREVER); @@ -500,7 +500,6 @@ rt_err_t rt_macb_tx( rt_device_t dev, struct pbuf* p) /* wait ack */ rt_sem_take(&sem_ack, RT_WAITING_FOREVER); rt_free(buf); - buf == RT_NULL; return RT_EOK; } @@ -555,7 +554,7 @@ struct pbuf *rt_macb_rx(rt_device_t dev) } if (status & RXBUF_FRAME_END) { - buffer = macb->rx_buffer + 128 * macb->rx_tail; + buffer = (void *)((unsigned int)macb->rx_buffer + 128 * macb->rx_tail); len = status & RXBUF_FRMLEN_MASK; p = pbuf_alloc(PBUF_LINK, len, PBUF_RAM); if (!p) @@ -579,14 +578,14 @@ struct pbuf *rt_macb_rx(rt_device_t dev) taillen = len - headlen; memcpy((void *)buf, buffer, headlen); - memcpy((void *)buf + headlen, + memcpy((void *)((unsigned int)buf + headlen), macb->rx_buffer, taillen); buffer = (void *)buf; for (q = p; q != RT_NULL; q= q->next) { /* read data from device */ memcpy((void *)q->payload, buffer, q->len); - buffer += q->len; + buffer = (void *)((unsigned int)buffer + q->len); } rt_free(buf); buf = RT_NULL; @@ -595,7 +594,7 @@ struct pbuf *rt_macb_rx(rt_device_t dev) { /* read data from device */ memcpy((void *)q->payload, buffer, q->len); - buffer += q->len; + buffer = (void *)((unsigned int)buffer + q->len); } } @@ -643,7 +642,7 @@ void macb_initialize() macb->rx_ring_dma = (unsigned long)macb->rx_ring; macb->tx_ring_dma = (unsigned long)macb->tx_ring; - macb->regs = (void *)AT91SAM9260_BASE_EMAC; + macb->regs = AT91SAM9260_BASE_EMAC; macb->phy_addr = 0x00; /* diff --git a/bsp/at91sam9260/macb.h b/bsp/at91sam9260/macb.h index 3b84bfa150..8d5950e78e 100755 --- a/bsp/at91sam9260/macb.h +++ b/bsp/at91sam9260/macb.h @@ -330,6 +330,7 @@ struct dma_desc { #define MACB_TX_USED_OFFSET 31 #define MACB_TX_USED_SIZE 1 +void rt_hw_macb_init(); #endif /* _MACB_H */ diff --git a/bsp/at91sam9260/mii.h b/bsp/at91sam9260/mii.h index 50a02f1e17..8c932039eb 100644 --- a/bsp/at91sam9260/mii.h +++ b/bsp/at91sam9260/mii.h @@ -158,7 +158,7 @@ * 100T4 this is fine. If your phy places 100T4 elsewhere in the * priority order, you will need to roll your own function. */ -static inline unsigned int mii_nway_result (unsigned int negotiated) +rt_inline unsigned int mii_nway_result (unsigned int negotiated) { unsigned int ret; diff --git a/bsp/at91sam9260/startup.c b/bsp/at91sam9260/startup.c index d7382f5e7c..3e3d85cd2e 100755 --- a/bsp/at91sam9260/startup.c +++ b/bsp/at91sam9260/startup.c @@ -20,12 +20,17 @@ #include <finsh.h> #endif +#ifdef RT_USING_DEVICE +#include <serial.h> +#endif + extern void rt_hw_interrupt_init(void); extern void rt_hw_board_init(void); extern void rt_serial_init(void); extern void rt_system_timer_init(void); extern void rt_system_scheduler_init(void); extern void rt_thread_idle_init(void); +extern void mmu_invalidate_icache(); extern void rt_hw_cpu_icache_enable(void); extern void rt_show_version(void); extern void rt_system_heap_init(void*, void*); @@ -174,4 +179,12 @@ void rtthread_startup(void) return ; } +int main(void) +{ + /* startup RT-Thread RTOS */ + rtthread_startup(); + + return 0; +} + /*@}*/ |
