summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbsp/at91sam9260/SConscript30
-rw-r--r--bsp/at91sam9260/applications/SConscript11
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/applications/application.c (renamed from bsp/at91sam9260/application.c)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/applications/startup.c (renamed from bsp/at91sam9260/startup.c)73
-rwxr-xr-xbsp/at91sam9260/board.c351
-rwxr-xr-xbsp/at91sam9260/board.h24
-rwxr-xr-xbsp/at91sam9260/console.c180
-rw-r--r--bsp/at91sam9260/drivers/SConscript31
-rw-r--r--bsp/at91sam9260/drivers/at91_i2c_gpio.c (renamed from bsp/at91sam9260/at91_i2c_gpio.c)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/drivers/at91_mci.c (renamed from bsp/at91sam9260/at91_mci.c)16
-rw-r--r--bsp/at91sam9260/drivers/at91_mci.h (renamed from bsp/at91sam9260/at91_mci.h)16
-rw-r--r--bsp/at91sam9260/drivers/board.c161
-rw-r--r--bsp/at91sam9260/drivers/board.h32
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/drivers/led.c (renamed from bsp/at91sam9260/led.c)16
-rw-r--r--bsp/at91sam9260/drivers/led.h32
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/drivers/macb.c (renamed from bsp/at91sam9260/macb.c)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/drivers/macb.h (renamed from bsp/at91sam9260/macb.h)16
-rw-r--r--bsp/at91sam9260/drivers/mii.h (renamed from bsp/at91sam9260/mii.h)16
-rw-r--r--bsp/at91sam9260/drivers/usart.c438
-rwxr-xr-xbsp/at91sam9260/led.h8
-rw-r--r--bsp/at91sam9260/platform/SConscript26
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_aic.h (renamed from libcpu/arm/at91sam926x/at91_aic.h)16
-rw-r--r--bsp/at91sam9260/platform/at91_pdc.h45
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_pio.h (renamed from libcpu/arm/at91sam926x/at91_pio.h)17
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_pit.h (renamed from libcpu/arm/at91sam926x/at91_pit.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_pmc.h (renamed from libcpu/arm/at91sam926x/at91_pmc.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_rstc.h (renamed from libcpu/arm/at91sam926x/at91_rstc.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_serial.h (renamed from libcpu/arm/at91sam926x/at91_serial.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_shdwc.h (renamed from libcpu/arm/at91sam926x/at91_shdwc.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91_tc.h (renamed from libcpu/arm/at91sam926x/at91_tc.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91sam9260_matrix.h (renamed from libcpu/arm/at91sam926x/at91sam9260_matrix.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/at91sam926x.h (renamed from libcpu/arm/at91sam926x/at91sam926x.h)19
-rw-r--r--bsp/at91sam9260/platform/gpio.h (renamed from libcpu/arm/at91sam926x/gpio.h)24
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/interrupt.c (renamed from libcpu/arm/at91sam926x/interrupt.c)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/io.h (renamed from libcpu/arm/at91sam926x/io.h)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/irq.h (renamed from libcpu/arm/at91sam926x/irq.h)16
-rw-r--r--bsp/at91sam9260/platform/reset.c44
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/start_gcc.S (renamed from libcpu/arm/at91sam926x/start_gcc.S)16
-rw-r--r--bsp/at91sam9260/platform/start_rvds.S (renamed from libcpu/arm/at91sam926x/start_rvds.S)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/system_clock.c (renamed from libcpu/arm/at91sam926x/system_clock.c)16
-rw-r--r--[-rwxr-xr-x]bsp/at91sam9260/platform/trap.c (renamed from libcpu/arm/at91sam926x/trap.c)17
-rwxr-xr-xbsp/at91sam9260/rtconfig.h20
-rwxr-xr-xbsp/at91sam9260/rtconfig.py2
-rw-r--r--[-rwxr-xr-x]libcpu/arm/arm926/context_gcc.S (renamed from libcpu/arm/at91sam926x/context_gcc.S)16
-rw-r--r--libcpu/arm/arm926/context_rvds.S (renamed from libcpu/arm/at91sam926x/context_rvds.S)16
-rw-r--r--[-rwxr-xr-x]libcpu/arm/arm926/cpuport.c (renamed from libcpu/arm/at91sam926x/cpu.c)39
-rw-r--r--libcpu/arm/arm926/mmu.c (renamed from libcpu/arm/at91sam926x/mmu.c)55
-rw-r--r--libcpu/arm/arm926/mmu.h63
-rw-r--r--[-rwxr-xr-x]libcpu/arm/arm926/stack.c (renamed from libcpu/arm/at91sam926x/stack.c)33
-rwxr-xr-xlibcpu/arm/at91sam926x/at91_pdc.h21
-rwxr-xr-xlibcpu/arm/at91sam926x/serial.c282
-rwxr-xr-xlibcpu/arm/at91sam926x/serial.h76
52 files changed, 1361 insertions, 1177 deletions
diff --git a/bsp/at91sam9260/SConscript b/bsp/at91sam9260/SConscript
index 4fe0f874fc..fe0ae941ae 100755
--- a/bsp/at91sam9260/SConscript
+++ b/bsp/at91sam9260/SConscript
@@ -1,24 +1,14 @@
-import rtconfig
+# for module compiling
+import os
Import('RTT_ROOT')
-from building import *
-src_bsp = ['application.c', 'startup.c', 'board.c']
-src_drv = ['console.c']
+cwd = str(Dir('#'))
+objs = []
+list = os.listdir(cwd)
-if GetDepend('RT_USING_LED'):
- src_drv += ['led.c']
+for d in list:
+ path = os.path.join(cwd, d)
+ if os.path.isfile(os.path.join(path, 'SConscript')):
+ objs = objs + SConscript(os.path.join(d, 'SConscript'))
-if GetDepend('RT_USING_SDIO'):
- src_drv += ['at91_mci.c']
-
-if GetDepend('RT_USING_LWIP'):
- src_drv += ['macb.c']
-
-if GetDepend('RT_USING_I2C') and GetDepend('RT_USING_I2C_BITOPS'):
- src_drv += ['at91_i2c_gpio.c']
-
-src = File(src_bsp + src_drv)
-CPPPATH = [RTT_ROOT + '/bsp/at91sam9260']
-group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH)
-
-Return('group')
+Return('objs')
diff --git a/bsp/at91sam9260/applications/SConscript b/bsp/at91sam9260/applications/SConscript
new file mode 100644
index 0000000000..01eb940dfb
--- /dev/null
+++ b/bsp/at91sam9260/applications/SConscript
@@ -0,0 +1,11 @@
+Import('RTT_ROOT')
+Import('rtconfig')
+from building import *
+
+cwd = os.path.join(str(Dir('#')), 'applications')
+src = Glob('*.c')
+CPPPATH = [cwd, str(Dir('#'))]
+
+group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/bsp/at91sam9260/application.c b/bsp/at91sam9260/applications/application.c
index 95eed6572e..fa2f06377b 100755..100644
--- a/bsp/at91sam9260/application.c
+++ b/bsp/at91sam9260/applications/application.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/startup.c b/bsp/at91sam9260/applications/startup.c
index 3e3d85cd2e..15e8138886 100755..100644
--- a/bsp/at91sam9260/startup.c
+++ b/bsp/at91sam9260/applications/startup.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -19,14 +29,8 @@
#ifdef RT_USING_FINSH
#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);
@@ -37,9 +41,6 @@ extern void rt_system_heap_init(void*, void*);
extern void rt_hw_finsh_init(void);
extern void rt_application_init(void);
-extern struct serial_device uart0;
-extern struct rt_device uart0_device;
-
/**
* @addtogroup at91sam9260
*/
@@ -109,50 +110,6 @@ void rtthread_startup(void)
/* initialize scheduler system */
rt_system_scheduler_init();
-#ifdef RT_USING_DEVICE
-#ifdef RT_USING_DBGU
- /* register dbgu */
- rt_hw_serial_register(&uart0_device, "uart0",
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX,
- &uart0);
-#endif
-
-#ifdef RT_USING_UART0
- /* register uart0 */
- rt_hw_serial_register(&uart1_device, "uart1",
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX,
- &uart1);
-#endif
-
-#ifdef RT_USING_UART1
- /* register uart1 */
- rt_hw_serial_register(&uart2_device, "uart2",
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX,
- &uart2);
-#endif
-
-#ifdef RT_USING_UART2
- /* register uart2 */
- rt_hw_serial_register(&uart3_device, "uart3",
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX,
- &uart3);
-#endif
-
-#ifdef RT_USING_UART3
- /* register uart3 */
- rt_hw_serial_register(&uart4_device, "uart4",
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX,
- &uart4);
-#endif
-
-#ifdef RT_USING_DFS
- //rt_hw_sdcard_init();
-#endif
-
- /*init all registed devices */
- rt_device_init_all();
-#endif
-
/* initialize application */
rt_application_init();
@@ -160,9 +117,7 @@ void rtthread_startup(void)
/* initialize finsh */
finsh_system_init();
#ifdef RT_USING_DEVICE
-#ifdef RT_USING_DBGU
- finsh_set_device("uart0");
-#endif
+ finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
#endif
diff --git a/bsp/at91sam9260/board.c b/bsp/at91sam9260/board.c
deleted file mode 100755
index 1ea8bfa5c6..0000000000
--- a/bsp/at91sam9260/board.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * File : board.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2009 RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2011-01-13 weety first version
- */
-
-#include <rtthread.h>
-#include <rthw.h>
-
-#include "board.h"
-
-/**
- * @addtogroup at91sam9260
- */
-/*@{*/
-
-
-extern void rt_hw_clock_init(void);
-extern void rt_hw_mmu_init(void);
-
-extern void rt_hw_get_clock(void);
-extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);
-extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
-
-/*set debug serial port*/
-//#define USE_UART1
-//#define USE_UART3
-//#define USE_DBGU
-
-#define DBGU ((struct uartport *)0xfffff200)
-#define UART0 ((struct uartport *)AT91SAM9260_BASE_US0)
-#define UART1 ((struct uartport *)AT91SAM9260_BASE_US1)
-#define UART2 ((struct uartport *)AT91SAM9260_BASE_US2)
-#define UART3 ((struct uartport *)AT91SAM9260_BASE_US3)
-#define UART4 ((struct uartport *)AT91SAM9260_BASE_US4)
-#define UART5 ((struct uartport *)AT91SAM9260_BASE_US5)
-
-struct serial_int_rx uart0_int_rx;
-struct serial_device uart0 =
-{
- DBGU,
- &uart0_int_rx,
- RT_NULL
-};
-struct rt_device uart0_device;
-
-struct serial_int_rx uart1_int_rx;
-struct serial_device uart1 =
-{
- UART0,
- &uart1_int_rx,
- RT_NULL
-};
-struct rt_device uart1_device;
-
-struct serial_int_rx uart2_int_rx;
-struct serial_device uart2 =
-{
- UART1,
- &uart2_int_rx,
- RT_NULL
-};
-struct rt_device uart2_device;
-
-struct serial_int_rx uart3_int_rx;
-struct serial_device uart3 =
-{
- UART2,
- &uart3_int_rx,
- RT_NULL
-};
-struct rt_device uart3_device;
-
-struct serial_int_rx uart4_int_rx;
-struct serial_device uart4 =
-{
- UART3,
- &uart4_int_rx,
- RT_NULL
-};
-struct rt_device uart4_device;
-
-
-/**
- * This function will handle serial
- */
-void rt_serial_handler(int vector, void *param)
-{
- int status;
- struct rt_device *dev = (rt_device_t)param;
-
- switch (vector)
- {
- #ifdef RT_USING_UART0
- case AT91SAM9260_ID_US0:
- status = readl(AT91SAM9260_BASE_US0+AT91_US_CSR);
- if (!(status & readl(AT91SAM9260_BASE_US0+AT91_US_IMR)))
- {
- return;
- }
- rt_hw_serial_isr(dev);
- break;
- #endif
- #ifdef RT_USING_UART1
- case AT91SAM9260_ID_US1:
- status = readl(AT91SAM9260_BASE_US1+AT91_US_CSR);
- if (!(status & readl(AT91SAM9260_BASE_US1+AT91_US_IMR)))
- {
- return;
- }
- rt_hw_serial_isr(dev);
- break;
- #endif
- #ifdef RT_USING_UART2
- case AT91SAM9260_ID_US2:
- status = readl(AT91SAM9260_BASE_US2+AT91_US_CSR);
- if (!(status & readl(AT91SAM9260_BASE_US2+AT91_US_IMR)))
- {
- return;
- }
- rt_hw_serial_isr(dev);
- break;
- #endif
- #ifdef RT_USING_UART3
- case AT91SAM9260_ID_US3:
- status = readl(AT91SAM9260_BASE_US3+AT91_US_CSR);
- if (!(status & readl(AT91SAM9260_BASE_US3+AT91_US_IMR)))
- {
- return;
- }
- rt_hw_serial_isr(dev);
- break;
- #endif
- default: break;
- }
-
-}
-
-void uart_port_init(rt_uint32_t base)
-{
- #define BAUDRATE 115200
- rt_uint32_t cd;
-
- writel(AT91_US_RSTTX | AT91_US_RSTRX |
- AT91_US_RXDIS | AT91_US_TXDIS,
- base + AT91_US_CR);
- writel( AT91_US_USMODE_NORMAL | AT91_US_USCLKS_MCK |
- AT91_US_CHRL_8 | AT91_US_PAR_NONE |
- AT91_US_NBSTOP_1 | AT91_US_CHMODE_NORMAL,
- base + AT91_US_MR);
- cd = (clk_get_rate(clk_get("mck")) / 16 + BAUDRATE/2) / BAUDRATE;
- writel(cd, base + AT91_US_BRGR);
- writel(AT91_US_RXEN | AT91_US_TXEN, base + AT91_US_CR);
-
- writel(0x1, base + AT91_US_IER);
-}
-
-/**
- * This function will handle init uart
- */
-void rt_hw_uart_init(void)
-{
-#ifdef RT_USING_UART0
- at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US0);
- at91_sys_write(AT91_PIOB + PIO_IDR, (1<<4)|(1<<5));
- at91_sys_write(AT91_PIOB + PIO_PUER, (1<<4));
- at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<5));
- at91_sys_write(AT91_PIOB + PIO_ASR, (1<<4)|(1<<5));
- at91_sys_write(AT91_PIOB + PIO_PDR, (1<<4)|(1<<5));
- uart_port_init(AT91SAM9260_BASE_US0);
- /* install interrupt handler */
- rt_hw_interrupt_install(AT91SAM9260_ID_US0, rt_serial_handler,
- (void *)&uart1_device, "UART0");
- rt_hw_interrupt_umask(AT91SAM9260_ID_US0);
-#endif
-#ifdef RT_USING_UART1
- at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US1);
- at91_sys_write(AT91_PIOB + PIO_IDR, (1<<6)|(1<<7));
- at91_sys_write(AT91_PIOB + PIO_PUER, (1<<6));
- at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<7));
- at91_sys_write(AT91_PIOB + PIO_ASR, (1<<6)|(1<<7));
- at91_sys_write(AT91_PIOB + PIO_PDR, (1<<6)|(1<<7));
- uart_port_init(AT91SAM9260_BASE_US1);
- /* install interrupt handler */
- rt_hw_interrupt_install(AT91SAM9260_ID_US1, rt_serial_handler,
- (void *)&uart2_device, "UART1");
- rt_hw_interrupt_umask(AT91SAM9260_ID_US1);
-#endif
-#ifdef RT_USING_UART2
- at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US2);
- at91_sys_write(AT91_PIOB + PIO_IDR, (1<<8)|(1<<9));
- at91_sys_write(AT91_PIOB + PIO_PUER, (1<<8));
- at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<9));
- at91_sys_write(AT91_PIOB + PIO_ASR, (1<<8)|(1<<9));
- at91_sys_write(AT91_PIOB + PIO_PDR, (1<<8)|(1<<9));
- uart_port_init(AT91SAM9260_BASE_US2);
- /* install interrupt handler */
- rt_hw_interrupt_install(AT91SAM9260_ID_US2, rt_serial_handler,
- (void *)&uart3_device, "UART2");
- rt_hw_interrupt_umask(AT91SAM9260_ID_US2);
-#endif
-#ifdef RT_USING_UART3
- at91_sys_write(AT91_PMC_PCER, 1<<AT91SAM9260_ID_US3);
- at91_sys_write(AT91_PIOB + PIO_IDR, (1<<10)|(1<<11));
- at91_sys_write(AT91_PIOB + PIO_PUER, (1<<10));
- at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<11));
- at91_sys_write(AT91_PIOB + PIO_ASR, (1<<10)|(1<<11));
- at91_sys_write(AT91_PIOB + PIO_PDR, (1<<10)|(1<<11));
- uart_port_init(AT91SAM9260_BASE_US3);
- /* install interrupt handler */
- rt_hw_interrupt_install(AT91SAM9260_ID_US3, rt_serial_handler,
- (void *)&uart4_device, "UART3");
- rt_hw_interrupt_umask(AT91SAM9260_ID_US3);
-
-#endif
-#ifdef RT_USING_DBGU
- #define BAUDRATE 115200
- rt_uint32_t cd;
- at91_sys_write(AT91_PIOB + PIO_IDR, (1<<14)|(1<<15));
- //at91_sys_write(AT91_PIOB + PIO_PUER, (1<<6));
- at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<14)|(1<<15));
- at91_sys_write(AT91_PIOB + PIO_ASR, (1<<14)|(1<<15));
- at91_sys_write(AT91_PIOB + PIO_PDR, (1<<14)|(1<<15));
- at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
- at91_sys_write(AT91_DBGU + AT91_US_CR, AT91_US_RSTTX | AT91_US_RSTRX | AT91_US_RXDIS | AT91_US_TXDIS);
- at91_sys_write(AT91_DBGU + AT91_US_IDR, 0xffffffff);
- at91_sys_write(AT91_DBGU + AT91_US_MR, AT91_US_USMODE_NORMAL | AT91_US_PAR_NONE);
- cd = (clk_get_rate(clk_get("mck")) / 16 + BAUDRATE/2) / BAUDRATE;
- at91_sys_write(AT91_DBGU + AT91_US_BRGR, cd);
- at91_sys_write(AT91_DBGU + AT91_US_CR, AT91_US_RXEN | AT91_US_TXEN);
-
- at91_sys_read(AT91_DBGU + AT91_US_CSR); //read for clearing interrupt
- at91_sys_write(AT91_DBGU + AT91_US_IER, 0x1);
-#endif
-}
-
-#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
-#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
-
-static rt_uint32_t pit_cycle; /* write-once */
-static rt_uint32_t pit_cnt; /* access only w/system irq blocked */
-
-/**
- * This function will handle rtos timer
- */
-void rt_timer_handler(int vector, void *param)
-{
- #ifdef RT_USING_DBGU
- if (at91_sys_read(AT91_DBGU + AT91_US_CSR) & 0x1) {
- //rt_kprintf("DBGU interrupt occur\n");
- rt_hw_serial_isr(&uart0_device);
- }
- #endif
- if (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS) {
- unsigned nr_ticks;
-
- /* Get number of ticks performed before irq, and ack it */
- nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
- rt_tick_increase();
- }
-}
-
-static void at91sam926x_pit_reset(void)
-{
- /* Disable timer and irqs */
- at91_sys_write(AT91_PIT_MR, 0);
-
- /* Clear any pending interrupts, wait for PIT to stop counting */
- while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0)
- ;
-
- /* Start PIT but don't enable IRQ */
- //at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
- pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
- at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
- | AT91_PIT_PITIEN);
- rt_kprintf("PIT_MR=0x%08x\n", at91_sys_read(AT91_PIT_MR));
-}
-
-/*
- * Set up both clocksource and clockevent support.
- */
-static void at91sam926x_pit_init(void)
-{
- rt_uint32_t pit_rate;
- rt_uint32_t bits;
-
- /*
- * Use our actual MCK to figure out how many MCK/16 ticks per
- * 1/HZ period (instead of a compile-time constant LATCH).
- */
- pit_rate = clk_get_rate(clk_get("mck")) / 16;
- rt_kprintf("pit_rate=%dHZ\n", pit_rate);
- pit_cycle = (pit_rate + RT_TICK_PER_SECOND/2) / RT_TICK_PER_SECOND;
-
- /* Initialize and enable the timer */
- at91sam926x_pit_reset();
-
-}
-
-/**
- * This function will init pit for system ticks
- */
- void rt_hw_timer_init()
- {
- at91sam926x_pit_init();
-
- /* install interrupt handler */
- rt_hw_interrupt_install(AT91_ID_SYS, rt_timer_handler,
- RT_NULL, "system");
- rt_hw_interrupt_umask(AT91_ID_SYS);
-
- }
-
- void at91_tc1_init()
- {
- at91_sys_write(AT91_PMC_PCER, 1<<AT91SAM9260_ID_TC0);
- writel(AT91_TC_TC0XC0S_NONE | AT91_TC_TC1XC1S_NONE | AT91_TC_TC2XC2S_NONE, AT91SAM9260_BASE_TCB0 + AT91_TC_BMR);
- writel(AT91_TC_CLKDIS, AT91SAM9260_BASE_TC0 + AT91_TC_CCR);
- writel(AT91_TC_TIMER_CLOCK4, AT91SAM9260_BASE_TC0 + AT91_TC_CMR);
- writel(0xffff, AT91SAM9260_BASE_TC0 + AT91_TC_CV);
- }
-
-/**
- * This function will init at91sam9260 board
- */
-void rt_hw_board_init()
-{
- /* initialize the system clock */
- rt_hw_clock_init();
-
- /* initialize uart */
- rt_hw_uart_init();
-
- /* initialize mmu */
- rt_hw_mmu_init();
-
- /* initialize timer0 */
- rt_hw_timer_init();
-
-}
-
-/*@}*/
diff --git a/bsp/at91sam9260/board.h b/bsp/at91sam9260/board.h
deleted file mode 100755
index 39764aff39..0000000000
--- a/bsp/at91sam9260/board.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * File : board.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2011-01-13 weety add board.h to this bsp
- */
-
-#ifndef __BOARD_H__
-#define __BOARD_H__
-
-#include <at91sam926x.h>
-#include <serial.h>
-
-void rt_hw_board_init(void);
-//void rt_hw_sdcard_init(void);
-
-#endif
diff --git a/bsp/at91sam9260/console.c b/bsp/at91sam9260/console.c
deleted file mode 100755
index 03836fb014..0000000000
--- a/bsp/at91sam9260/console.c
+++ /dev/null
@@ -1,180 +0,0 @@
-#include <rtthread.h>
-
-#include <serial.h>
-
-#define RT_CONSOLE_WIDTH 240
-#define RT_CONSOLE_HEIGHT 320
-
-#define RT_CONSOLE_FONT_WIDTH 8
-#define RT_CONSOLE_FONT_HEIGHT 16
-
-#define RT_CONSOLE_COL (RT_CONSOLE_WIDTH/RT_CONSOLE_FONT_WIDTH)
-#define RT_CONSOLE_ROW (RT_CONSOLE_HEIGHT/RT_CONSOLE_FONT_HEIGHT)
-
-#define RT_CONSOLE_TAB 4
-
-#define RT_CONSOLE_FOREPIXEL (0x001f)
-
-extern struct serial_device uart0;
-
-struct rt_console
-{
- rt_uint8_t* video_ptr;
- rt_uint8_t* font_ptr;
-
- /* bpp and pixel of width */
- rt_uint8_t bpp;
- rt_uint32_t pitch;
-
- /* current cursor */
- rt_uint8_t current_col;
- rt_uint8_t current_row;
-};
-struct rt_console console;
-
-void rt_hw_console_init(rt_uint8_t* video_ptr, rt_uint8_t* font_ptr, rt_uint8_t bpp);
-void rt_hw_console_newline(void);
-void rt_hw_console_putc(char c);
-void rt_hw_console_clear(void);
-
-void rt_hw_console_init(rt_uint8_t* video_ptr, rt_uint8_t* font_ptr, rt_uint8_t bpp)
-{
- rt_memset(&console, 0, sizeof(struct rt_console));
-
- console.video_ptr = video_ptr;
- console.font_ptr = font_ptr;
- console.bpp = bpp;
- console.pitch = console.bpp * RT_CONSOLE_WIDTH;
-
- rt_hw_console_clear();
-}
-
-void rt_hw_console_putc(char c)
-{
- switch (c)
- {
- case 10:
- case 11:
- case 12:
- case 13:
- /* to next line */
- rt_hw_console_newline();
- console.current_col = 0;
- break;
-
- case 9:
- console.current_col += RT_CONSOLE_TAB;
- break;
-
- default:
- {
- rt_uint8_t* font_ptr;
- register rt_uint32_t cursor;
- register rt_uint32_t i, j;
-
- if (console.current_col == RT_CONSOLE_COL)
- {
- rt_hw_console_newline();
- console.current_col = 0;
-
- rt_hw_console_putc(c);
- return;
- }
-
- font_ptr = console.font_ptr + c * RT_CONSOLE_FONT_HEIGHT;
- cursor = (console.current_row * RT_CONSOLE_FONT_HEIGHT) * console.pitch
- + console.current_col * RT_CONSOLE_FONT_WIDTH * console.bpp;
-
- for (i = 0; i < RT_CONSOLE_FONT_HEIGHT; i ++ )
- {
- for (j = 0; j < RT_CONSOLE_FONT_WIDTH; j ++)
- {
- if ( ((font_ptr[i] >> (7-j)) & 0x01) != 0 )
- {
- /* draw a pixel */
- rt_uint8_t *ptr = &(console.video_ptr[cursor + i * console.pitch + j * console.bpp]);
- switch(console.bpp)
- {
- case 1:
- *ptr = RT_CONSOLE_FOREPIXEL;
- break;
- case 2:
- *(rt_uint16_t*)ptr = RT_CONSOLE_FOREPIXEL;
- break;
- case 3:
- ptr[0] = RT_CONSOLE_FOREPIXEL & 0xff;
- ptr[1] = (RT_CONSOLE_FOREPIXEL >> 8) & 0xff;
- ptr[2] = (RT_CONSOLE_FOREPIXEL >> 16) & 0xff;
- break;
- case 4:
- *(rt_uint32_t*)ptr = RT_CONSOLE_FOREPIXEL;
- break;
- }
- }
- }
- }
-
- console.current_col ++;
- }
- break;
- }
-}
-
-void rt_hw_console_newline()
-{
- console.current_row ++;
- if (console.current_row >= RT_CONSOLE_ROW)
- {
- rt_uint32_t i;
-
- /* scroll to next line */
- for (i = 0; i < RT_CONSOLE_ROW - 1; i ++)
- {
- rt_memcpy(console.video_ptr + i * RT_CONSOLE_FONT_HEIGHT * console.pitch,
- console.video_ptr + (i + 1) * RT_CONSOLE_FONT_HEIGHT * console.pitch,
- RT_CONSOLE_FONT_HEIGHT * console.pitch);
- }
-
- /* clear last line */
- rt_memset(console.video_ptr + (RT_CONSOLE_ROW - 1) * RT_CONSOLE_FONT_HEIGHT * console.pitch,
- 0,
- RT_CONSOLE_FONT_HEIGHT * console.pitch);
-
- console.current_row = RT_CONSOLE_ROW - 1;
- }
-}
-
-void rt_hw_console_clear()
-{
- console.current_col = 0;
- console.current_row = 0;
-
- rt_memset(console.video_ptr, 0, RT_CONSOLE_HEIGHT * console.pitch);
-}
-
-/* write one character to serial, must not trigger interrupt */
-void rt_hw_serial_putc(const char c)
-{
- /*
- to be polite with serial console add a line feed
- to the carriage return character
- */
- if (c=='\n')rt_hw_serial_putc('\r');
-
- while (!(uart0.uart_device->USART_CSR & TXRDY));
- uart0.uart_device->USART_THR = (c & 0x1FF);
-}
-
-/**
- * This function is used by rt_kprintf to display a string on console.
- *
- * @param str the displayed string
- */
-void rt_hw_console_output(const char* str)
-{
- while (*str)
- {
- rt_hw_serial_putc(*str++);
- }
-}
-
diff --git a/bsp/at91sam9260/drivers/SConscript b/bsp/at91sam9260/drivers/SConscript
new file mode 100644
index 0000000000..d0470f9049
--- /dev/null
+++ b/bsp/at91sam9260/drivers/SConscript
@@ -0,0 +1,31 @@
+Import('RTT_ROOT')
+Import('rtconfig')
+from building import *
+
+cwd = os.path.join(str(Dir('#')), 'drivers')
+
+# add the general drvers.
+src = Split("""
+board.c
+usart.c
+""")
+
+# add Ethernet drvers.
+if GetDepend('RT_USING_LED'):
+ src += ['led.c']
+
+if GetDepend('RT_USING_SDIO'):
+ src += ['at91_mci.c']
+
+if GetDepend('RT_USING_LWIP'):
+ src += ['macb.c']
+
+if GetDepend('RT_USING_I2C') and GetDepend('RT_USING_I2C_BITOPS'):
+ src += ['at91_i2c_gpio.c']
+
+
+CPPPATH = [cwd]
+
+group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/bsp/at91sam9260/at91_i2c_gpio.c b/bsp/at91sam9260/drivers/at91_i2c_gpio.c
index bbee2033aa..c83c36218d 100644
--- a/bsp/at91sam9260/at91_i2c_gpio.c
+++ b/bsp/at91sam9260/drivers/at91_i2c_gpio.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/at91_mci.c b/bsp/at91sam9260/drivers/at91_mci.c
index 39fd364f11..fdfdcf459c 100755..100644
--- a/bsp/at91sam9260/at91_mci.c
+++ b/bsp/at91sam9260/drivers/at91_mci.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/at91_mci.h b/bsp/at91sam9260/drivers/at91_mci.h
index 3a726aabe2..2591f20c98 100644
--- a/bsp/at91sam9260/at91_mci.h
+++ b/bsp/at91sam9260/drivers/at91_mci.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/drivers/board.c b/bsp/at91sam9260/drivers/board.c
new file mode 100644
index 0000000000..15ef7c9dd6
--- /dev/null
+++ b/bsp/at91sam9260/drivers/board.c
@@ -0,0 +1,161 @@
+/*
+ * File : board.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009 RT-Thread Develop Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety first version
+ */
+
+#include <rtthread.h>
+#include <rthw.h>
+
+#include "board.h"
+#include <mmu.h>
+
+/**
+ * @addtogroup at91sam9260
+ */
+/*@{*/
+
+
+extern void rt_hw_clock_init(void);
+
+extern void rt_hw_get_clock(void);
+extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);
+extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
+extern void rt_dbgu_isr(void);
+
+static struct mem_desc at91_mem_desc[] = {
+ { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB }, /* None cached for 4G memory */
+ { 0x20000000, 0x24000000-1, 0x20000000, RW_CB }, /* 64M cached SDRAM memory */
+ { 0x00000000, 0x100000, 0x20000000, RW_CB }, /* isr vector table */
+ { 0x90000000, 0x90400000 - 1, 0x00200000, RW_NCNB }, /* 4K SRAM0 + 4k SRAM1 */
+ { 0xA0000000, 0xA4000000-1, 0x20000000, RW_NCNB } /* 64M none-cached SDRAM memory */
+};
+
+
+#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
+#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
+
+static rt_uint32_t pit_cycle; /* write-once */
+static rt_uint32_t pit_cnt; /* access only w/system irq blocked */
+
+/**
+ * This function will handle rtos timer
+ */
+void rt_timer_handler(int vector, void *param)
+{
+ #ifdef RT_USING_DBGU
+ if (at91_sys_read(AT91_DBGU + AT91_US_CSR) & 0x1)
+ {
+ rt_dbgu_isr();
+ }
+ #endif
+ if (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS)
+ {
+ unsigned nr_ticks;
+
+ /* Get number of ticks performed before irq, and ack it */
+ nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
+ rt_tick_increase();
+ }
+}
+
+static void at91sam926x_pit_reset(void)
+{
+ /* Disable timer and irqs */
+ at91_sys_write(AT91_PIT_MR, 0);
+
+ /* Clear any pending interrupts, wait for PIT to stop counting */
+ while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0)
+ ;
+
+ /* Start PIT but don't enable IRQ */
+ //at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
+ pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
+ at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
+ | AT91_PIT_PITIEN);
+ rt_kprintf("PIT_MR=0x%08x\n", at91_sys_read(AT91_PIT_MR));
+}
+
+/*
+ * Set up both clocksource and clockevent support.
+ */
+static void at91sam926x_pit_init(void)
+{
+ rt_uint32_t pit_rate;
+ rt_uint32_t bits;
+
+ /*
+ * Use our actual MCK to figure out how many MCK/16 ticks per
+ * 1/HZ period (instead of a compile-time constant LATCH).
+ */
+ pit_rate = clk_get_rate(clk_get("mck")) / 16;
+ rt_kprintf("pit_rate=%dHZ\n", pit_rate);
+ pit_cycle = (pit_rate + RT_TICK_PER_SECOND/2) / RT_TICK_PER_SECOND;
+
+ /* Initialize and enable the timer */
+ at91sam926x_pit_reset();
+
+}
+
+/**
+ * This function will init pit for system ticks
+ */
+ void rt_hw_timer_init()
+ {
+ at91sam926x_pit_init();
+
+ /* install interrupt handler */
+ rt_hw_interrupt_install(AT91_ID_SYS, rt_timer_handler,
+ RT_NULL, "system");
+ rt_hw_interrupt_umask(AT91_ID_SYS);
+
+ }
+
+ void at91_tc1_init()
+ {
+ at91_sys_write(AT91_PMC_PCER, 1<<AT91SAM9260_ID_TC0);
+ writel(AT91_TC_TC0XC0S_NONE | AT91_TC_TC1XC1S_NONE | AT91_TC_TC2XC2S_NONE, AT91SAM9260_BASE_TCB0 + AT91_TC_BMR);
+ writel(AT91_TC_CLKDIS, AT91SAM9260_BASE_TC0 + AT91_TC_CCR);
+ writel(AT91_TC_TIMER_CLOCK4, AT91SAM9260_BASE_TC0 + AT91_TC_CMR);
+ writel(0xffff, AT91SAM9260_BASE_TC0 + AT91_TC_CV);
+ }
+
+/**
+ * This function will init at91sam9260 board
+ */
+void rt_hw_board_init()
+{
+ /* initialize the system clock */
+ rt_hw_clock_init();
+
+ /* initialize uart */
+ rt_hw_uart_init();
+ rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
+
+ /* initialize mmu */
+ rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0]));
+
+ /* initialize timer0 */
+ rt_hw_timer_init();
+
+}
+
+/*@}*/
diff --git a/bsp/at91sam9260/drivers/board.h b/bsp/at91sam9260/drivers/board.h
new file mode 100644
index 0000000000..e6c8f77865
--- /dev/null
+++ b/bsp/at91sam9260/drivers/board.h
@@ -0,0 +1,32 @@
+/*
+ * File : board.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety add board.h to this bsp
+ */
+
+#ifndef __BOARD_H__
+#define __BOARD_H__
+
+#include <at91sam926x.h>
+
+void rt_hw_board_init(void);
+
+#endif
diff --git a/bsp/at91sam9260/led.c b/bsp/at91sam9260/drivers/led.c
index f3fddcce53..6c8f202108 100755..100644
--- a/bsp/at91sam9260/led.c
+++ b/bsp/at91sam9260/drivers/led.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/drivers/led.h b/bsp/at91sam9260/drivers/led.h
new file mode 100644
index 0000000000..f2967bc92d
--- /dev/null
+++ b/bsp/at91sam9260/drivers/led.h
@@ -0,0 +1,32 @@
+/*
+ * File : led.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety first version
+ */
+
+#ifndef __LED_H__
+#define __LED_H__
+
+void led_init(void);
+void led_on(int num);
+void led_off(int num);
+
+#endif
diff --git a/bsp/at91sam9260/macb.c b/bsp/at91sam9260/drivers/macb.c
index 293a0662db..57631185a1 100755..100644
--- a/bsp/at91sam9260/macb.c
+++ b/bsp/at91sam9260/drivers/macb.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/macb.h b/bsp/at91sam9260/drivers/macb.h
index 4697790f62..4e579e427a 100755..100644
--- a/bsp/at91sam9260/macb.h
+++ b/bsp/at91sam9260/drivers/macb.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/mii.h b/bsp/at91sam9260/drivers/mii.h
index 8c932039eb..2f6dd18e71 100644
--- a/bsp/at91sam9260/mii.h
+++ b/bsp/at91sam9260/drivers/mii.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/drivers/usart.c b/bsp/at91sam9260/drivers/usart.c
new file mode 100644
index 0000000000..7b95ca0e4d
--- /dev/null
+++ b/bsp/at91sam9260/drivers/usart.c
@@ -0,0 +1,438 @@
+/*
+ * File : usart.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety first version
+ * 2013-07-21 weety using serial component
+ */
+
+#include <rtthread.h>
+#include <rthw.h>
+#include <at91sam926x.h>
+#include <rtdevice.h>
+
+#define RXRDY 0x01
+#define TXRDY (1 << 1)
+
+typedef struct uartport
+{
+ volatile rt_uint32_t CR;
+ volatile rt_uint32_t MR;
+ volatile rt_uint32_t IER;
+ volatile rt_uint32_t IDR;
+ volatile rt_uint32_t IMR;
+ volatile rt_uint32_t CSR;
+ volatile rt_uint32_t RHR;
+ volatile rt_uint32_t THR;
+ volatile rt_uint32_t BRGR;
+ volatile rt_uint32_t RTOR;
+ volatile rt_uint32_t TTGR;
+ volatile rt_uint32_t reserved0[5];
+ volatile rt_uint32_t FIDI;
+ volatile rt_uint32_t NER;
+ volatile rt_uint32_t reserved1;
+ volatile rt_uint32_t IFR;
+ volatile rt_uint32_t reserved2[44];
+ volatile rt_uint32_t RPR;
+ volatile rt_uint32_t RCR;
+ volatile rt_uint32_t TPR;
+ volatile rt_uint32_t TCR;
+ volatile rt_uint32_t RNPR;
+ volatile rt_uint32_t RNCR;
+ volatile rt_uint32_t TNPR;
+ volatile rt_uint32_t TNCR;
+ volatile rt_uint32_t PTCR;
+ volatile rt_uint32_t PTSR;
+}uartport;
+
+#define CIDR FIDI
+#define EXID NER
+#define FNR reserved1
+
+#define DBGU ((struct uartport *)AT91SAM9260_BASE_DBGU)
+
+#define UART0 ((struct uartport *)AT91SAM9260_BASE_US0)
+#define UART1 ((struct uartport *)AT91SAM9260_BASE_US1)
+#define UART2 ((struct uartport *)AT91SAM9260_BASE_US2)
+#define UART3 ((struct uartport *)AT91SAM9260_BASE_US3)
+
+struct at91_uart {
+ uartport *port;
+ int irq;
+};
+
+
+
+/**
+ * This function will handle serial
+ */
+void rt_at91_usart_handler(int vector, void *param)
+{
+ int status;
+ struct at91_uart *uart;
+ rt_device_t dev = (rt_device_t)param;
+ uart = (struct at91_uart *)dev->user_data;
+ status = uart->port->CSR;
+ if (!(status & uart->port->IMR))
+ {
+ return;
+ }
+ rt_interrupt_enter();
+ rt_hw_serial_isr(dev);
+ rt_interrupt_leave();
+}
+
+/**
+* UART device in RT-Thread
+*/
+static rt_err_t at91_usart_configure(struct rt_serial_device *serial,
+ struct serial_configure *cfg)
+{
+ int div;
+ int mode = 0;
+ struct at91_uart *uart;
+
+ RT_ASSERT(serial != RT_NULL);
+ RT_ASSERT(cfg != RT_NULL);
+ uart = (struct at91_uart *)serial->parent.user_data;
+
+ uart->port->CR = AT91_US_RSTTX | AT91_US_RSTRX |
+ AT91_US_RXDIS | AT91_US_TXDIS;
+ mode |= AT91_US_USMODE_NORMAL | AT91_US_USCLKS_MCK |
+ AT91_US_CHMODE_NORMAL;
+ switch (cfg->data_bits)
+ {
+ case DATA_BITS_8:
+ mode |= AT91_US_CHRL_8;
+ break;
+ case DATA_BITS_7:
+ mode |= AT91_US_CHRL_7;
+ break;
+ case DATA_BITS_6:
+ mode |= AT91_US_CHRL_6;
+ break;
+ case DATA_BITS_5:
+ mode |= AT91_US_CHRL_5;
+ break;
+ default:
+ mode |= AT91_US_CHRL_8;
+ break;
+ }
+
+ switch (cfg->stop_bits)
+ {
+ case STOP_BITS_2:
+ mode |= AT91_US_NBSTOP_2;
+ break;
+ case STOP_BITS_1:
+ default:
+ mode |= AT91_US_NBSTOP_1;
+ break;
+ }
+
+ switch (cfg->parity)
+ {
+ case PARITY_ODD:
+ mode |= AT91_US_PAR_ODD;
+ break;
+ case PARITY_EVEN:
+ mode |= AT91_US_PAR_EVEN;
+ break;
+ case PARITY_NONE:
+ default:
+ mode |= AT91_US_PAR_NONE;
+ break;
+ }
+
+ uart->port->MR = mode;
+ div = (clk_get_rate(clk_get("mck")) / 16 + cfg->baud_rate/2) / cfg->baud_rate;
+ uart->port->BRGR = div;
+ uart->port->CR = AT91_US_RXEN | AT91_US_TXEN;
+ uart->port->IER = 0x01;
+
+ return RT_EOK;
+}
+
+static rt_err_t at91_usart_control(struct rt_serial_device *serial,
+ int cmd, void *arg)
+{
+ struct at91_uart* uart;
+
+ RT_ASSERT(serial != RT_NULL);
+ uart = (struct at91_uart *)serial->parent.user_data;
+
+ switch (cmd)
+ {
+ case RT_DEVICE_CTRL_CLR_INT:
+ /* disable rx irq */
+ rt_hw_interrupt_mask(uart->irq);
+ break;
+ case RT_DEVICE_CTRL_SET_INT:
+ /* enable rx irq */
+ rt_hw_interrupt_umask(uart->irq);
+ break;
+ }
+
+ return RT_EOK;
+}
+
+static int at91_usart_putc(struct rt_serial_device *serial, char c)
+{
+ rt_uint32_t level;
+ struct at91_uart *uart = serial->parent.user_data;
+
+ while (!(uart->port->CSR & TXRDY));
+ uart->port->THR = c;
+
+ return 1;
+}
+
+static int at91_usart_getc(struct rt_serial_device *serial)
+{
+ int result;
+ struct at91_uart *uart = serial->parent.user_data;
+
+ if (uart->port->CSR & RXRDY)
+ {
+ result = uart->port->RHR & 0xff;
+ }
+ else
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
+static const struct rt_uart_ops at91_usart_ops =
+{
+ at91_usart_configure,
+ at91_usart_control,
+ at91_usart_putc,
+ at91_usart_getc,
+};
+
+#if defined(RT_USING_DBGU)
+static struct rt_serial_device serial_dbgu;
+static struct serial_ringbuffer dbgu_int_rx;
+struct at91_uart dbgu = {
+ DBGU,
+ AT91_ID_SYS
+};
+
+#endif
+
+#if defined(RT_USING_UART0)
+static struct rt_serial_device serial0;
+static struct serial_ringbuffer uart0_int_rx;
+struct at91_uart uart0 = {
+ UART0,
+ AT91SAM9260_ID_US0
+};
+#endif
+
+#if defined(RT_USING_UART1)
+static struct rt_serial_device serial1;
+static struct serial_ringbuffer uart1_int_rx;
+struct at91_uart uart1 = {
+ UART1,
+ AT91SAM9260_ID_US1
+};
+#endif
+
+#if defined(RT_USING_UART2)
+static struct rt_serial_device serial2;
+static struct serial_ringbuffer uart2_int_rx;
+struct at91_uart uart2 = {
+ UART2,
+ AT91SAM9260_ID_US2
+};
+#endif
+
+#if defined(RT_USING_UART3)
+static struct rt_serial_device serial3;
+static struct serial_ringbuffer uart3_int_rx;
+struct at91_uart uart3 = {
+ UART3,
+ AT91SAM9260_ID_US3
+};
+#endif
+
+void at91_usart_gpio_init(void)
+{
+ rt_uint32_t val;
+
+#ifdef RT_USING_DBGU
+ at91_sys_write(AT91_PIOB + PIO_IDR, (1<<14)|(1<<15));
+ //at91_sys_write(AT91_PIOB + PIO_PUER, (1<<6));
+ at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<14)|(1<<15));
+ at91_sys_write(AT91_PIOB + PIO_ASR, (1<<14)|(1<<15));
+ at91_sys_write(AT91_PIOB + PIO_PDR, (1<<14)|(1<<15));
+ at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+#endif
+
+#ifdef RT_USING_UART0
+ at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US0);
+ at91_sys_write(AT91_PIOB + PIO_IDR, (1<<4)|(1<<5));
+ at91_sys_write(AT91_PIOB + PIO_PUER, (1<<4));
+ at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<5));
+ at91_sys_write(AT91_PIOB + PIO_ASR, (1<<4)|(1<<5));
+ at91_sys_write(AT91_PIOB + PIO_PDR, (1<<4)|(1<<5));
+#endif
+
+#ifdef RT_USING_UART1
+ at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US1);
+ at91_sys_write(AT91_PIOB + PIO_IDR, (1<<6)|(1<<7));
+ at91_sys_write(AT91_PIOB + PIO_PUER, (1<<6));
+ at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<7));
+ at91_sys_write(AT91_PIOB + PIO_ASR, (1<<6)|(1<<7));
+ at91_sys_write(AT91_PIOB + PIO_PDR, (1<<6)|(1<<7));
+#endif
+
+#ifdef RT_USING_UART2
+ at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US2);
+ at91_sys_write(AT91_PIOB + PIO_IDR, (1<<8)|(1<<9));
+ at91_sys_write(AT91_PIOB + PIO_PUER, (1<<8));
+ at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<9));
+ at91_sys_write(AT91_PIOB + PIO_ASR, (1<<8)|(1<<9));
+ at91_sys_write(AT91_PIOB + PIO_PDR, (1<<8)|(1<<9));
+#endif
+
+#ifdef RT_USING_UART3
+ at91_sys_write(AT91_PMC_PCER, 1<<AT91SAM9260_ID_US3);
+ at91_sys_write(AT91_PIOB + PIO_IDR, (1<<10)|(1<<11));
+ at91_sys_write(AT91_PIOB + PIO_PUER, (1<<10));
+ at91_sys_write(AT91_PIOB + PIO_PUDR, (1<<11));
+ at91_sys_write(AT91_PIOB + PIO_ASR, (1<<10)|(1<<11));
+ at91_sys_write(AT91_PIOB + PIO_PDR, (1<<10)|(1<<11));
+#endif
+}
+
+
+
+
+/**
+ * This function will handle init uart
+ */
+void rt_hw_uart_init(void)
+{
+ at91_usart_gpio_init();
+
+#if defined(RT_USING_DBGU)
+ serial_dbgu.ops = &at91_usart_ops;
+ serial_dbgu.int_rx = &dbgu_int_rx;
+ serial_dbgu.config.baud_rate = BAUD_RATE_115200;
+ serial_dbgu.config.bit_order = BIT_ORDER_LSB;
+ serial_dbgu.config.data_bits = DATA_BITS_8;
+ serial_dbgu.config.parity = PARITY_NONE;
+ serial_dbgu.config.stop_bits = STOP_BITS_1;
+ serial_dbgu.config.invert = NRZ_NORMAL;
+
+ /* register vcom device */
+ rt_hw_serial_register(&serial_dbgu, "dbgu",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &dbgu);
+#endif
+
+#if defined(RT_USING_UART0)
+ serial0.ops = &at91_usart_ops;
+ serial0.int_rx = &uart0_int_rx;
+ serial0.config.baud_rate = BAUD_RATE_115200;
+ serial0.config.bit_order = BIT_ORDER_LSB;
+ serial0.config.data_bits = DATA_BITS_8;
+ serial0.config.parity = PARITY_NONE;
+ serial0.config.stop_bits = STOP_BITS_1;
+ serial0.config.invert = NRZ_NORMAL;
+
+ /* register vcom device */
+ rt_hw_serial_register(&serial0, "uart0",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart0);
+ rt_hw_interrupt_install(uart0.irq, rt_at91_usart_handler,
+ (void *)&(serial0.parent), "UART0");
+ rt_hw_interrupt_umask(uart0.irq);
+#endif
+
+#if defined(RT_USING_UART1)
+ serial1.ops = &at91_usart_ops;
+ serial1.int_rx = &uart1_int_rx;
+ serial1.config.baud_rate = BAUD_RATE_115200;
+ serial1.config.bit_order = BIT_ORDER_LSB;
+ serial1.config.data_bits = DATA_BITS_8;
+ serial1.config.parity = PARITY_NONE;
+ serial1.config.stop_bits = STOP_BITS_1;
+ serial1.config.invert = NRZ_NORMAL;
+
+ /* register vcom device */
+ rt_hw_serial_register(&serial1, "uart1",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart1);
+ rt_hw_interrupt_install(uart1.irq, rt_at91_usart_handler,
+ (void *)&(serial1.parent), "UART1");
+ rt_hw_interrupt_umask(uart1.irq);
+#endif
+
+#if defined(RT_USING_UART2)
+ serial2.ops = &at91_usart_ops;
+ serial2.int_rx = &uart2_int_rx;
+ serial2.config.baud_rate = BAUD_RATE_115200;
+ serial2.config.bit_order = BIT_ORDER_LSB;
+ serial2.config.data_bits = DATA_BITS_8;
+ serial2.config.parity = PARITY_NONE;
+ serial2.config.stop_bits = STOP_BITS_1;
+ serial2.config.invert = NRZ_NORMAL;
+
+ /* register vcom device */
+ rt_hw_serial_register(&serial2, "uart2",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart2);
+ rt_hw_interrupt_install(uart2.irq, rt_at91_usart_handler,
+ (void *)&(serial2.parent), "UART2");
+ rt_hw_interrupt_umask(uart2.irq);
+#endif
+
+#if defined(RT_USING_UART3)
+ serial3.ops = &at91_usart_ops;
+ serial3.int_rx = &uart3_int_rx;
+ serial3.config.baud_rate = BAUD_RATE_115200;
+ serial3.config.bit_order = BIT_ORDER_LSB;
+ serial3.config.data_bits = DATA_BITS_8;
+ serial3.config.parity = PARITY_NONE;
+ serial3.config.stop_bits = STOP_BITS_1;
+ serial3.config.invert = NRZ_NORMAL;
+
+ /* register vcom device */
+ rt_hw_serial_register(&serial3, "uart3",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart3);
+ rt_hw_interrupt_install(uart3.irq, rt_at91_usart_handler,
+ (void *)&(serial3.parent), "UART3");
+ rt_hw_interrupt_umask(uart3.irq);
+#endif
+}
+
+#ifdef RT_USING_DBGU
+void rt_dbgu_isr(void)
+{
+ rt_at91_usart_handler(dbgu.irq, &(serial_dbgu.parent));
+}
+#endif
+
+
diff --git a/bsp/at91sam9260/led.h b/bsp/at91sam9260/led.h
deleted file mode 100755
index 71fd6947e6..0000000000
--- a/bsp/at91sam9260/led.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __LED_H__
-#define __LED_H__
-
-void led_init(void);
-void led_on(int num);
-void led_off(int num);
-
-#endif
diff --git a/bsp/at91sam9260/platform/SConscript b/bsp/at91sam9260/platform/SConscript
new file mode 100644
index 0000000000..1f5de6e772
--- /dev/null
+++ b/bsp/at91sam9260/platform/SConscript
@@ -0,0 +1,26 @@
+Import('RTT_ROOT')
+Import('rtconfig')
+from building import *
+
+cwd = GetCurrentDir()
+CPPPATH = [cwd]
+
+# The set of source files associated with this SConscript file.
+if rtconfig.PLATFORM == 'armcc':
+ src = Glob('*.c') + Glob('*_rvds.S')
+
+if rtconfig.PLATFORM == 'gcc':
+ src = Glob('*.c') + Glob('*_gcc.S') + Glob('*_init.S')
+
+if rtconfig.PLATFORM == 'iar':
+ src = Glob('*.c') + Glob('*_iar.S')
+
+if rtconfig.PLATFORM == 'cl':
+ src = Glob('*.c')
+
+if rtconfig.PLATFORM == 'mingw':
+ src = Glob('*.c')
+
+group = DefineGroup('platform', src, depend = [''], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/libcpu/arm/at91sam926x/at91_aic.h b/bsp/at91sam9260/platform/at91_aic.h
index 6de01c4444..45bd63733d 100755..100644
--- a/libcpu/arm/at91sam926x/at91_aic.h
+++ b/bsp/at91sam9260/platform/at91_aic.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/platform/at91_pdc.h b/bsp/at91sam9260/platform/at91_pdc.h
new file mode 100644
index 0000000000..132a620126
--- /dev/null
+++ b/bsp/at91sam9260/platform/at91_pdc.h
@@ -0,0 +1,45 @@
+/*
+ * File : at91_pdc.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety first version
+ */
+
+#ifndef __AT91_PDC_H__
+#define __AT91_PDC_H__
+
+#define AT91_PDC_RPR 0x100 /* Receive Pointer Register */
+#define AT91_PDC_RCR 0x104 /* Receive Counter Register */
+#define AT91_PDC_TPR 0x108 /* Transmit Pointer Register */
+#define AT91_PDC_TCR 0x10c /* Transmit Counter Register */
+#define AT91_PDC_RNPR 0x110 /* Receive Next Pointer Register */
+#define AT91_PDC_RNCR 0x114 /* Receive Next Counter Register */
+#define AT91_PDC_TNPR 0x118 /* Transmit Next Pointer Register */
+#define AT91_PDC_TNCR 0x11c /* Transmit Next Counter Register */
+
+#define AT91_PDC_PTCR 0x120 /* Transfer Control Register */
+#define AT91_PDC_RXTEN (1 << 0) /* Receiver Transfer Enable */
+#define AT91_PDC_RXTDIS (1 << 1) /* Receiver Transfer Disable */
+#define AT91_PDC_TXTEN (1 << 8) /* Transmitter Transfer Enable */
+#define AT91_PDC_TXTDIS (1 << 9) /* Transmitter Transfer Disable */
+
+#define AT91_PDC_PTSR 0x124 /* Transfer Status Register */
+
+#endif
diff --git a/libcpu/arm/at91sam926x/at91_pio.h b/bsp/at91sam9260/platform/at91_pio.h
index 917d1e2c9d..7aed6f42ed 100755..100644
--- a/libcpu/arm/at91sam926x/at91_pio.h
+++ b/bsp/at91sam9260/platform/at91_pio.h
@@ -3,9 +3,20 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_pit.h b/bsp/at91sam9260/platform/at91_pit.h
index 00e2df1f3e..5a960f454d 100755..100644
--- a/libcpu/arm/at91sam926x/at91_pit.h
+++ b/bsp/at91sam9260/platform/at91_pit.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_pmc.h b/bsp/at91sam9260/platform/at91_pmc.h
index 39e7699d1c..17319545c4 100755..100644
--- a/libcpu/arm/at91sam926x/at91_pmc.h
+++ b/bsp/at91sam9260/platform/at91_pmc.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_rstc.h b/bsp/at91sam9260/platform/at91_rstc.h
index efa302830d..c49cf15fcd 100755..100644
--- a/libcpu/arm/at91sam926x/at91_rstc.h
+++ b/bsp/at91sam9260/platform/at91_rstc.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_serial.h b/bsp/at91sam9260/platform/at91_serial.h
index 6c476d3f6f..be314f7ea0 100755..100644
--- a/libcpu/arm/at91sam926x/at91_serial.h
+++ b/bsp/at91sam9260/platform/at91_serial.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_shdwc.h b/bsp/at91sam9260/platform/at91_shdwc.h
index 059a22e121..fb99465f22 100755..100644
--- a/libcpu/arm/at91sam926x/at91_shdwc.h
+++ b/bsp/at91sam9260/platform/at91_shdwc.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91_tc.h b/bsp/at91sam9260/platform/at91_tc.h
index f7fb920baa..a3480701f4 100755..100644
--- a/libcpu/arm/at91sam926x/at91_tc.h
+++ b/bsp/at91sam9260/platform/at91_tc.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91sam9260_matrix.h b/bsp/at91sam9260/platform/at91sam9260_matrix.h
index 4405c58b8f..340d4a6f40 100755..100644
--- a/libcpu/arm/at91sam926x/at91sam9260_matrix.h
+++ b/bsp/at91sam9260/platform/at91sam9260_matrix.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/at91sam926x.h b/bsp/at91sam9260/platform/at91sam926x.h
index 8f164edb1b..add608d14c 100755..100644
--- a/libcpu/arm/at91sam926x/at91sam926x.h
+++ b/bsp/at91sam9260/platform/at91sam926x.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -95,7 +105,8 @@ extern "C" {
#define AT91SAM9260_BASE_TC4 0xfffdc040
#define AT91SAM9260_BASE_TC5 0xfffdc080
#define AT91SAM9260_BASE_ADC 0xfffe0000
-#define AT91_BASE_SYS 0xffffe800
+#define AT91_BASE_SYS 0xffffe800
+#define AT91SAM9260_BASE_DBGU 0xfffff200
/*
* System Peripherals (offset from AT91_BASE_SYS)
diff --git a/libcpu/arm/at91sam926x/gpio.h b/bsp/at91sam9260/platform/gpio.h
index 1872d3d68d..eb2e8a9595 100644
--- a/libcpu/arm/at91sam926x/gpio.h
+++ b/bsp/at91sam9260/platform/gpio.h
@@ -1,3 +1,27 @@
+/*
+ * File : gpio.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety first version
+ */
+
#ifndef __GPIO_H__
#define __GPIO_H__
diff --git a/libcpu/arm/at91sam926x/interrupt.c b/bsp/at91sam9260/platform/interrupt.c
index 0a1809e43b..099345ef11 100755..100644
--- a/libcpu/arm/at91sam926x/interrupt.c
+++ b/bsp/at91sam9260/platform/interrupt.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/io.h b/bsp/at91sam9260/platform/io.h
index 3afdd1ceff..5cb9cac782 100755..100644
--- a/libcpu/arm/at91sam926x/io.h
+++ b/bsp/at91sam9260/platform/io.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/irq.h b/bsp/at91sam9260/platform/irq.h
index b56d9a1f79..fe1fea41d0 100755..100644
--- a/libcpu/arm/at91sam926x/irq.h
+++ b/bsp/at91sam9260/platform/irq.h
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/at91sam9260/platform/reset.c b/bsp/at91sam9260/platform/reset.c
new file mode 100644
index 0000000000..4be76e69a1
--- /dev/null
+++ b/bsp/at91sam9260/platform/reset.c
@@ -0,0 +1,44 @@
+/*
+ * File : reset.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-01-13 weety modified from mini2440
+ */
+
+#include <rthw.h>
+#include <rtthread.h>
+#include "at91sam926x.h"
+
+/**
+ * @addtogroup AT91SAM926X
+ */
+/*@{*/
+
+void machine_reset(void)
+{
+ at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
+}
+
+void machine_shutdown(void)
+{
+ at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
+}
+
+/*@}*/
diff --git a/libcpu/arm/at91sam926x/start_gcc.S b/bsp/at91sam9260/platform/start_gcc.S
index f2ac7ad6e7..b5c7897938 100755..100644
--- a/libcpu/arm/at91sam926x/start_gcc.S
+++ b/bsp/at91sam9260/platform/start_gcc.S
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http:/*openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/start_rvds.S b/bsp/at91sam9260/platform/start_rvds.S
index 49ad09ea17..58661f9cb0 100644
--- a/libcpu/arm/at91sam926x/start_rvds.S
+++ b/bsp/at91sam9260/platform/start_rvds.S
@@ -3,9 +3,19 @@
; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team
; *
-; * The license and distribution terms for this file may be
-; * found in the file LICENSE in this distribution or at
-; * http://www.rt-thread.org/license/LICENSE
+; * This program 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 2 of the License, or
+; * (at your option) any later version.
+; *
+; * This program 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, write to the Free Software Foundation, Inc.,
+; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; *
; * Change Logs:
; * Date Author Notes
diff --git a/libcpu/arm/at91sam926x/system_clock.c b/bsp/at91sam9260/platform/system_clock.c
index 8af42bfccf..13f11609d2 100755..100644
--- a/libcpu/arm/at91sam926x/system_clock.c
+++ b/bsp/at91sam9260/platform/system_clock.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/trap.c b/bsp/at91sam9260/platform/trap.c
index 9be71ddcae..7fd4011451 100755..100644
--- a/libcpu/arm/at91sam926x/trap.c
+++ b/bsp/at91sam9260/platform/trap.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -156,7 +166,6 @@ void rt_hw_trap_irq()
at91_sys_write(AT91_AIC_EOICR, 0);
return;
}
- //at91_sys_write(AT91_AIC_EOICR, 0x55555555);
/* get interrupt service routine */
isr_func = irq_desc[irq].handler;
diff --git a/bsp/at91sam9260/rtconfig.h b/bsp/at91sam9260/rtconfig.h
index ab5f3e5c51..176c84c0a0 100755
--- a/bsp/at91sam9260/rtconfig.h
+++ b/bsp/at91sam9260/rtconfig.h
@@ -62,18 +62,27 @@
/* Using SLAB Allocator */
#define RT_USING_SLAB
-/* SECTION: Device System */
-/* Using Device System */
-#define RT_USING_DEVICE
+/* SECTION: the runtime libc library */
+/* the runtime libc library */
+#define RT_USING_NEWLIB
+#define RT_USING_PTHREADS
/* Using Module System */
#define RT_USING_MODULE
#define RT_USING_LIBDL
+/* SECTION: Device System */
+/* Using Device System */
+#define RT_USING_DEVICE
+
+#define RT_USING_DEVICE_IPC
+#define RT_USING_SERIAL
+
/* SECTION: Console options */
#define RT_USING_CONSOLE
/* the buffer size of console */
#define RT_CONSOLEBUF_SIZE 128
+#define RT_CONSOLE_DEVICE_NAME "dbgu"
/* SECTION: finsh, a C-Express shell */
/* Using FinSH as Shell*/
@@ -83,11 +92,6 @@
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_STACK_SIZE 4096
-/* SECTION: the runtime libc library */
-/* the runtime libc library */
-#define RT_USING_NEWLIB
-#define RT_USING_PTHREADS
-
/* SECTION: C++ support */
/* Using C++ support */
/* #define RT_USING_CPLUSPLUS */
diff --git a/bsp/at91sam9260/rtconfig.py b/bsp/at91sam9260/rtconfig.py
index 07432cedc0..10870f8807 100755
--- a/bsp/at91sam9260/rtconfig.py
+++ b/bsp/at91sam9260/rtconfig.py
@@ -2,7 +2,7 @@ import os
# toolchains options
ARCH = 'arm'
-CPU = 'at91sam926x'
+CPU = 'arm926'
TextBase = '0x20000000'
CROSS_TOOL = 'gcc'
diff --git a/libcpu/arm/at91sam926x/context_gcc.S b/libcpu/arm/arm926/context_gcc.S
index 30d8235331..a3f07a1860 100755..100644
--- a/libcpu/arm/at91sam926x/context_gcc.S
+++ b/libcpu/arm/arm926/context_gcc.S
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/arm/at91sam926x/context_rvds.S b/libcpu/arm/arm926/context_rvds.S
index 86f13dd1ba..631da83372 100644
--- a/libcpu/arm/at91sam926x/context_rvds.S
+++ b/libcpu/arm/arm926/context_rvds.S
@@ -3,9 +3,19 @@
; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team
; *
-; * The license and distribution terms for this file may be
-; * found in the file LICENSE in this distribution or at
-; * http://www.rt-thread.org/license/LICENSE
+; * This program 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 2 of the License, or
+; * (at your option) any later version.
+; *
+; * This program 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, write to the Free Software Foundation, Inc.,
+; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; *
; * Change Logs:
; * Date Author Notes
diff --git a/libcpu/arm/at91sam926x/cpu.c b/libcpu/arm/arm926/cpuport.c
index dce573c83d..9908471a5c 100755..100644
--- a/libcpu/arm/at91sam926x/cpu.c
+++ b/libcpu/arm/arm926/cpuport.c
@@ -3,9 +3,19 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -14,16 +24,13 @@
#include <rthw.h>
#include <rtthread.h>
-#include "at91sam926x.h"
-
-/**
- * @addtogroup AT91SAM926X
- */
-/*@{*/
#define ICACHE_MASK (rt_uint32_t)(1 << 12)
#define DCACHE_MASK (rt_uint32_t)(1 << 2)
+extern void machine_reset(void);
+extern void machine_shutdown(void);
+
#ifdef __GNUC__
rt_inline rt_uint32_t cp15_rd(void)
{
@@ -148,16 +155,6 @@ rt_base_t rt_hw_cpu_dcache_status()
return (cp15_rd() & DCACHE_MASK);
}
-static void at91sam9260_reset(void)
-{
- at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
-}
-
-static void at91sam9260_poweroff(void)
-{
- at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
-}
-
/**
* reset cpu by dog's time-out
*
@@ -166,7 +163,7 @@ void rt_hw_cpu_reset()
{
rt_kprintf("Restarting system...\n");
- at91sam9260_reset();
+ machine_reset();
while(1); /* loop forever and wait for reset to happen */
@@ -183,7 +180,7 @@ void rt_hw_cpu_shutdown()
rt_kprintf("shutdown...\n");
level = rt_hw_interrupt_disable();
- at91sam9260_poweroff();
+ machine_shutdown();
while (level)
{
RT_ASSERT(0);
diff --git a/libcpu/arm/at91sam926x/mmu.c b/libcpu/arm/arm926/mmu.c
index 5b88eee27c..debb88f267 100644
--- a/libcpu/arm/at91sam926x/mmu.c
+++ b/libcpu/arm/arm926/mmu.c
@@ -3,39 +3,25 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
-#include <rtthread.h>
-
-#define CACHE_LINE_SIZE 32
-
-#define DESC_SEC (0x2|(1<<4))
-#define CB (3<<2) //cache_on, write_back
-#define CNB (2<<2) //cache_on, write_through
-#define NCB (1<<2) //cache_off,WR_BUF on
-#define NCNB (0<<2) //cache_off,WR_BUF off
-#define AP_RW (3<<10) //supervisor=RW, user=RW
-#define AP_RO (2<<10) //supervisor=RW, user=RO
-
-#define DOMAIN_FAULT (0x0)
-#define DOMAIN_CHK (0x1)
-#define DOMAIN_NOTCHK (0x3)
-#define DOMAIN0 (0x0<<5)
-#define DOMAIN1 (0x1<<5)
-
-#define DOMAIN0_ATTR (DOMAIN_CHK<<0)
-#define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
-
-#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */
-#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */
-#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
-#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
+#include "mmu.h"
#ifdef __CC_ARM
void mmu_setttbase(rt_uint32_t i)
@@ -459,7 +445,7 @@ void mmu_setmtt(rt_uint32_t vaddrStart, rt_uint32_t vaddrEnd, rt_uint32_t paddrS
}
}
-void rt_hw_mmu_init(void)
+void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size)
{
/* disable I/D cache */
mmu_disable_dcache();
@@ -468,11 +454,12 @@ void rt_hw_mmu_init(void)
mmu_invalidate_tlb();
/* set page table */
- mmu_setmtt(0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB); /* None cached for 4G memory */
- mmu_setmtt(0x20000000, 0x24000000-1, 0x20000000, RW_CB); /* 64M cached SDRAM memory */
- mmu_setmtt(0x00000000, 0x100000, 0x20000000, RW_CB); /* isr vector table */
- mmu_setmtt(0x90000000, 0x90400000 - 1, 0x00200000, RW_NCNB); /* 4K SRAM0 + 4k SRAM1 */
- mmu_setmtt(0xA0000000, 0xA4000000-1, 0x20000000, RW_NCNB); /* 64M none-cached SDRAM memory */
+ for (; size > 0; size--)
+ {
+ mmu_setmtt(mdesc->vaddr_start, mdesc->vaddr_end,
+ mdesc->paddr_start, mdesc->attr);
+ mdesc++;
+ }
/* set MMU table address */
mmu_setttbase((rt_uint32_t)_page_table);
diff --git a/libcpu/arm/arm926/mmu.h b/libcpu/arm/arm926/mmu.h
new file mode 100644
index 0000000000..d6c497efb9
--- /dev/null
+++ b/libcpu/arm/arm926/mmu.h
@@ -0,0 +1,63 @@
+/*
+ * File : mmu.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
+#ifndef __MMU_H__
+#define __MMU_H__
+
+#include <rtthread.h>
+
+#define CACHE_LINE_SIZE 32
+
+#define DESC_SEC (0x2|(1<<4))
+#define CB (3<<2) //cache_on, write_back
+#define CNB (2<<2) //cache_on, write_through
+#define NCB (1<<2) //cache_off,WR_BUF on
+#define NCNB (0<<2) //cache_off,WR_BUF off
+#define AP_RW (3<<10) //supervisor=RW, user=RW
+#define AP_RO (2<<10) //supervisor=RW, user=RO
+
+#define DOMAIN_FAULT (0x0)
+#define DOMAIN_CHK (0x1)
+#define DOMAIN_NOTCHK (0x3)
+#define DOMAIN0 (0x0<<5)
+#define DOMAIN1 (0x1<<5)
+
+#define DOMAIN0_ATTR (DOMAIN_CHK<<0)
+#define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
+
+#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */
+#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */
+#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
+#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
+
+struct mem_desc {
+ rt_uint32_t vaddr_start;
+ rt_uint32_t vaddr_end;
+ rt_uint32_t paddr_start;
+ rt_uint32_t attr;
+};
+
+void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size);
+
+#endif
+
diff --git a/libcpu/arm/at91sam926x/stack.c b/libcpu/arm/arm926/stack.c
index 7075fcff80..f58b43cbd4 100755..100644
--- a/libcpu/arm/at91sam926x/stack.c
+++ b/libcpu/arm/arm926/stack.c
@@ -3,21 +3,37 @@
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2011-01-13 weety copy from mini2440
*/
#include <rtthread.h>
-#include "at91sam926x.h"
-/**
- * @addtogroup AT91SAM926X
- */
-/*@{*/
+/*****************************/
+/* CPU Mode */
+/*****************************/
+#define USERMODE 0x10
+#define FIQMODE 0x11
+#define IRQMODE 0x12
+#define SVCMODE 0x13
+#define ABORTMODE 0x17
+#define UNDEFMODE 0x1b
+#define MODEMASK 0x1f
+#define NOINT 0xc0
/**
* This function will initialize thread stack
@@ -57,4 +73,3 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
return (rt_uint8_t *)stk;
}
-/*@}*/
diff --git a/libcpu/arm/at91sam926x/at91_pdc.h b/libcpu/arm/at91sam926x/at91_pdc.h
deleted file mode 100755
index 1e52944c92..0000000000
--- a/libcpu/arm/at91sam926x/at91_pdc.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __AT91_PDC_H__
-#define __AT91_PDC_H__
-
-#define AT91_PDC_RPR 0x100 /* Receive Pointer Register */
-#define AT91_PDC_RCR 0x104 /* Receive Counter Register */
-#define AT91_PDC_TPR 0x108 /* Transmit Pointer Register */
-#define AT91_PDC_TCR 0x10c /* Transmit Counter Register */
-#define AT91_PDC_RNPR 0x110 /* Receive Next Pointer Register */
-#define AT91_PDC_RNCR 0x114 /* Receive Next Counter Register */
-#define AT91_PDC_TNPR 0x118 /* Transmit Next Pointer Register */
-#define AT91_PDC_TNCR 0x11c /* Transmit Next Counter Register */
-
-#define AT91_PDC_PTCR 0x120 /* Transfer Control Register */
-#define AT91_PDC_RXTEN (1 << 0) /* Receiver Transfer Enable */
-#define AT91_PDC_RXTDIS (1 << 1) /* Receiver Transfer Disable */
-#define AT91_PDC_TXTEN (1 << 8) /* Transmitter Transfer Enable */
-#define AT91_PDC_TXTDIS (1 << 9) /* Transmitter Transfer Disable */
-
-#define AT91_PDC_PTSR 0x124 /* Transfer Status Register */
-
-#endif
diff --git a/libcpu/arm/at91sam926x/serial.c b/libcpu/arm/at91sam926x/serial.c
deleted file mode 100755
index a5136f5d10..0000000000
--- a/libcpu/arm/at91sam926x/serial.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * File : serial.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2011-01-13 weety first version
- */
-
-#include <rtthread.h>
-
-#include "serial.h"
-
-/**
- * @addtogroup AT91SAM926X
- */
-/*@{*/
-
-/* RT-Thread Device Interface */
-/**
- * This function initializes serial
- */
-static rt_err_t rt_serial_init (rt_device_t dev)
-{
- struct serial_device* uart = (struct serial_device*) dev->user_data;
-
- if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
- {
-
- if (dev->flag & RT_DEVICE_FLAG_INT_RX)
- {
- rt_memset(uart->int_rx->rx_buffer, 0,
- sizeof(uart->int_rx->rx_buffer));
- uart->int_rx->read_index = uart->int_rx->save_index = 0;
- }
-
- if (dev->flag & RT_DEVICE_FLAG_INT_TX)
- {
- rt_memset(uart->int_tx->tx_buffer, 0,
- sizeof(uart->int_tx->tx_buffer));
- uart->int_tx->write_index = uart->int_tx->save_index = 0;
- }
-
- dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
- }
-
- return RT_EOK;
-}
-
-/* save a char to serial buffer */
-static void rt_serial_savechar(struct serial_device* uart, char ch)
-{
- rt_base_t level;
-
- /* disable interrupt */
- level = rt_hw_interrupt_disable();
-
- uart->int_rx->rx_buffer[uart->int_rx->save_index] = ch;
- uart->int_rx->save_index ++;
- if (uart->int_rx->save_index >= UART_RX_BUFFER_SIZE)
- uart->int_rx->save_index = 0;
-
- /* if the next position is read index, discard this 'read char' */
- if (uart->int_rx->save_index == uart->int_rx->read_index)
- {
- uart->int_rx->read_index ++;
- if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
- uart->int_rx->read_index = 0;
- }
-
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
-}
-
-static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
-{
- RT_ASSERT(dev != RT_NULL);
-
- return RT_EOK;
-}
-
-static rt_err_t rt_serial_close(rt_device_t dev)
-{
- RT_ASSERT(dev != RT_NULL);
-
- return RT_EOK;
-}
-
-static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
-{
- rt_uint8_t* ptr;
- rt_err_t err_code;
- struct serial_device* uart;
-
- ptr = buffer;
- err_code = RT_EOK;
- uart = (struct serial_device*)dev->user_data;
-
- if (dev->flag & RT_DEVICE_FLAG_INT_RX)
- {
- rt_base_t level;
-
- /* interrupt mode Rx */
- while (size)
- {
- if (uart->int_rx->read_index != uart->int_rx->save_index)
- {
- *ptr++ = uart->int_rx->rx_buffer[uart->int_rx->read_index];
- size --;
-
- /* disable interrupt */
- level = rt_hw_interrupt_disable();
-
- uart->int_rx->read_index ++;
- if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
- uart->int_rx->read_index = 0;
-
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
- }
- else
- {
- /* set error code */
- err_code = -RT_EEMPTY;
- break;
- }
- }
- }
- else
- {
- /* polling mode */
- while ((rt_uint32_t)ptr - (rt_uint32_t)buffer < size)
- {
- while (uart->uart_device->USART_CSR & RXRDY)
- {
- *ptr = uart->uart_device->USART_RHR & 0xff;
- ptr ++;
- }
- }
- }
-
- /* set error code */
- rt_set_errno(err_code);
- return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
-}
-
-static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
-{
- rt_uint8_t* ptr;
- rt_err_t err_code;
- struct serial_device* uart;
-
- err_code = RT_EOK;
- ptr = (rt_uint8_t*)buffer;
- uart = (struct serial_device*)dev->user_data;
-
- if (dev->flag & RT_DEVICE_FLAG_INT_TX)
- {
- /* interrupt mode Tx */
- while (uart->int_tx->save_index != uart->int_tx->write_index)
- {
- /* save on tx buffer */
- uart->int_tx->tx_buffer[uart->int_tx->save_index] = *ptr++;
-
- -- size;
-
- /* move to next position */
- uart->int_tx->save_index ++;
-
- /* wrap save index */
- if (uart->int_tx->save_index >= UART_TX_BUFFER_SIZE)
- uart->int_tx->save_index = 0;
- }
-
- /* set error code */
- if (size > 0)
- err_code = -RT_EFULL;
- }
- else
- {
- /* polling mode */
- while (size)
- {
- /*
- * to be polite with serial console add a line feed
- * to the carriage return character
- */
- if (*ptr == '\n' && (dev->flag & RT_DEVICE_FLAG_STREAM))
- {
- while (!(uart->uart_device->USART_CSR & TXRDY));
- uart->uart_device->USART_THR = '\r';
- }
-
- while (!(uart->uart_device->USART_CSR & TXRDY));
- uart->uart_device->USART_THR = (*ptr & 0xFF);
-
- ++ptr; --size;
- }
- }
-
- /* set error code */
- rt_set_errno(err_code);
-
- return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
-}
-
-static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
-{
- RT_ASSERT(dev != RT_NULL);
-
- switch (cmd)
- {
- case RT_DEVICE_CTRL_SUSPEND:
- /* suspend device */
- dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
- break;
-
- case RT_DEVICE_CTRL_RESUME:
- /* resume device */
- dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
- break;
- }
-
- return RT_EOK;
-}
-
-/*
- * serial register
- */
-rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial)
-{
- RT_ASSERT(device != RT_NULL);
-
- device->type = RT_Device_Class_Char;
- device->rx_indicate = RT_NULL;
- device->tx_complete = RT_NULL;
- device->init = rt_serial_init;
- device->open = rt_serial_open;
- device->close = rt_serial_close;
- device->read = rt_serial_read;
- device->write = rt_serial_write;
- device->control = rt_serial_control;
- device->user_data = serial;
-
- /* register a character device */
- return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
-}
-
-/* ISR for serial interrupt */
-void rt_hw_serial_isr(rt_device_t device)
-{
- struct serial_device* uart = (struct serial_device*) device->user_data;
-
- /* interrupt mode receive */
- RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
-
- /* save on rx buffer */
- while (uart->uart_device->USART_CSR & RXRDY)
- {
- rt_serial_savechar(uart, uart->uart_device->USART_RHR & 0xff);
- }
-
- /* invoke callback */
- if (device->rx_indicate != RT_NULL)
- {
- rt_size_t rx_length;
-
- /* get rx length */
- rx_length = uart->int_rx->read_index > uart->int_rx->save_index ?
- UART_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
- uart->int_rx->save_index - uart->int_rx->read_index;
-
- device->rx_indicate(device, rx_length);
- }
-}
-
-/*@}*/
diff --git a/libcpu/arm/at91sam926x/serial.h b/libcpu/arm/at91sam926x/serial.h
deleted file mode 100755
index 67f6d3c659..0000000000
--- a/libcpu/arm/at91sam926x/serial.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef __RT_HW_SERIAL_H__
-#define __RT_HW_SERIAL_H__
-
-#include <rthw.h>
-#include <rtthread.h>
-
-#include "at91sam926x.h"
-
-#define RXRDY 0x01
-#define TXRDY (1 << 1)
-#define BPS 115200 /* serial baudrate */
-
-#define UART_RX_BUFFER_SIZE 64
-#define UART_TX_BUFFER_SIZE 64
-
-struct serial_int_rx
-{
- rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
- rt_uint32_t read_index, save_index;
-};
-
-struct serial_int_tx
-{
- rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE];
- rt_uint32_t write_index, save_index;
-};
-
-typedef struct uartport
-{
-/* USART register offsets */
- volatile rt_uint32_t USART_CR;
- volatile rt_uint32_t USART_MR;
- volatile rt_uint32_t USART_IER;
- volatile rt_uint32_t USART_IDR;
- volatile rt_uint32_t USART_IMR;
- volatile rt_uint32_t USART_CSR;
- volatile rt_uint32_t USART_RHR;
- volatile rt_uint32_t USART_THR;
- volatile rt_uint32_t USART_BRGR;
- volatile rt_uint32_t USART_RTOR;
- volatile rt_uint32_t USART_TTGR;
- volatile rt_uint32_t reseverd0[5];
- volatile rt_uint32_t USART_FIDI;
- volatile rt_uint32_t USART_NER;
- volatile rt_uint32_t USART_XXR;
- volatile rt_uint32_t USART_IFR;
- volatile rt_uint32_t reserved1[44];
- volatile rt_uint32_t USART_RPR;
- volatile rt_uint32_t USART_RCR;
- volatile rt_uint32_t USART_TPR;
- volatile rt_uint32_t USART_TCR;
- volatile rt_uint32_t USART_RNPR;
- volatile rt_uint32_t USART_RNCR;
- volatile rt_uint32_t USART_TNPR;
- volatile rt_uint32_t USART_TNCR;
- volatile rt_uint32_t USART_PTCR;
- volatile rt_uint32_t USART_PTSR;
-}uartport;
-
-
-struct serial_device
-{
- uartport* uart_device;
-
- /* rx structure */
- struct serial_int_rx* int_rx;
-
- /* tx structure */
- struct serial_int_tx* int_tx;
-};
-
-rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial);
-
-void rt_hw_serial_isr(rt_device_t device);
-
-#endif