Led and buttons examples
Description: Test LED examples on freedom-k66f, nucleo-f401re and blackpill-f411ce boards. Update linker file for bluepill-f103c6.
This commit is contained in:
parent
517d55a2ce
commit
447f03cfd0
@ -44,6 +44,11 @@
|
|||||||
#define HAVE_SPI 1
|
#define HAVE_SPI 1
|
||||||
#define HAVE_USBDEV 1
|
#define HAVE_USBDEV 1
|
||||||
|
|
||||||
|
#undef HAVE_LEDS
|
||||||
|
#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
|
||||||
|
# define HAVE_LEDS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_KINETIS_RTC)
|
#if defined(CONFIG_KINETIS_RTC)
|
||||||
#define HAVE_RTC_DRIVER 1
|
#define HAVE_RTC_DRIVER 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,8 +32,21 @@
|
|||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_USERLED
|
||||||
|
# include <nuttx/leds/userled.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_LEDS_DEVPATH
|
||||||
|
# define LED_DRIVER_PATH CONFIG_EXAMPLES_LEDS_DEVPATH
|
||||||
|
#else
|
||||||
|
# define LED_DRIVER_PATH "/dev/userleds"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
#include <nuttx/input/buttons.h>
|
|
||||||
|
#ifdef CONFIG_INPUT_BUTTONS
|
||||||
|
# include <nuttx/input/buttons.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "kinetis_spi.h"
|
#include "kinetis_spi.h"
|
||||||
#include "freedom-k66f.h"
|
#include "freedom-k66f.h"
|
||||||
@ -59,6 +72,17 @@ int k66_bringup(void)
|
|||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifdef HAVE_LEDS
|
||||||
|
/* Register the LED driver */
|
||||||
|
|
||||||
|
ret = userled_lower_initialize(LED_DRIVER_PATH);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PROC
|
#ifdef HAVE_PROC
|
||||||
/* Mount the proc filesystem */
|
/* Mount the proc filesystem */
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
# include <nuttx/leds/userled.h>
|
# include <nuttx/leds/userled.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_INPUT_BUTTONS
|
||||||
|
# include <nuttx/input/buttons.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nucleo-f4x1re.h"
|
#include "nucleo-f4x1re.h"
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
@ -93,6 +97,16 @@ int stm32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_INPUT_BUTTONS
|
||||||
|
/* Register the BUTTON driver */
|
||||||
|
|
||||||
|
ret = btn_lower_initialize("/dev/buttons");
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Configure SPI-based devices */
|
/* Configure SPI-based devices */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_SPI1
|
#ifdef CONFIG_STM32_SPI1
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
flash (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
|
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,10 @@ if(CONFIG_ARCH_LEDS)
|
|||||||
list(APPEND SRCS stm32_autoleds.c)
|
list(APPEND SRCS stm32_autoleds.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_USERLED)
|
||||||
|
list(APPEND SRCS stm32_userleds.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SPI)
|
if(CONFIG_SPI)
|
||||||
list(APPEND SRCS stm32_spi.c)
|
list(APPEND SRCS stm32_spi.c)
|
||||||
endif()
|
endif()
|
||||||
|
@ -30,6 +30,10 @@ ifeq ($(CONFIG_ARCH_LEDS),y)
|
|||||||
CSRCS += stm32_autoleds.c
|
CSRCS += stm32_autoleds.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USERLED),y)
|
||||||
|
CSRCS += stm32_userleds.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADC_HX711),y)
|
ifeq ($(CONFIG_ADC_HX711),y)
|
||||||
CSRCS += stm32_hx711.c
|
CSRCS += stm32_hx711.c
|
||||||
endif
|
endif
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_USERLED
|
||||||
|
# include <nuttx/leds/userled.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_OTGFS
|
#ifdef CONFIG_STM32_OTGFS
|
||||||
# include "stm32_usbhost.h"
|
# include "stm32_usbhost.h"
|
||||||
#endif
|
#endif
|
||||||
@ -84,6 +88,16 @@ int stm32_bringup(void)
|
|||||||
{
|
{
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
#ifdef CONFIG_STM32F411MINIMUM_GPIO
|
#ifdef CONFIG_STM32F411MINIMUM_GPIO
|
||||||
ret = stm32_gpio_initialize();
|
ret = stm32_gpio_initialize();
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
100
boards/arm/stm32/stm32f411-minimum/src/stm32_userleds.c
Normal file
100
boards/arm/stm32/stm32f411-minimum/src/stm32_userleds.c
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32/stm32f411-minimum/src/stm32_userleds.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 <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "stm32.h"
|
||||||
|
#include "stm32f411-minimum.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This array maps an LED number to GPIO pin configuration */
|
||||||
|
|
||||||
|
static const uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||||
|
{
|
||||||
|
GPIO_LED1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_userled_initialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint32_t board_userled_initialize(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Configure LED GPIOs for output */
|
||||||
|
|
||||||
|
for (i = 0; i < BOARD_NLEDS; i++)
|
||||||
|
{
|
||||||
|
stm32_configgpio(g_ledcfg[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return BOARD_NLEDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_userled
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_userled(int led, bool ledon)
|
||||||
|
{
|
||||||
|
if ((unsigned)led < BOARD_NLEDS)
|
||||||
|
{
|
||||||
|
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_userled_all
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_userled_all(uint32_t ledset)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Configure LED GPIOs for output */
|
||||||
|
|
||||||
|
for (i = 0; i < BOARD_NLEDS; i++)
|
||||||
|
{
|
||||||
|
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !CONFIG_ARCH_LEDS */
|
Loading…
x
Reference in New Issue
Block a user