mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
esp32c3-devkit-rust-1: Add ARCH LED support
This commit is contained in:
committed by
Xiang Xiao
parent
23a7d8a693
commit
456aaa8c1c
@@ -308,6 +308,8 @@ config ARCH_BOARD_ESP32C3_DEVKIT
|
|||||||
config ARCH_BOARD_ESP32C3_DEVKIT_RUST1
|
config ARCH_BOARD_ESP32C3_DEVKIT_RUST1
|
||||||
bool "Espressif ESP32-C3-RUST-1 board"
|
bool "Espressif ESP32-C3-RUST-1 board"
|
||||||
depends on ARCH_CHIP_ESP32C3MINI1
|
depends on ARCH_CHIP_ESP32C3MINI1
|
||||||
|
select ARCH_HAVE_LEDS
|
||||||
|
select ARCH_HAVE_BUTTONS
|
||||||
---help---
|
---help---
|
||||||
The ESP32-C3-DevKit-RUST-1 features the ESP32-C3 CPU with a RISC-V core.
|
The ESP32-C3-DevKit-RUST-1 features the ESP32-C3 CPU with a RISC-V core.
|
||||||
This board includes the ESP32-C3-MINI-1 module, a 6DoF IMU, a temperature
|
This board includes the ESP32-C3-MINI-1 module, a 6DoF IMU, a temperature
|
||||||
|
|||||||
@@ -25,6 +25,18 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define NUM_BUTTONS 1
|
||||||
|
|
||||||
|
#define LED_STARTED 0 /* ON */
|
||||||
|
#define LED_HEAPALLOCATE 1 /* ON */
|
||||||
|
#define LED_IRQSENABLED 2 /* N/A */
|
||||||
|
#define LED_STACKCREATED 3 /* N/A */
|
||||||
|
#define LED_INIRQ 4 /* N/A */
|
||||||
|
#define LED_SIGNAL 5 /* N/A */
|
||||||
|
#define LED_ASSERTION 6 /* N/A */
|
||||||
|
#define LED_PANIC 7 /* Blinking */
|
||||||
|
#define LED_CPU 8 /* N/A */
|
||||||
|
|
||||||
/* Clocking *****************************************************************/
|
/* Clocking *****************************************************************/
|
||||||
|
|
||||||
#define BOARD_XTAL_FREQUENCY 40000000
|
#define BOARD_XTAL_FREQUENCY 40000000
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ CSRCS += esp32c3_appinit.c
|
|||||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||||
CSRCS += esp32c3_reset.c
|
CSRCS += esp32c3_reset.c
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||||
|
CSRCS += esp32c3_autoleds.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL_IOCTL),y)
|
ifeq ($(CONFIG_BOARDCTL_IOCTL),y)
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_autoleds.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 <debug.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "esp32c3_gpio.h"
|
||||||
|
#include "hardware/esp32c3_gpio_sigmap.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* IO7 is connected to LED D2 */
|
||||||
|
|
||||||
|
#define GPIO_LED 7
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static inline void set_led(bool v)
|
||||||
|
{
|
||||||
|
ledinfo("Turn LED %s\n", v ? "on":"off");
|
||||||
|
esp32c3_gpiowrite(GPIO_LED, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_autoled_initialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_autoled_initialize(void)
|
||||||
|
{
|
||||||
|
/* Configure the LED's pin to be used as output */
|
||||||
|
|
||||||
|
esp32c3_gpio_matrix_out(GPIO_LED, SIG_GPIO_OUT_IDX, 0, 0);
|
||||||
|
esp32c3_configgpio(GPIO_LED, OUTPUT_FUNCTION_1 | INPUT_FUNCTION_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_autoled_on
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_autoled_on(int led)
|
||||||
|
{
|
||||||
|
ledinfo("board_autoled_on(%d)\n", led);
|
||||||
|
|
||||||
|
switch (led)
|
||||||
|
{
|
||||||
|
case LED_STARTED:
|
||||||
|
case LED_HEAPALLOCATE:
|
||||||
|
|
||||||
|
/* As the board provides only one soft controllable LED, we simply
|
||||||
|
* turn it on when the board boots.
|
||||||
|
*/
|
||||||
|
|
||||||
|
set_led(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LED_PANIC:
|
||||||
|
|
||||||
|
/* For panic state, the LED is blinking */
|
||||||
|
|
||||||
|
set_led(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ledinfo("Not handled LED state: %d\n", led);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_autoled_off
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_autoled_off(int led)
|
||||||
|
{
|
||||||
|
switch (led)
|
||||||
|
{
|
||||||
|
case LED_PANIC:
|
||||||
|
|
||||||
|
/* For panic state, the LED is blinking */
|
||||||
|
|
||||||
|
set_led(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ledinfo("Not handled LED state: %d\n", led);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
|
||||||
#include "riscv_internal.h"
|
#include "riscv_internal.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user