Statistics: Posted by ESP_Faye — Wed May 27, 2015 10:03 am
Code:
/*
* user_config.h
*
* Created on: 18/05/2015
* Author: Barry
*/
#ifndef USER_USER_CONFIG_H_
#define USER_USER_CONFIG_H_
#define USE_US_TIMER
#endif /* USER_USER_CONFIG_H_ */
Code:
/*
* user_main.c
*
* Created on: 18/05/2015
* Author: Barry
*/
#include "osapi.h"
#include "c_types.h"
#include "ets_sys.h"
#include "gpio.h"
#include "user_config.h"
#include "user_interface.h"
static bool inpinval = true;
static bool toggle = true;
static volatile os_timer_t sample_window_timer;
void user_rf_pre_init(void)
{
}
void sample_window_timer_cb(void *arg){
inpinval = GPIO_INPUT_GET(GPIO_ID_PIN(5)); //5
toggle = !toggle;
GPIO_OUTPUT_SET(GPIO_ID_PIN(15), toggle);//15
}
//Init function
void user_init()
{
system_timer_reinit();
gpio_init();
uart_div_modify(0, UART_CLK_FREQ / 115200);
// GPIO15 As Output
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15);
GPIO_OUTPUT_SET(GPIO_ID_PIN(15), 1);
// GPIO5 as Input
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
inpinval = GPIO_INPUT_GET(GPIO_ID_PIN(5));
os_timer_disarm(&sample_window_timer);
os_timer_setfn(&sample_window_timer, (os_timer_func_t *)sample_window_timer_cb, NULL);
#ifdef USE_US_TIMER
os_timer_arm_us(&sample_window_timer, 100, 1);
#else
os_timer_arm(&sample_window_timer, 1, 1);
#endif
}
Statistics: Posted by BarryP — Wed May 27, 2015 7:34 am
Statistics: Posted by BarryP — Fri May 22, 2015 8:18 am