summaryrefslogtreecommitdiff
path: root/bsp/nios_ii
diff options
context:
space:
mode:
authorMing, Bai <[email protected]>2013-01-08 22:40:58 +0800
committerMing, Bai <[email protected]>2013-01-08 22:40:58 +0800
commitb4de7cce57305033e86c3b187271683b609ddb26 (patch)
tree5380a19a3f6bced1d04439a94bf1f76fffb3a179 /bsp/nios_ii
parentf3192c229349119dfd8361a09a52fbab6f99f97e (diff)
Re-normalizing the repo
Diffstat (limited to 'bsp/nios_ii')
-rw-r--r--bsp/nios_ii/application.c228
-rw-r--r--bsp/nios_ii/board.c174
-rw-r--r--bsp/nios_ii/board.h44
-rw-r--r--bsp/nios_ii/get_update_finsh.sh6
-rw-r--r--bsp/nios_ii/get_update_rt-thread.sh14
-rw-r--r--bsp/nios_ii/readme_cn.txt78
-rw-r--r--bsp/nios_ii/readme_en.txt2
-rw-r--r--bsp/nios_ii/rtconfig.h294
-rw-r--r--bsp/nios_ii/startup.c198
-rw-r--r--bsp/nios_ii/uart.c244
-rw-r--r--bsp/nios_ii/uart.h12
11 files changed, 647 insertions, 647 deletions
diff --git a/bsp/nios_ii/application.c b/bsp/nios_ii/application.c
index eeca09a9f1..22037c8f9a 100644
--- a/bsp/nios_ii/application.c
+++ b/bsp/nios_ii/application.c
@@ -1,114 +1,114 @@
-/*
- * File : application.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006-2011, 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
- *
- * Change Logs:
- * Date Author Notes
- * 2011-02-14 aozima first implementation for Nios II.
- * 2011-03-04 aozima add led.
- */
-
-#include <rtthread.h>
-#include "board.h"
-
-/**
- * @addtogroup NIOS_II
- */
-
-/*@{*/
-
-#include "system.h"
-#include "altera_avalon_pio_regs.h"
-
-// trun on led n
-#define rt_hw_led_on(n) IOWR_ALTERA_AVALON_PIO_DATA(\
- LED_BASE,\
- IORD_ALTERA_AVALON_PIO_DATA(LED_BASE) | 1<<n)
-// trun off led n
-#define rt_hw_led_off(n) IOWR_ALTERA_AVALON_PIO_DATA(\
- LED_BASE,\
- IORD_ALTERA_AVALON_PIO_DATA(LED_BASE) & ~(1<<n) )
-
-ALIGN(RT_ALIGN_SIZE)
-static char thread_led1_stack[1024];
-struct rt_thread thread_led1;
-static void rt_thread_entry_led1(void* parameter)
-{
- unsigned int count=0;
- while (1)
- {
- /* led1 on */
-#ifndef RT_USING_FINSH
- rt_kprintf("led1 on,count : %d\r\n",count);
-#endif
- count++;
- rt_hw_led_on(1);
- /* sleep 0.5 second and switch to other thread */
- rt_thread_delay(RT_TICK_PER_SECOND/2);
-
- /* led1 off */
-#ifndef RT_USING_FINSH
- rt_kprintf("led1 off\r\n");
-#endif
- rt_hw_led_off(1);
- rt_thread_delay(RT_TICK_PER_SECOND/2);
- }
-}
-
-ALIGN(RT_ALIGN_SIZE)
-static char thread_led2_stack[1024];
-struct rt_thread thread_led2;
-void rt_thread_entry_led2(void* parameter)
-{
- unsigned int count=0;
- while (1)
- {
- /* led2 on */
-#ifndef RT_USING_FINSH
- rt_kprintf("led2 on,count : %d\r\n",count);
-#endif
- count++;
- rt_hw_led_on(2);
- rt_thread_delay(RT_TICK_PER_SECOND);
-
- /* led2 off */
-#ifndef RT_USING_FINSH
- rt_kprintf("led2 off\r\n");
-#endif
- rt_hw_led_off(2);
- rt_thread_delay(RT_TICK_PER_SECOND);
- }
-}
-
-int rt_application_init()
-{
- // led_init();
-
- //------- init led1 thread
- rt_thread_init(&thread_led1,
- "led1",
- rt_thread_entry_led1,
- RT_NULL,
- &thread_led1_stack[0],
- sizeof(thread_led1_stack),11,5);
- rt_thread_startup(&thread_led1);
-
- //------- init led2 thread
- rt_thread_init(&thread_led2,
- "led2",
- rt_thread_entry_led2,
- RT_NULL,
- &thread_led2_stack[0],
- sizeof(thread_led2_stack),12,5);
- rt_thread_startup(&thread_led2);
-
- return 0;
-}
-
-/*@}*/
-
+/*
+ * File : application.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2011, 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-02-14 aozima first implementation for Nios II.
+ * 2011-03-04 aozima add led.
+ */
+
+#include <rtthread.h>
+#include "board.h"
+
+/**
+ * @addtogroup NIOS_II
+ */
+
+/*@{*/
+
+#include "system.h"
+#include "altera_avalon_pio_regs.h"
+
+// trun on led n
+#define rt_hw_led_on(n) IOWR_ALTERA_AVALON_PIO_DATA(\
+ LED_BASE,\
+ IORD_ALTERA_AVALON_PIO_DATA(LED_BASE) | 1<<n)
+// trun off led n
+#define rt_hw_led_off(n) IOWR_ALTERA_AVALON_PIO_DATA(\
+ LED_BASE,\
+ IORD_ALTERA_AVALON_PIO_DATA(LED_BASE) & ~(1<<n) )
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread_led1_stack[1024];
+struct rt_thread thread_led1;
+static void rt_thread_entry_led1(void* parameter)
+{
+ unsigned int count=0;
+ while (1)
+ {
+ /* led1 on */
+#ifndef RT_USING_FINSH
+ rt_kprintf("led1 on,count : %d\r\n",count);
+#endif
+ count++;
+ rt_hw_led_on(1);
+ /* sleep 0.5 second and switch to other thread */
+ rt_thread_delay(RT_TICK_PER_SECOND/2);
+
+ /* led1 off */
+#ifndef RT_USING_FINSH
+ rt_kprintf("led1 off\r\n");
+#endif
+ rt_hw_led_off(1);
+ rt_thread_delay(RT_TICK_PER_SECOND/2);
+ }
+}
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread_led2_stack[1024];
+struct rt_thread thread_led2;
+void rt_thread_entry_led2(void* parameter)
+{
+ unsigned int count=0;
+ while (1)
+ {
+ /* led2 on */
+#ifndef RT_USING_FINSH
+ rt_kprintf("led2 on,count : %d\r\n",count);
+#endif
+ count++;
+ rt_hw_led_on(2);
+ rt_thread_delay(RT_TICK_PER_SECOND);
+
+ /* led2 off */
+#ifndef RT_USING_FINSH
+ rt_kprintf("led2 off\r\n");
+#endif
+ rt_hw_led_off(2);
+ rt_thread_delay(RT_TICK_PER_SECOND);
+ }
+}
+
+int rt_application_init()
+{
+ // led_init();
+
+ //------- init led1 thread
+ rt_thread_init(&thread_led1,
+ "led1",
+ rt_thread_entry_led1,
+ RT_NULL,
+ &thread_led1_stack[0],
+ sizeof(thread_led1_stack),11,5);
+ rt_thread_startup(&thread_led1);
+
+ //------- init led2 thread
+ rt_thread_init(&thread_led2,
+ "led2",
+ rt_thread_entry_led2,
+ RT_NULL,
+ &thread_led2_stack[0],
+ sizeof(thread_led2_stack),12,5);
+ rt_thread_startup(&thread_led2);
+
+ return 0;
+}
+
+/*@}*/
+
diff --git a/bsp/nios_ii/board.c b/bsp/nios_ii/board.c
index bc171c7dbf..2614a25095 100644
--- a/bsp/nios_ii/board.c
+++ b/bsp/nios_ii/board.c
@@ -1,87 +1,87 @@
-/*
- * File : board.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006-2011, 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
- *
- * Change Logs:
- * Date Author Notes
- * 2011-02-14 aozima first implementation for Nios II.
- */
-
-
-#include <rthw.h>
-#include <rtthread.h>
-
-#include <stdio.h>
-#include "system.h"
-#include "sys/alt_irq.h"
-#include "altera_avalon_timer_regs.h"
-
-#include "uart.h"
-
-extern int alt_irq_register (alt_u32 id,
- void* context,
- void (*alt_isr_func)(void* isr_context, alt_u32 id) );
-
-/**
- * @addtogroup NIOS_II
- */
-
-/*@{*/
-
-/**
- * This is the timer interrupt service routine.
- *
- */
-void rt_hw_timer_handler(void * context,unsigned long id)
-{
- void* base = (void*)TIMER_BASE;
-
- /* clear the interrupt */
- IOWR_ALTERA_AVALON_TIMER_STATUS (base, 0);
-
- /* enter interrupt */
- rt_interrupt_enter();
-
- rt_tick_increase();
-
- /* leave interrupt */
- rt_interrupt_leave();
-}
-
-void sysTick_config(void)
-{
- void* base = (void*)TIMER_BASE;
-
- IOWR_ALTERA_AVALON_TIMER_CONTROL (base,
- ALTERA_AVALON_TIMER_CONTROL_ITO_MSK |
- ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
- ALTERA_AVALON_TIMER_CONTROL_START_MSK);
-
- alt_irq_register (TIMER_IRQ, NULL, rt_hw_timer_handler);
-}
-
-static void rt_hw_show_info(void)
-{
- rt_kprintf("\r\n\r\n---------- board info ----------\r\n");
- rt_kprintf("ALT_DEVICE_FAMILY: %s\r\n",ALT_DEVICE_FAMILY);
- rt_kprintf("ALT_CPU_ARCHITECTURE: %s\r\n",ALT_CPU_ARCHITECTURE);
- rt_kprintf("ALT_CPU_CPU_FREQ: %uMHz\r\n",ALT_CPU_CPU_FREQ/1000000UL);
- rt_kprintf("memory size: at 0x%08X 0x%08X byte\r\n",SDRAM_BASE,SDRAM_SPAN);
-}
-
-void rt_hw_board_init(void)
-{
- rt_hw_uart_init();
- rt_console_set_device("uart");
- rt_hw_show_info();
-
- sysTick_config();
-}
-
-/*@}*/
-
+/*
+ * File : board.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2011, 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-02-14 aozima first implementation for Nios II.
+ */
+
+
+#include <rthw.h>
+#include <rtthread.h>
+
+#include <stdio.h>
+#include "system.h"
+#include "sys/alt_irq.h"
+#include "altera_avalon_timer_regs.h"
+
+#include "uart.h"
+
+extern int alt_irq_register (alt_u32 id,
+ void* context,
+ void (*alt_isr_func)(void* isr_context, alt_u32 id) );
+
+/**
+ * @addtogroup NIOS_II
+ */
+
+/*@{*/
+
+/**
+ * This is the timer interrupt service routine.
+ *
+ */
+void rt_hw_timer_handler(void * context,unsigned long id)
+{
+ void* base = (void*)TIMER_BASE;
+
+ /* clear the interrupt */
+ IOWR_ALTERA_AVALON_TIMER_STATUS (base, 0);
+
+ /* enter interrupt */
+ rt_interrupt_enter();
+
+ rt_tick_increase();
+
+ /* leave interrupt */
+ rt_interrupt_leave();
+}
+
+void sysTick_config(void)
+{
+ void* base = (void*)TIMER_BASE;
+
+ IOWR_ALTERA_AVALON_TIMER_CONTROL (base,
+ ALTERA_AVALON_TIMER_CONTROL_ITO_MSK |
+ ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
+ ALTERA_AVALON_TIMER_CONTROL_START_MSK);
+
+ alt_irq_register (TIMER_IRQ, NULL, rt_hw_timer_handler);
+}
+
+static void rt_hw_show_info(void)
+{
+ rt_kprintf("\r\n\r\n---------- board info ----------\r\n");
+ rt_kprintf("ALT_DEVICE_FAMILY: %s\r\n",ALT_DEVICE_FAMILY);
+ rt_kprintf("ALT_CPU_ARCHITECTURE: %s\r\n",ALT_CPU_ARCHITECTURE);
+ rt_kprintf("ALT_CPU_CPU_FREQ: %uMHz\r\n",ALT_CPU_CPU_FREQ/1000000UL);
+ rt_kprintf("memory size: at 0x%08X 0x%08X byte\r\n",SDRAM_BASE,SDRAM_SPAN);
+}
+
+void rt_hw_board_init(void)
+{
+ rt_hw_uart_init();
+ rt_console_set_device("uart");
+ rt_hw_show_info();
+
+ sysTick_config();
+}
+
+/*@}*/
+
diff --git a/bsp/nios_ii/board.h b/bsp/nios_ii/board.h
index a9a7faeff0..d7c6d3540f 100644
--- a/bsp/nios_ii/board.h
+++ b/bsp/nios_ii/board.h
@@ -1,22 +1,22 @@
-/*
- * File : board.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006-2011, 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
- *
- * Change Logs:
- * Date Author Notes
- * 2011-02-14 aozima first implementation for Nios II.
- */
-
-#ifndef BOARD_H_INCLUDED
-#define BOARD_H_INCLUDED
-
-#include <rthw.h>
-
-extern void rt_hw_board_init(void);
-
-#endif // BOARD_H_INCLUDED
+/*
+ * File : board.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2011, 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-02-14 aozima first implementation for Nios II.
+ */
+
+#ifndef BOARD_H_INCLUDED
+#define BOARD_H_INCLUDED
+
+#include <rthw.h>
+
+extern void rt_hw_board_init(void);
+
+#endif // BOARD_H_INCLUDED
diff --git a/bsp/nios_ii/get_update_finsh.sh b/bsp/nios_ii/get_update_finsh.sh
index ffa26da461..6cb2f2a2e8 100644
--- a/bsp/nios_ii/get_update_finsh.sh
+++ b/bsp/nios_ii/get_update_finsh.sh
@@ -1,3 +1,3 @@
-#!/bin/sh
-echo "get and update finsh"
-svn co https://rt-thread.googlecode.com/svn/trunk/components/finsh/ ./rt-thread/components/finsh
+#!/bin/sh
+echo "get and update finsh"
+svn co https://rt-thread.googlecode.com/svn/trunk/components/finsh/ ./rt-thread/components/finsh
diff --git a/bsp/nios_ii/get_update_rt-thread.sh b/bsp/nios_ii/get_update_rt-thread.sh
index 668d1aa6cc..8e9f5eafa5 100644
--- a/bsp/nios_ii/get_update_rt-thread.sh
+++ b/bsp/nios_ii/get_update_rt-thread.sh
@@ -1,7 +1,7 @@
-#!/bin/sh
-echo "get and update RT-Thread kernel source"
-svn co https://rt-thread.googlecode.com/svn/trunk/src/ ./rt-thread/src
-echo "get and update RT-Thread include file"
-svn co https://rt-thread.googlecode.com/svn/trunk/include/ ./rt-thread/include
-echo "get and update Nios II architecture for RT-Thread"
-svn co https://rt-thread.googlecode.com/svn/trunk/libcpu/nios/nios_ii/ ./rt-thread/libcpu/nios/nios_ii
+#!/bin/sh
+echo "get and update RT-Thread kernel source"
+svn co https://rt-thread.googlecode.com/svn/trunk/src/ ./rt-thread/src
+echo "get and update RT-Thread include file"
+svn co https://rt-thread.googlecode.com/svn/trunk/include/ ./rt-thread/include
+echo "get and update Nios II architecture for RT-Thread"
+svn co https://rt-thread.googlecode.com/svn/trunk/libcpu/nios/nios_ii/ ./rt-thread/libcpu/nios/nios_ii
diff --git a/bsp/nios_ii/readme_cn.txt b/bsp/nios_ii/readme_cn.txt
index 87b97705a2..6884bee2bf 100644
--- a/bsp/nios_ii/readme_cn.txt
+++ b/bsp/nios_ii/readme_cn.txt
@@ -1,39 +1,39 @@
-1. �����淽������һ���հ�Nios II����.
-2. ���ӱ�Ŀ¼������Դ�����ͷ�ļ�,������RT-Thread�ں˼�Nios II CPU����Ҫ���ļ�.
-��rt-thread
- ��
- ����include
- �� rtdef.h
- �� rthw.h
- �� rtm.h
- �� rtthread.h
- ��
- ����libcpu
- �� ����nios
- �� ����nios_ii
- �� context_gcc.S
- �� interrupt.c
- �� stack.c
- �� vector.S
- ��
- ����src
- clock.c
- device.c
- idle.c
- ipc.c
- irq.c
- kservice.c
- kservice.h
- mem.c
- mempool.c
- module.c
- module.h
- object.c
- rtm.c
- scheduler.c
- SConscript
- slab.c
- thread.c
- timer.c
-3. ����ͷ�ļ�����·��
-4. ������Ҫ�޸�rtconfig.h (Ĭ��Ϊ�����ں�)
+1. �����淽������һ���հ�Nios II����.
+2. ���ӱ�Ŀ¼������Դ�����ͷ�ļ�,������RT-Thread�ں˼�Nios II CPU����Ҫ���ļ�.
+��rt-thread
+ ��
+ ����include
+ �� rtdef.h
+ �� rthw.h
+ �� rtm.h
+ �� rtthread.h
+ ��
+ ����libcpu
+ �� ����nios
+ �� ����nios_ii
+ �� context_gcc.S
+ �� interrupt.c
+ �� stack.c
+ �� vector.S
+ ��
+ ����src
+ clock.c
+ device.c
+ idle.c
+ ipc.c
+ irq.c
+ kservice.c
+ kservice.h
+ mem.c
+ mempool.c
+ module.c
+ module.h
+ object.c
+ rtm.c
+ scheduler.c
+ SConscript
+ slab.c
+ thread.c
+ timer.c
+3. ����ͷ�ļ�����·��
+4. ������Ҫ�޸�rtconfig.h (Ĭ��Ϊ�����ں�)
diff --git a/bsp/nios_ii/readme_en.txt b/bsp/nios_ii/readme_en.txt
index b5a4eda5ac..d69bd3c5fc 100644
--- a/bsp/nios_ii/readme_en.txt
+++ b/bsp/nios_ii/readme_en.txt
@@ -1,2 +1,2 @@
-see readme_cn.txt
+see readme_cn.txt
^_^ \ No newline at end of file
diff --git a/bsp/nios_ii/rtconfig.h b/bsp/nios_ii/rtconfig.h
index 3f59b4010f..527a8523a6 100644
--- a/bsp/nios_ii/rtconfig.h
+++ b/bsp/nios_ii/rtconfig.h
@@ -1,147 +1,147 @@
- /* system.h - SOPC Builder system and BSP software package information */
- #include "system.h"
-
-/* RT-Thread config file */
-#ifndef __RTTHREAD_CFG_H__
-#define __RTTHREAD_CFG_H__
-
-/* RT_NAME_MAX*/
-#define RT_NAME_MAX 8
-
-/* RT_ALIGN_SIZE*/
-#define RT_ALIGN_SIZE 4
-
-/* PRIORITY_MAX */
-#define RT_THREAD_PRIORITY_MAX 32
-
-/* Tick per Second */
-/* TIMER_TICKS_PER_SEC define in system.h */
-#define RT_TICK_PER_SECOND TIMER_TICKS_PER_SEC
-
-/* SECTION: RT_DEBUG */
-/* Thread Debug */
-#define RT_DEBUG
-//#define THREAD_DEBUG
-//#define SCHEDULER_DEBUG
-//#define IRQ_DEBUG
-
-#define IDLE_THREAD_STACK_SIZE 1024
-
-#define RT_USING_OVERFLOW_CHECK
-
-/* Using Hook */
-#define RT_USING_HOOK
-
-/* Using Software Timer */
-/* #define RT_USING_TIMER_SOFT */
-#define RT_TIMER_THREAD_PRIO 4
-#define RT_TIMER_THREAD_STACK_SIZE 512
-#define RT_TIMER_TICK_PER_SECOND 10
-
-/* SECTION: IPC */
-/* Using Semaphore*/
-#define RT_USING_SEMAPHORE
-
-/* Using Mutex */
-#define RT_USING_MUTEX
-
-/* Using Event */
-#define RT_USING_EVENT
-
-/* Using MailBox */
-#define RT_USING_MAILBOX
-
-/* Using Message Queue */
-#define RT_USING_MESSAGEQUEUE
-
-/* SECTION: Memory Management */
-/* Using Memory Pool Management*/
-#define RT_USING_MEMPOOL
-
-/* Using Dynamic Heap Management */
-#define RT_USING_HEAP
-
-/* Using Small MM */
-#define RT_USING_SMALL_MEM
-
-/* SECTION: Device System */
-/* Using Device System */
-#define RT_USING_DEVICE
-#define RT_USING_UART1
-
-/* SECTION: Console options */
-#define RT_USING_CONSOLE
-/* the buffer size of console*/
-#define RT_CONSOLEBUF_SIZE 128
-
-#define RT_USING_NEWLIB
-
-/* SECTION: finsh, a C-Express shell */
-#define RT_USING_FINSH
-/* Using symbol table */
-#define FINSH_USING_SYMTAB
-#define FINSH_USING_DESCRIPTION
-#define __fsymtab_start _alt_partition_FSymTab_start
-#define __fsymtab_end _alt_partition_FSymTab_end
-#define __vsymtab_start _alt_partition_VSymTab_start
-#define __vsymtab_end _alt_partition_VSymTab_end
-
-/* SECTION: device filesystem */
-//#define RT_USING_DFS
-#define RT_USING_DFS_ELMFAT
-
-/* the max number of mounted filesystem */
-#define DFS_FILESYSTEMS_MAX 2
-/* the max number of opened files */
-#define DFS_FD_MAX 4
-/* the max number of cached sector */
-#define DFS_CACHE_MAX_NUM 4
-
-/* SECTION: lwip, a lighwight TCP/IP protocol stack */
-//#define RT_USING_LWIP
-/* LwIP uses RT-Thread Memory Management */
-#define RT_LWIP_USING_RT_MEM
-/* Enable ICMP protocol*/
-#define RT_LWIP_ICMP
-/* Enable UDP protocol*/
-#define RT_LWIP_UDP
-/* Enable TCP protocol*/
-#define RT_LWIP_TCP
-/* Enable DNS */
-#define RT_LWIP_DNS
-
-/* the number of simulatenously active TCP connections*/
-#define RT_LWIP_TCP_PCB_NUM 5
-
-/* Using DHCP */
-//#define RT_LWIP_DHCP
-
-/* ip address of target*/
-#define RT_LWIP_IPADDR0 192
-#define RT_LWIP_IPADDR1 168
-#define RT_LWIP_IPADDR2 1
-#define RT_LWIP_IPADDR3 30
-
-/* gateway address of target*/
-#define RT_LWIP_GWADDR0 192
-#define RT_LWIP_GWADDR1 168
-#define RT_LWIP_GWADDR2 1
-#define RT_LWIP_GWADDR3 1
-
-/* mask address of target*/
-#define RT_LWIP_MSKADDR0 255
-#define RT_LWIP_MSKADDR1 255
-#define RT_LWIP_MSKADDR2 255
-#define RT_LWIP_MSKADDR3 0
-
-/* tcp thread options */
-#define RT_LWIP_TCPTHREAD_PRIORITY 12
-#define RT_LWIP_TCPTHREAD_MBOX_SIZE 4
-#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
-
-/* ethernet if thread options */
-#define RT_LWIP_ETHTHREAD_PRIORITY 15
-#define RT_LWIP_ETHTHREAD_MBOX_SIZE 4
-#define RT_LWIP_ETHTHREAD_STACKSIZE 512
-
-#endif
+ /* system.h - SOPC Builder system and BSP software package information */
+ #include "system.h"
+
+/* RT-Thread config file */
+#ifndef __RTTHREAD_CFG_H__
+#define __RTTHREAD_CFG_H__
+
+/* RT_NAME_MAX*/
+#define RT_NAME_MAX 8
+
+/* RT_ALIGN_SIZE*/
+#define RT_ALIGN_SIZE 4
+
+/* PRIORITY_MAX */
+#define RT_THREAD_PRIORITY_MAX 32
+
+/* Tick per Second */
+/* TIMER_TICKS_PER_SEC define in system.h */
+#define RT_TICK_PER_SECOND TIMER_TICKS_PER_SEC
+
+/* SECTION: RT_DEBUG */
+/* Thread Debug */
+#define RT_DEBUG
+//#define THREAD_DEBUG
+//#define SCHEDULER_DEBUG
+//#define IRQ_DEBUG
+
+#define IDLE_THREAD_STACK_SIZE 1024
+
+#define RT_USING_OVERFLOW_CHECK
+
+/* Using Hook */
+#define RT_USING_HOOK
+
+/* Using Software Timer */
+/* #define RT_USING_TIMER_SOFT */
+#define RT_TIMER_THREAD_PRIO 4
+#define RT_TIMER_THREAD_STACK_SIZE 512
+#define RT_TIMER_TICK_PER_SECOND 10
+
+/* SECTION: IPC */
+/* Using Semaphore*/
+#define RT_USING_SEMAPHORE
+
+/* Using Mutex */
+#define RT_USING_MUTEX
+
+/* Using Event */
+#define RT_USING_EVENT
+
+/* Using MailBox */
+#define RT_USING_MAILBOX
+
+/* Using Message Queue */
+#define RT_USING_MESSAGEQUEUE
+
+/* SECTION: Memory Management */
+/* Using Memory Pool Management*/
+#define RT_USING_MEMPOOL
+
+/* Using Dynamic Heap Management */
+#define RT_USING_HEAP
+
+/* Using Small MM */
+#define RT_USING_SMALL_MEM
+
+/* SECTION: Device System */
+/* Using Device System */
+#define RT_USING_DEVICE
+#define RT_USING_UART1
+
+/* SECTION: Console options */
+#define RT_USING_CONSOLE
+/* the buffer size of console*/
+#define RT_CONSOLEBUF_SIZE 128
+
+#define RT_USING_NEWLIB
+
+/* SECTION: finsh, a C-Express shell */
+#define RT_USING_FINSH
+/* Using symbol table */
+#define FINSH_USING_SYMTAB
+#define FINSH_USING_DESCRIPTION
+#define __fsymtab_start _alt_partition_FSymTab_start
+#define __fsymtab_end _alt_partition_FSymTab_end
+#define __vsymtab_start _alt_partition_VSymTab_start
+#define __vsymtab_end _alt_partition_VSymTab_end
+
+/* SECTION: device filesystem */
+//#define RT_USING_DFS
+#define RT_USING_DFS_ELMFAT
+
+/* the max number of mounted filesystem */
+#define DFS_FILESYSTEMS_MAX 2
+/* the max number of opened files */
+#define DFS_FD_MAX 4
+/* the max number of cached sector */
+#define DFS_CACHE_MAX_NUM 4
+
+/* SECTION: lwip, a lighwight TCP/IP protocol stack */
+//#define RT_USING_LWIP
+/* LwIP uses RT-Thread Memory Management */
+#define RT_LWIP_USING_RT_MEM
+/* Enable ICMP protocol*/
+#define RT_LWIP_ICMP
+/* Enable UDP protocol*/
+#define RT_LWIP_UDP
+/* Enable TCP protocol*/
+#define RT_LWIP_TCP
+/* Enable DNS */
+#define RT_LWIP_DNS
+
+/* the number of simulatenously active TCP connections*/
+#define RT_LWIP_TCP_PCB_NUM 5
+
+/* Using DHCP */
+//#define RT_LWIP_DHCP
+
+/* ip address of target*/
+#define RT_LWIP_IPADDR0 192
+#define RT_LWIP_IPADDR1 168
+#define RT_LWIP_IPADDR2 1
+#define RT_LWIP_IPADDR3 30
+
+/* gateway address of target*/
+#define RT_LWIP_GWADDR0 192
+#define RT_LWIP_GWADDR1 168
+#define RT_LWIP_GWADDR2 1
+#define RT_LWIP_GWADDR3 1
+
+/* mask address of target*/
+#define RT_LWIP_MSKADDR0 255
+#define RT_LWIP_MSKADDR1 255
+#define RT_LWIP_MSKADDR2 255
+#define RT_LWIP_MSKADDR3 0
+
+/* tcp thread options */
+#define RT_LWIP_TCPTHREAD_PRIORITY 12
+#define RT_LWIP_TCPTHREAD_MBOX_SIZE 4
+#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
+
+/* ethernet if thread options */
+#define RT_LWIP_ETHTHREAD_PRIORITY 15
+#define RT_LWIP_ETHTHREAD_MBOX_SIZE 4
+#define RT_LWIP_ETHTHREAD_STACKSIZE 512
+
+#endif
diff --git a/bsp/nios_ii/startup.c b/bsp/nios_ii/startup.c
index 2f5a6a27bf..cb43a7ae0b 100644
--- a/bsp/nios_ii/startup.c
+++ b/bsp/nios_ii/startup.c
@@ -1,99 +1,99 @@
-/*
- * File : startup.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006-2011, 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
- *
- * Change Logs:
- * Date Author Notes
- * 2011-02-14 aozima first implementation for Nios II.
- * 2011-03-04 aozima add HEAP and finsh support .
- */
-
-#include <rtthread.h>
-#include "system.h"
-#include "board.h"
-
-/**
- * @addtogroup NIOS_II
- */
-
-/*@{*/
-
-extern int rt_application_init(void);
-
-#ifdef RT_USING_FINSH
-extern void finsh_system_init(void);
-extern void finsh_set_device(const char* device);
-#endif
-
-#ifdef RT_USING_HEAP
-extern int _alt_partition_sdram_load_addr;
-#endif
-
-/**
- * This function will startup RT-Thread RTOS.
- */
-void rtthread_startup(void)
-{
- /* init board */
- rt_hw_board_init();
-
- /* show version */
- rt_show_version();
-
- /* init tick */
- rt_system_tick_init();
-
- /* init kernel object */
- rt_system_object_init();
-
- /* init timer system */
- rt_system_timer_init();
-
-#ifdef RT_USING_HEAP
- rt_system_heap_init( &_alt_partition_sdram_load_addr, (void*)(SDRAM_BASE + SDRAM_SPAN) );
-#endif
-
- /* init scheduler system */
- rt_system_scheduler_init();
-
- /* init application */
- rt_application_init();
-
- /* init timer thread */
- rt_system_timer_thread_init();
-
-#ifdef RT_USING_FINSH
- /* init finsh */
- finsh_system_init();
- finsh_set_device("uart");
-#endif
-
- /* init idle thread */
- rt_thread_idle_init();
-
- /* start scheduler */
- rt_system_scheduler_start();
-
- /* never reach here */
- return ;
-}
-
-int main(void)
-{
- rt_uint32_t UNUSED level;
-
- /* disable interrupt first */
- level = rt_hw_interrupt_disable();
-
- /* startup RT-Thread RTOS */
- rtthread_startup();
-
- return 0;
-}
-
-/*@}*/
+/*
+ * File : startup.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2011, 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-02-14 aozima first implementation for Nios II.
+ * 2011-03-04 aozima add HEAP and finsh support .
+ */
+
+#include <rtthread.h>
+#include "system.h"
+#include "board.h"
+
+/**
+ * @addtogroup NIOS_II
+ */
+
+/*@{*/
+
+extern int rt_application_init(void);
+
+#ifdef RT_USING_FINSH
+extern void finsh_system_init(void);
+extern void finsh_set_device(const char* device);
+#endif
+
+#ifdef RT_USING_HEAP
+extern int _alt_partition_sdram_load_addr;
+#endif
+
+/**
+ * This function will startup RT-Thread RTOS.
+ */
+void rtthread_startup(void)
+{
+ /* init board */
+ rt_hw_board_init();
+
+ /* show version */
+ rt_show_version();
+
+ /* init tick */
+ rt_system_tick_init();
+
+ /* init kernel object */
+ rt_system_object_init();
+
+ /* init timer system */
+ rt_system_timer_init();
+
+#ifdef RT_USING_HEAP
+ rt_system_heap_init( &_alt_partition_sdram_load_addr, (void*)(SDRAM_BASE + SDRAM_SPAN) );
+#endif
+
+ /* init scheduler system */
+ rt_system_scheduler_init();
+
+ /* init application */
+ rt_application_init();
+
+ /* init timer thread */
+ rt_system_timer_thread_init();
+
+#ifdef RT_USING_FINSH
+ /* init finsh */
+ finsh_system_init();
+ finsh_set_device("uart");
+#endif
+
+ /* init idle thread */
+ rt_thread_idle_init();
+
+ /* start scheduler */
+ rt_system_scheduler_start();
+
+ /* never reach here */
+ return ;
+}
+
+int main(void)
+{
+ rt_uint32_t UNUSED level;
+
+ /* disable interrupt first */
+ level = rt_hw_interrupt_disable();
+
+ /* startup RT-Thread RTOS */
+ rtthread_startup();
+
+ return 0;
+}
+
+/*@}*/
diff --git a/bsp/nios_ii/uart.c b/bsp/nios_ii/uart.c
index 463b02e34b..0024992725 100644
--- a/bsp/nios_ii/uart.c
+++ b/bsp/nios_ii/uart.c
@@ -1,122 +1,122 @@
-#include <rthw.h>
-#include <rtthread.h>
-
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "system.h"
-#include "sys/alt_irq.h"
-#include "altera_avalon_uart_regs.h"
-
-extern int alt_irq_register (alt_u32 id,
- void* context,
- void (*alt_isr_func)(void* isr_context, alt_u32 id) );
-
-static void set_baudrate(unsigned int baudrate)
-{
- IOWR_ALTERA_AVALON_UART_DIVISOR(RS232_BASE,
- (unsigned int)(ALT_CPU_FREQ/baudrate+0.5) );
-}
-
-/********* rt-thread *********/
-#include <rtthread.h>
-
-struct rt_device uart_device;
-uint8_t rx_buf[100];
-uint32_t rx_put_index;
-uint32_t rx_get_index;
-
-static rt_err_t rt_uart_init (rt_device_t dev)
-{
- set_baudrate(115200);
-
- IOWR_ALTERA_AVALON_UART_CONTROL(RS232_BASE, 0x80);//�����ж�ʹ��
- IOWR_ALTERA_AVALON_UART_STATUS(RS232_BASE, 0x0); // clean status
-
- rx_put_index = 0;
- rx_get_index = 0;
-
- return RT_EOK;
-}
-
-static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
-{
- return RT_EOK;
-}
-
-static rt_err_t rt_uart_close(rt_device_t dev)
-{
- return RT_EOK;
-}
-
-static rt_size_t rt_uart_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
-{
- if( rx_get_index )
- {
- *(uint8_t *)buffer = rx_buf[0];
- rx_get_index--;
- return size;
- }
- return 0;
-}
-
-static rt_size_t rt_uart_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
-{
- const char * write_point = buffer;
- while(size--)
- {
- if(*write_point == '\n')
- {
- IOWR_ALTERA_AVALON_UART_TXDATA(RS232_BASE,'\r');
- while( !(IORD_ALTERA_AVALON_UART_STATUS(RS232_BASE)&(1<<6)) ); // status bit6 : TRDY
- }
- IOWR_ALTERA_AVALON_UART_TXDATA(RS232_BASE,*write_point);
- write_point++;
- while( !(IORD_ALTERA_AVALON_UART_STATUS(RS232_BASE)&(1<<6)) ); // status bit6 : TRDY
- }
-
- return size;
-}
-
-static rt_err_t rt_uart_control(rt_device_t dev, rt_uint8_t cmd, void *args)
-{
- return RT_EOK;
-}
-
-static void uart_isr(void * context,alt_u32 id)
-{
- rx_buf[rx_get_index] = IORD_ALTERA_AVALON_UART_RXDATA(RS232_BASE);
- rx_get_index++;
- if (uart_device.rx_indicate != RT_NULL)
- {
- uart_device.rx_indicate(&uart_device, 1);
- }
-}
-
-void rt_hw_uart_init(void)
-{
- // init uart
- set_baudrate(115200);
- IOWR_ALTERA_AVALON_UART_CONTROL(RS232_BASE, 0x80);//�����ж�ʹ��
- IOWR_ALTERA_AVALON_UART_STATUS(RS232_BASE, 0x0); // clean status
- alt_irq_register(RS232_IRQ, NULL, uart_isr);
-
- // register device
- uart_device.type = RT_Device_Class_Char;
- /* device interface */
- uart_device.init = rt_uart_init;
- uart_device.open = rt_uart_open;
- uart_device.close = rt_uart_close;
- uart_device.read = rt_uart_read;
- uart_device.write = rt_uart_write;
- uart_device.control = rt_uart_control;
-
- uart_device.user_data = RT_NULL;
- uart_device.rx_indicate = RT_NULL;
- uart_device.tx_complete = RT_NULL;
-
- rt_device_register(&uart_device,
- "uart", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
-}
+#include <rthw.h>
+#include <rtthread.h>
+
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "system.h"
+#include "sys/alt_irq.h"
+#include "altera_avalon_uart_regs.h"
+
+extern int alt_irq_register (alt_u32 id,
+ void* context,
+ void (*alt_isr_func)(void* isr_context, alt_u32 id) );
+
+static void set_baudrate(unsigned int baudrate)
+{
+ IOWR_ALTERA_AVALON_UART_DIVISOR(RS232_BASE,
+ (unsigned int)(ALT_CPU_FREQ/baudrate+0.5) );
+}
+
+/********* rt-thread *********/
+#include <rtthread.h>
+
+struct rt_device uart_device;
+uint8_t rx_buf[100];
+uint32_t rx_put_index;
+uint32_t rx_get_index;
+
+static rt_err_t rt_uart_init (rt_device_t dev)
+{
+ set_baudrate(115200);
+
+ IOWR_ALTERA_AVALON_UART_CONTROL(RS232_BASE, 0x80);//�����ж�ʹ��
+ IOWR_ALTERA_AVALON_UART_STATUS(RS232_BASE, 0x0); // clean status
+
+ rx_put_index = 0;
+ rx_get_index = 0;
+
+ return RT_EOK;
+}
+
+static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
+{
+ return RT_EOK;
+}
+
+static rt_err_t rt_uart_close(rt_device_t dev)
+{
+ return RT_EOK;
+}
+
+static rt_size_t rt_uart_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
+{
+ if( rx_get_index )
+ {
+ *(uint8_t *)buffer = rx_buf[0];
+ rx_get_index--;
+ return size;
+ }
+ return 0;
+}
+
+static rt_size_t rt_uart_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
+{
+ const char * write_point = buffer;
+ while(size--)
+ {
+ if(*write_point == '\n')
+ {
+ IOWR_ALTERA_AVALON_UART_TXDATA(RS232_BASE,'\r');
+ while( !(IORD_ALTERA_AVALON_UART_STATUS(RS232_BASE)&(1<<6)) ); // status bit6 : TRDY
+ }
+ IOWR_ALTERA_AVALON_UART_TXDATA(RS232_BASE,*write_point);
+ write_point++;
+ while( !(IORD_ALTERA_AVALON_UART_STATUS(RS232_BASE)&(1<<6)) ); // status bit6 : TRDY
+ }
+
+ return size;
+}
+
+static rt_err_t rt_uart_control(rt_device_t dev, rt_uint8_t cmd, void *args)
+{
+ return RT_EOK;
+}
+
+static void uart_isr(void * context,alt_u32 id)
+{
+ rx_buf[rx_get_index] = IORD_ALTERA_AVALON_UART_RXDATA(RS232_BASE);
+ rx_get_index++;
+ if (uart_device.rx_indicate != RT_NULL)
+ {
+ uart_device.rx_indicate(&uart_device, 1);
+ }
+}
+
+void rt_hw_uart_init(void)
+{
+ // init uart
+ set_baudrate(115200);
+ IOWR_ALTERA_AVALON_UART_CONTROL(RS232_BASE, 0x80);//�����ж�ʹ��
+ IOWR_ALTERA_AVALON_UART_STATUS(RS232_BASE, 0x0); // clean status
+ alt_irq_register(RS232_IRQ, NULL, uart_isr);
+
+ // register device
+ uart_device.type = RT_Device_Class_Char;
+ /* device interface */
+ uart_device.init = rt_uart_init;
+ uart_device.open = rt_uart_open;
+ uart_device.close = rt_uart_close;
+ uart_device.read = rt_uart_read;
+ uart_device.write = rt_uart_write;
+ uart_device.control = rt_uart_control;
+
+ uart_device.user_data = RT_NULL;
+ uart_device.rx_indicate = RT_NULL;
+ uart_device.tx_complete = RT_NULL;
+
+ rt_device_register(&uart_device,
+ "uart", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
+}
diff --git a/bsp/nios_ii/uart.h b/bsp/nios_ii/uart.h
index 8fa5cb976b..e4fae8d133 100644
--- a/bsp/nios_ii/uart.h
+++ b/bsp/nios_ii/uart.h
@@ -1,6 +1,6 @@
-#ifndef UART_H_INCLUDED
-#define UART_H_INCLUDED
-
-extern void rt_hw_uart_init(void);
-
-#endif // UART_H_INCLUDED
+#ifndef UART_H_INCLUDED
+#define UART_H_INCLUDED
+
+extern void rt_hw_uart_init(void);
+
+#endif // UART_H_INCLUDED