Skip to content
Snippets Groups Projects
Commit 02e43ab1 authored by Mark Olsson's avatar Mark Olsson
Browse files

Adds support for the 3 user LEDs on the Nucleo-144 board family

Extra: procfs support doesn't work, so the code for this has been removed from AppInitialize
parent e35e986d
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -46,10 +47,12 @@ ...@@ -46,10 +47,12 @@
# include <stdint.h> # include <stdint.h>
#endif #endif
#ifdef __KERNEL__
#include "stm32_rcc.h" #include "stm32_rcc.h"
#ifdef CONFIG_STM32F7_SDMMC1 #ifdef CONFIG_STM32F7_SDMMC1
# include "stm32_sdmmc.h" # include "stm32_sdmmc.h"
#endif #endif
#endif
/************************************************************************************ /************************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
...@@ -226,13 +229,19 @@ ...@@ -226,13 +229,19 @@
/* LED index values for use with board_userled() */ /* LED index values for use with board_userled() */
#define BOARD_LED1 0 #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_LD1 BOARD_LED1
#define BOARD_LD2 BOARD_LED2
#define BOARD_LD3 BOARD_LED3
/* LED bits for use with board_userled_all() */ /* LED bits for use with board_userled_all() */
#define BOARD_LED1_BIT (1 << BOARD_LED1) #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 /* 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 * include/board.h and src/stm32_leds.c. The LEDs are used to encode OS-related
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
* configs/nucleo-144/src/nucleo-144.h * configs/nucleo-144/src/nucleo-144.h
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -67,7 +68,13 @@ ...@@ -67,7 +68,13 @@
*/ */
#define GPIO_LD1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | \ #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 /* 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. * button is depressed. Note that the EXTI interrupt is configured.
...@@ -97,4 +104,3 @@ void weak_function stm32_spidev_initialize(void); ...@@ -97,4 +104,3 @@ void weak_function stm32_spidev_initialize(void);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_NUCLEO_144_SRC_NUCLEO_144_H */ #endif /* __CONFIGS_NUCLEO_144_SRC_NUCLEO_144_H */
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -38,9 +39,10 @@ ...@@ -38,9 +39,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <syslog.h>
#include "stm32_ccm.h"
#include "nucleo-144.h" #include "nucleo-144.h"
#include <nuttx/leds/userled.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
...@@ -62,26 +64,13 @@ ...@@ -62,26 +64,13 @@
int board_app_initialize(void) int board_app_initialize(void)
{ {
#ifdef CONFIG_FS_PROCFS
int ret; int ret;
#ifdef CONFIG_STM32_CCM_PROCFS /* Register the LED driver */
/* Register the CCM procfs entry. This must be done before the procfs is ret = userled_lower_initialize(LED_DRIVER_PATH);
* mounted.
*/
(void)ccm_procfs_register();
#endif
/* Mount the procfs file system */
ret = mount(NULL, SAMV71_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0) if (ret < 0)
{ {
SYSLOG("ERROR: Failed to mount procfs at %s: %d\n", syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
SAMV71_PROCFS_MOUNTPOINT, ret); }
} return 1;
#endif
return OK;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -42,6 +43,8 @@ ...@@ -42,6 +43,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <debug.h> #include <debug.h>
#include <arch/board/board.h>
#include "stm32_gpio.h" #include "stm32_gpio.h"
#include "nucleo-144.h" #include "nucleo-144.h"
...@@ -63,6 +66,16 @@ ...@@ -63,6 +66,16 @@
# define ledvdbg(x...) # define ledvdbg(x...)
#endif #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 * Public Functions
****************************************************************************/ ****************************************************************************/
...@@ -80,7 +93,13 @@ ...@@ -80,7 +93,13 @@
void board_userled_initialize(void) 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) ...@@ -95,10 +114,10 @@ void board_userled_initialize(void)
void board_userled(int led, bool ledon) void board_userled(int led, bool ledon)
{ {
if (led == BOARD_STATUS_LED) if ((unsigned)led < 3)
{ {
stm32_gpiowrite(GPIO_LD1, !ledon); stm32_gpiowrite(g_ledcfg[led], ledon);
} }
} }
/**************************************************************************** /****************************************************************************
...@@ -114,7 +133,12 @@ void board_userled(int led, bool ledon) ...@@ -114,7 +133,12 @@ void board_userled(int led, bool ledon)
void board_userled_all(uint8_t ledset) 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 */ #endif /* !CONFIG_ARCH_LEDS */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment