void rtc_init(void) { unsigned char data; #ifdef HAVE_RTC_ALARM /* Check + save alarm bit first, before the power thread starts watching */ rtc_check_alarm_started(false); #endif /* Clear the Stop bit if it is set */ data = rtc_read(0x01); if(data & 0x80) rtc_write(0x01, 0x00); /* Clear the HT bit if it is set */ data = rtc_read(0x0c); if(data & 0x40) { data &= ~0x40; rtc_write(0x0c,data); } #ifdef HAVE_RTC_ALARM /* Clear Trec bit, write-protecting the RTC for 200ms when shutting off */ /* without this, the alarm won't work! */ data = rtc_read(0x04); if (data & 0x80) { data &= ~0x80; rtc_write(0x04, data); } /* Also, make sure that the OUT bit in register 8 is 1, otherwise the player can't be turned off. */ rtc_write(8, rtc_read(8) | 0x80); #endif }
void root_menu(void) { int previous_browser = GO_TO_FILEBROWSER; int selected = 0; if (global_settings.start_in_screen == 0) next_screen = (int)global_status.last_screen; else next_screen = global_settings.start_in_screen - 2; add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, rootmenu_track_changed_callback); #ifdef HAVE_RTC_ALARM if ( rtc_check_alarm_started(true) ) { rtc_enable_alarm(false); next_screen = GO_TO_WPS; #if CONFIG_TUNER if (global_settings.alarm_wake_up_screen == ALARM_START_FM) next_screen = GO_TO_FM; #endif #ifdef HAVE_RECORDING if (global_settings.alarm_wake_up_screen == ALARM_START_REC) { recording_start_automatic = true; next_screen = GO_TO_RECSCREEN; } #endif } #endif /* HAVE_RTC_ALARM */ #ifdef HAVE_HEADPHONE_DETECTION if (next_screen == GO_TO_WPS && (global_settings.unplug_autoresume && !headphones_inserted() )) next_screen = GO_TO_ROOT; #endif while (true) { switch (next_screen) { case MENU_ATTACHED_USB: case MENU_SELECTED_EXIT: /* fall through */ case GO_TO_ROOT: if (last_screen != GO_TO_ROOT) selected = get_selection(last_screen); #if (CONFIG_PLATFORM&PLATFORM_ANDROID) /* When we are in the main menu we want the hardware BACK * button to be handled by Android instead of rockbox */ android_ignore_back_button(true); #endif next_screen = do_menu(&root_menu_, &selected, NULL, false); #if (CONFIG_PLATFORM&PLATFORM_ANDROID) android_ignore_back_button(false); #endif if (next_screen != GO_TO_PREVIOUS) last_screen = GO_TO_ROOT; break; case GO_TO_PREVIOUS: next_screen = last_screen; break; case GO_TO_PREVIOUS_BROWSER: next_screen = previous_browser; break; case GO_TO_PREVIOUS_MUSIC: next_screen = previous_music; break; case GO_TO_ROOTITEM_CONTEXT: next_screen = load_context_screen(selected); break; #ifdef HAVE_PICTUREFLOW_INTEGRATION case GO_TO_PICTUREFLOW: while ( !tagcache_is_usable() ) { splash(0, str(LANG_TAGCACHE_BUSY)); if ( action_userabort(HZ/5) ) break; } { char pf_path[MAX_PATH]; snprintf(pf_path, sizeof(pf_path), "%s/pictureflow.rock", PLUGIN_DEMOS_DIR); next_screen = load_plugin_screen(pf_path); } previous_browser = GO_TO_PICTUREFLOW; break; #endif default: if (next_screen == GO_TO_FILEBROWSER #ifdef HAVE_TAGCACHE || next_screen == GO_TO_DBBROWSER #endif ) previous_browser = next_screen; if (next_screen == GO_TO_WPS #if CONFIG_TUNER || next_screen == GO_TO_FM #endif ) previous_music = next_screen; next_screen = load_screen(next_screen); break; } /* switch() */ } }
void rtc_init(void) { rtc_check_alarm_started(false); }