Skip to content

Commit

Permalink
zcu111: add support for board led
Browse files Browse the repository at this point in the history
  • Loading branch information
zouboan authored and acassis committed Jul 16, 2024
1 parent b817db8 commit 85e8536
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 2 deletions.
1 change: 0 additions & 1 deletion boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_ARCH_LEDS is not set
# CONFIG_DEBUG_OPT_UNUSED_SECTIONS is not set
CONFIG_ARCH="arm64"
CONFIG_ARCH_ARM64=y
Expand Down
42 changes: 42 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,46 @@
* Pre-processor Definitions
****************************************************************************/

/* LED definitions **********************************************************/

/* The ZCU111 PL has only one MIO LEDs, Others LED connected to PL.
*
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
* any way. The following definitions are used to access individual LEDs.
*/

/* LED index values for use with board_userled() */

#define BOARD_LED1 0
#define BOARD_NLEDS 1

/* LED bits for use with board_userled_all() */

#define BOARD_LED1_BIT (1 << BOARD_LED1)

/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* The following definitions describe how NuttX controls the LED:
*
* SYMBOL Meaning LED1 state
* ------------------ ----------------------- ----------
* LED_STARTED NuttX has been started OFF
* LED_HEAPALLOCATE Heap has been allocated OFF
* LED_IRQSENABLED Interrupts enabled OFF
* LED_STACKCREATED Idle stack created ON
* LED_INIRQ In an interrupt No change
* LED_SIGNAL In a signal handler No change
* LED_ASSERTION An assertion failed No change
* LED_PANIC The system has crashed Blinking
* LED_IDLE STM32 is is sleep mode Not used
*/

#define LED_STARTED 0
#define LED_HEAPALLOCATE 0
#define LED_IRQSENABLED 0
#define LED_STACKCREATED 1
#define LED_INIRQ 2
#define LED_SIGNAL 2
#define LED_ASSERTION 2
#define LED_PANIC 1

#endif /* __BOARDS_ARM64_ZYNQ_MPSOC_ZCU111_INCLUDE_BOARD_H */
4 changes: 4 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ include $(TOPDIR)/Make.defs
CSRCS = zcu111_boardinit.c
CSRCS += zcu111_appinit.c

ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += zcu111_autoleds.c
endif

ifeq ($(CONFIG_ETC_ROMFS),y)
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
endif
Expand Down
14 changes: 14 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@

#include <nuttx/config.h>
#include <stdint.h>
#include "zynq_mio.h"

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Configuration ************************************************************/

/* LEDs *********************************************************************/

/* Green LED on MIO23 */

#define LED_DS50 23

#ifndef __ASSEMBLY__

/****************************************************************************
Expand Down
81 changes: 81 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm64/zynq-mpsoc/zcu111/src/zcu111_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 <stdint.h>
#include <stdbool.h>
#include <debug.h>

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

#include "chip.h"
#include "arm64_internal.h"
#include "zcu111.h"

#if defined(CONFIG_ARCH_LEDS)

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

/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/

void board_autoled_initialize(void)
{
/* Configure LED GPIOs for output */

zynq_mio_setdirpin(LED_DS50, 1);
zynq_mio_setoutenpin(LED_DS50, 1);
zynq_mio_writepin(LED_DS50, false);
}

/****************************************************************************
* Name: board_autoled_on
****************************************************************************/

void board_autoled_on(int led)
{
if (led == BOARD_LED1)
{
zynq_mio_writepin(LED_DS50, true);
}
}

/****************************************************************************
* Name: board_autoled_off
****************************************************************************/

void board_autoled_off(int led)
{
if (led == BOARD_LED1)
{
zynq_mio_writepin(LED_DS50, false);
}
}

#endif /* CONFIG_ARCH_LEDS */
5 changes: 4 additions & 1 deletion boards/arm64/zynq-mpsoc/zcu111/src/zcu111_boardinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ void zynq_memory_initialize(void)

void zynq_board_initialize(void)
{
/* resets the GPIO module by writing reset values to all registers */

zynq_mio_initialize();
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */

/* board_autoled_initialize(); */
board_autoled_initialize();
#endif
}

Expand Down

0 comments on commit 85e8536

Please sign in to comment.