Skip to content

Instantly share code, notes, and snippets.

@projectgus
Created March 3, 2015 11:08
Show Gist options
  • Save projectgus/45d4cc4140e72f1e5a51 to your computer and use it in GitHub Desktop.
Save projectgus/45d4cc4140e72f1e5a51 to your computer and use it in GitHub Desktop.
Debuggable esp8266 program
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include <stdio.h>
volatile uint32_t fast_blink = 250*1000;
volatile uint32_t slow_blink = 1200*1000;
//Init function
void ICACHE_FLASH_ATTR
user_init()
{
int i;
// Initialize the GPIO subsystem.
gpio_init();
//Set GPIO2 to output mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
//Set GPIO2 low
gpio_output_set(0, BIT2, BIT2, 0);
ets_wdt_disable();
for(i = 0 ; i < 10; i ++) {
gpio_output_set(BIT2, 0, BIT2, 0);
ets_delay_us(fast_blink);
gpio_output_set(0, BIT2, BIT2, 0);
ets_delay_us(fast_blink);
}
while(1) {
gpio_output_set(BIT2, 0, BIT2, 0);
ets_delay_us(slow_blink);
gpio_output_set(0, BIT2, BIT2, 0);
ets_delay_us(slow_blink);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment