void user_init(void) { //Init uart uart_init(BIT_RATE_115200, BIT_RATE_115200); os_delay_us(1000); ets_uart_printf("Booting...\r\n"); // i2c i2c_init(); if(!eeprom_writeByte(0x78,0x01,0x00)) ets_uart_printf("Write failed\n\r"); //Disarm timer os_timer_disarm(&sensor_timer); //Setup timer os_timer_setfn(&sensor_timer, (os_timer_func_t *)sensor_timerfunc, NULL); //Arm timer for every 10 sec. os_timer_arm(&sensor_timer, 5000, 1); system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
static void ICACHE_FLASH_ATTR writeByByteTest() { time = system_get_time(); errors = 0; address = 0; console_printf("-----------------------------------------------\r\n"); console_printf("Write byte test:\r\n"); console_printf("Start address: %d, End address: %d\r\n", MIN_ADDRESS, MAX_ADDRESS); console_printf("Writing data: "); for (address = MIN_ADDRESS; address <= MAX_ADDRESS; address++) { wdata = address % loop_size; if(!eeprom_writeByte(DEVICEADDRESS, address, wdata)) console_printf("Failed write, address: %d, data: %d\r\n", address, (uint8_t)wdata); else { if (!(address % 500)) { //console_printf( "Address: %d, data: %d\r\n", address, (uint8_t)wdata); console_printf("..500.."); } } sleepms(3); } finishTime = system_get_time() - time; console_printf("DONE!\r\n"); console_printf("Total Time (seconds): %d\r\n", (uint32_t)(finishTime / 1000000)); console_printf("Write operations per second: %d\r\n", (uint32_t)(MAX_ADDRESS / (finishTime / 1000000))); console_printf("-----------------------------------------------\r\n"); console_printf("\r\n"); }
void sensor_timerfunc(void *arg) { uint8 data; char temp[80]; data = eeprom_readByte(0x50,0x01); os_sprintf(temp, "Byte: %x \n\r",data); ets_uart_printf(temp); data = data + 1; if(!eeprom_writeByte(0x50,0x01,data)) ets_uart_printf("Write failed\n\r"); }