/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { system_update_cpu_freq(160); //overclock :) uart_init(BIT_RATE_115200,BIT_RATE_115200); NODE_DBG("User Init"); uint32_t size = flash_get_size_byte(); NODE_DBG("Flash size %d",size); config_wifi(); relay_init(); init_dns(); init_http_server(); //uncomment to send data to mqtt broker //mqtt_app_init(); //uncomment if you have sensors intalled //sensors_init(); #ifdef DEVELOP_VERSION //arm timer os_memset(&heapTimer,0,sizeof(os_timer_t)); os_timer_disarm(&heapTimer); os_timer_setfn(&heapTimer, (os_timer_func_t *)heapTimerCb, NULL); os_timer_arm(&heapTimer, 5000, 1); #endif }
static int node_info( lua_State* L ) { lua_pushinteger(L, NODE_VERSION_MAJOR); lua_pushinteger(L, NODE_VERSION_MINOR); lua_pushinteger(L, NODE_VERSION_REVISION); lua_pushinteger(L, system_get_chip_id()); // chip id lua_pushinteger(L, spi_flash_get_id()); // flash id lua_pushinteger(L, flash_get_size_byte() / 1024); // flash size in KB lua_pushinteger(L, flash_get_mode()); lua_pushinteger(L, flash_get_speed()); return 8; }
// Lua: flashsize() static int node_flashsize( lua_State* L ) { //uint32_t sz = 0; //if(lua_type(L, 1) == LUA_TNUMBER) //{ // sz = luaL_checkinteger(L, 1); // if(sz > 0) // { // flash_set_size_byte(sz); // } //} uint32_t sz = flash_get_size_byte(); lua_pushinteger( L, sz ); return 1; }
uint16_t flash_get_sec_num(void) { return flash_get_size_byte() / SPI_FLASH_SEC_SIZE; }