cleanup code.

This commit is contained in:
aozima 2013-07-12 18:38:30 +08:00
parent a183f1fbe9
commit e749fb6e9a
5 changed files with 55 additions and 166 deletions

View File

@ -15,9 +15,7 @@
#include <rthw.h> #include <rthw.h>
#include <rtthread.h> #include <rtthread.h>
#include "stm32f10x.h"
#include "board.h" #include "board.h"
#include "rtc.h"
/** /**
* @addtogroup STM32 * @addtogroup STM32
@ -68,9 +66,6 @@ void rtthread_startup(void)
/* show version */ /* show version */
rt_show_version(); rt_show_version();
/* init tick */
rt_system_tick_init();
/* init kernel object */ /* init kernel object */
rt_system_object_init(); rt_system_object_init();
@ -89,25 +84,14 @@ void rtthread_startup(void)
/* init memory system */ /* init memory system */
rt_system_heap_init((void*)&__bss_end, (void*)STM32_SRAM_END); rt_system_heap_init((void*)&__bss_end, (void*)STM32_SRAM_END);
#endif #endif
#endif #endif /* STM32_EXT_SRAM */
#endif #endif /* RT_USING_HEAP */
/* init scheduler system */ /* init scheduler system */
rt_system_scheduler_init(); rt_system_scheduler_init();
#ifdef RT_USING_DFS /* init timer thread */
/* init sdcard driver */ rt_system_timer_thread_init();
#if STM32_USE_SDIO
rt_hw_sdcard_init();
#else
rt_hw_msd_init();
#endif
#endif
rt_hw_rtc_init();
/* init all device */
rt_device_init_all();
/* init application */ /* init application */
rt_application_init(); rt_application_init();
@ -115,12 +99,9 @@ void rtthread_startup(void)
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
/* init finsh */ /* init finsh */
finsh_system_init(); finsh_system_init();
finsh_set_device("uart1"); finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif #endif
/* init timer thread */
rt_system_timer_thread_init();
/* init idle thread */ /* init idle thread */
rt_thread_idle_init(); rt_thread_idle_init();

View File

@ -153,7 +153,7 @@ void EXT_SRAM_Configuration(void)
* This is the timer interrupt service routine. * This is the timer interrupt service routine.
* *
*/ */
void rt_hw_timer_handler(void) void SysTick_Handler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -167,7 +167,7 @@ void rt_hw_timer_handler(void)
/** /**
* This function will initial STM32 board. * This function will initial STM32 board.
*/ */
void rt_hw_board_init() void rt_hw_board_init(void)
{ {
/* NVIC Configuration */ /* NVIC Configuration */
NVIC_Configuration(); NVIC_Configuration();
@ -180,7 +180,7 @@ void rt_hw_board_init()
#endif #endif
rt_hw_usart_init(); rt_hw_usart_init();
rt_console_set_device(CONSOLE_DEVICE); rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
} }
/*@}*/ /*@}*/

View File

@ -16,10 +16,9 @@
#ifndef __BOARD_H__ #ifndef __BOARD_H__
#define __BOARD_H__ #define __BOARD_H__
#include "stm32f10x.h"
/* board configuration */ /* board configuration */
// <o> SDCard Driver <1=>SDIO sdcard <0=>SPI MMC card
// <i>Default: 1
#define STM32_USE_SDIO 1
/* whether use board external SRAM memory */ /* whether use board external SRAM memory */
// <e>Use external SRAM memory on the board // <e>Use external SRAM memory on the board
@ -38,38 +37,6 @@
#define STM32_SRAM_SIZE 64 #define STM32_SRAM_SIZE 64
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
// <o> Console on USART: <0=> no console <1=>USART 1 <2=>USART 2 <3=> USART 3 #endif /* __BOARD_H__ */
// <i>Default: 1
#define STM32_CONSOLE_USART 1
// <o> Ethernet Interface: <0=> Microchip ENC28J60 <1=> Davicom DM9000A
// <i>Default: 0
#define STM32_ETH_IF 1
void rt_hw_board_led_on(int n);
void rt_hw_board_led_off(int n);
void rt_hw_board_init(void);
#if STM32_CONSOLE_USART == 0
#define CONSOLE_DEVICE "no"
#elif STM32_CONSOLE_USART == 1
#define CONSOLE_DEVICE "uart1"
#elif STM32_CONSOLE_USART == 2
#define CONSOLE_DEVICE "uart2"
#elif STM32_CONSOLE_USART == 3
#define CONSOLE_DEVICE "uart3"
#endif
void rt_hw_usart_init(void);
/* SD Card init function */
void rt_hw_sdcard_init(void);
void rt_hw_msd_init(void);
/* ETH interface init function */
void rt_hw_enc28j60_init(void);
void rt_hw_dm9000_init(void);
#endif
// <<< Use Configuration Wizard in Context Menu >>> // <<< Use Configuration Wizard in Context Menu >>>

View File

@ -3236,3 +3236,17 @@ __return:
rt_kprintf("sdcard init failed\n"); rt_kprintf("sdcard init failed\n");
GPIO_SetBits(GPIOC,GPIO_Pin_6); /* SD card power down */ GPIO_SetBits(GPIOC,GPIO_Pin_6); /* SD card power down */
} }
void SDIO_IRQHandler(void)
{
extern int SD_ProcessIRQSrc(void);
/* enter interrupt */
rt_interrupt_enter();
/* Process All SDIO Interrupt Sources */
SD_ProcessIRQSrc();
/* leave interrupt */
rt_interrupt_leave();
}

View File

@ -57,10 +57,10 @@ void NMI_Handler(void)
*/ */
void MemManage_Handler(void) void MemManage_Handler(void)
{ {
/* Go to infinite loop when Memory Manage exception occurs */ /* Go to infinite loop when Memory Manage exception occurs */
while (1) while (1)
{ {
} }
} }
/** /**
@ -70,10 +70,10 @@ void MemManage_Handler(void)
*/ */
void BusFault_Handler(void) void BusFault_Handler(void)
{ {
/* Go to infinite loop when Bus Fault exception occurs */ /* Go to infinite loop when Bus Fault exception occurs */
while (1) while (1)
{ {
} }
} }
/** /**
@ -83,10 +83,10 @@ void BusFault_Handler(void)
*/ */
void UsageFault_Handler(void) void UsageFault_Handler(void)
{ {
/* Go to infinite loop when Usage Fault exception occurs */ /* Go to infinite loop when Usage Fault exception occurs */
while (1) while (1)
{ {
} }
} }
/** /**
@ -107,11 +107,10 @@ void DebugMon_Handler(void)
{ {
} }
void SysTick_Handler(void) //void SysTick_Handler(void)
{ //{
extern void rt_hw_timer_handler(void); // // definition in boarc.c
rt_hw_timer_handler(); //}
}
/******************************************************************************/ /******************************************************************************/
/* STM32F10x Peripherals Interrupt Handlers */ /* STM32F10x Peripherals Interrupt Handlers */
@ -131,7 +130,7 @@ void DMA1_Channel2_IRQHandler(void)
{ {
#ifdef RT_USING_UART3 #ifdef RT_USING_UART3
extern struct rt_device uart3_device; extern struct rt_device uart3_device;
extern void rt_hw_serial_dma_tx_isr(struct rt_device *device); extern void rt_hw_serial_dma_tx_isr(struct rt_device *device);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -161,7 +160,7 @@ void USART1_IRQHandler(void)
{ {
#ifdef RT_USING_UART1 #ifdef RT_USING_UART1
extern struct rt_device uart1_device; extern struct rt_device uart1_device;
extern void rt_hw_serial_isr(struct rt_device *device); extern void rt_hw_serial_isr(struct rt_device *device);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -184,7 +183,7 @@ void USART2_IRQHandler(void)
{ {
#ifdef RT_USING_UART2 #ifdef RT_USING_UART2
extern struct rt_device uart2_device; extern struct rt_device uart2_device;
extern void rt_hw_serial_isr(struct rt_device *device); extern void rt_hw_serial_isr(struct rt_device *device);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -207,7 +206,7 @@ void USART3_IRQHandler(void)
{ {
#ifdef RT_USING_UART3 #ifdef RT_USING_UART3
extern struct rt_device uart3_device; extern struct rt_device uart3_device;
extern void rt_hw_serial_isr(struct rt_device *device); extern void rt_hw_serial_isr(struct rt_device *device);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -219,77 +218,7 @@ void USART3_IRQHandler(void)
#endif #endif
} }
#if defined(RT_USING_DFS) && STM32_USE_SDIO #ifdef RT_USING_LWIP
/*******************************************************************************
* Function Name : SDIO_IRQHandler
* Description : This function handles SDIO global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SDIO_IRQHandler(void)
{
extern int SD_ProcessIRQSrc(void);
/* enter interrupt */
rt_interrupt_enter();
/* Process All SDIO Interrupt Sources */
SD_ProcessIRQSrc();
/* leave interrupt */
rt_interrupt_leave();
}
#endif
#ifdef RT_USING_LWIP
#ifdef STM32F10X_CL
/*******************************************************************************
* Function Name : ETH_IRQHandler
* Description : This function handles ETH interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void ETH_IRQHandler(void)
{
extern void rt_hw_stm32_eth_isr(void);
/* enter interrupt */
rt_interrupt_enter();
rt_hw_stm32_eth_isr();
/* leave interrupt */
rt_interrupt_leave();
}
#else
#if (STM32_ETH_IF == 0)
/*******************************************************************************
* Function Name : EXTI0_IRQHandler
* Description : This function handles External interrupt Line 0 request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void EXTI2_IRQHandler(void)
{
extern void enc28j60_isr(void);
/* enter interrupt */
rt_interrupt_enter();
enc28j60_isr();
/* Clear the Key Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line2);
/* leave interrupt */
rt_interrupt_leave();
}
#endif
#if (STM32_ETH_IF == 1)
/******************************************************************************* /*******************************************************************************
* Function Name : EXTI4_IRQHandler * Function Name : EXTI4_IRQHandler
* Description : This function handles External lines 9 to 5 interrupt request. * Description : This function handles External lines 9 to 5 interrupt request.
@ -299,22 +228,20 @@ void EXTI2_IRQHandler(void)
*******************************************************************************/ *******************************************************************************/
void EXTI4_IRQHandler(void) void EXTI4_IRQHandler(void)
{ {
extern void rt_dm9000_isr(void); extern void rt_dm9000_isr(void);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
/* Clear the DM9000A EXTI line pending bit */ /* Clear the DM9000A EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line4); EXTI_ClearITPendingBit(EXTI_Line4);
rt_dm9000_isr(); rt_dm9000_isr();
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
#endif #endif /* RT_USING_LWIP */
#endif
#endif /* end of RT_USING_LWIP */
/** /**
* @} * @}