10000 GPIO numbering wrong (GIT8266O-717) · Issue #1139 · espressif/ESP8266_RTOS_SDK · GitHub
[go: up one dir, main page]

Skip to content
GPIO numbering wrong (GIT8266O-717) #1139
Closed
@bertmelis

Description

@bertmelis

I've installed the latest SDK on Windows 10. Firmware is running on a Wemos D1 Mini.
I tried to run a simple blink but the pin numbering is completely wrong.

With

#define GPIO_OUTPUT_IO GPIO_Pin_4

a LED blinks on D0 which imho should map to GPIO16.
Output is

pin: 16
pin bitmask: 65536

With

#define GPIO_OUTPUT_IO GPIO_Pin_2

a LED blinks on D2 which should map to GPIO4
Output is

pin: 4
pin bitmask: 16

It becomes worse when using GPIO_Pin_5:

C:/msys32/home/Bert/esp/pmsensor02/main/main.c:15:21: warning: conversion from 'long long unsigned int' to 'unsigned int' changes value from '4294967296' to '0' [-Woverflow]
     .pin_bit_mask = (1ULL<<GPIO_OUTPUT_IO),
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

#define GPIO_OUTPUT_IO GPIO_Pin_4

void blink() {
  gpio_config_t io_conf = {
    .intr_type = GPIO_INTR_DISABLE,
    .mode = GPIO_MODE_OUTPUT,
    .pin_bit_mask = (1ULL<<GPIO_OUTPUT_IO),
    .pull_down_en = 0,
    .pull_up_en = 0,
  };
  gpio_config(&io_conf);

  printf("pin: %lu\n", GPIO_OUTPUT_IO);
  printf("pin bitmask: %u\n", io_conf.pin_bit_mask);

  int cnt = 0;
  while (true) {
    vTaskDelay(1000 / portTICK_RATE_MS);
    gpio_set_level(GPIO_OUTPUT_IO, cnt % 2);
  }
}

TaskHandle_t xHandle = NULL;

void app_main() {
  printf("Starting blink task\n");
  BaseType_t xReturned = xTaskCreate(blink,
                                     "BLINK",
                                     2048,
                                     (void*)1,
                                     1,
                                     &xHandle);
  if (xReturned != pdPASS) {
    printf("Error creating BLINK task\n");
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0