Пример #1
0
/******************************************************************************
* Name       : uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara)
* Function   : A demo task for PT application
* Input      : uint8  u8Evt  1~254     Event for the task
*              void  *pPara            Pointer of parameter

* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 8th Jul 2016
******************************************************************************/
uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara)
{   
    PT_INIT();
    
    PT_BEGIN();

    /******************************************************************/
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
    /******************************************************************/

    while(1)
    {
        TASK_PT_DEMO_LED_On(LED_RED);
        PT_DELAY(1000);
        TASK_PT_DEMO_LED_Off(LED_RED);

        TASK_PT_DEMO_LED_On(LED_GREEN);
        PT_DELAY(1000);
        TASK_PT_DEMO_LED_Off(LED_GREEN);

        TASK_PT_DEMO_LED_On(LED_BLUE);
        PT_DELAY(1000);
        TASK_PT_DEMO_LED_Off(LED_BLUE);
    }

    PT_END();

    return SW_OK;

}
Пример #2
0
/******************************************************************************
* Name       : uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt)
* Function   : IEC870 physical layer test
* Input      : uint8 u8Evt  1~254     Event for the task
* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 13th Jul 2016
******************************************************************************/
uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt)
{   
    PT_INIT();
    
    PT_BEGIN();

    /******************************************************************/
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
    /******************************************************************/

    CC1101_Init();
    PT_DELAY(1000);

    CC1101_Global_Config(sg_au8RxConfig);
    CC1101_PA_Config(sg_au8PaTabal);

    while(1)
    {
#ifdef __PL_RCV_ENABLE
        //TASK_PT_DEMO_LED_On(LED_RED);
        PL_RECEIVE(sg_au8RxFIFO);
        TASK_PT_DEMO_LED_Off(LED_RED);

        Manchester_Decode(&(sg_au8RxFIFO[1]), sg_au8RxData);

        Print_RF_Info();
#endif

#ifdef __PL_SND_ENABLE
        PT_DELAY(1000);
           
        TASK_PT_DEMO_LED_On(LED_BLUE);
#if defined (__PL_RCV_ENABLE) && defined (__PL_RCV_ENABLE)        
        PL_SEND(sg_au8RxFIFO);
#else
        PL_SEND(sg_au8Test);
#endif 
        TASK_PT_DEMO_LED_Off(LED_BLUE);
        
        PT_DELAY(500);
#endif
    }

    PT_END();

    return SW_OK;

}
Пример #3
0
/******************************************************************************
* Name       : uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara)
* Function   : A demo task for PT application
* Input      : uint8  u8Evt  1~254     Event for the task
*              void  *pPara            Pointer of parameter
* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 8th Jul 2016
******************************************************************************/
uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara)
{    
    PT_INIT();
    
    PT_BEGIN();

    /******************************************************************/
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
    /******************************************************************/

    while(1)
    {
        printf("I am another Task!!\n");
        PT_DELAY(1000);
    }

    PT_END();

    return SW_OK;

}
Пример #4
0
/******************************************************************************
* Name       : uint8 lED_Demo_Process(uint8 u8Evt)
* Function   : LEd demo process
* Input      : uint8 u8Evt  1~254     Event for the task
*              void  *pPara           Pointer of parameter
* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 3rd May 2016
******************************************************************************/
uint8 LED_Demo_Process(uint8 u8Evt, void *pPara)
{   
    /* Check which event should be processed */
    switch (u8Evt)
    {
        /* If it is a timer event */
        case EVENT_PERIODIC:       
        {
            DBG_PRINT("I am the task for LED demo and I am working!!\n");
               
            static uint8 s_u8Clr = BOARD_CONFIG_LED_BLUE;
            TASK1_LED_Off(s_u8Clr);
            s_u8Clr = (s_u8Clr + 1) % (BOARD_CONFIG_LED_BLUE+1);
            TASK1_LED_On(s_u8Clr);
            switch(s_u8Clr)
            {
                case BOARD_CONFIG_LED_BLUE:
                {
                    DBG_PRINT("Blue!!\n");
                    break;
                }
                case BOARD_CONFIG_LED_RED:
                {
                    DBG_PRINT("Red!!\n");
                    break;
                }
                case BOARD_CONFIG_LED_YELLOW:
                {
                    DBG_PRINT("Yellow!!\n");
                    break;
                }
                case BOARD_CONFIG_LED_GREEN:
                {
                    DBG_PRINT("Green!!\n");
                    break;
                }
                default:
                {
                    break;
                }
            }
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a message event */
        case EVENT_MSG:       
        {
            
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a test event */
        case EVENT_TEST:       
        {
            
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a timer event */
        case EVENT_TIMER:       
        {
            
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a message event */
        case EVENT_INIT:       
        {
            /******************************************************************/
            MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
            /******************************************************************/

            /*--------------------   Add your init code here   ----------------------*/
            Moe_Timer_Periodic(300);
            /*-------------------   The end of your init code   ---------------------*/
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is other event */
        default:       
        {
            return u8Evt;     /* Return event to indicate event is NOT processed */
        }
    }
}
Пример #5
0
/******************************************************************************
* Name       : uint8 Task3_Process(uint8 u8Evt)
* Function   : Task 3 process
* Input      : uint8 u8Evt  1~254     Event for the task
* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 3rd May 2016
******************************************************************************/
uint8 Task3_Process(uint8 u8Evt)
{   
    /* Check which event should be processed */
    switch (u8Evt)
    {
        /* If it is a timer event */
        case EVENT_PERIODIC:       
        {
            DBG_PRINT("I am task 3 and I am working!!\n");
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a message event */
        case EVENT_MSG:       
        {
            uint8  u8MsgType;
            void  *ptMsg;
            static uint8 sg_u8Cnt = 0;

            ptMsg = (void*)Moe_Msg_Receive(sg_u8TaskID, &u8MsgType);
            while(ptMsg)
            {   sg_u8Cnt++;
                switch(u8MsgType)
                {
                    case MSG_TYPE_TEST:
                    {
                        T_TEST_MSG *ptTestMsg = (T_TEST_MSG*)ptMsg;
                        DBG_PRINT("This is task %d\n",sg_u8TaskID);
                        DBG_PRINT("Get %d messages\n",sg_u8Cnt);
                        DBG_PRINT("I get a uint32 data 0x%x!\n",(ptTestMsg->DATA.u32Data));
                        DBG_PRINT("I get a uint16 data 0x%x,0x%x!\n",(ptTestMsg->DATA.au16Data[0]),(ptTestMsg->DATA.au16Data[1]));
                        DBG_PRINT("I get a uint8 data 0x%x,0x%x,0x%x,0x%x!\n\n",(ptTestMsg->DATA.au8Data[0]),(ptTestMsg->DATA.au8Data[1]),(ptTestMsg->DATA.au8Data[2]),(ptTestMsg->DATA.au8Data[3]));
                    }
                }
                ptMsg = (void*)Moe_Msg_Receive(sg_u8TaskID, &u8MsgType);
            }
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a test event */
        case EVENT_TEST:       
        {
            
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a timer event */
        case EVENT_TIMER:       
        {
            
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is a message event */
        case EVENT_INIT:       
        {
            /******************************************************************/
            MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
            /******************************************************************/

            /*--------------------   Add your init code here   ----------------------*/
           // Moe_Timer_Periodic(1500);
            /*-------------------   The end of your init code   ---------------------*/
            return SW_OK;     /* Return SW_OK to indicate event is processed */
        }

        /* If it is other event */
        default:       
        {
            return u8Evt;     /* Return event to indicate event is NOT processed */
        }
    }
}