[六足机器人]基于ucosii的F407VGT6

本文介绍了一个基于uC/OS-II操作系统的STM32应用实例,包括任务调度、SPI通信、NRF24L01无线模块使用等关键技术实现细节。

主函数

#include "gui.h"
#include "stm32f4xx.h"
#include "delay.h"
#include "led.h"
#include "usart.h"
#include "ucos_ii.h"
#include "pwm.h"
#include "control.h"
#include "app_cfg.h"
#include "bsp.h"
#include "24l01.h"
#include "spi.h"

//Task Stack Setting
#define  APP_TASK_START_STK_SIZE           512
#define  APP_LED1_STK_SIZE			   	   1024
#define  APP_NRF24L01_STK_SIZE			   1024
#define  APP_LED3_STK_SIZE			       1024

//Task Priority
#define  APP_TASK_START_PRIO               3
#define  APP_LED1_PRIO                     5
#define  APP_NRF24L01_PRIO                 4
#define  APP_LED3_PRIO                     7

//Stack Size setting 
static  OS_STK App_TaskStartStk[APP_TASK_START_STK_SIZE];
static  OS_STK App_LED1Stk[APP_LED1_STK_SIZE];
static  OS_STK App_NRF24L01Stk[APP_NRF24L01_STK_SIZE];
static  OS_STK App_LED3Stk[APP_LED3_STK_SIZE];

//Function Statement
static  void  App_TaskStart(void *p_arg);
static  void  App_Task_LED1(void *p_arg);
static  void  App_Task_NRF24L01(void *p_arg);
static  void  App_Task_ACTION(void *p_arg);

u8 tmp_buf[33];//data received buffer
u8 cmd_last = 0xff;
static u8 cmd = 0;     //command of action

int main(void)
{  
    OSInit();      			   //uC/OS-II init
	TIM_Init();
	NRF24L01_Init();    
//	Stand_Up();
	LED_Init();         		//LED Init
	while(NRF24L01_Check())
	{
    	LED1(On);
		OSTimeDlyHMSM(0,0,0,50);
		LED1(Off);
		OSTimeDlyHMSM(0,0,0,50);
	}
	RX_Mode();						
    OSTaskCreate(App_TaskStart,(void*)0,(OS_STK*)&App_TaskStartStk[APP_TASK_START_STK_SIZE-1],APP_TASK_START_PRIO);    
    OSStart();                                                  
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值