diff --git a/bsp/stm32_lib3.1.0/app.c b/bsp/stm32_lib3.1.0/app.c index 93c25227a1d7ec2704f689d47620f19ed1d3c08a..1bcc6b81d4f56ac8ecce1b29e7a374f3b36cbdef 100644 --- a/bsp/stm32_lib3.1.0/app.c +++ b/bsp/stm32_lib3.1.0/app.c @@ -23,14 +23,14 @@ void rt_init_thread_entry001(void *parameter) GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(LEDG_PORT,&GPIO_InitStructure); - while(1) + while (1) { - rt_kprintf("thread001:%d\r\n",count++); - GPIO_ResetBits(LEDG_PORT,LEDG_PIN); - rt_thread_delay(64); - rt_kprintf("thread001:%d\r\n",count++); - GPIO_SetBits(LEDG_PORT,LEDG_PIN); - rt_thread_delay(64); + rt_kprintf("thread001:%d\r\n",count++); + GPIO_ResetBits(LEDG_PORT,LEDG_PIN); + rt_thread_delay(RT_TICK_PER_SECOND); + rt_kprintf("thread001:%d\r\n",count++); + GPIO_SetBits(LEDG_PORT,LEDG_PIN); + rt_thread_delay(RT_TICK_PER_SECOND); } } @@ -48,23 +48,23 @@ void rt_init_thread_entry002(void *parameter) GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(LEDR_PORT,&GPIO_InitStructure); - while(1) + while (1) { - rt_kprintf("thread001:%d\r\n",count++); - GPIO_ResetBits(LEDR_PORT,LEDR_PIN); - rt_thread_delay(32); - rt_kprintf("thread001:%d\r\n",count++); - GPIO_SetBits(LEDR_PORT,LEDR_PIN); - rt_thread_delay(32); + rt_kprintf("thread001:%d\r\n",count++); + GPIO_ResetBits(LEDR_PORT,LEDR_PIN); + rt_thread_delay(RT_TICK_PER_SECOND*2); + rt_kprintf("thread001:%d\r\n",count++); + GPIO_SetBits(LEDR_PORT,LEDR_PIN); + rt_thread_delay(RT_TICK_PER_SECOND*2); } } int rt_application_init() { - rt_thread_init(&thread001,"led",rt_init_thread_entry001,RT_NULL,&thread001_stack[0], sizeof(thread001_stack),20,10); - rt_thread_init(&thread002,"led2",rt_init_thread_entry002,RT_NULL,&thread002_stack[0], sizeof(thread002_stack),20,10); - rt_thread_startup(&thread001); - rt_thread_startup(&thread002); + rt_thread_init(&thread001,"led",rt_init_thread_entry001,RT_NULL,&thread001_stack[0], sizeof(thread001_stack),20,10); + rt_thread_init(&thread002,"led2",rt_init_thread_entry002,RT_NULL,&thread002_stack[0], sizeof(thread002_stack),20,10); + rt_thread_startup(&thread001); + rt_thread_startup(&thread002); return 0; } diff --git a/bsp/stm32_lib3.1.0/board.c b/bsp/stm32_lib3.1.0/board.c index 70b6a212f42ed6e62e6cea51fdef24b6aee8a4a9..6e6b06a65f22320b8f0c01dbfa2fefbf6b99d82d 100644 --- a/bsp/stm32_lib3.1.0/board.c +++ b/bsp/stm32_lib3.1.0/board.c @@ -1,59 +1,6 @@ #include #include "stm32f10x.h" - -ErrorStatus HSEStartUpStatus; - -/******************************************************************************* - * Function Name : RCC_Configuration - * Description : Configures the different system clocks. - * Input : None - * Output : None - * Return : None - *******************************************************************************/ -void RCC_Configuration(void) -{ - /* RCC system reset(for debug purpose) */ - RCC_DeInit(); - - /* Enable HSE */ - RCC_HSEConfig(RCC_HSE_ON); - - /* Wait till HSE is ready */ - HSEStartUpStatus = RCC_WaitForHSEStartUp(); - - if (HSEStartUpStatus == SUCCESS) - { - /* HCLK = SYSCLK */ - RCC_HCLKConfig(RCC_SYSCLK_Div1); - - /* PCLK2 = HCLK */ - RCC_PCLK2Config(RCC_HCLK_Div1); - /* PCLK1 = HCLK/2 */ - RCC_PCLK1Config(RCC_HCLK_Div2); - - /* Flash 2 wait state */ - FLASH_SetLatency(FLASH_Latency_2); - /* Enable Prefetch Buffer */ - FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); - - /* PLLCLK = 8MHz * 9 = 72 MHz */ - RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_6); - - /* Enable PLL */ - RCC_PLLCmd(ENABLE); - - /* Wait till PLL is ready */ - while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) ; - - /* Select PLL as system clock source */ - RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); - - /* Wait till PLL is used as system clock source */ - while (RCC_GetSYSCLKSource() != 0x08) ; - } -} - /******************************************************************************* * Function Name : NVIC_Configuration * Description : Configures the nested vectored interrupt controller. @@ -90,8 +37,6 @@ void SysTick_Configuration(void) SysTick_Config(cnts); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); - //SysTick_CounterCmd(SysTick_Counter_Enable); - //SysTick_ITConfig(ENABLE); } /* init console to support rt_kprintf */ @@ -173,8 +118,6 @@ void rt_hw_console_output(const char* str) void board_init(void) { - RCC_Configuration(); - /* NVIC Configuration */ NVIC_Configuration(); @@ -191,12 +134,12 @@ void board_init(void) extern void rt_hw_interrupt_thread_switch(void); void rt_hw_timer_handler(void) { - /* enter interrupt */ - rt_interrupt_enter(); + /* enter interrupt */ + rt_interrupt_enter(); - rt_tick_increase(); + rt_tick_increase(); - /* leave interrupt */ - rt_interrupt_leave(); - rt_hw_interrupt_thread_switch(); + /* leave interrupt */ + rt_interrupt_leave(); + rt_hw_interrupt_thread_switch(); } diff --git a/bsp/stm32_lib3.1.0/main.c b/bsp/stm32_lib3.1.0/main.c index ae8c60ef2279608725d4e3487804a80216592561..16fdf00acff18cfd321590a2aec6803140f5165d 100644 --- a/bsp/stm32_lib3.1.0/main.c +++ b/bsp/stm32_lib3.1.0/main.c @@ -15,54 +15,55 @@ extern int __bss_end; void rtthread_startup(void) { - board_init(); - /* show version */ - 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*)0x20005000); - //#warning Image$$RW_IRAM1$$ZI$$Limit + rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x20005000); + //#warning Image$$RW_IRAM1$$ZI$$Limit #elif __ICCARM__ rt_system_heap_init(__segment_end("HEAP"), (void*)0x20005000); #else - /* init memory system */ - rt_system_heap_init((void*)&__bss_end, (void*)0x20005000); + /* init memory system */ + rt_system_heap_init((void*)&__bss_end, (void*)0x20005000); #endif #endif - /* init scheduler system */ - rt_system_scheduler_init(); + /* init scheduler system */ + rt_system_scheduler_init(); - /* init all device */ - rt_device_init_all(); + /* init all device */ + rt_device_init_all(); - /* init application */ - rt_application_init(); + /* init application */ + rt_application_init(); - /* 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(); } int main(void) { - rt_uint32_t UNUSED level; + rt_uint32_t UNUSED level; - /* disable interrupt first */ - level = rt_hw_interrupt_disable(); + /* disable interrupt first */ + level = rt_hw_interrupt_disable(); + + SystemInit(); + board_init(); rtthread_startup(); while (1); diff --git a/bsp/stm32_lib3.1.0/stm32f10x_it.c b/bsp/stm32_lib3.1.0/stm32f10x_it.c index 8daa4f6e56e315651be407d4b6eb2675f16c03b7..6f25d7817ebb974300caee41160252027aa8982f 100644 --- a/bsp/stm32_lib3.1.0/stm32f10x_it.c +++ b/bsp/stm32_lib3.1.0/stm32f10x_it.c @@ -575,12 +575,12 @@ extern void rt_hw_timer_handler(void); void SysTickHandler(void) { - /* handle os tick */ - rt_hw_timer_handler(); + /* handle os tick */ + rt_hw_timer_handler(); } /******************************************************************************* -* Function Name : +* Function Name : * Description : This function handles Usage Fault exception. * Input : None * Output : None @@ -912,7 +912,37 @@ void SDIO_IRQHandler(void) { } +void DMA2_Channel5_IRQHandler(void) +{ +} + +void ETH_IRQHandler(void) +{ +} + +void ETH_WKUP_IRQHandler(void) +{ +} + +void CAN2_TX_IRQHandler(void) +{ +} +void CAN2_RX0_IRQHandler(void) +{ +} + +void CAN2_RX1_IRQHandler(void) +{ +} + +void CAN2_SCE_IRQHandler(void) +{ +} + +void OTG_FS_IRQHandler(void) +{ +} /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ diff --git a/bsp/stm32_lib3.1.0/stm32f10x_it.h b/bsp/stm32_lib3.1.0/stm32f10x_it.h index daf2abdc2b74ad51dd9f7cc6606012082c90a579..fe38e5449822798d9cf2de772d6680ea40a79e8e 100644 --- a/bsp/stm32_lib3.1.0/stm32f10x_it.h +++ b/bsp/stm32_lib3.1.0/stm32f10x_it.h @@ -97,6 +97,7 @@ extern "C" void EXTI15_10_IRQHandler(void); void RTCAlarm_IRQHandler(void); void USBWakeUp_IRQHandler(void); + /****** HD ******/ void TIM8_BRK_IRQHandler(void); void TIM8_UP_IRQHandler(void); void TIM8_TRG_COM_IRQHandler(void); @@ -114,6 +115,15 @@ extern "C" void DMA2_Channel2_IRQHandler(void); void DMA2_Channel3_IRQHandler(void); void DMA2_Channel4_5_IRQHandler(void); + /********* CL **********/ + void DMA2_Channel5_IRQHandler(void); + void ETH_IRQHandler(void); + void ETH_WKUP_IRQHandler(void); + void CAN2_TX_IRQHandler(void); + void CAN2_RX0_IRQHandler(void); + void CAN2_RX1_IRQHandler(void); + void CAN2_SCE_IRQHandler(void); + void OTG_FS_IRQHandler(void); #ifdef __cplusplus }