void button_close_device(void) { if (!initialized) return; /* Assumes HP detection is not available */ initialized = false; mc13783_enable_event(MC13783_ONOFD1_EVENT, false); ext_btn = BUTTON_NONE; }
void usb_init_device(void) { /* Do one-time inits */ usb_drv_startup(); /* Initially poll */ usb_connect_event(); /* Enable PMIC event */ mc13783_enable_event(MC13783_USB_EVENT); }
void INIT_ATTR headphone_init(void) { /* A thread is required to monitor the remote ADC and jack state. */ semaphore_init(&headphone_wakeup, 1, 0); headphone_thread_id = create_thread(headphone_thread, headphone_stack, sizeof(headphone_stack), 0, headphone_thread_name IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU)); /* Initially poll and then enable PMIC event */ headphone_detect_event(); mc13783_enable_event(MC13783_ONOFD2_EVENT); }
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 }