xtensa/esp32: Added Userled support
This commit is contained in:
parent
83745652c4
commit
ddc0d30063
@ -191,6 +191,7 @@ config ARCH_BOARD_QUICKFEATHER
|
|||||||
config ARCH_BOARD_ESP32CORE
|
config ARCH_BOARD_ESP32CORE
|
||||||
bool "Espressif ESP32 Core board V2"
|
bool "Espressif ESP32 Core board V2"
|
||||||
depends on ARCH_CHIP_ESP32
|
depends on ARCH_CHIP_ESP32
|
||||||
|
select ARCH_HAVE_LEDS
|
||||||
---help---
|
---help---
|
||||||
The ESP32 is a dual-core system from Espressif with two Harvard
|
The ESP32 is a dual-core system from Espressif with two Harvard
|
||||||
architecture Xtensa LX6 CPUs. All embedded memory, external memory
|
architecture Xtensa LX6 CPUs. All embedded memory, external memory
|
||||||
|
52
boards/xtensa/esp32/esp32-core/configs/leds/defconfig
Normal file
52
boards/xtensa/esp32/esp32-core/configs/leds/defconfig
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32-core"
|
||||||
|
CONFIG_ARCH_BOARD_ESP32CORE=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_ESP32_UART0=y
|
||||||
|
CONFIG_EXAMPLES_LEDS=y
|
||||||
|
CONFIG_EXPERIMENTAL=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_MAX_TASKS=16
|
||||||
|
CONFIG_MM_REGIONS=2
|
||||||
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SDCLONE_DISABLE=y
|
||||||
|
CONFIG_SPI=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_USERLED=y
|
||||||
|
CONFIG_USERLED_LOWER=y
|
||||||
|
CONFIG_USER_ENTRYPOINT="nsh_main"
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_ESP32_SPI2_DMA is not set
|
# CONFIG_ESP32_SPI2_DMA is not set
|
||||||
# CONFIG_MMCSD_HAVE_CARDDETECT is not set
|
# CONFIG_MMCSD_HAVE_CARDDETECT is not set
|
||||||
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
|
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
CONFIG_ARCH="xtensa"
|
CONFIG_ARCH="xtensa"
|
||||||
CONFIG_ARCH_BOARD="esp32-core"
|
CONFIG_ARCH_BOARD="esp32-core"
|
||||||
CONFIG_ARCH_BOARD_ESP32CORE=y
|
CONFIG_ARCH_BOARD_ESP32CORE=y
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
# CONFIG_NSH_ARGCAT is not set
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
# CONFIG_NSH_CMDPARMS is not set
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
@ -85,4 +85,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* LED definitions **********************************************************/
|
||||||
|
|
||||||
|
/* Define how many LEDs this board has (needed by userleds) */
|
||||||
|
|
||||||
|
#define BOARD_NLEDS 1
|
||||||
|
#define GPIO_LED1 2
|
||||||
|
|
||||||
#endif /* __BOARDS_XTENSA_ESP32_ESP32_CORE_INCLUDE_BOARD_H */
|
#endif /* __BOARDS_XTENSA_ESP32_ESP32_CORE_INCLUDE_BOARD_H */
|
||||||
|
@ -66,6 +66,10 @@ CSRCS += esp32_timer.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USERLED),y)
|
||||||
|
CSRCS += esp32_userleds.c
|
||||||
|
endif
|
||||||
|
|
||||||
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32.template.ld
|
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32.template.ld
|
||||||
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32_out.ld
|
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32_out.ld
|
||||||
|
|
||||||
|
@ -53,6 +53,11 @@
|
|||||||
#ifdef CONFIG_TIMER
|
#ifdef CONFIG_TIMER
|
||||||
# include <nuttx/timers/timer.h>
|
# include <nuttx/timers/timer.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USERLED
|
||||||
|
# include <nuttx/leds/userled.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
|
|
||||||
@ -244,6 +249,16 @@ int esp32_bringup(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USERLED
|
||||||
|
/* Register the LED driver */
|
||||||
|
|
||||||
|
ret = userled_lower_initialize("/dev/userleds");
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we got here then perhaps not all initialization was successful, but
|
/* If we got here then perhaps not all initialization was successful, but
|
||||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||||
* capabilities.
|
* capabilities.
|
||||||
|
91
boards/xtensa/esp32/esp32-core/src/esp32_userleds.c
Normal file
91
boards/xtensa/esp32/esp32-core/src/esp32_userleds.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32/esp32-core/src/esp32_userleds.c
|
||||||
|
*
|
||||||
|
* 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 <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
#include "esp32_gpio.h"
|
||||||
|
#include "esp32-core.h"
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This array maps an LED number to GPIO pin configuration */
|
||||||
|
|
||||||
|
static const uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||||
|
{
|
||||||
|
GPIO_LED1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_userled_initialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint32_t board_userled_initialize(void)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < BOARD_NLEDS; i++)
|
||||||
|
{
|
||||||
|
esp32_configgpio(g_ledcfg[i], OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return BOARD_NLEDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_userled
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_userled(int led, bool ledon)
|
||||||
|
{
|
||||||
|
if ((unsigned)led < BOARD_NLEDS)
|
||||||
|
{
|
||||||
|
esp32_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++)
|
||||||
|
{
|
||||||
|
esp32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user