Exemplo n.º 1
0
/*****************************************************************************
 * FUNCTION
 *  avk_mytimer_expiry_handler
 * DESCRIPTION
 *  mytimer proc for EVT_ID_MMI_TIMER_EXPIRY_PROC_EXT
 * PARAMETERS
 *  evt : [IN] mmi timer event pointer in fact
 * RETURNS
 *  0 : callback manager will continue to deliver this event
 *  non-zero : callback manager will stop deliver this event
 *****************************************************************************/
extern "C" mmi_ret avk_mytimer_expiry_handler(mmi_event_struct *evt)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_timer_event_struct *timer_event;
    ilm_struct *ilm;
    kal_uint16 timer_index;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    timer_event = (mmi_timer_event_struct *)evt;
    ilm = (ilm_struct *)timer_event->expiry_msg;
    timer_index = evshed_get_index(ilm);
    if (AVK_MYTIMER_BASE_ID == timer_index)
    {
        evshed_timer_handler((event_scheduler *)g_mytimer_base_cntx);
        /* my timer expiry msg, return non-zero to stop deliver timer event */
        return 1;
    }
    /* not my timer expiry msg, return 0 to continue to deliver timer event for other listeners */
    return 0;
}
Exemplo n.º 2
0
void usbc_cosim_core_task_main(task_entry_struct* task_entry_ptr)
{
    kal_uint8 wait_count = 0;
    ilm_struct current_ilm;
    kal_uint32 rt_event;
    kal_uint16 timer_index;
    module_type dest_mod;
    msg_type msg_id;
    usbc_class_device_esl_connect_parm  *rsp_msg_p;
    usbc_core_t* pUsbCore = usbc_core_get_instance();

    kal_set_active_module_id(MOD_USBCORE);
    kal_mem_set(&current_ilm, 0, sizeof(ilm_struct));

    usbc_esl_printf("Start USBCORE task loop...\n");
    while(1)
    {
        while ( msg_get_extq_messages() > 0 )
        {
            if ( msg_receive_extq(&current_ilm) != KAL_TRUE )
            {
                break;
            }

            switch (current_ilm.msg_id)
            {
                case MSG_ID_TIMER_EXPIRY:
                    timer_index = evshed_get_index(&current_ilm);
                    switch (timer_index)
                    {
                        case USBC_WK_NOTIFY_INDEX:
                            ASSERT(0);
                            evshed_timer_handler(pUsbCore->usbc_es_wk_notify_g);
                            break;

                        default:
                            break;
                    }
                    break;

                default:
                    break;
            }

            destroy_ilm(&current_ilm);
        }

        /* Wait someone notify HMU to wake up HIF. */
        rt_event = hmu_hifeg_wait(HIF_DRV_EG_HIF_TICK_EVENT | HIF_DRV_EG_USBC_IND_EVENT);
        if ((HIF_DRV_EG_HIF_TICK_EVENT & rt_event) &&
            (pUsbCore->state != USBC_USB_STATE_SUSPENDED))
        {
            /* poll HIF queue data */
            usbc_esl_printf("Start HIF USB poll queue...\n");
            usbc_normal_hif_poll_queue();
            usbc_esl_printf("End HIF USB poll queue...\n");
        }
        if ((HIF_DRV_EG_USBC_IND_EVENT & rt_event))
        {
            /* Handle indications */
            usbc_normal_hif_process_indications();
        }

        // wait for IPCORE finishing handling ILMs in ipc_init
        if (wait_count < 1)
        {
            wait_count++;

            if(wait_count == 1)
            {
                usbc_esl_printf("Emulare USB enumeration...\n");
                // Emulate USB plug-in for ESL COSIM
                usbc_cosim_hif_attach();

                usbc_esl_printf("Set USB class to connected state...\n");
                // change USB classes state to transfer data
                rsp_msg_p = (usbc_class_device_esl_connect_parm*)construct_local_para(sizeof(usbc_class_device_esl_connect_parm), TD_RESET);
                ASSERT(rsp_msg_p);
                rsp_msg_p->class_device_id = 0;
                msg_id = MSG_ID_USBCLASS_USBCORE_ESL_ENTER_CONNECTED_STATE_REQ;

                switch ((pUsbCore->class_device[0]).class_type)
                {
#ifdef __USB_MBIM_SUPPORT__
                    case USB_CLASS_MBIM:
                        dest_mod = MOD_MBIM;
                        break;
#endif
#ifdef __USB_ECM_SUPPORT__
                    case USB_CLASS_ECM:
                        dest_mod = MOD_ECM;
                        break;
#endif
#ifdef __USB_RNDIS_SUPPORT__			
                    case USB_CLASS_RNDIS:
                        dest_mod = MOD_RNDIS;
                        break;
#endif			
                    default:
                        // We assume the first class device must be a NIC for ESL CO-SIM
                        ASSERT(0);
                        return;
                        break;
                }

                msg_send6(MOD_USBCORE,  // src module
                          dest_mod,  // dst module
                          0,       // sap id
                          msg_id,
                          (local_para_struct*)rsp_msg_p,
                          0); //msg id
            }
        }
    }
}