Skip to content

Instantly share code, notes, and snippets.

@zarya
Created October 13, 2014 13:20
Show Gist options
  • Save zarya/b883911bfbbc097abedf to your computer and use it in GitHub Desktop.
Save zarya/b883911bfbbc097abedf to your computer and use it in GitHub Desktop.
#include "ets_sys.h"
#include "driver/i2c_master.h"
#include "driver/uart.h"
#include "osapi.h"
#include "os_type.h"
#include "user_interface.h"
#include "functions.h"
#include "config.h"
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static void user_procTask(os_event_t *events);
static volatile os_timer_t sensor_timer;
void sensor_timerfunc(void *arg)
{
//Read data
uart0_sendStr("sensor pull: ");
i2c_master_start();
i2c_master_writeByte(0x77);
i2c_master_writeByte(0x77);
i2c_master_writeByte(0x77);
i2c_master_writeByte(0x77);
i2c_master_stop();
uart0_sendStr("Done\r\n");
}
static void ICACHE_FLASH_ATTR
user_procTask(os_event_t *events)
{
os_delay_us(10);
}
void user_init(void)
{
char ssid[32] = SSID;
char password[64] = SSID_PASSWORD;
struct station_config stationConf;
dataStrCpy(&stationConf.ssid, ssid, 32);
dataStrCpy(&stationConf.password, password, 32);
//Init uart
uart_init(BIT_RATE_115200, BIT_RATE_115200);
//Setup wifi
wifi_set_opmode( 0x1 );
wifi_station_set_config(&stationConf);
// wifi_station_connect();
i2c_master_gpio_init();
uart0_sendStr("Booting\r\n");
//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 1 sec.
os_timer_arm(&sensor_timer, 10000, 1);
system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment