From f51d6b8c723a736d0fb198eb1b67b787c21903a4 Mon Sep 17 00:00:00 2001 From: ThomasNS Date: Tue, 27 Jun 2023 11:08:40 +0200 Subject: [PATCH] add userled driver initialization --- arch/arm/src/xmc4/xmc4_serial.c | 1 - arch/arm/src/xmc4/xmc4_spi.c | 4 +-- boards/arm/xmc4/xmc4700-relax/include/board.h | 3 +- boards/arm/xmc4/xmc4700-relax/src/xmc4_boot.c | 2 -- .../arm/xmc4/xmc4700-relax/src/xmc4_bringup.c | 30 ++++++++++++++----- boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c | 8 ++--- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/arch/arm/src/xmc4/xmc4_serial.c b/arch/arm/src/xmc4/xmc4_serial.c index 5417d2563c..f28d6899b3 100644 --- a/arch/arm/src/xmc4/xmc4_serial.c +++ b/arch/arm/src/xmc4/xmc4_serial.c @@ -1150,5 +1150,4 @@ int up_putc(int ch) #endif } - #endif /* HAVE_UART_DEVICE && USE_SERIALDRIVER */ diff --git a/arch/arm/src/xmc4/xmc4_spi.c b/arch/arm/src/xmc4/xmc4_spi.c index 0d44c1f1e1..f542788b58 100644 --- a/arch/arm/src/xmc4/xmc4_spi.c +++ b/arch/arm/src/xmc4/xmc4_spi.c @@ -221,7 +221,7 @@ static bool spi_checkreg(struct xmc4_spidev_s *spi, bool wr, uint32_t value, uint32_t address); #else -# define spi_checkreg(spi, wr, value, address) (false) +# define spi_checkreg(spi, wr, value, address) (false) #endif static inline uint32_t spi_getreg(struct xmc4_spidev_s *spi, @@ -233,7 +233,7 @@ static inline struct xmc4_spidev_s *spi_device(struct xmc4_spics_s *spics); #ifdef CONFIG_DEBUG_SPI_INFO static void spi_dumpregs(struct xmc4_spidev_s *spi, const char *msg); #else -# define spi_dumpregs(spi, msg) +# define spi_dumpregs(spi, msg) #endif static inline void spi_flush(struct xmc4_spidev_s *spi); diff --git a/boards/arm/xmc4/xmc4700-relax/include/board.h b/boards/arm/xmc4/xmc4700-relax/include/board.h index 8ef1120e30..9fa315644a 100644 --- a/boards/arm/xmc4/xmc4700-relax/include/board.h +++ b/boards/arm/xmc4/xmc4700-relax/include/board.h @@ -320,10 +320,9 @@ #define BOARD_SPI_DX USIC_DXC #define GPIO_SPI4_MOSI (GPIO_U2C0_DOUT0_2 | GPIO_PADA2_STRONGMEDIUM) -#define GPIO_SPI4_MISO (GPIO_U1C0_DX0C) +#define GPIO_SPI4_MISO (GPIO_U2C0_DX0C) #define GPIO_SPI4_SCLK (GPIO_U2C0_SCLKOUT_1 | GPIO_PADA2_STRONGMEDIUM) - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/boards/arm/xmc4/xmc4700-relax/src/xmc4_boot.c b/boards/arm/xmc4/xmc4700-relax/src/xmc4_boot.c index 74bbb8e52b..92b772d153 100644 --- a/boards/arm/xmc4/xmc4700-relax/src/xmc4_boot.c +++ b/boards/arm/xmc4/xmc4700-relax/src/xmc4_boot.c @@ -50,8 +50,6 @@ void xmc4_board_initialize(void) /* Configure on-board LEDs if LED support has been selected. */ board_autoled_initialize(); -#else - board_userled_initialize(); #endif #ifdef CONFIG_XMC4_USCI_SPI diff --git a/boards/arm/xmc4/xmc4700-relax/src/xmc4_bringup.c b/boards/arm/xmc4/xmc4700-relax/src/xmc4_bringup.c index cd0baa75cc..23767c17b3 100644 --- a/boards/arm/xmc4/xmc4700-relax/src/xmc4_bringup.c +++ b/boards/arm/xmc4/xmc4700-relax/src/xmc4_bringup.c @@ -26,9 +26,15 @@ #include #include -#include #include +#ifdef CONFIG_XMC4_USCI_SPI +# include +#endif +#ifdef CONFIG_USERLED +# include +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -50,15 +56,25 @@ int xmc4_bringup(void) spi = xmc4_spibus_initialize(4); if (!spi) - { - return -ENODEV; - } + { + return -ENODEV; + } ret = spi_register(spi, 0); if (ret < 0) - { - snerr("ERROR: Failed to register driver: %d\n", ret); - } + { + snerr("ERROR: Failed to register driver: %d\n", ret); + } +#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 return ret; diff --git a/boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c b/boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c index 5c32be5206..56f4d257a8 100644 --- a/boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c +++ b/boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/xmc4/xmc4500-relax/src/xmc4_spi.c + * boards/arm/xmc4/xmc4700-relax/src/xmc4_spi.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -42,7 +42,7 @@ * Name: xmc4_spidev_initialize * * Description: - * Called to configure SPI chip select GPIO pins for the FRDM-KL25Z board. + * Called to configure SPI chip select GPIO pins. * ****************************************************************************/ @@ -186,7 +186,7 @@ void xmc4_spi4select(struct spi_dev_s *dev, uint32_t devid, * devid - Identifies the (logical) device * * Returned Values: - * Bit-encoded SPI status (see include/nuttx/spi/spi.h. + * Bit-encoded SPI status (see include/nuttx/spi/spi.h). * ****************************************************************************/ @@ -238,7 +238,7 @@ uint8_t xmc4_spi4status(struct spi_dev_s *dev, uint32_t devid) * cmd - Determines where command or data should be selected. * * Returned Values: - * Bit-encoded SPI status (see include/nuttx/spi/spi.h. + * Bit-encoded SPI status (see include/nuttx/spi/spi.h). * ****************************************************************************/