⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emu_utilities.c

📁 51 56546fdfffffffffffffffffffff34
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* Configure the transceiver */    emu_set_transceiver_state((EMU_XCVR_STATE_T)accessory_config_table[accessory].transceiver_state);    /* Set the CONN mode */    EMU_GLUE_set_conn_mode((EMU_CONN_MODE_T)accessory_config_table[accessory].conn_mode);}/*==================================================================================================FUNCTION:   emu_initialize_regs   DESCRIPTION:    This function is used to initialize the EMU related registers in the power IC to a state that   will allow for detection of an accessory. ARGUMENTS PASSED:    None    RETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   NoneIMPORTANT NOTES:   None==================================================================================================*/voidemu_initialize_regs(void){    /* Disable power to the accessory */    EMU_GLUE_set_reverse_mode(0);        /* Disable the ID current srouce */    EMU_GLUE_set_id_pull_up(0);       /* Enable the 150K D+ pull up */    EMU_GLUE_set_dplus_150k_pull_up(1);        /* Disable the ID pull down */    EMU_GLUE_set_id_pull_down(0);        /* Set the conn mode USB mode (default)*/    EMU_GLUE_set_conn_mode(EMU_CONN_MODE_USB);    /* Set USB to full speed mode */    EMU_GLUE_set_low_speed_mode(0);           /* Disable the headset pull up */    EMU_GLUE_set_id_stereo_pull_up(0);      /* Set up the USB transceiver for debouncing */    emu_set_transceiver_state(EMU_XCVR_STATE_OFF);        /* Disable the 1.5K USB pull up */    EMU_GLUE_set_dplus_1_5k_pull_up(0);}/*==================================================================================================FUNCTION:   emu_glue_layer_events_config   DESCRIPTION:    This function take the passed in timer and interrupt data and returns value formatted for the   event bit mask that is returned to the glue layer. ARGUMENTS PASSED:    timer      - time in 10s of mS that the glue layer should wait before calling the common                 algorithm               - EMU_EVENT_TIMER_NO_CHANGE, the timer is already set correctly and should not                 be changed..               - EMU_EVENT_TIMER_CONTINUE, the glue layer should call the EMU common alg                 immediately.               - EMU_EVENT_TIMER_DISABLE, the glue layer should disable all interrupts and timers              interrupts - The interrupts that should be unmasked. The EMU_EVENT_INT_MASK_ALL define is                 provided to mask all interrupts    RETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   NoneIMPORTANT NOTES:   None==================================================================================================*/voidemu_glue_layer_events_config(EMU_DATA_T *emu_data, long timer, unsigned long interrupts){    switch(timer)    {        case EMU_EVENT_TIMER_DISABLE:            emu_data->event_bit_mask = interrupts;            break;        case EMU_EVENT_TIMER_CONTINUE:            emu_data->event_bit_mask = (EMU_EVENT_TIMER | interrupts);            break;        default:            emu_data->event_bit_mask =                (((timer << EMU_EVENT_TIMER_VAL_SHIFT) & EMU_EVENT_TIMER_VAL_MASK) |                    EMU_EVENT_TIMER | interrupts);            break;    }}/*==================================================================================================FUNCTION:   emu_setup_for_lower_layer_statesDESCRIPTION:    This function is called by the upper layer states before transitioning to the lower layer states.ARGUMENTS PASSED:   accessory - the currently connected accessory  RETURN VALUE:   The EMU_UPPER_LAYER_STATE_DEBOUNCING upper layer state. When transitioning to the lower layer   states the upper layer state must be reset to EMU_UPPER_LAYER_STATE_DEBOUNCING state.PRE-CONDITIONS:   None POST-CONDITIONS:   NoneIMPORTANT NOTES:   None==================================================================================================*/EMU_UPPER_LAYER_STATE_Temu_setup_for_lower_layer_states(EMU_DATA_T *emu_data){    /* Used to determine the lower layer state based on the currently connected accessory */    static const EMU_LOWER_LAYER_STATE_T accessory_to_lower_layer_state_table[EMU_ACCY_TYPE__NUM_DEVICES] =    {        /*Accessory                          Lower Layer State                             */        /*EMU_ACCY_TYPE_NONE              */ EMU_LOWER_LAYER_STATE_CONNECTED_NONE_OR_INVALID,        /*EMU_ACCY_TYPE_INVALID           */ EMU_LOWER_LAYER_STATE_CONNECTED_NONE_OR_INVALID,        /*EMU_ACCY_TYPE_NOT_SUPPORTED     */ EMU_LOWER_LAYER_STATE_CONNECTED_NONE_OR_INVALID,        /*EMU_ACCY_TYPE_CHARGER_MID       */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CHARGER_MID_MPX   */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CHARGER_FAST      */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CHARGER_FAST_MPX  */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CARKIT_MID        */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CARKIT_FAST       */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CABLE_USB         */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CABLE_REGRESSION  */ EMU_LOWER_LAYER_STATE_CONNECTED_SPD_POLL,        /*EMU_ACCY_TYPE_CABLE_FACTORY     */ EMU_LOWER_LAYER_STATE_CONNECTED_FACTORY,        /*EMU_ACCY_TYPE_CABLE_USB_OTG     */ EMU_LOWER_LAYER_STATE_CONNECTED_NONE_OR_INVALID,        /*EMU_ACCY_TYPE_HEADSET_EMU_MONO  */ EMU_LOWER_LAYER_STATE_CONNECTED_HEADSET,        /*EMU_ACCY_TYPE_HEADSET_EMU_STEREO*/ EMU_LOWER_LAYER_STATE_CONNECTED_HEADSET    };    if (emu_data->accessory >= EMU_ACCY_TYPE__NUM_DEVICES)    {        emu_data->accessory = EMU_ACCY_TYPE_INVALID;    }        /* Go to the lower layer state for the connected accessory */    emu_data->lower_layer_state = accessory_to_lower_layer_state_table[emu_data->accessory];        /* Allow the state machine to enter the lower layer states */    emu_data->is_lower_layer_allowed = 1;            /* Configure the accessory */    emu_configure_accessory(emu_data->accessory);    EMU_GLUE_log_event((unsigned char)EMU_LOG_EVENT_ACCY_NOTIFY,                       (unsigned char) sizeof(emu_data->accessory),                       (unsigned char *)&emu_data->accessory);    /* If nothing is connected, make sure the previously connected accessory is removed */    if (emu_data->accessory != emu_data->prev_accessory)    {        if (emu_data->prev_accessory != EMU_ACCY_TYPE_NONE)        {            EMU_GLUE_accy_notify(emu_data->prev_accessory, 0);        }        if (emu_data->accessory != EMU_ACCY_TYPE_NONE)        {            EMU_GLUE_accy_notify(emu_data->accessory, 1);        }    }    /* Keep track of the previously connected accessory */    emu_data->prev_accessory = emu_data->accessory;    /* Reset the upper layer state */    return EMU_UPPER_LAYER_STATE_DEBOUNCING;}/*================================================================================================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -