void user_rf_pre_init(void) { RESET_COUNTER counter; if(system_get_rst_info()->reason != REASON_EXT_SYS_RST) { reset_counter(0); } else { system_rtc_mem_read(64, &counter, sizeof(counter)); if(counter.magic == RESET_COUNTER_MAGIC && counter.resetCounter <= RESET_NUM) { counter.resetCounter++; if(counter.resetCounter == RESET_NUM) { reset_counter(0); mSpecialMode = 1; } else { system_rtc_mem_write(RESET_COUNTER_RTC_ADDRESS, &counter, sizeof(counter)); os_timer_disarm(&mResetTimer); os_timer_setfn(&mResetTimer, (os_timer_func_t *)reset_counter, NULL); os_timer_arm(&mResetTimer, 1000, 0); } } else { reset_counter(0); } } system_restore(); rtc_mem_check(0); }
/****************************************************************************** * FunctionName : user_plug_long_press * Description : key's long press function, needed to be installed * Parameters : none * Returns : none *******************************************************************************/ LOCAL void ICACHE_FLASH_ATTR user_plug_long_press(void) { user_esp_platform_set_active(0); system_restore(); system_restart(); }
/****************************************************************************** * FunctionName : user_plug_long_press * Description : key's long press function, needed to be installed, preserved function. * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR peri_key_long_press(void) { os_printf("long press..\n"); os_printf("clean data and restart!"); system_restore(); system_restart(); }
void ICACHE_FLASH_ATTR factory_reset() { mjyun_systemrecovery(); system_restore(); os_delay_us(2000); system_restart(); }
/****************************************************************************** * FunctionName : key_long_press * Description : key's long press function, needed to be installed * Parameters : none * Returns : none *******************************************************************************/ static void ICACHE_FLASH_ATTR key_long_press( void ) { os_printf("long press \n"); flash_param_set_id(CONFIG_RESET_ID); system_restore(); system_restart(); }
void xkey_long_press(void) { #ifdef DEBUG os_printf("key long pressed\r\n"); #endif system_restore(); system_restart(); }
/****************************************************************************** * FunctionName : user_plug_long_press * Description : key's long press function, needed to be installed * Parameters : none * Returns : none *******************************************************************************/ LOCAL void user_key_long_press(void) { int boot_flag=12345; // user_esp_platform_set_active(0); system_restore(); system_rtc_mem_write(70, &boot_flag, sizeof(boot_flag)); system_rtc_mem_read(70, &boot_flag, sizeof(boot_flag)); #if RESTORE_KEEP_TIMER user_platform_timer_bkup(); #endif system_restart(); }
void ap_init(void) { // Check if configuration is ok already (compare SSID) struct softap_config netcfg; wifi_softap_get_config(&netcfg); if (os_strcmp(WIFI_SSID, netcfg.ssid) == 0) return; // Configuration is not good, change config and reboot system_restore(); os_memcpy(netcfg.ssid, WIFI_SSID, os_strlen(WIFI_SSID)); netcfg.ssid[os_strlen(WIFI_SSID)] = 0x00; netcfg.ssid_len = os_strlen(WIFI_SSID); netcfg.channel = 1; netcfg.authmode = AUTH_OPEN; netcfg.beacon_interval = 100; wifi_softap_set_config(&netcfg); wifi_set_opmode(0x02); system_restart(); }
void STC_FLASHMEM ConfigurationManager::restore() { FlashDictionary::eraseContent(); system_restore(); }
/*--------------------------------------------------------------------------*/ int main(int argc, char **argv) { /* * Initalize hardware. */ msp430_cpu_init(); clock_init(); uart_init(9600); /* Must come before first printf */ /* xmem_init(); */ PRINTF("iWatch 0.10 build at " __TIME__ " " __DATE__ "\n"); UCSCTL8 &= ~BIT2; /* * Hardware initialization done! */ /* * Initialize Contiki and our processes. */ process_init(); process_start(&etimer_process, NULL); rtimer_init(); ctimer_init(); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); backlight_init(); battery_init(); SPI_FLASH_Init(); if (system_testing()) { clock_time_t t; backlight_on(200, 0); t = clock_seconds(); // sleep 1 while(clock_seconds() - t <= 3); printf("$$OK BACKLIGHT\n"); t = clock_seconds(); while(clock_seconds() - t <= 3); backlight_on(0, 0); motor_on(200, 0); // sleep 1s t = clock_seconds(); while(clock_seconds() - t <= 3); printf("$$OK MOTOR\n"); t = clock_seconds(); while(clock_seconds() - t <= 3); motor_on(0, 0); #if PRODUCT_W001 I2C_Init(); codec_init(); codec_bypass(1); // sleep 1s t = clock_seconds(); while(clock_seconds() - t <= 3); printf("$$OK MIC\n"); // sleep 1s t = clock_seconds(); while(clock_seconds() - t <= 3); codec_bypass(0); codec_shutdown(); #endif } int reason = CheckUpgrade(); window_init(reason); button_init(); rtc_init(); CFSFontWrapperLoad(); system_init(); // check system status and do factor reset if needed I2C_Init(); //codec_init(); //ant_init(); bluetooth_init(); #ifdef PRODUCT_W004 //bmx_init(); #else mpu6050_init(); #endif // check the button status if (button_snapshot() & (1 << BUTTON_UP)) { clock_time_t t; // delay 1 second // button up is pressed, we will set emerging flag motor_on(200, CLOCK_SECOND * 2); t = clock_seconds(); while(clock_seconds() - t <= 1); if (button_snapshot() & (1 << BUTTON_UP)) system_setemerging(); motor_on(0, 0); } if (!system_retail()) { bluetooth_discoverable(1); } #if PRODUCT_W001 if (system_testing()) ant_init(MODE_HRM); #endif system_restore(); // protocol_init(); // protocol_start(1); process_start(&system_process, NULL); /* * This is the scheduler loop. */ msp430_dco_required = 0; /* check firmware update */ if (reason == 0xff) { printf("Start Upgrade\n"); Upgrade(); // never return if sucessfully upgrade } watchdog_start(); while(1) { int r; do { /* Reset watchdog. */ watchdog_periodic(); r = process_run(); } while(r > 0); /* * Idle processing. */ int s = splhigh(); /* Disable interrupts. */ /* uart1_active is for avoiding LPM3 when still sending or receiving */ if(process_nevents() != 0) { splx(s); /* Re-enable interrupts. */ } else { static unsigned long irq_energest = 0; /* Re-enable interrupts and go to sleep atomically. */ ENERGEST_OFF(ENERGEST_TYPE_CPU); ENERGEST_ON(ENERGEST_TYPE_LPM); /* We only want to measure the processing done in IRQs when we are asleep, so we discard the processing time done when we were awake. */ energest_type_set(ENERGEST_TYPE_IRQ, irq_energest); watchdog_stop(); if (shutdown_mode) { system_shutdown(1); // never return LPM4; } if (msp430_dco_required) { __low_power_mode_0(); } else { __low_power_mode_3(); } /* We get the current processing time for interrupts that was done during the LPM and store it for next time around. */ __disable_interrupt(); irq_energest = energest_type_time(ENERGEST_TYPE_IRQ); __enable_interrupt(); watchdog_start(); ENERGEST_OFF(ENERGEST_TYPE_LPM); ENERGEST_ON(ENERGEST_TYPE_CPU); } } }
// Lua: restore() static int node_restore (lua_State *L) { system_restore(); return 0; }