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
This commit is contained in:
Mark Olsson 2016-05-20 13:45:16 +02:00
parent e35e986ddf
commit 02e43ab1b3
4 changed files with 58 additions and 30 deletions

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -46,10 +47,12 @@
# include <stdint.h>
#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

View File

@ -2,7 +2,8 @@
* configs/nucleo-144/src/nucleo-144.h
*
* 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
* 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 */

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -38,9 +39,10 @@
****************************************************************************/
#include <nuttx/config.h>
#include <syslog.h>
#include "stm32_ccm.h"
#include "nucleo-144.h"
#include <nuttx/leds/userled.h>
/****************************************************************************
* 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;
}

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -42,6 +43,8 @@
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#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 */