diff options
| author | [email protected] <[email protected]> | 2011-12-18 05:13:10 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2011-12-18 05:13:10 +0000 |
| commit | ae73bd59bc0ae7f206a3b2935a0a3001b7ceb566 (patch) | |
| tree | a70da58619d826bcc03fd7f93cba559d9d4c40c2 /bsp/microblaze | |
| parent | 08f25161d9f988eaefd37e4d06fe244bed381418 (diff) | |
modify format
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1844 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/microblaze')
| -rwxr-xr-x | bsp/microblaze/application.c | 6 | ||||
| -rwxr-xr-x | bsp/microblaze/board.c | 186 | ||||
| -rwxr-xr-x | bsp/microblaze/board.h | 1 | ||||
| -rwxr-xr-x | bsp/microblaze/rtconfig.h | 2 | ||||
| -rwxr-xr-x | bsp/microblaze/startup.c | 132 |
5 files changed, 158 insertions, 169 deletions
diff --git a/bsp/microblaze/application.c b/bsp/microblaze/application.c index 46e5ef6232..12fadcd26f 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 d0f54e0013..d81451139e 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 MacroBlaze + * 2011-12-17 nl1031 for MicroBlaze * */ @@ -39,17 +39,15 @@ #define RS232_DEVICE_ID XPAR_USB_UART_DEVICE_ID #ifdef RT_USING_UART1 -#define USB_UART_BASE ((struct uartport *)XPAR_USB_UART_BASEADDR) +#define USB_UART_BASE ((struct uartport *)XPAR_USB_UART_BASEADDR) #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 void rt_hw_board_led_init(void); @@ -58,22 +56,22 @@ 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; + 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); } /** @@ -83,8 +81,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); } /** @@ -94,23 +92,21 @@ 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; + 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 /* @@ -124,109 +120,107 @@ void rt_hw_led_flash(void) */ void rt_hw_console_output(const char* str) { - while (*str) - { + while (*str) + { - /* Transmit Character */ - XUartLite_SendByte(STDOUT_BASEADDRESS, *str); - if (*str == '\n') - XUartLite_SendByte(STDOUT_BASEADDRESS, '\r'); - str++; - } + /* Transmit Character */ + 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); - XIntc_Start(&int_ctl, XIN_REAL_MODE); + rt_hw_interrupt_umask(XPAR_INTC_0_TMRCTR_0_VEC_ID); -} + XIntc_Start(&int_ctl, XIN_REAL_MODE); +} -void rt_tmr_init (void) +void rt_tmr_init(void) { - rt_uint32_t ctl; - XStatus status; + 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); -} + 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); +} /** * This function will initial SPARTAN 6 LX9 board. */ void rt_hw_board_init() { - /* init hardware console */ - rt_hw_console_init(); + /* 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 9e542c17c5..cf8bc477d7 100755 --- a/bsp/microblaze/board.h +++ b/bsp/microblaze/board.h @@ -13,7 +13,6 @@ #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 674de50c4d..827efea543 100755 --- a/bsp/microblaze/rtconfig.h +++ b/bsp/microblaze/rtconfig.h @@ -16,7 +16,6 @@ /* Tick per Second*/
#define RT_TICK_PER_SECOND 100
-
/* SECTION: RT_DEBUG */
/* Thread Debug*/
/* #define RT_THREAD_DEBUG */
@@ -89,7 +88,6 @@ #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 16a23394bd..f15db49d24 100755 --- a/bsp/microblaze/startup.c +++ b/bsp/microblaze/startup.c @@ -16,105 +16,103 @@ #include <rthw.h> #include <rtthread.h> -//#include <AT91SAM7S.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(); - - rt_show_version(); + /* init board */ + rt_hw_board_init(); - /* init tick */ - rt_system_tick_init(); + rt_show_version(); - /* init kernel object */ - rt_system_object_init(); + /* init tick */ + rt_system_tick_init(); - /* init timer system */ - rt_system_timer_init(); + /* init kernel object */ + rt_system_object_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)); -#endif
-#endif
+ /* init timer system */ + rt_system_timer_init(); - /* init scheduler system */ - rt_system_scheduler_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)); +#endif +#endif + + /* 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(); + /* init idle thread */ + rt_thread_idle_init(); + + /* start scheduler */ + rt_system_scheduler_start(); - /* start scheduler */ - rt_system_scheduler_start(); + /* never reach here */ + return; +} - /* never reach here */ - return ; -}
+int main(void) +{ + /* invoke rtthread_startup */ + rtthread_startup(); -int main (void)
-{
- /* invoke rtthread_startup */
- rtthread_startup();
-
- return 0;
-}
+ return 0; +} /*@}*/ |
