示例#1
0
void button_init_device(void)
{
#ifdef BOOTLOADER
    /* Can be called more than once in the bootloader */
    if (initialized)
        return;

    initialized = true;
#endif

    /* Enable keypad clock */
    ccm_module_clock_gating(CG_KPP, CGM_ON_RUN_WAIT);

    /* 1. Enable number of rows in keypad (KPCR[4:0])
     *
     * Configure the rows/cols in KPP
     * LSB nybble in KPP is for 5 rows
     * MSB nybble in KPP is for 3 cols */
    KPP_KPCR |= 0x1f;

    /* 2. Write 0's to KPDR[10:8] */
    KPP_KPDR &= ~(0x7 << 8);

    /* 3. Configure the keypad columns as open-drain (KPCR[10:8]). */
    KPP_KPCR |= (0x7 << 8);

    /* 4. Configure columns as output, rows as input (KDDR[10:8,4:0]) */
    KPP_KDDR = (KPP_KDDR | (0x7 << 8)) & ~0x1f;

    /* 5. Clear the KPKD Status Flag and Synchronizer chain.
     * 6. Set the KDIE control bit bit. */
    KPP_KPSR = KPP_KPSR_KRSS | KPP_KPSR_KDSC | KPP_KPSR_KPKD;

    power_button_update(!(mc13783_read(MC13783_INTERRUPT_SENSE1)
                            & MC13783_ONOFD1S));
    mc13783_enable_event(MC13783_ONOFD1_EVENT, true);

#ifdef HAVE_HEADPHONE_DETECTION
    headphone_init();
#endif
}
示例#2
0
/* Power button event - called from PMIC ISR */
void button_power_event(void)
{
    power_button_update(!mc13783_event_sense(MC13783_ONOFD1_EVENT));
}
/* Power button event - called from PMIC ISR */
void MC13783_EVENT_CB_ONOFD1(void)
{
    power_button_update(!mc13783_event_sense());
}