Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/xtensa/esp32/esp32-devkitc/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/* Define how many LEDs this board has (needed by userleds) */

#define BOARD_NLEDS 1
#define GPIO_LED1 2 /* Typical On-board LED is on GPIO 2 */

/* GPIO pins used by the GPIO Subsystem */

Expand Down
54 changes: 15 additions & 39 deletions boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@
/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdint.h>
#include <stdbool.h>
#include <nuttx/debug.h>

#include <nuttx/board.h>
#include <arch/board/board.h>

#include "espressif/esp_gpio.h"
#include "esp32-devkitc.h"

Expand All @@ -42,11 +36,7 @@

/* This array maps an LED number to GPIO pin configuration */

static const uint32_t g_ledcfg[BOARD_NLEDS] =
{
GPIO_LED1,
};

static const uint32_t g_ledcfg[BOARD_NLEDS] = { GPIO_LED1 };

Check failure on line 39 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Blank line precedes right brace at line

Check failure on line 39 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Right bracket not on separate line

Check failure on line 39 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Left bracket not on separate line
/****************************************************************************
* Public Functions
****************************************************************************/
Expand All @@ -55,42 +45,28 @@
* Name: board_userled_initialize
****************************************************************************/

uint32_t board_userled_initialize(void)
{
uint8_t i;

for (i = 0; i < BOARD_NLEDS; i++)
{
esp_configgpio(g_ledcfg[i], OUTPUT);
}

uint32_t board_userled_initialize(void) {

Check failure on line 48 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Left bracket not on separate line
for (int i = 0; i < BOARD_NLEDS; i++) {

Check failure on line 49 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Left bracket not on separate line
esp_configgpio(g_ledcfg[i], OUTPUT);
}

Check failure on line 51 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Right brace must be followed by a blank line

Check failure on line 51 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Bad right brace alignment
return BOARD_NLEDS;
}

Check failure on line 53 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Right brace must be followed by a blank line

/****************************************************************************
* Name: board_userled
****************************************************************************/

void board_userled(int led, bool ledon)
{
if ((unsigned)led < BOARD_NLEDS)
{
esp_gpiowrite(g_ledcfg[led], ledon);
}
}

Check failure on line 58 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Too many blank lines
void board_userled(int led, bool ledon) {

Check failure on line 59 in boards/xtensa/esp32/esp32-devkitc/src/esp32_userleds.c

View workflow job for this annotation

GitHub Actions / check

Left bracket not on separate line
if ((unsigned)led < BOARD_NLEDS) {
esp_gpiowrite(g_ledcfg[led], ledon);
}
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/

void board_userled_all(uint32_t ledset)
{
uint8_t i;

/* Configure LED1-8 GPIOs for output */

for (i = 0; i < BOARD_NLEDS; i++)
{
esp_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
}
}
void board_userled_all(uint32_t ledset) {
for (int i = 0; i < BOARD_NLEDS; i++) {
esp_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
}
}
1 change: 1 addition & 0 deletions boards/xtensa/esp32/heltec_wifi_lora32/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/* Define how many LEDs this board has (needed by userleds) */

#define BOARD_NLEDS 1
#define GPIO_LED1 25 /* White LED on Heltec WiFi LoRa 32 */

/* GPIO pins used by the GPIO Subsystem */

Expand Down
5 changes: 5 additions & 0 deletions boards/xtensa/esp32/heltec_wifi_lora32/src/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ DEPPATH += --dep-path board
VPATH += :board
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board


ifeq ($(CONFIG_USERLED),y)
CSRCS += esp32_userleds.c
endif

16 changes: 16 additions & 0 deletions boards/xtensa/esp32/heltec_wifi_lora32/src/esp32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

#include "esp32_start.h"

#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#endif



#ifdef CONFIG_ESPRESSIF_HR_TIMER
# include "espressif/esp_hr_timer.h"
#endif
Expand Down Expand Up @@ -110,6 +116,16 @@ int esp32_bringup(void)
* capabilities.
*/


#ifdef CONFIG_USERLED
ret = userled_lower_initialize("/dev/userleds");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
}
#endif


UNUSED(ret);
return OK;
}
90 changes: 90 additions & 0 deletions boards/xtensa/esp32/heltec_wifi_lora32/src/esp32_userleds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/****************************************************************************
* boards/xtensa/esp32/heltec_wifi_lora32/src/esp32_userleds.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdbool.h>

#include <nuttx/board.h>
#include <arch/board/board.h>

#include "espressif/esp_gpio.h"
#include "heltec_wifi_lora32.h"

/****************************************************************************
* Private Data
****************************************************************************/

static const uint32_t g_ledcfg[BOARD_NLEDS] =
{
GPIO_LED1,
};

/****************************************************************************
* Public Functions
****************************************************************************/

/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/

uint32_t board_userled_initialize(void)
{
int i;

for (i = 0; i < BOARD_NLEDS; i++)
{
esp_configgpio(g_ledcfg[i], OUTPUT);
}

return BOARD_NLEDS;
}

/****************************************************************************
* Name: board_userled
****************************************************************************/

void board_userled(int led, bool ledon)
{
if ((unsigned int)led < BOARD_NLEDS)
{
esp_gpiowrite(g_ledcfg[led], ledon);
}
}

/****************************************************************************
* Name: board_userled_all
****************************************************************************/

void board_userled_all(uint32_t ledset)
{
int i;

for (i = 0; i < BOARD_NLEDS; i++)
{
esp_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
}
}