Code:
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
static const int pin = 10;
static volatile os_timer_t some_timer;
void some_timerfunc(void *arg)
{
//Do blinky stuff
if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & (1<<pin))
{
// set gpio low
gpio_output_set(0, (1<<pin), 0, 0);
}
else
{
// set gpio high
gpio_output_set((1<<pin), 0, 0, 0);
}
}
void ICACHE_FLASH_ATTR user_init()
{
// init gpio subsytem
gpio_init();
// configure UART TXD to be GPIO1, set as output
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U , FUNC_GPIO10);
gpio_output_set(0, 0, (1<<pin), 0);
// setup timer (500ms, repeating)
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);
os_timer_arm(&some_timer, 500, 1);
}
Statistics: Posted by bad_mood — Tue Jun 14, 2016 4:24 pm
Statistics: Posted by csc13 — Sun Jun 12, 2016 8:09 am
Statistics: Posted by Adex — Sun Jul 19, 2015 2:21 am
Statistics: Posted by gailu — Fri Jun 26, 2015 1:34 am
Code:
// Example code using GPIO9 and GPIO10
// Note, the following code will not work as expected on unmodified hardware
// *****************************************************************************************
// assign SD_DATA2 and SD_DATA2 GPIO function
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, FUNC_GPIO9);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, FUNC_GPIO10);
// set GPIO9 and GPIO10 low
gpio_output_set(0, BIT9, BIT9, 0);
gpio_output_set(0, BIT10, BIT10, 0);
// set GPIO9 and GPIO10 high
gpio_output_set(BIT9, 0, BIT9, 0);
gpio_output_set(BIT10, 0, BIT10, 0);
Statistics: Posted by rudi — Thu Jun 25, 2015 11:22 pm
Code:
#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
#include "gpio.h"
void user_rf_pre_init(void)
{
}
void user_init(void)
{
uart_reattach();
os_printf("SDK version:%s\n", system_get_sdk_version());
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, FUNC_GPIO9);
GPIO_OUTPUT_SET(GPIO_ID_PIN(9), 0);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, FUNC_GPIO10);
GPIO_OUTPUT_SET(GPIO_ID_PIN(10), 0);
}
Code:
#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
#include "gpio.h"
void user_rf_pre_init(void)
{
}
void user_init(void)
{
uart_reattach();
os_printf("SDK version:%s\n", system_get_sdk_version());
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
GPIO_OUTPUT_SET(GPIO_ID_PIN(14), 0);
}
Statistics: Posted by gailu — Thu Jun 25, 2015 4:56 pm