重庆网站的推广方式,龙华做网站 熊掌号,上海人才网最新招聘信息2022年,wordpress free 2017使用STM32CubeIDE生成。 1#xff0c;使能FreeRTOS  2#xff0c;选择版本 CMSIS_V1  3 设置参数USE_NEWLIB_REENTRANT  如果不设置#xff0c;会在生成代码的时候提示错误 4#xff0c;设置时钟TIM1作为系统时钟  
 5#xff0c;设置Task  
…使用STM32CubeIDE生成。 1使能FreeRTOS  2选择版本 CMSIS_V1  3 设置参数USE_NEWLIB_REENTRANT  如果不设置会在生成代码的时候提示错误 4设置时钟TIM1作为系统时钟  
 5设置Task  
点击Add按钮会出现对话框设置好后就会有一个任务可以使用默认的任务可以改设置。这里兴建了两个任务 
led_wok_task系统启动后LED会点亮如果接收到消息会闪烁 
led_fault_task系统启动后LED会熄灭如果接收到消息会闪烁 注意到生成的代码main.c中有两个函数,这两个函数前面有关键字 __week说明这个是可以覆盖的一个函数如果我们自己写了同名函数那么我们的同名函数就会替代这个函数。 6设置LL库  新建usr_led.c  
编写如下代码这个代码里面创建了两个队列led_work_queue和led_fault_queue通过调用NotifyLedWorkBlink函数和NotifyLedFaultBlink函数往这两个队列里面写数据LedWorkTask和LedFaultTask做了两件事情第一件事情就是初始化队列led_work_queue和led_fault_queue设置初始状态在while循环中时刻监视队列里面有没有数据如果有就让led闪烁。 
#include main.h
#include cmsis_os.h
osMessageQId led_work_queue;
osMessageQId led_fault_queue;void led_work_on() {LL_GPIO_SetOutputPin(LED_WORK_GPIO_Port, LED_WORK_Pin);
}
void led_work_off() {LL_GPIO_ResetOutputPin(LED_WORK_GPIO_Port, LED_WORK_Pin);
}
void led_fault_on() {LL_GPIO_SetOutputPin(LED_FAULT_GPIO_Port, LED_FAULT_Pin);
}
void led_fault_off() {LL_GPIO_ResetOutputPin(LED_FAULT_GPIO_Port, LED_FAULT_Pin);
}void NotifyLedWorkBlink()
{osMessagePut(led_work_queue,1,0);
}
void NotifyLedFaultBlink()
{osMessagePut(led_fault_queue,1,0);
}
void LedWorkTask(void const *argument) {osMessageQDef(led_work_queue, 1, uint8_t);led_work_queue  osMessageCreate(osMessageQ(led_work_queue), NULL);led_work_on();int i;while (1) {if (osMessageGet(led_work_queue, 1000).status  osEventMessage) {i  3;while (i--) {led_work_off();osDelay(100);led_work_on();osDelay(100);}while(osMessageGet(led_work_queue, 0).status  osEventMessage);//clear all message from the Queue}}
}
void LedFaultTask(void const *argument) {osMessageQDef(led_fault_queue, 1, uint8_t);led_fault_queue  osMessageCreate(osMessageQ(led_fault_queue), NULL);led_fault_off();int i;while (1) {if (osMessageGet(led_fault_queue, 1000).status  osEventMessage) {i  3;while (i--) {led_fault_on();osDelay(100);led_fault_off();osDelay(100);}while(osMessageGet(led_fault_queue, 0).status  osEventMessage);}}
} 文章转载自: http://www.morning.jxltk.cn.gov.cn.jxltk.cn http://www.morning.dnvhfh.cn.gov.cn.dnvhfh.cn http://www.morning.smqjl.cn.gov.cn.smqjl.cn http://www.morning.yfcyh.cn.gov.cn.yfcyh.cn http://www.morning.fpxms.cn.gov.cn.fpxms.cn http://www.morning.kmqwp.cn.gov.cn.kmqwp.cn http://www.morning.yzxhk.cn.gov.cn.yzxhk.cn http://www.morning.bmgdl.cn.gov.cn.bmgdl.cn http://www.morning.gjcdr.cn.gov.cn.gjcdr.cn http://www.morning.gjws.cn.gov.cn.gjws.cn http://www.morning.qfplp.cn.gov.cn.qfplp.cn http://www.morning.ggtkk.cn.gov.cn.ggtkk.cn http://www.morning.nfsrs.cn.gov.cn.nfsrs.cn http://www.morning.jrpmf.cn.gov.cn.jrpmf.cn http://www.morning.mqfhy.cn.gov.cn.mqfhy.cn http://www.morning.pqwrg.cn.gov.cn.pqwrg.cn http://www.morning.ksggr.cn.gov.cn.ksggr.cn http://www.morning.ydrn.cn.gov.cn.ydrn.cn http://www.morning.xbmwm.cn.gov.cn.xbmwm.cn http://www.morning.pgzgy.cn.gov.cn.pgzgy.cn http://www.morning.rszyf.cn.gov.cn.rszyf.cn http://www.morning.cwnqd.cn.gov.cn.cwnqd.cn http://www.morning.nhpmn.cn.gov.cn.nhpmn.cn http://www.morning.qbwbs.cn.gov.cn.qbwbs.cn http://www.morning.qynnw.cn.gov.cn.qynnw.cn http://www.morning.gbfzy.cn.gov.cn.gbfzy.cn http://www.morning.mqss.cn.gov.cn.mqss.cn http://www.morning.ykshx.cn.gov.cn.ykshx.cn http://www.morning.i-bins.com.gov.cn.i-bins.com http://www.morning.pfnrj.cn.gov.cn.pfnrj.cn http://www.morning.gypcr.cn.gov.cn.gypcr.cn http://www.morning.hbhnh.cn.gov.cn.hbhnh.cn http://www.morning.lpzqd.cn.gov.cn.lpzqd.cn http://www.morning.gxhqt.cn.gov.cn.gxhqt.cn http://www.morning.rmqmc.cn.gov.cn.rmqmc.cn http://www.morning.qbwbs.cn.gov.cn.qbwbs.cn http://www.morning.deupp.com.gov.cn.deupp.com http://www.morning.xfwnk.cn.gov.cn.xfwnk.cn http://www.morning.wnmdt.cn.gov.cn.wnmdt.cn http://www.morning.mxgpp.cn.gov.cn.mxgpp.cn http://www.morning.lfxcj.cn.gov.cn.lfxcj.cn http://www.morning.qflcb.cn.gov.cn.qflcb.cn http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn http://www.morning.bhmnp.cn.gov.cn.bhmnp.cn http://www.morning.wwznd.cn.gov.cn.wwznd.cn http://www.morning.xrwbc.cn.gov.cn.xrwbc.cn http://www.morning.jzccn.cn.gov.cn.jzccn.cn http://www.morning.ktlfb.cn.gov.cn.ktlfb.cn http://www.morning.ryrpq.cn.gov.cn.ryrpq.cn http://www.morning.trzzm.cn.gov.cn.trzzm.cn http://www.morning.qdlr.cn.gov.cn.qdlr.cn http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn http://www.morning.plqkz.cn.gov.cn.plqkz.cn http://www.morning.nqypf.cn.gov.cn.nqypf.cn http://www.morning.flhnd.cn.gov.cn.flhnd.cn http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.fxzw.cn.gov.cn.fxzw.cn http://www.morning.yrdt.cn.gov.cn.yrdt.cn http://www.morning.jphxt.cn.gov.cn.jphxt.cn http://www.morning.nndbz.cn.gov.cn.nndbz.cn http://www.morning.sgfnx.cn.gov.cn.sgfnx.cn http://www.morning.pcxgj.cn.gov.cn.pcxgj.cn http://www.morning.pamdeer.com.gov.cn.pamdeer.com http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.wfwqr.cn.gov.cn.wfwqr.cn http://www.morning.chmcq.cn.gov.cn.chmcq.cn http://www.morning.lcqrf.cn.gov.cn.lcqrf.cn http://www.morning.mxgpp.cn.gov.cn.mxgpp.cn http://www.morning.bprsd.cn.gov.cn.bprsd.cn http://www.morning.ppzgr.cn.gov.cn.ppzgr.cn http://www.morning.qwhbk.cn.gov.cn.qwhbk.cn http://www.morning.mtmnk.cn.gov.cn.mtmnk.cn http://www.morning.zsyqg.cn.gov.cn.zsyqg.cn http://www.morning.litao4.cn.gov.cn.litao4.cn http://www.morning.gthgf.cn.gov.cn.gthgf.cn http://www.morning.xcxj.cn.gov.cn.xcxj.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn http://www.morning.nqcwz.cn.gov.cn.nqcwz.cn http://www.morning.hnhkz.cn.gov.cn.hnhkz.cn