#include
#include
#define ADC1_DR_Address ((u32)0x4001204C)
static OS_TCB AppTaskStartTCB;
static OS_TCB AppTaskConfigTCB;
static OS_TCB AppTasktestsemTCB;
static CPU_STK AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE];
static CPU_STK AppTaskConfigStk[APP_CFG_TASK_START_STK_SIZE];
static CPU_STK AppTasktestsemStk[APP_CFG_TASK_START_STK_SIZE];
OS_SEM testsem;
OS_TMR MYTIMER1;
static void AppTaskStart (void *p_arg);
static void AppTaskCreate (void);
static void AppObjCreate (void);
static void userTaskStart (void);
static void userTasksem (void);
void MYCALLBACKFUNCT(void *p_arg) ;
CPU_FP32 AD_value_1,AD_value_2;
CPU_INT16U ADC_ConvertedValue[2];
int main(void)
{
OS_ERR err;
BSP_IntDisAll();
OSInit(&err);
ADC1_CH6_DMA_Config(ADC1_DR_Address,ADC_ConvertedValue);
ADC_SoftwareStartConv(ADC1);
OSTaskCreate((OS_TCB *)&AppTaskStartTCB,
(CPU_CHAR *)"App Task Start",
(OS_TASK_PTR )AppTaskStart,
(void *)0,
(OS_PRIO )APP_CFG_TASK_START_PRIO,
(CPU_STK *)&AppTaskStartStk[0],
(CPU_STK_SIZE )AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10],
(CPU_STK_SIZE )APP_CFG_TASK_START_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(&err);
(void)&err;
return (0);
}
static void AppTaskStart (void *p_arg)
{
OS_ERR err;
(void)p_arg;
BSP_Init();
CPU_Init();
BSP_Tick_Init();
Mem_Init();
Math_Init();
#if OS_CFG_STAT_TASK_EN > 0u
OSStatTaskCPUUsageInit(&err);
#endif
#ifdef CPU_CFG_INT_DIS_MEAS_EN
CPU_IntDisMeasMaxCurReset();
#endif
BSP_LED_Off(0);
#if (APP_CFG_SERIAL_EN == DEF_ENABLED)
App_SerialInit();
#endif
APP_TRACE_DBG(("Creating Application kernel objects\n\r"));
AppObjCreate();
APP_TRACE_DBG(("Creating Application Tasks\n\r"));
AppTaskCreate();
while (DEF_TRUE) {
//BSP_LED_Toggle(0);
OSTimeDlyHMSM(0, 0, 0, 100,
OS_OPT_TIME_HMSM_STRICT,
&err);
}
}
static void AppTaskCreate (void)
{
//BSP_LED_Toggle(1);
OS_ERR err;
OSTaskCreate((OS_TCB *)&AppTaskConfigTCB,
(CPU_CHAR *)"user task Start",
(OS_TASK_PTR )userTaskStart,
(void *)0,
(OS_PRIO )APP_USER_PRIO_3,
(CPU_STK *)&AppTaskConfigStk[0],
(CPU_STK_SIZE )AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10],
(CPU_STK_SIZE )APP_CFG_TASK_START_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);
if(err != OS_ERR_NONE)
{
; //???í?ó???????í
}
OSTaskCreate((OS_TCB *)&AppTasktestsemTCB,
(CPU_CHAR *)"user sem Start",
(OS_TASK_PTR )userTasksem,
(void *)0,
(OS_PRIO )APP_USER_PRIO_4,
(CPU_STK *)&AppTasktestsemStk[0],
(CPU_STK_SIZE )AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10],
(CPU_STK_SIZE )APP_CFG_TASK_START_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);
if(err != OS_ERR_NONE)
{
; //???í?ó???????í
}
OSSemCreate( &testsem,
"my testsem",
(OS_SEM_CTR)0,
&err);
if(err != OS_ERR_NONE)
{
; //???í?ó???????í
}
OSTmrCreate((OS_TMR *)&MYTIMER1,
(CPU_CHAR *)"TIME TEST",
(OS_TICK ) 0,
(OS_TICK ) 10,
(OS_OPT ) OS_OPT_TMR_PERIODIC,
(OS_TMR_CALLBACK_PTR ) MYCALLBACKFUNCT,
(void * )0,
(OS_ERR *)&err );
OSTmrStart((OS_TMR *)&MYTIMER1,
(OS_ERR *)&err);
while (DEF_TRUE) {
// BSP_LED_Toggle(2);
OSTimeDlyHMSM(0, 0, 0, 100,
OS_OPT_TIME_HMSM_STRICT,
&err);}
}
static void AppObjCreate (void)
{
}
static void userTaskStart(void) //???????????è???????©???÷
{
OS_ERR err;
CPU_TS ts;
while(DEF_ON){ //?????????????????·?
OSSemPend( &testsem,
10,
OS_OPT_PEND_BLOCKING,
&ts,
&err );
if(err == OS_ERR_NONE)
{
// ; //???í?ó???????í
BSP_LED_Toggle(1);
}
}
}
static void userTasksem(void) //???????????è???????©???÷
{
OS_ERR err;
// BSP_LED_Toggle(3);
while(DEF_TRUE){q
BSP_LED_Toggle(4);
OSSemPost( &testsem,
OS_OPT_POST_1,
&err ) ;
if(err != OS_ERR_NONE)
{
; //???í?ó???????í
}
OSTimeDlyHMSM(0, 0, 0, 100,
OS_OPT_TIME_HMSM_STRICT,
&err);
}
}
void MYCALLBACKFUNCT(void *p_arg)
{
BSP_LED_Toggle(2);
}