我建立的第一个 项目---让一个灯闪起来了。。。
我做的增加内容包括:
1.声明了一下 Task_Led2 static OS_STK Task_Led2Stk[Task_Led2_STK_SIZE];
2.不知道什么意义 static void Task_Led2(void* p_arg);
3.BSP_Init 硬件初始化中,我对led初始化话的函数 GPIO_Configuration 中添加了
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOD, &GPIO_InitStructure); //此刻注意是GPIOD 而不是GPIOB
4,建立led2任务
OSTaskCreateExt(Task_Led2,
(void *)0,
(OS_STK *)&Task_Led2Stk[Task_Led2_STK_SIZE-1],
Task_Led2_PRIO,
Task_Led2_PRIO,
(OS_STK *)&Task_Led2Stk[0],
Task_Led2_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR);
5,建立闪烁函数
static void Task_Led2(void* p_arg) //我又加入一个灯亮
{
(void) p_arg;
while (1)
{ /* 100ms间隔LED闪烁 */
Led1_ON();
OSTimeDlyHMSM(0, 0, 0, 100);
Led1_OFF();
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
6. 对 Led1_ON() 开和关进行设置
#define Led1_ON() GPIO_SetBits(GPIOD, GPIO_Pin_6); //LED11亮
#define Led1_OFF() GPIO_ResetBits(GPIOD, GPIO_Pin_6); //LED12灭
7.功盖任务建立存储空间
TASK STACK SIZES
* Size of the task stacks (# of OS_STK entries)
*********************************************************************************************************
*/
#define APP_TASK_START_STK_SIZE 128
#define APP_TASK_KBD_STK_SIZE 256
#define Task_Com1_STK_SIZE 256
#define APP_TASK_USER_IF_STK_SIZE 512
#define Task_Adc_STK_SIZE 512
#define Task_Led1_STK_SIZE 128
#define Task_Led2_STK_SIZE 128
#define Task_Led3_STK_SIZE
浙公网安备 33010602011771号