mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-25 16:57:20 +00:00
It is a big patch for stm32f0x, see the fellow :
1. fix heap management for stm32f0xx(SRAM=8k)
2. add USART1, USART2 driver for stm32f051R8
3. fix finsh support for stm32f0x
4. fix board components initial for stm32f0x and open debug msg
5. add led driver(pc9) and test thread for stm32f0discovery board
6. add init thread for stm32f0x do components initial
7. add rcc initial for stm32f0x in rt_hw_board_init()
8. add print rcc freq information function
the console output example is:
SYSCLK_Frequency is 48000000HZ
PCLK_Frequency is 48000000HZ
HCLK_Frequency is 48000000HZ
CECCLK_Frequency is 32786HZ
ADCCLK_Frequency is 14000000HZ
USART1CLK_Frequency is 48000000HZ
I2C1CLK_Frequency is 8000000HZ
SystemCoreClock is 48000000HZ
initialize rti_start:0 done
\ | /
- RT - Thread Operating System
/ | \ 1.2.0 build Nov 15 2013
2006 - 2013 Copyright by rt-thread team
do components intialization.
initialize rti_board_end:0 done
initialize rt_hw_led_init:32768 done
initialize finsh_system_init:0 done
finsh>>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
* 2013-11-15 bright add init thread and components initial
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -21,63 +22,65 @@
|
||||
|
||||
#include <board.h>
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
#include <components.h>
|
||||
#endif /* RT_USING_COMPONENTS_INIT */
|
||||
|
||||
/*
|
||||
LED_GREEN: PC8
|
||||
LED_RED : PC9
|
||||
*/
|
||||
#define rt_hw_led_on() GPIO_SetBits(GPIOC, GPIO_Pin_9)
|
||||
#define rt_hw_led_off() GPIO_ResetBits(GPIOC, GPIO_Pin_9)
|
||||
|
||||
static void rt_hw_led_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* Enable the GPIO_LED Clock */
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
|
||||
|
||||
/* Configure the GPIO_LED pin */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
static char led_stack[384];
|
||||
static struct rt_thread led_thread;
|
||||
#include "led.h"
|
||||
|
||||
/* led thread entry */
|
||||
static void led_thread_entry(void* parameter)
|
||||
{
|
||||
rt_hw_led_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
rt_hw_led_on();
|
||||
rt_thread_delay(RT_TICK_PER_SECOND/4);
|
||||
rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
|
||||
rt_hw_led_off();
|
||||
rt_thread_delay(RT_TICK_PER_SECOND/4);
|
||||
}
|
||||
rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
static void rt_init_thread_entry(void* parameter)
|
||||
{
|
||||
rt_thread_t led_thread;
|
||||
|
||||
/* Initialization RT-Thread Components */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
/* Set finsh device */
|
||||
#ifdef RT_USING_FINSH
|
||||
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
/* Create led thread */
|
||||
led_thread = rt_thread_create("led",
|
||||
led_thread_entry, RT_NULL,
|
||||
256, 20, 20);
|
||||
if(led_thread != RT_NULL)
|
||||
rt_thread_startup(led_thread);
|
||||
}
|
||||
|
||||
int rt_application_init()
|
||||
{
|
||||
rt_err_t result;
|
||||
rt_thread_t init_thread;
|
||||
|
||||
result = rt_thread_init(&led_thread,
|
||||
"led",
|
||||
led_thread_entry,
|
||||
RT_NULL,
|
||||
&led_stack[0],
|
||||
sizeof(led_stack),
|
||||
4,
|
||||
2);
|
||||
if(result == RT_EOK) rt_thread_startup(&led_thread);
|
||||
#if (RT_THREAD_PRIORITY_MAX == 32)
|
||||
init_thread = rt_thread_create("init",
|
||||
rt_init_thread_entry, RT_NULL,
|
||||
512, 8, 20);
|
||||
#else
|
||||
init_thread = rt_thread_create("init",
|
||||
rt_init_thread_entry, RT_NULL,
|
||||
512, 80, 20);
|
||||
#endif
|
||||
if(init_thread != RT_NULL)
|
||||
rt_thread_startup(init_thread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
Reference in New Issue
Block a user