boards/arm/stm32/stm32ldiscovery: modernize board init little bit, userleds and buttons like for other boards
Also fix typo in Kconfig Update some obsolete comments nxstyle changes Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
parent
afc8eadf5a
commit
e9bd306265
@ -3,7 +3,7 @@
|
|||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
#
|
#
|
||||||
|
|
||||||
if ARCH_BOARD_STM32FL_DISCOVERY
|
if ARCH_BOARD_STM32L_DISCOVERY
|
||||||
|
|
||||||
config STM32LDISCO_QETIMER
|
config STM32LDISCO_QETIMER
|
||||||
int "Timer to use with QE encoder"
|
int "Timer to use with QE encoder"
|
||||||
|
@ -199,8 +199,8 @@ LEDs
|
|||||||
|
|
||||||
These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||||
defined. In that case, the usage by the board port is defined in
|
defined. In that case, the usage by the board port is defined in
|
||||||
include/board.h and src/up_leds.c. The LEDs are used to encode OS-related
|
include/board.h and src/stm32_autoleds.c. The LEDs are used to encode
|
||||||
events as follows:
|
OS-related events as follows:
|
||||||
|
|
||||||
SYMBOL Meaning LED state
|
SYMBOL Meaning LED state
|
||||||
LED3 LED4
|
LED3 LED4
|
||||||
|
@ -52,19 +52,22 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Clocking *************************************************************************/
|
/* Clocking *****************************************************************/
|
||||||
/* Four different clock sources can be used to drive the system clock (SYSCLK):
|
|
||||||
|
/* Four different clock sources can be used to drive the system clock
|
||||||
|
* (SYSCLK):
|
||||||
*
|
*
|
||||||
* - HSI high-speed internal oscillator clock
|
* - HSI high-speed internal oscillator clock
|
||||||
* Generated from an internal 16 MHz RC oscillator
|
* Generated from an internal 16 MHz RC oscillator
|
||||||
* - HSE high-speed external oscillator clock
|
* - HSE high-speed external oscillator clock
|
||||||
* Normally driven by an external crystal (X3). However, this crystal is not fitted
|
* Normally driven by an external crystal (X3). However, this crystal is
|
||||||
* on the STM32L-Discovery board.
|
* not fitted on the STM32L-Discovery board.
|
||||||
* - PLL clock
|
* - PLL clock
|
||||||
* - MSI multispeed internal oscillator clock
|
* - MSI multispeed internal oscillator clock
|
||||||
* The MSI clock signal is generated from an internal RC oscillator. Seven frequency
|
* The MSI clock signal is generated from an internal RC oscillator.
|
||||||
* ranges are available: 65.536 kHz, 131.072 kHz, 262.144 kHz, 524.288 kHz, 1.048 MHz,
|
* Seven frequency ranges are available: 65.536 kHz, 131.072 kHz,
|
||||||
* 2.097 MHz (default value) and 4.194 MHz.
|
* 262.144 kHz, 524.288 kHz, 1.048 MHz, 2.097 MHz (default value) and
|
||||||
|
* 4.194 MHz.
|
||||||
*
|
*
|
||||||
* The devices have the following two secondary clock sources
|
* The devices have the following two secondary clock sources
|
||||||
* - LSI low-speed internal RC clock
|
* - LSI low-speed internal RC clock
|
||||||
@ -95,13 +98,15 @@
|
|||||||
* MHz frequency. This is required to provide a 48 MHz clock to the USB or
|
* MHz frequency. This is required to provide a 48 MHz clock to the USB or
|
||||||
* SDIO (SDIOCLK or USBCLK = PLLVCO/2).
|
* SDIO (SDIOCLK or USBCLK = PLLVCO/2).
|
||||||
* SYSCLK
|
* SYSCLK
|
||||||
* The system clock is derived from the PLL VCO divided by the output division factor.
|
* The system clock is derived from the PLL VCO divided by the output
|
||||||
|
* division factor.
|
||||||
* Limitations:
|
* Limitations:
|
||||||
* 96 MHz as PLLVCO when the product is in range 1 (1.8V),
|
* 96 MHz as PLLVCO when the product is in range 1 (1.8V),
|
||||||
* 48 MHz as PLLVCO when the product is in range 2 (1.5V),
|
* 48 MHz as PLLVCO when the product is in range 2 (1.5V),
|
||||||
* 24 MHz when the product is in range 3 (1.2V).
|
* 24 MHz when the product is in range 3 (1.2V).
|
||||||
* Output division to avoid exceeding 32 MHz as SYSCLK.
|
* Output division to avoid exceeding 32 MHz as SYSCLK.
|
||||||
* The minimum input clock frequency for PLL is 2 MHz (when using HSE as PLL source).
|
* The minimum input clock frequency for PLL is 2 MHz (when using HSE as
|
||||||
|
* PLL source).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define STM32_CFGR_PLLSRC 0 /* Source is 16MHz HSI */
|
#define STM32_CFGR_PLLSRC 0 /* Source is 16MHz HSI */
|
||||||
@ -115,8 +120,8 @@
|
|||||||
# define STM32_PLL_FREQUENCY (4*STM32_HSI_FREQUENCY) /* PLL VCO Frequency is 64MHz */
|
# define STM32_PLL_FREQUENCY (4*STM32_HSI_FREQUENCY) /* PLL VCO Frequency is 64MHz */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use the PLL and set the SYSCLK source to be the divided down PLL VCO output
|
/* Use the PLL and set the SYSCLK source to be the divided down PLL VCO
|
||||||
* frequency (STM32_PLL_FREQUENCY divided by the PLLDIV value).
|
* output frequency (STM32_PLL_FREQUENCY divided by the PLLDIV value).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define STM32_SYSCLK_SW RCC_CFGR_SW_PLL /* Use the PLL as the SYSCLK */
|
#define STM32_SYSCLK_SW RCC_CFGR_SW_PLL /* Use the PLL as the SYSCLK */
|
||||||
@ -159,23 +164,25 @@
|
|||||||
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
|
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
|
||||||
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
|
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
|
||||||
|
|
||||||
/* LED definitions ******************************************************************/
|
/* LED definitions **********************************************************/
|
||||||
|
|
||||||
/* The STM32L-Discovery board has four LEDs. Two of these are controlled by
|
/* The STM32L-Discovery board has four LEDs. Two of these are controlled by
|
||||||
* logic on the board and are not available for software control:
|
* logic on the board and are not available for software control:
|
||||||
*
|
*
|
||||||
* LD1 COM: LD2 default status is red. LD2 turns to green to indicate that
|
* LD1 COM: LD2 default status is red. LD2 turns to green to indicate
|
||||||
* communications are in progress between the PC and the ST-LINK/V2.
|
* that communications are in progress between the PC and the
|
||||||
|
* ST-LINK/V2.
|
||||||
* LD2 PWR: Red LED indicates that the board is powered.
|
* LD2 PWR: Red LED indicates that the board is powered.
|
||||||
*
|
*
|
||||||
* And two LEDs can be controlled by software:
|
* And two LEDs can be controlled by software:
|
||||||
*
|
*
|
||||||
* User LD3: Green LED is a user LED connected to the I/O PB7 of the STM32L152
|
* User LD3: Green LED is a user LED connected to the I/O PB7 of the
|
||||||
* MCU.
|
* STM32L152 MCU.
|
||||||
* User LD4: Blue LED is a user LED connected to the I/O PB6 of the STM32L152
|
* User LD4: Blue LED is a user LED connected to the I/O PB6 of the
|
||||||
* MCU.
|
* STM32L152 MCU.
|
||||||
*
|
*
|
||||||
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
|
||||||
* way. The following definitions are used to access individual LEDs.
|
* any way. The following definitions are used to access individual LEDs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* LED index values for use with board_userled() */
|
/* LED index values for use with board_userled() */
|
||||||
@ -189,8 +196,9 @@
|
|||||||
#define BOARD_LED1_BIT (1 << BOARD_LED1)
|
#define BOARD_LED1_BIT (1 << BOARD_LED1)
|
||||||
#define BOARD_LED2_BIT (1 << BOARD_LED2)
|
#define BOARD_LED2_BIT (1 << BOARD_LED2)
|
||||||
|
|
||||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 8 LEDs on board the
|
/* If CONFIG_ARCH_LEDS is defined, then NuttX will control the 2 LEDs on
|
||||||
* STM32L-Discovery. The following definitions describe how NuttX controls the LEDs:
|
* board the STM32L-Discovery. The following definitions describe how NuttX
|
||||||
|
* controls the LEDs:
|
||||||
*
|
*
|
||||||
* SYMBOL Meaning LED state
|
* SYMBOL Meaning LED state
|
||||||
* LED1 LED2
|
* LED1 LED2
|
||||||
@ -215,12 +223,14 @@
|
|||||||
#define LED_ASSERTION 2
|
#define LED_ASSERTION 2
|
||||||
#define LED_PANIC 3
|
#define LED_PANIC 3
|
||||||
|
|
||||||
/* Button definitions ***************************************************************/
|
/* Button definitions *******************************************************/
|
||||||
/* The STM32L-Discovery supports two buttons; only one button is controllable by
|
|
||||||
* software:
|
/* The STM32L-Discovery supports two buttons; only one button is controllable
|
||||||
|
* by software:
|
||||||
*
|
*
|
||||||
* B1 USER: user and wake-up button connected to the I/O PA0 of the STM32L152RBT6.
|
* B1 USER: user and wake-up button connected to the I/O PA0 of the
|
||||||
* B2 RESET: pushbutton connected to NRST is used to RESET the STM32L152RBT6.
|
* STM32L152.
|
||||||
|
* B2 RESET: pushbutton connected to NRST is used to RESET the STM32L152.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BUTTON_USER 0
|
#define BUTTON_USER 0
|
||||||
@ -228,11 +238,12 @@
|
|||||||
|
|
||||||
#define BUTTON_USER_BIT (1 << BUTTON_USER)
|
#define BUTTON_USER_BIT (1 << BUTTON_USER)
|
||||||
|
|
||||||
/* Alternate Pin Functions **********************************************************/
|
/* Alternate Pin Functions **************************************************/
|
||||||
/* The STM32L-Discovery has no on-board RS-232 driver. Further, there are no USART
|
|
||||||
* pins that do not conflict with the on board resources, in particular, the LCD:
|
/* The STM32L-Discovery has no on-board RS-232 driver. Further, there
|
||||||
* Most USART pins are available if the LCD is enabled; USART2 may be used if either
|
* are no USART pins that do not conflict with the on board resources, in
|
||||||
* the LCD or the on-board LEDs are disabled.
|
* particular, the LCD. Most USART pins are available if the LCD is enabled;
|
||||||
|
* USART2 may be used if either the LCD or the on-board LEDs are disabled.
|
||||||
*
|
*
|
||||||
* PA9 USART1_TX LCD glass COM1 P2, pin 22
|
* PA9 USART1_TX LCD glass COM1 P2, pin 22
|
||||||
* PA10 USART1_RX LCD glass COM2 P2, pin 21
|
* PA10 USART1_RX LCD glass COM2 P2, pin 21
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
@ -77,7 +75,11 @@
|
|||||||
|
|
||||||
int board_app_initialize(uintptr_t arg)
|
int board_app_initialize(uintptr_t arg)
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_BOARD_LATE_INITIALIZE
|
||||||
/* Perform board initialization here */
|
/* Perform board initialization here */
|
||||||
|
|
||||||
return stm32_bringup();
|
return stm32_bringup();
|
||||||
|
#else
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 2 LEDs on
|
|
||||||
|
/* If CONFIG_ARCH_LEDS is defined, then NuttX will control the 2 LEDs on
|
||||||
* board the STM32L-Discovery. The following definitions describe how NuttX
|
* board the STM32L-Discovery. The following definitions describe how NuttX
|
||||||
* controls the LEDs:
|
* controls the LEDs:
|
||||||
*
|
*
|
||||||
|
@ -47,14 +47,6 @@
|
|||||||
#include "arm_arch.h"
|
#include "arm_arch.h"
|
||||||
#include "stm32ldiscovery.h"
|
#include "stm32ldiscovery.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -63,16 +55,17 @@
|
|||||||
* Name: stm32_boardinitialize
|
* Name: stm32_boardinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* All STM32 architectures must provide the following entry point. This entry point
|
* All STM32 architectures must provide the following entry point.
|
||||||
* is called early in the initialization -- after all memory has been configured
|
* This entry point is called early in the initialization -- after all
|
||||||
* and mapped but before any devices have been initialized.
|
* memory has been configured and mapped but before any devices have been
|
||||||
|
* initialized.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void stm32_boardinitialize(void)
|
void stm32_boardinitialize(void)
|
||||||
{
|
{
|
||||||
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
|
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
|
||||||
* stm32_spidev_initialize() has been brought into the link.
|
* function stm32_spidev_initialize() has been brought into the link.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
||||||
@ -93,22 +86,23 @@ void stm32_boardinitialize(void)
|
|||||||
* Name: board_late_initialize
|
* Name: board_late_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional initialization call
|
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
|
||||||
* will be performed in the boot-up sequence to a function called
|
* initialization call will be performed in the boot-up sequence to a
|
||||||
* board_late_initialize(). board_late_initialize() will be called immediately after
|
* function called board_late_initialize(). board_late_initialize() will
|
||||||
* up_initialize() is called and just before the initial application is started.
|
* be called immediately after up_initialize() is called and just before
|
||||||
* This additional initialization phase may be used, for example, to initialize
|
* the initial application is started. This additional initialization
|
||||||
* board-specific device drivers.
|
* phase may be used, for example, to initialize board-specific device
|
||||||
|
* drivers.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_LATE_INITIALIZE
|
#ifdef CONFIG_BOARD_LATE_INITIALIZE
|
||||||
void board_late_initialize(void)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_LIB_BOARDCTL
|
/* Perform board initialization here instead of from the
|
||||||
/* Perform board initialization here instead of from the board_app_initialize(). */
|
* board_app_initialize().
|
||||||
|
*/
|
||||||
|
|
||||||
stm32_bringup();
|
stm32_bringup();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,17 +39,20 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <nuttx/input/buttons.h>
|
#include <nuttx/input/buttons.h>
|
||||||
|
#include <nuttx/leds/userled.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32ldiscovery.h"
|
#include "stm32ldiscovery.h"
|
||||||
|
|
||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
#include "board_qencoder.h"
|
# include "board_qencoder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -74,7 +77,34 @@ int stm32_bringup(void)
|
|||||||
{
|
{
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
|
#ifdef CONFIG_FS_PROCFS
|
||||||
|
/* Mount the procfs file system */
|
||||||
|
|
||||||
|
ret = mount(NULL, "/proc", "procfs", 0, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_USERLED) && !defined(CONFIG_ARCH_LEDS)
|
||||||
|
#ifdef CONFIG_USERLED_LOWER
|
||||||
|
/* Register the LED driver */
|
||||||
|
|
||||||
|
ret = userled_lower_initialize("/dev/userleds");
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Enable USER LED support for some other purpose */
|
||||||
|
|
||||||
|
board_userled_initialize();
|
||||||
|
#endif /* CONFIG_USERLED_LOWER */
|
||||||
|
#endif /* CONFIG_USERLED && !CONFIG_ARCH_LEDS */
|
||||||
|
|
||||||
#ifdef CONFIG_BUTTONS
|
#ifdef CONFIG_BUTTONS
|
||||||
|
#ifdef CONFIG_BUTTONS_LOWER
|
||||||
/* Register the BUTTON driver */
|
/* Register the BUTTON driver */
|
||||||
|
|
||||||
ret = btn_lower_initialize("/dev/buttons");
|
ret = btn_lower_initialize("/dev/buttons");
|
||||||
@ -82,7 +112,12 @@ int stm32_bringup(void)
|
|||||||
{
|
{
|
||||||
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
|
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
|
/* Enable BUTTON support for some other purpose */
|
||||||
|
|
||||||
|
board_button_initialize();
|
||||||
|
#endif /* CONFIG_BUTTONS_LOWER */
|
||||||
|
#endif /* CONFIG_BUTTONS */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_LCD
|
#ifdef CONFIG_STM32_LCD
|
||||||
/* Initialize the SLCD and register the SLCD device as /dev/slcd0 */
|
/* Initialize the SLCD and register the SLCD device as /dev/slcd0 */
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H
|
#ifndef __BOARDS_ARM_STM32_STM32LDISCOVERY_SRC_STM32LDISCOVERY_H
|
||||||
#define __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H
|
#define __BOARDS_ARM_STM32_STM32LDISCOVERY_SRC_STM32LDISCOVERY_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@ -289,4 +289,4 @@ int stm32_pwm_setup(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */
|
#endif /* __BOARDS_ARM_STM32_STM32LDISCOVERY_SRC_STM32LDISCOVERY_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user