blink example: Change default to GPIO2 as this pin has an LED on most boards

This commit is contained in:
Angus Gratton 2016-02-09 10:58:56 +11:00
parent 3dfa2272cc
commit 30d8e162b3

View file

@ -8,7 +8,7 @@
#include "task.h" #include "task.h"
#include "esp8266.h" #include "esp8266.h"
const int gpio = 14; const int gpio = 2;
/* This task uses the high level GPIO API (esp_gpio.h) to blink an LED. /* This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
* *
@ -30,7 +30,7 @@ void blinkenTask(void *pvParameters)
The step that sets the iomux register can't be automatically The step that sets the iomux register can't be automatically
updated from the 'gpio' constant variable, so you need to change updated from the 'gpio' constant variable, so you need to change
the line that sets IOMUX_GPIO14 if you change 'gpio'. the line that sets IOMUX_GPIO2 if you change 'gpio'.
There is no significant performance benefit to this way over the There is no significant performance benefit to this way over the
blinkenTask version, so it's probably better to use the blinkenTask blinkenTask version, so it's probably better to use the blinkenTask
@ -41,7 +41,7 @@ void blinkenTask(void *pvParameters)
void blinkenRegisterTask(void *pvParameters) void blinkenRegisterTask(void *pvParameters)
{ {
GPIO.ENABLE_OUT_SET = BIT(gpio); GPIO.ENABLE_OUT_SET = BIT(gpio);
IOMUX_GPIO14 = IOMUX_GPIO14_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */ IOMUX_GPIO2 = IOMUX_GPIO2_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */
while(1) { while(1) {
GPIO.OUT_SET = BIT(gpio); GPIO.OUT_SET = BIT(gpio);
vTaskDelay(1000 / portTICK_RATE_MS); vTaskDelay(1000 / portTICK_RATE_MS);