Created
April 5, 2016 04:51
-
-
Save mash/0f5b1a2d85fa7fd67d0786fdd8706c2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ets_sys.h" | |
#include "osapi.h" | |
#include "user_interface.h" | |
#include "user_devicefind.h" | |
#include "user_webserver.h" | |
#include "user_iot_version.h" | |
#include "common/common.h" // ALIGNED | |
#include "user_persistent_variables.h" | |
#include "gpio.h" | |
#include "driver/gpio16.h" | |
uint8 iot_version[20] = {0}; | |
struct persistent_variables_t ALIGNED persistent_variables; | |
LOCAL os_timer_t blink_timer; | |
void user_rf_pre_init(void) { | |
} | |
LOCAL void ICACHE_FLASH_ATTR user_uart_setup(void) { | |
// 0 refers to uart0 | |
uart_div_modify(0, UART_CLK_FREQ / 115200); | |
} | |
LOCAL void ICACHE_FLASH_ATTR user_dump_version(void) { | |
ets_delay_us(1000000); // 1s | |
os_printf("SDK version:%s\n", system_get_sdk_version()); | |
os_sprintf(iot_version,"%s%d.%d.%dt%d(%s)",VERSION_TYPE,IOT_VERSION_MAJOR, \ | |
IOT_VERSION_MINOR,IOT_VERSION_REVISION,device_type,UPGRADE_FALG); | |
os_printf("IOT VERSION = %s\n",iot_version); | |
} | |
LOCAL void ICACHE_FLASH_ATTR user_dump_rst_info(void) { | |
struct rst_info *rtc_info = system_get_rst_info(); | |
os_printf("reset reason: %x\n", rtc_info->reason); | |
if (rtc_info->reason == REASON_WDT_RST || | |
rtc_info->reason == REASON_EXCEPTION_RST || | |
rtc_info->reason == REASON_SOFT_WDT_RST) { | |
if (rtc_info->reason == REASON_EXCEPTION_RST) { | |
os_printf("Fatal exception (%d):\n", rtc_info->exccause); | |
} | |
os_printf("epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\n", | |
rtc_info->epc1, rtc_info->epc2, rtc_info->epc3, rtc_info->excvaddr, rtc_info->depc); | |
} | |
} | |
LOCAL void ICACHE_FLASH_ATTR user_init_done_cb(void) { | |
os_printf("user_init_done_cb\n"); | |
wifi_station_connect(); | |
} | |
LOCAL void ICACHE_FLASH_ATTR blink(void *arg) { | |
static bool b = false; | |
os_printf("blink\n"); | |
b = !b; | |
gpio16_output_set(b); | |
} | |
void user_init(void) { | |
user_uart_setup(); | |
user_dump_version(); | |
PRINT_MEMORY(); | |
user_dump_rst_info(); | |
system_init_done_cb(&user_init_done_cb); | |
// green | |
gpio16_output_conf(); | |
os_timer_disarm(&blink_timer); | |
os_timer_setfn(&blink_timer, (os_timer_func_t *)blink, NULL); | |
os_timer_arm(&blink_timer, 300, USER_TIMER_REPEAT); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment