-
按照我这个图操作吧
-
你这图狗屁不通呢 电都不知道如何走了 上管和上管导通
-
这程序过于欠缺
不懂硬件的根本无法操作
-
最后修改启动文件startup_stm32f10x_hd.s ,加载不同的启动文件 时不用怕,修改的内容都是一样的:
OS_CPU_PendSVHandler 替换所有的PendSV_Handler
OS_CPU_SysTickHandler替换所有的SysTick_Handler
使中断执行uCos的中断函数。
-
CPU_CHAR *pstr_fmt = (CPU_CHAR *)0;
CPU_DATA i = 0u;
CPU_INT32U nbr_fmt = 0u;
CPU_INT32U nbr_log = 0u;
CPU_INT08U nbr_dig_max = 0u;
CPU_INT08U nbr_dig_min = 0u;
CPU_INT08U nbr_dig_fmtd = 0u;
CPU_INT08U nbr_neg_sign = 0u;
CPU_INT08U nbr_lead_char = 0u;
CPU_INT08U dig_val = 0u;
CPU_INT08U lead_char_delta_0 = 0u;
CPU_INT08U lead_char_delta_a = 0u;
CPU_BOOLEAN lead_char_dig = 0u;
CPU_BOOLEAN lead_char_0 = 0u;
CPU_BOOLEAN fmt_invalid = 0u;
CPU_BOOLEAN print_char = 0u;
CPU_BOOLEAN nbr_neg_fmtd = 0u;
-
修改os_cfg.h
OS_CFG_TS_EN宏定义改为0u
OS_CFG_SCHED_LOCK_TIME_MEAS_EN 宏定义改为0u
OS_CFG_TASK_DEL_EN 宏定义改为 1u
其它可根据自己的功能需要 先1u或ou。
-
cpu_a.s
;********************************************************************************************************
; uC/CPU
; CPU CONFIGURATION & PORT LAYER
;
; (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
;
; All rights reserved. Protected by international copyright laws.
;
; uC/CPU is provided in source form to registered licensees ONLY. It is
; illegal to distribute this source code to any third party unless you receive
; written permission by an authorized Micrium representative. Knowledge of
; the source code may NOT be used to develop a similar product.
;
; Please help us continue to provide the Embedded community with the finest
; software available. Your honesty is greatly appreciated.
;
; You can contact us at www.micrium.com.
;********************************************************************************************************
;********************************************************************************************************
;
; CPU PORT FILE
;
; ARM-Cortex-M3
; GNU C Compiler
;
; Filename : cpu_a.s
; Version : V1.29.00.00
; Programmer(s) : JJL
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
EXPORT CPU_IntDis
EXPORT CPU_IntEn
EXPORT CPU_SR_Save
EXPORT CPU_SR_Restore
EXPORT CPU_WaitForInt
EXPORT CPU_WaitForExcept
EXPORT CPU_CntLeadZeros
EXPORT CPU_CntTrailZeros
EXPORT CPU_RevBits
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
PRESERVE8
AREA |.text|, CODE, READONLY
THUMB
;$PAGE
;********************************************************************************************************
; DISABLE and ENABLE INTERRUPTS
;
; Description : Disable/Enable interrupts.
;
; Prototypes : void CPU_IntDis(void);
; void CPU_IntEn (void);
;********************************************************************************************************
;.thumb_func
CPU_IntDis
CPSID I
BX LR
;.thumb_func
CPU_IntEn
CPSIE I
BX LR
;********************************************************************************************************
; CRITICAL SECTION FUNCTIONS
;
; Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the
; state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts
; are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts).
; The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register.
;
; Prototypes : CPU_SR CPU_SR_Save (void);
; void CPU_SR_Restore(CPU_SR cpu_sr);
;
; Note(s) : (1) These functions are used in general like this :
;
; void Task (void *p_arg)
; {
; CPU_SR_ALLOC(); /* Allocate storage for CPU status register */
; :
; :
; CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */
; :
; :
; CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */
; :
; }
;********************************************************************************************************
;.thumb_func
CPU_SR_Save
MRS R0, PRIMASK ; Set prio int mask to mask all (except faults)
CPSID I
BX LR
;.thumb_func
CPU_SR_Restore ; See Note #2.
MSR PRIMASK, R0
BX LR
;$PAGE
;********************************************************************************************************
; WAIT FOR INTERRUPT
;
; Description : Enters sleep state, which will be exited when an interrupt is received.
;
; Prototypes : void CPU_WaitForInt (void)
;
; Argument(s) : none.
;********************************************************************************************************
;.thumb_func
CPU_WaitForInt
WFI ; Wait for interrupt
BX LR
;********************************************************************************************************
; WAIT FOR EXCEPTION
;
; Description : Enters sleep state, which will be exited when an exception is received.
;
; Prototypes : void CPU_WaitForExcept (void)
;
; Argument(s) : none.
;********************************************************************************************************
;.thumb_func
CPU_WaitForExcept
WFE ; Wait for exception
BX LR
;$PAGE
;********************************************************************************************************
; CPU_CntLeadZeros()
; COUNT LEADING ZEROS
;
; Description : Counts the number of contiguous, most-significant, leading zero bits before the
; first binary one bit in a data value.
;
; Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val);
;
; Argument(s) : val Data value to count leading zero bits.
;
; Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'.
;
; Caller(s) : Application.
;
; This function is an INTERNAL CPU module function but MAY be called by application
; function(s).
;
; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
; CPU WORD CONFIGURATION Note #1').
;
; (b) For 32-bit values :
;
; b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros
; --- --- --- --- --- --- --- --- ---------------
; 1 x x x x x x x 0
; 0 1 x x x x x x 1
; 0 0 1 x x x x x 2
; : : : : : : : : :
; : : : : : : : : :
; 0 0 0 1 x x x x 27
; 0 0 0 0 1 x x x 28
; 0 0 0 0 0 1 x x 29
; 0 0 0 0 0 0 1 x 30
; 0 0 0 0 0 0 0 1 31
; 0 0 0 0 0 0 0 0 32
;
;
; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT is
; #define'd in 'cpu_cfg.h' or 'cpu.h'.
;********************************************************************************************************
;.thumb_func
CPU_CntLeadZeros
CLZ R0, R0 ; Count leading zeros
BX LR
;$PAGE
;********************************************************************************************************
; CPU_CntTrailZeros()
; COUNT TRAILING ZEROS
;
; Description : Counts the number of contiguous, least-significant, trailing zero bits before the
; first binary one bit in a data value.
;
; Prototype : CPU_DATA CPU_CntTrailZeros(CPU_DATA val);
;
; Argument(s) : val Data value to count trailing zero bits.
;
; Return(s) : Number of contiguous, least-significant, trailing zero bits in 'val'.
;
; Caller(s) : Application.
;
; This function is an INTERNAL CPU module function but MAY be called by application
; function(s).
;
; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
; CPU WORD CONFIGURATION Note #1').
;
; (b) For 32-bit values :
;
; b31 b30 b29 b28 b27 ... b02 b01 b00 # Trailing Zeros
; --- --- --- --- --- --- --- --- ----------------
; x x x x x x x 1 0
; x x x x x x 1 0 1
; x x x x x 1 0 0 2
; : : : : : : : : :
; : : : : : : : : :
; x x x x 1 0 0 0 27
; x x x 1 0 0 0 0 28
; x x 1 0 0 0 0 0 29
; x 1 0 0 0 0 0 0 30
; 1 0 0 0 0 0 0 0 31
; 0 0 0 0 0 0 0 0 32
;
;
; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT is
; #define'd in 'cpu_cfg.h' or 'cpu.h'.
;********************************************************************************************************
;.thumb_func
CPU_CntTrailZeros
RBIT R0, R0 ; Reverse bits
CLZ R0, R0 ; Count leading zeros
BX LR
;$PAGE
;********************************************************************************************************
; CPU_RevBits()
; REVERSE BITS
;
; Description : Reverses the bits in a data value.
;
; Prototypes : CPU_DATA CPU_RevBits(CPU_DATA val);
;
; Argument(s) : val Data value to reverse bits.
;
; Return(s) : Value with all bits in 'val' reversed (see Note #1).
;
; Caller(s) : Application.
;
; This function is an INTERNAL CPU module function but MAY be called by application function(s).
;
; Note(s) : (1) The final, reversed data value for 'val' is such that :
;
; 'val's final bit 0 = 'val's original bit N
; 'val's final bit 1 = 'val's original bit (N - 1)
; 'val's final bit 2 = 'val's original bit (N - 2)
;
; ... ...
;
; 'val's final bit (N - 2) = 'val's original bit 2
; 'val's final bit (N - 1) = 'val's original bit 1
; 'val's final bit N = 'val's original bit 0
;********************************************************************************************************
;.thumb_func
CPU_RevBits
RBIT R0, R0 ; Reverse bits
BX LR
;$PAGE
;********************************************************************************************************
; CPU ASSEMBLY PORT FILE END
;********************************************************************************************************
END
-
下面对Project\App\uCOS_III\uC-CPU\Ports 下cpu_a.s进行修改, 因为这是GNU的汇编代码。
如下替换:
‘@’ 换为‘;’
.global 换为EXPORT
以下代码
.text
.align 2
.thumb
.syntax unified
换为
PRESERVE8
AREA |.text|, CODE, READONLY
THUMB
把函数名上的.thumb_func 在前后添加 ‘;’注释掉;
并把函数 名后紧跟的‘:’删除。
-
app_cfg.h
/*
*********************************************************************************************************
* EXAMPLE CODE
*
* (c) Copyright 2003-2007; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* APPLICATION CONFIGURATION
*
* ST Microelectronics STM32
* on the
*
* Micrium uC-Eval-STM32F107
* Evaluation Board
*
* Filename : app_cfg.h
* Version : V1.00
* Programmer(s) : FT
*********************************************************************************************************
*/
#ifndef APP_CFG_MODULE_PRESENT
#define APP_CFG_MODULE_PRESENT
/*
*********************************************************************************************************
* MODULE ENABLE / DISABLE
*********************************************************************************************************
*/
#define APP_CFG_FS_EN DEF_DISABLED
#define APP_CFG_USB_DEV_EN DEF_DISABLED
#define APP_CFG_USB_OTG_EN DEF_DISABLED
#define APP_CFG_USB_HOST_EN DEF_DISABLED
/*
*********************************************************************************************************
* TASKS NAMES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* TASK PRIORITIES
*********************************************************************************************************
*/
#define APP_TASK_START_PRIO 2
/*
*********************************************************************************************************
* TASK STACK SIZES
* Size of the task stacks (# of OS_STK entries)
*********************************************************************************************************
*/
#define APP_TASK_START_STK_SIZE 512
/*
*********************************************************************************************************
* uC/LIB CONFIGURATION
*********************************************************************************************************
*/
#define LIB_MEM_CFG_OPTIMIZE_ASM_EN DEF_ENABLED
#define LIB_MEM_CFG_ARG_CHK_EXT_EN DEF_ENABLED
#define LIB_MEM_CFG_ALLOC_EN DEF_ENABLED
#define LIB_MEM_CFG_POOL_NBR 10
#define LIB_MEM_CFG_HEAP_SIZE (2 * 1024L)
/*
*********************************************************************************************************
* BSP CONFIGURATION
*********************************************************************************************************
*/
#define BSP_CFG_SER_COMM_SEL BSP_SER_COMM_UART_02
/*
*********************************************************************************************************
* TRACE / DEBUG CONFIGURATION
*********************************************************************************************************
*/
#define TRACE_LEVEL_OFF 0
#define TRACE_LEVEL_INFO 1
#define TRACE_LEVEL_DBG 2
#define APP_TRACE_LEVEL TRACE_LEVEL_DBG
#define APP_TRACE BSP_Ser_Printf
#include
void BSP_Ser_Printf (CPU_CHAR *format, ...);
#define FS_TRACE_LEVEL TRACE_LEVEL_DBG
#define FS_TRACE BSP_Ser_Printf
#define APP_TRACE_INFO(x) ((APP_TRACE_LEVEL >= TRACE_LEVEL_INFO) ? (void)(APP_TRACE x) : (void)0)
#define APP_TRACE_DBG(x) ((APP_TRACE_LEVEL >= TRACE_LEVEL_DBG ) ? (void)(APP_TRACE x) : (void)0)
/* task priority */
#define STARTUP_TASK_PRIO 4
//#define TASK_MODBUS_PRIO 5
//#define TASK_SI4432_PRIO 6
#define TASK1_PRIO 10
#define TASK2_PRIO 13
#define TASK3_PRIO 14
/* task stack size */
#define STARTUP_TASK_STK_SIZE 100
#define TASK_MODBUS_SIZE 80
#define TASK1_STK_SIZE 80
#define TASK2_STK_SIZE 80
#define TASK3_STK_SIZE 80
//#define TASK_SI432_SIZE 80
#endif
-
Config.h
/****************************************Copyright (c)**************************************************
** Modified by: 王宏强
** Modified date: 2012-05-20
** Version: v3.0
** Descriptions: 修改用于STM32F10x
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "os.h"
/********************************/
/* 系统配置函数 */
/********************************/
#define LED_0 0
#define LED_1 1
#define LED_2 2
#define LED_3 3
#define LED_4 4
#define LED_5 5
void Delay(volatile CPU_INT32U nCount);
void IWDG_Init(void);
void SysTickInit(void);
void SystemConfigInit(void);
void led_init(void);
void led_on(CPU_INT32U n);
void led_off(CPU_INT32U n);
/********************************************************************************************************
** End Of File
********************************************************************************************************/
-
Config.c
/*
********************************************************************************
* uC/OS-II
*
* ARM Cortex-M3 Port
*
* File : Config.C
* Version : V1.0
* By : 王宏强
*
* For : Stm32f10x
* Mode : Thumb2
* Toolchain :
* RealView Microcontroller Development Kit (MDK)
* Keil uVision
* Description : STM32F10x 内部 系统的配置
*
* 1,系统中断优先级模式设置
* 2,系统程序启动指定
* 3,系统时钟计时器配置
* 4,芯片引脚初始化
*
* Date : 2012.05.22
*******************************************************************************/
#include "misc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_iwdg.h"
#include "config.h"
GPIO_InitTypeDef GPIO_InitStructure;
/*******************************************************************************
* Function Name : GPIO_Configuration
* Description : Configures the different GPIO ports.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void GPIO_Configuration(void)
{
#ifdef USE_STM3210B_EVAL
/* Enable the USART2 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
#endif
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOE, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, DISABLE);
}
/*******************************************************************************
* Function Name : Delay
* Description : Inserts a delay time.
* Input : nCount: specifies the delay time length.
* Output : None
* Return : None
*******************************************************************************/
void Delay(volatile CPU_INT32U nCount)
{
for(; nCount != 0; nCount--);
}
/*******************************************************************************
函 数 名:void IWDG_Init(void)
功能描述:看门狗初始化
入口参数:
返回参数:
创建时间: 2011.6.24
********************************************************************************/
void IWDG_Init(void)
{
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
IWDG_SetPrescaler( IWDG_Prescaler_64); //最小
IWDG_SetReload( 0x138); //40KHz内部时钟 0.5s
IWDG_WriteAccessCmd( IWDG_WriteAccess_Disable );
IWDG_Enable();
IWDG_ReloadCounter();
}
/*******************************************************************************
* Function Name :void SysTickInit(void)
* Description :系统定时器时间配置
* Input :
* Output :
* Other :时基为1ms
* Date :2011.11.03 12:59:13
*******************************************************************************/
void SysTickInit(void)
{
SysTick_Config(SystemCoreClock / 1000); //uCOS时基1ms
}
/*******************************************************************************
* Function Name :void InterruptOrder(void)
* Description :中断向量,优先级
* Input :
* Output :
* Other :
* Date :2011.10.27 11:50:05
*******************************************************************************/
void NVIC_Configuration(void)
{
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_1 );//优先级设置
}
/*******************************************************************************
* Function Name :void SystemConfig(void)
* Description :系统初始化
* Input :
* Output :
* Other :
* Date :2011.10.27 13:14:59
*******************************************************************************/
void SystemConfigInit(void)
{
NVIC_Configuration(); //中断优先级设置
GPIO_Configuration(); //端口初始化,所有端口关
}
void led_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void led_on(CPU_INT32U n)
{
switch (n)
{
case LED_0:
GPIO_SetBits(GPIOD, GPIO_Pin_2);
break;
case LED_1:
GPIO_SetBits(GPIOD, GPIO_Pin_3);
break;
case LED_2:
GPIO_SetBits(GPIOD, GPIO_Pin_4);
break;
case LED_3:
GPIO_SetBits(GPIOB, GPIO_Pin_9);
break;
case LED_4:
GPIO_SetBits(GPIOA, GPIO_Pin_12);
break;
case LED_5:
GPIO_SetBits(GPIOA, GPIO_Pin_11);
break;
default:
break;
}
}
void led_off(CPU_INT32U n)
{
switch (n)
{
case LED_0:
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
break;
case LED_1:
GPIO_ResetBits(GPIOD, GPIO_Pin_3);
break;
case LED_2:
GPIO_ResetBits(GPIOD, GPIO_Pin_4);
break;
case LED_3:
GPIO_ResetBits(GPIOB, GPIO_Pin_9);
break;
case LED_4:
GPIO_ResetBits(GPIOA, GPIO_Pin_12);
break;
case LED_5:
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
break;
default:
break;
}
}
-
Kernel.h
#ifndef _kernel_h_
#define _kernel_h_
#include "os.h"
static void task1(void *p_arg);
static void task2(void *p_arg);
static void task3(void *p_arg);
void KeranlTask(void);
#endif
-
Kernel.c
/*-------------------------------------------------------------------------
软件主体
-------------------------------------------------------------------------*/
#include "os.h"
#include "kernel.h"
#include "config.h"
extern void SysTickInit(void);
static OS_TCB taskStartTCB;
static CPU_STK startTaskStk[STARTUP_TASK_STK_SIZE]; //启动任务的程序空间
static OS_TCB task1TCB;
static CPU_STK task1_stk[TASK1_STK_SIZE];
static OS_TCB task2TCB;
static CPU_STK task2_stk[TASK2_STK_SIZE];
static OS_TCB task3TCB;
static CPU_STK task3_stk[TASK3_STK_SIZE];
static volatile OS_SEM taskSem;
static volatile OS_ERR err;
/*******************************************************************************
* Function Name :void StartTask(void)
* Description :启动任务
* Input :
* Output :
* Other :
* Date :2012.04.18 11:48:23
*******************************************************************************/
void StartTask(void)
{
led_init();
SysTickInit();
OSTaskCreate( (OS_TCB *)&task1TCB,
(CPU_CHAR *)"task1",
(OS_TASK_PTR)task1,
(void *)0,
(OS_PRIO )TASK1_PRIO,
(CPU_STK *)&task1_stk[0],
(CPU_STK_SIZE)TASK1_STK_SIZE / 10,
(CPU_STK_SIZE)TASK1_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSTaskCreate( (OS_TCB *)&task2TCB,
(CPU_CHAR *)"task2",
(OS_TASK_PTR)task2,
(void *)0,
(OS_PRIO ) TASK2_PRIO,
(CPU_STK *)&task2_stk[0],
(CPU_STK_SIZE)TASK2_STK_SIZE / 10,
(CPU_STK_SIZE)TASK2_STK_SIZE,
(OS_MSG_QTY)0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSTaskCreate( (OS_TCB *)&task3TCB,
(CPU_CHAR *)"task3",
(OS_TASK_PTR)task3,
(void *)0,
(OS_PRIO )TASK3_PRIO,
(CPU_STK *)&task3_stk[0],
(CPU_STK_SIZE)TASK3_STK_SIZE / 10,
(CPU_STK_SIZE)TASK3_STK_SIZE,
(OS_MSG_QTY)0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSSemCreate( (OS_SEM *)&taskSem,
(CPU_CHAR *)"taskSem",
(OS_SEM_CTR)0,
(OS_ERR *)err);
OSTaskDel( (OS_TCB *)&taskStartTCB,
(OS_ERR *)&err);
}
static void task1(void *p_arg)
{
while (1)
{
led_on(LED_4);
OSTimeDly( (OS_TICK )200,
(OS_OPT )OS_OPT_TIME_DLY,
(OS_ERR *)&err);
led_off(LED_4);
OSTimeDly( (OS_TICK )200,
(OS_OPT )OS_OPT_TIME_DLY,
(OS_ERR *)&err);
OSSemPost( (OS_SEM *)&taskSem,
(OS_OPT )OS_OPT_POST_ALL,
(OS_ERR *)&err);
}
}
static void task2(void *p_arg)
{
while (1)
{
led_on(LED_5);
OSSemPend( (OS_SEM *)&taskSem,
(OS_TICK )10000,
(OS_OPT )OS_OPT_PEND_BLOCKING,
(CPU_TS *)0,
(OS_ERR *)&err);
led_off(LED_5);
OSSemPend( (OS_SEM *)&taskSem,
(OS_TICK )10000,
(OS_OPT )OS_OPT_PEND_BLOCKING,
(CPU_TS *)0,
(OS_ERR *)&err);
}
}
static void task3(void *p_arg)
{
while (1)
{
led_on(LED_3);
OSTimeDly( (OS_TICK )100,
(OS_OPT )OS_OPT_TIME_DLY,
(OS_ERR *)&err);
led_off(LED_3);
OSTimeDly( (OS_TICK )100,
(OS_OPT )OS_OPT_TIME_DLY,
(OS_ERR *)&err);
}
}
/*******************************************************************************
* Function Name :void KeranlTask(void)
* Description :启动任务
* Input :
* Output :
* Other :
* Date :2012.04.18 11:05:47
*******************************************************************************/
void KeranlTask(void)
{
CPU_Init();
OSInit((OS_ERR *)&err);
OSTaskCreate( (OS_TCB *)&taskStartTCB,
(CPU_CHAR *)"task_start",
(OS_TASK_PTR)StartTask,
(void *)0,
(OS_PRIO ) STARTUP_TASK_PRIO,
(CPU_STK *)&startTaskStk[0],
(CPU_STK_SIZE)STARTUP_TASK_STK_SIZE / 10,
(CPU_STK_SIZE)STARTUP_TASK_STK_SIZE,
(OS_MSG_QTY)0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSStart((OS_ERR *)&err);
}
-
Main.c
#include "os.h"
#include "Kernel.h"
#include "Config.h"
int main()
{
SystemConfigInit();
KeranlTask();
return 0;
}
-
Main.c, Kernel.c,Kernel.h,Config.c,Config.h代码如下提供
-
-
-
-
-
2.添加工程文件: