diff options
| author | [email protected] <[email protected]> | 2012-10-26 03:36:13 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-10-26 03:36:13 +0000 |
| commit | 6fe2afed8ca4deaa94cc9f8795fb8dcd7e880225 (patch) | |
| tree | 789cfbb616d3bb80cf95034e7bf77ac326b62adf /bsp | |
| parent | 2cdbbf8b0536b60ac931b7f401f731a4f560c37b (diff) | |
for rt-thread 1.1.0
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2372 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp')
| -rwxr-xr-x | bsp/microblaze/application.c | 6 | ||||
| -rwxr-xr-x | bsp/microblaze/board.c | 189 | ||||
| -rwxr-xr-x | bsp/microblaze/board.h | 1 | ||||
| -rwxr-xr-x | bsp/microblaze/rtconfig.h | 2 | ||||
| -rwxr-xr-x | bsp/microblaze/startup.c | 130 |
5 files changed, 172 insertions, 156 deletions
diff --git a/bsp/microblaze/application.c b/bsp/microblaze/application.c index 12fadcd26f..46e5ef6232 100755 --- a/bsp/microblaze/application.c +++ b/bsp/microblaze/application.c @@ -15,12 +15,12 @@ /** * @addtogroup sam7s */ -/*@{*/ -#include <rtthread.h> +/*@{*/
+#include <rtthread.h>
int rt_application_init() { - return 0; + return 0; } /*@}*/ diff --git a/bsp/microblaze/board.c b/bsp/microblaze/board.c index d81451139e..1de9171151 100755 --- a/bsp/microblaze/board.c +++ b/bsp/microblaze/board.c @@ -11,7 +11,7 @@ * Date Author Notes * 2006-08-23 Bernard first implementation * - * 2011-12-17 nl1031 for MicroBlaze + * 2011-12-17 nl1031 for MacroBlaze * */ @@ -43,11 +43,14 @@ #endif /* Global Variables: */ -XTmrCtr timer; /* The instance of the timer */ -XGpio gpio_output; /* The driver instance for GPIO Device configured as O/P */ -XUartLite uart_lite; /* Instance of the UartLite device */ -XIntc int_ctl; /* The instance of the Interrupt Controller */ -static rt_uint32_t led_data; +XTmrCtr timer; /* The instance of the timer */ +XGpio gpio_output; /* The driver instance for GPIO Device configured as O/P */ +XUartLite uart_lite; /* Instance of the UartLite device */ +XIntc int_ctl; /* The instance of the Interrupt Controller */ +static rt_uint32_t led_data; +static int cnt; + + static void rt_hw_board_led_init(void); @@ -56,22 +59,23 @@ static void rt_hw_board_led_init(void); */ static void rt_hw_board_led_init() { - rt_uint32_t status; - led_data = 0; - status = XGpio_Initialize(&gpio_output, LEDS_DEVICE_ID); - if (status != XST_SUCCESS) - { - return; - } + rt_uint32_t status; + led_data = 0; + cnt = 0; + status = XGpio_Initialize(&gpio_output, LEDS_DEVICE_ID); + if (status != XST_SUCCESS) + { + return; + } - /* - * Set the direction for all signals to be outputs - */ - XGpio_SetDataDirection(&gpio_output, 1, 0x0); - /* - * Set the GPIO outputs to high - */ - XGpio_DiscreteWrite(&gpio_output, 1, 3); + /* + * Set the direction for all signals to be outputs + */ + XGpio_SetDataDirection(&gpio_output, 1, 0x0); + /* + * Set the GPIO outputs to high + */ + XGpio_DiscreteWrite(&gpio_output, 1, 3); } /** @@ -81,8 +85,8 @@ static void rt_hw_board_led_init() */ void rt_hw_board_led_on(rt_uint32_t led) { - led_data |= led; - XGpio_DiscreteWrite(&gpio_output, 1, led_data); + led_data |= led; + XGpio_DiscreteWrite(&gpio_output, 1, led_data); } /** @@ -92,21 +96,23 @@ void rt_hw_board_led_on(rt_uint32_t led) */ void rt_hw_board_led_off(rt_uint32_t led) { - led_data &= ~led; - XGpio_DiscreteWrite(&gpio_output, 1, led_data); + led_data &= ~led; + XGpio_DiscreteWrite(&gpio_output, 1, led_data); } + void rt_hw_led_flash(void) { - rt_uint32_t i; + volatile rt_uint32_t i; - rt_hw_board_led_off(1); - for (i = 0; i < 20000; i++) ; + rt_hw_board_led_off(1); + for (i = 0; i < 20000; i ++); - rt_hw_board_led_on(1); - for (i = 0; i < 20000; i++) ; + rt_hw_board_led_on(1); + for (i = 0; i < 20000; i ++); } + #ifdef RT_USING_CONSOLE /* @@ -120,107 +126,112 @@ void rt_hw_led_flash(void) */ void rt_hw_console_output(const char* str) { - while (*str) - { + while (*str) + { + + /* Transmit Character */ - /* Transmit Character */ - XUartLite_SendByte(STDOUT_BASEADDRESS, *str); - if (*str == '\n') - XUartLite_SendByte(STDOUT_BASEADDRESS, '\r'); - str++; - } + XUartLite_SendByte(STDOUT_BASEADDRESS, *str); + if (*str == '\n') + XUartLite_SendByte(STDOUT_BASEADDRESS, '\r'); + str++; + } } static void rt_hw_console_init() { - rt_uint32_t status; + rt_uint32_t status; - /* - * Initialize the UartLite driver so that it is ready to use. - */ - status = XUartLite_Initialize(&uart_lite, RS232_DEVICE_ID); - if (status != XST_SUCCESS) - { - return; - } + /* + * Initialize the UartLite driver so that it is ready to use. + */ + status = XUartLite_Initialize(&uart_lite, RS232_DEVICE_ID); + if (status != XST_SUCCESS) + { + return; + } } #endif + void rt_hw_timer_handler(void) { - rt_uint32_t csr; - csr = XTmrCtr_ReadReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET); - /* - * Check if timer expired and interrupt occured - */ - if (csr & XTC_CSR_INT_OCCURED_MASK) - { - rt_tick_increase(); - - XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, csr | XTC_CSR_INT_OCCURED_MASK); - } + rt_uint32_t csr; + csr = XTmrCtr_ReadReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET); + /* + * Check if timer expired and interrupt occured + */ + if (csr & XTC_CSR_INT_OCCURED_MASK) + { + rt_tick_increase(); + XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, csr | XTC_CSR_INT_OCCURED_MASK); + } } + /* - ********************************************************************************************************* - * rt_intc_init() - * - * Description: This function intializes the interrupt controller by registering the appropriate handler - * functions and enabling interrupts. - * - * Arguments : None - * - * Returns : None - ********************************************************************************************************* - */ +********************************************************************************************************* +* rt_intc_init() +* +* Description: This function intializes the interrupt controller by registering the appropriate handler +* functions and enabling interrupts. +* +* Arguments : None +* +* Returns : None +********************************************************************************************************* +*/ -void rt_intc_init(void) +void rt_intc_init (void) { - XStatus status; + XStatus status; XIntc_MasterDisable(XPAR_INTC_0_BASEADDR); status = XIntc_Initialize(&int_ctl, XPAR_INTC_0_DEVICE_ID); - /* install interrupt handler */ - rt_hw_interrupt_install(XPAR_INTC_0_TMRCTR_0_VEC_ID, (rt_isr_handler_t) rt_hw_timer_handler, RT_NULL); - - rt_hw_interrupt_umask(XPAR_INTC_0_TMRCTR_0_VEC_ID); + /* install interrupt handler */ + rt_hw_interrupt_install(XPAR_INTC_0_TMRCTR_0_VEC_ID, (rt_isr_handler_t)rt_hw_timer_handler, RT_NULL); + rt_hw_interrupt_umask(XPAR_INTC_0_TMRCTR_0_VEC_ID); - XIntc_Start(&int_ctl, XIN_REAL_MODE); + XIntc_Start(&int_ctl, XIN_REAL_MODE); } -void rt_tmr_init(void) -{ - rt_uint32_t ctl; - XStatus status; - - status = XTmrCtr_Initialize(&timer, XPAR_AXI_TIMER_0_DEVICE_ID); - XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TLR_OFFSET, PIV); +void rt_tmr_init (void) +{ + rt_uint32_t ctl; + XStatus status; + status = XTmrCtr_Initialize(&timer,XPAR_AXI_TIMER_0_DEVICE_ID); + XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TLR_OFFSET, PIV); ctl = XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK; - XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, ctl); + XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, ctl); } + + /** * This function will initial SPARTAN 6 LX9 board. */ void rt_hw_board_init() { - /* init hardware console */ - rt_hw_console_init(); + microblaze_disable_icache(); + microblaze_disable_dcache(); + /* init hardware console */ + rt_hw_console_init(); - /* init led */ - rt_hw_board_led_init(); + /* init led */ + rt_hw_board_led_init(); - /* init intc */ + /* init intc */ rt_intc_init(); /* timer init */ rt_tmr_init(); + } diff --git a/bsp/microblaze/board.h b/bsp/microblaze/board.h index cf8bc477d7..9e542c17c5 100755 --- a/bsp/microblaze/board.h +++ b/bsp/microblaze/board.h @@ -13,6 +13,7 @@ #define __BOARD_H__ +#define MCK 50000000 void rt_hw_board_led_on(rt_uint32_t); void rt_hw_board_led_off(rt_uint32_t); diff --git a/bsp/microblaze/rtconfig.h b/bsp/microblaze/rtconfig.h index 827efea543..674de50c4d 100755 --- a/bsp/microblaze/rtconfig.h +++ b/bsp/microblaze/rtconfig.h @@ -16,6 +16,7 @@ /* Tick per Second*/
#define RT_TICK_PER_SECOND 100
+
/* SECTION: RT_DEBUG */
/* Thread Debug*/
/* #define RT_THREAD_DEBUG */
@@ -88,6 +89,7 @@ #define FINSH_THREAD_STACK_SIZE 8192
#define RT_USING_TC
+
/* SECTION: a runtime libc library */
/* a runtime libc library*/
/* #define RT_USING_NEWLIB */
diff --git a/bsp/microblaze/startup.c b/bsp/microblaze/startup.c index f15db49d24..c3aeae2a2b 100755 --- a/bsp/microblaze/startup.c +++ b/bsp/microblaze/startup.c @@ -16,103 +16,105 @@ #include <rthw.h> #include <rtthread.h> -#include "board.h" +#include "board.h"
-#ifdef RT_USING_FINSH -#include <finsh.h> -extern void finsh_system_init(void); -#endif +#ifdef RT_USING_FINSH
+#include <finsh.h>
+extern void finsh_system_init(void);
+#endif
extern void rt_hw_led_flash(void); -/*@{*/ -#ifdef __CC_ARM -extern int Image$$RW_IRAM1$$ZI$$Limit; -#endif +/*@{*/ +#ifdef __CC_ARM
+extern int Image$$RW_IRAM1$$ZI$$Limit;
+#endif
+
#ifdef __GNUC__ extern unsigned char __bss_start; extern unsigned char __bss_end; -#endif +#endif
extern void rt_hw_interrupt_init(void); -extern int rt_application_init(void); -#ifdef RT_USING_DEVICE -extern rt_err_t rt_hw_serial_init(void); -#endif +extern int rt_application_init(void); +#ifdef RT_USING_DEVICE
+extern rt_err_t rt_hw_serial_init(void);
+#endif
/** * This function will startup RT-Thread RTOS. */ void rtthread_startup(void) { - /* init hardware interrupt */ - rt_hw_interrupt_init(); + /* init hardware interrupt */ + rt_hw_interrupt_init();
- /* init board */ - rt_hw_board_init(); + /* init board */ + rt_hw_board_init(); + + rt_show_version(); - rt_show_version(); + /* init tick */ + rt_system_tick_init(); - /* init tick */ - rt_system_tick_init(); + /* init kernel object */ + rt_system_object_init(); - /* init kernel object */ - rt_system_object_init(); + /* init timer system */ + rt_system_timer_init(); - /* init timer system */ - rt_system_timer_init(); +#ifdef RT_USING_HEAP
+#ifdef __CC_ARM
+ rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
+#elif __ICCARM__
+ rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
+#else
+ rt_system_heap_init((void*)&__bss_end, (void*)(&__bss_end+0x4000)); -#ifdef RT_USING_HEAP -#ifdef __CC_ARM - rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000); -#elif __ICCARM__ - rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000); -#else - rt_system_heap_init((void*) &__bss_end, (void*) (&__bss_end + 0x4000)); -#endif -#endif +#endif
+#endif
- /* init scheduler system */ - rt_system_scheduler_init(); + /* init scheduler system */ + rt_system_scheduler_init(); #ifdef RT_USING_HOOK /* if the hook is used */ - /* set idle thread hook */ - rt_thread_idle_sethook(rt_hw_led_flash); -#endif + /* set idle thread hook */ + rt_thread_idle_sethook(rt_hw_led_flash); +#endif
-#ifdef RT_USING_DEVICE - /* init hardware serial device */ - rt_hw_serial_init(); - /* init all device */ - rt_device_init_all(); -#endif +#ifdef RT_USING_DEVICE
+ /* init hardware serial device */
+ rt_hw_serial_init();
+ /* init all device */
+ rt_device_init_all();
+#endif
- /* init application */ - rt_application_init(); + /* init application */ + rt_application_init(); #ifdef RT_USING_FINSH - /* init finsh */ - finsh_system_init(); - finsh_set_device("uart1"); + /* init finsh */ + finsh_system_init(); + finsh_set_device("uart1"); #endif - /* init idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); + /* init idle thread */ + rt_thread_idle_init(); - /* never reach here */ - return; -} + /* start scheduler */ + rt_system_scheduler_start(); -int main(void) -{ - /* invoke rtthread_startup */ - rtthread_startup(); + /* never reach here */ + return ; +}
- return 0; -} +int main (void)
+{
+ /* invoke rtthread_startup */
+ rtthread_startup();
+
+ return 0;
+}
/*@}*/ |
