diff --git a/configs/nucleo-144/include/board.h b/configs/nucleo-144/include/board.h index 0e9020c0de..e90b4146d3 100644 --- a/configs/nucleo-144/include/board.h +++ b/configs/nucleo-144/include/board.h @@ -3,6 +3,7 @@ * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt + * Author: Mark Olsson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,10 +47,12 @@ # include #endif +#ifdef __KERNEL__ #include "stm32_rcc.h" #ifdef CONFIG_STM32F7_SDMMC1 # include "stm32_sdmmc.h" #endif +#endif /************************************************************************************ * Pre-processor Definitions @@ -226,13 +229,19 @@ /* LED index values for use with board_userled() */ #define BOARD_LED1 0 -#define BOARD_NLEDS 1 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_NLEDS 3 #define BOARD_LD1 BOARD_LED1 +#define BOARD_LD2 BOARD_LED2 +#define BOARD_LD3 BOARD_LED3 /* LED bits for use with board_userled_all() */ #define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) /* If CONFIG_ARCH_LEDS is defined, the usage by the board port is defined in * include/board.h and src/stm32_leds.c. The LEDs are used to encode OS-related diff --git a/configs/nucleo-144/src/nucleo-144.h b/configs/nucleo-144/src/nucleo-144.h index 7628bd120b..06d2b6a605 100644 --- a/configs/nucleo-144/src/nucleo-144.h +++ b/configs/nucleo-144/src/nucleo-144.h @@ -2,7 +2,8 @@ * configs/nucleo-144/src/nucleo-144.h * * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt + * Author: Gregory Nutt + * Author: Mark Olsson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -67,7 +68,13 @@ */ #define GPIO_LD1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | \ - GPIO_PORTI | GPIO_PIN1) + GPIO_PORTB | GPIO_PIN0) +#define GPIO_LD2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | \ + GPIO_PORTB | GPIO_PIN7) +#define GPIO_LD3 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | \ + GPIO_PORTB | GPIO_PIN14) + +#define LED_DRIVER_PATH "/dev/userleds" /* Pushbutton B1, labelled "User", is connected to GPIO PI11. A high value will be sensed when the * button is depressed. Note that the EXTI interrupt is configured. @@ -97,4 +104,3 @@ void weak_function stm32_spidev_initialize(void); #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_NUCLEO_144_SRC_NUCLEO_144_H */ - diff --git a/configs/nucleo-144/src/stm32_appinitialize.c b/configs/nucleo-144/src/stm32_appinitialize.c index 6c80705c3a..cbdae3906d 100644 --- a/configs/nucleo-144/src/stm32_appinitialize.c +++ b/configs/nucleo-144/src/stm32_appinitialize.c @@ -3,6 +3,7 @@ * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt + * Author: Mark Olsson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,9 +39,10 @@ ****************************************************************************/ #include +#include -#include "stm32_ccm.h" #include "nucleo-144.h" +#include /**************************************************************************** * Pre-processor Definitions @@ -62,26 +64,13 @@ int board_app_initialize(void) { -#ifdef CONFIG_FS_PROCFS int ret; -#ifdef CONFIG_STM32_CCM_PROCFS - /* Register the CCM procfs entry. This must be done before the procfs is - * mounted. - */ - - (void)ccm_procfs_register(); -#endif - - /* Mount the procfs file system */ - - ret = mount(NULL, SAMV71_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + /* Register the LED driver */ + ret = userled_lower_initialize(LED_DRIVER_PATH); if (ret < 0) - { - SYSLOG("ERROR: Failed to mount procfs at %s: %d\n", - SAMV71_PROCFS_MOUNTPOINT, ret); - } -#endif - - return OK; + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } + return 1; } diff --git a/configs/nucleo-144/src/stm32_userleds.c b/configs/nucleo-144/src/stm32_userleds.c index 19146d241d..1a0b4a5cc2 100644 --- a/configs/nucleo-144/src/stm32_userleds.c +++ b/configs/nucleo-144/src/stm32_userleds.c @@ -3,6 +3,7 @@ * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt + * Author: Mark Olsson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,6 +43,8 @@ #include #include +#include + #include "stm32_gpio.h" #include "nucleo-144.h" @@ -63,6 +66,16 @@ # define ledvdbg(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[3] = +{ + GPIO_LD1, GPIO_LD2, GPIO_LD3 +}; + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -80,7 +93,13 @@ void board_userled_initialize(void) { - stm32_configgpio(GPIO_LD1); + int i; + + /* Configure LED1-3 GPIOs for output */ + for (i = 0; i < 3; i++) + { + stm32_configgpio(g_ledcfg[i]); + } } /**************************************************************************** @@ -95,10 +114,10 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == BOARD_STATUS_LED) - { - stm32_gpiowrite(GPIO_LD1, !ledon); - } + if ((unsigned)led < 3) + { + stm32_gpiowrite(g_ledcfg[led], ledon); + } } /**************************************************************************** @@ -114,7 +133,12 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - stm32_gpiowrite(GPIO_LD1, (ledset & BOARD_STATUS_LED_BIT) != 0); + int i; + /* Configure LED1-3 GPIOs for output */ + for (i = 0; i < 3; i++) + { + stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0); + } } #endif /* !CONFIG_ARCH_LEDS */