|
自己學(xué)著將ucosiii移植到stm32f7中了
單片機源程序如下:
- #include "main.h"
- #include "stm32f7xx_hal.h"
- #include "sysclk.h"
- #include "uart.h"
- #include "stdio.h"
- #include "os.h"
- int fputc(int ch, FILE *f);
- #define START_TASK_PRIO 6u
- #define START_STK_SIZE 128
- OS_TCB StartTaskTCB;
- CPU_STK START_TASK_STK[START_STK_SIZE];
- void Start_Task(void *p_arg);
- #define TASK1_TASK_PRIO 7u
- #define TASK1_STK_SIZE 128
- OS_TCB TASK1_TCB;
- CPU_STK TASK1_TASK_STK[TASK1_STK_SIZE];
- void task1(void *p_arg);
- int main(void)
- {
- HAL_Init();
- Sysclk_config();
- USART1_UART_Init(19200);
- printf("usart1 config!\n");
- OS_ERR err;
- CPU_SR_ALLOC();
- OSInit(&err);
- CPU_CRITICAL_ENTER();
- OSTaskCreate(
- (OS_TCB *) &StartTaskTCB,
- (CPU_CHAR*) "start_task",
- (OS_TASK_PTR) Start_Task,
- (void*) 0u,
- ( OS_PRIO ) START_TASK_PRIO,
- (CPU_STK *) &START_TASK_STK[0],
- (CPU_STK_SIZE)START_STK_SIZE/10,
- (CPU_STK_SIZE)START_STK_SIZE,
- (OS_MSG_QTY) 0u,
- (OS_TICK) 0u,
- (void*) 0u,
- (OS_OPT) OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR,
- (OS_ERR*) &err);
- CPU_CRITICAL_EXIT();
-
- OSStart(&err);
- }
- void Start_Task(void *p_arg){
- OS_ERR err;
- CPU_SR_ALLOC();
- p_arg=p_arg;
- CPU_CRITICAL_ENTER();
- OSTaskCreate(
- (OS_TCB *) &TASK1_TCB,
- (CPU_CHAR*) "task1",
- (OS_TASK_PTR) task1,
- (void*) 0u,
- ( OS_PRIO ) TASK1_TASK_PRIO,
- (CPU_STK *) &TASK1_TASK_STK[0],
- (CPU_STK_SIZE)TASK1_STK_SIZE/10,
- (CPU_STK_SIZE)TASK1_STK_SIZE,
- (OS_MSG_QTY) 0u,
- (OS_TICK) 0u,
- (void*) 0u,
- (OS_OPT) OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR,
- (OS_ERR*) &err);
- CPU_CRITICAL_EXIT();
- printf("creat start task!\n");
- }
- void task1(void *p_arg){
- p_arg=p_arg;
- CPU_SR_ALLOC();
- while(1){
- CPU_CRITICAL_ENTER();
- printf("creat task1!\n");
- CPU_CRITICAL_EXIT();
- HAL_Delay(2000);
- }
- }
- int fputc(int ch, FILE *f)
- {
- HAL_UART_Transmit(&huart1 , (uint8_t *)&ch, 1, 2);
-
- return ch;
- }
- void _Error_Handler(char *file, int line)
- {
- while(1)
- {
- }
- }
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復(fù)制代碼
所有資料51hei提供下載:
ucosiii_stm32f746_template.rar
(1.63 MB, 下載次數(shù): 19)
2018-10-12 10:16 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|