boards/risc-v/k210/maix-bit: Add initial autoled support

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2020-06-06 13:18:14 +08:00 committed by Masayuki Ishikawa
parent bcd7ccc0b5
commit 2b0324c3bf
7 changed files with 91 additions and 2 deletions

View file

@ -47,6 +47,7 @@ CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c
CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c
CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c k210_schedulesigaction.c
CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c
CMN_CSRCS += riscv_mdelay.c
ifeq ($(CONFIG_STACK_COLORATION),y)
CMN_CSRCS += riscv_checkstack.c

View file

@ -80,8 +80,8 @@
#define K210_IO_SL (1 << 19)
#define K210_IO_ST (1 << 23)
#define K210_FLAG_GPIOHS (K210_IO_DS(0xf) | K210_IO_OUTPUT_ENABLE | \
K210_IO_INPUT_ENABLE | K210_IO_ST)
#define K210_IOFLAG_GPIOHS (K210_IO_DS(0xf) | K210_IO_OUTPUT_ENABLE | \
K210_IO_INPUT_ENABLE | K210_IO_ST)
/****************************************************************************
* Public Functions Prototypes

View file

@ -549,6 +549,7 @@ config ARCH_BOARD_LX_CPU
config ARCH_BOARD_MAIX_BIT
bool "Sipeed Maix Bit board"
depends on ARCH_CHIP_K210
select ARCH_HAVE_LEDS
---help---
This is the board configuration for the port of NuttX to the
Sipeed Maix Bit board. This board features the RISC-V K210

View file

@ -48,6 +48,28 @@
#include "k210.h"
#include "k210_fpioa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define BOARD_LED_PAD 14 /* Connected to red led */
/* Map pad 14 to gpiohs io 0 */
#define BOARD_LED_IO_FUNC K210_IO_FUNC_GPIOHS0
#define BOARD_LED_IO 0
#define LED_STARTED 0 /* N/C */
#define LED_HEAPALLOCATE 1 /* N/C */
#define LED_IRQSENABLED 2 /* N/C */
#define LED_STACKCREATED 3 /* N/C */
#define LED_INIRQ 4 /* N/C */
#define LED_SIGNAL 5 /* N/C */
#define LED_ASSERTION 6 /* N/C */
#define LED_PANIC 7 /* blink */
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -41,4 +41,8 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += k210_appinit.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += k210_leds.c
endif
include $(TOPDIR)/boards/Board.mk

View file

@ -41,6 +41,7 @@
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
/****************************************************************************
@ -68,4 +69,5 @@
void k210_boardinitialize(void)
{
board_autoled_initialize();
}

View file

@ -0,0 +1,59 @@
/****************************************************************************
* boards/risc-v/k210/maix-bit/src/k210_leds.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 <nuttx/board.h>
#include <arch/board/board.h>
#include "k210_fpioa.h"
#include "k210_gpiohs.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void board_autoled_initialize(void)
{
k210_fpioa_config(BOARD_LED_PAD, BOARD_LED_IO_FUNC | K210_IOFLAG_GPIOHS);
k210_gpiohs_set_direction(BOARD_LED_IO, true);
k210_gpiohs_set_value(BOARD_LED_IO, true); /* LED off */
}
void board_autoled_on(int led)
{
if (led == LED_PANIC)
{
k210_gpiohs_set_value(BOARD_LED_IO, false);
}
}
void board_autoled_off(int led)
{
if (led == LED_PANIC)
{
k210_gpiohs_set_value(BOARD_LED_IO, true);
}
}