static void config_wakeup(void) { Pm *p_pm = PM; /* EIC and PICOUART can wakeup the device. */ bpm_enable_wakeup_source(BPM, (1 << BPM_BKUPWEN_EIC) | (1 << BPM_BKUPWEN_PICOUART)); p_pm->PM_AWEN = 1 << PM_AWEN_PICOUART; p_pm->PM_IER = PM_IER_WAKE; NVIC_SetPriority(PM_IRQn,1); NVIC_EnableIRQ(PM_IRQn); /* EIC can wake the device from backup mode. */ bpm_enable_backup_pin(BPM, 1 << GPIO_PUSH_BUTTON_EIC_LINE); }
/** * \brief Event Button Init. */ void event_button_init(void) { // Structure holding the configuration parameters // of the EIC module. struct eic_line_config eic_line_conf; // Initialize EIC Controller sysclk_enable_peripheral_clock(EIC); // Enable level-triggered interrupt. eic_line_conf.eic_mode = EIC_MODE_EDGE_TRIGGERED; // Interrupt will trigger on low-level. eic_line_conf.eic_level = EIC_LEVEL_LOW_LEVEL; // Edge on falling edge eic_line_conf.eic_edge = EIC_EDGE_FALLING_EDGE; // Enable filter. eic_line_conf.eic_filter = EIC_FILTER_DISABLED; // For Wake Up mode, initialize in asynchronous mode eic_line_conf.eic_async = EIC_ASYNCH_MODE; // Enable clock for EIC controller eic_enable(EIC); // Init the EIC controller with the options eic_line_set_config(EIC, GPIO_PUSH_BUTTON_EIC_LINE, &eic_line_conf); // Init the callback eic_line_set_callback(EIC, GPIO_PUSH_BUTTON_EIC_LINE, eic5_callback, EIC_5_IRQn, 1); // Enable the EIC line eic_line_enable(EIC, GPIO_PUSH_BUTTON_EIC_LINE); // EIC can wake the device from backup mode bpm_enable_wakeup_source(BPM, BPM_BKUP_WAKEUP_SRC_EIC | BPM_BKUP_WAKEUP_SRC_AST); // EIC can wake the device from backup mode bpm_enable_backup_pin(BPM, 1 << GPIO_PUSH_BUTTON_EIC_LINE); // Retain I/O lines after wakeup from backup bpm_disable_io_retention(BPM); bpm_enable_io_retention(BPM); bpm_enable_fast_wakeup(BPM); sysclk_disable_peripheral_clock(EIC); event_pbEvent = false; // Initialize WDT Controller sysclk_enable_peripheral_clock(WDT); enable_wdt(); }
/** * \brief Initializes and enables interrupt pin change */ static void ui_enable_asynchronous_interrupt(void) { /* Initialize EIC for button wakeup */ sysclk_enable_peripheral_clock(EIC); struct eic_line_config eic_opt ={ .eic_mode = EIC_MODE_EDGE_TRIGGERED, .eic_edge = EIC_EDGE_FALLING_EDGE, .eic_level = EIC_LEVEL_LOW_LEVEL, .eic_filter = EIC_FILTER_DISABLED, .eic_async = EIC_ASYNCH_MODE }; eic_enable(EIC); eic_line_set_config(EIC, UI_WAKEUP_EIC_LINE, &eic_opt); eic_line_set_callback(EIC, UI_WAKEUP_EIC_LINE, UI_WAKEUP_HANDLER, UI_WAKEUP_IRQN, UI_WAKEUP_IRQ_LEVEL); eic_line_enable(EIC, UI_WAKEUP_EIC_LINE); eic_line_enable_interrupt(EIC, UI_WAKEUP_EIC_LINE); /* EIC can wakeup the device */ bpm_enable_wakeup_source(BPM, (1 << UI_WAKEUP_BPM_SRC)); /* EIC can wake the device from backup mode */ bpm_enable_backup_pin(BPM, 1 << UI_WAKEUP_EIC_LINE); }