提交 65b4117c 编写于 作者: wuyangyong's avatar wuyangyong

add stm32 cl

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@32 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 4cd031e3
......@@ -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;
}
#include <rtthread.h>
#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();
}
......@@ -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);
......
......@@ -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 */
......
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册