Changes from review of last PR

This commit is contained in:
Gregory Nutt
2016-03-25 15:01:16 -06:00
parent b089e98a83
commit 9ceba8cd8f
17 changed files with 713 additions and 905 deletions
+5
View File
@@ -648,6 +648,11 @@ configs/stm32f746g-disco
MCU. The STM32F746NGH6 is a 216MHz Cortex-M7 operation with 1024Kb Flash MCU. The STM32F746NGH6 is a 216MHz Cortex-M7 operation with 1024Kb Flash
memory and 300Kb SRAM. memory and 300Kb SRAM.
configs/stm32l476vg-disco
STMicro STM32L476VG_DISCO development board featuring the STM32L476VG
MCU. The STM32L476VG is a Cortex-M4 optimised for low-power operation
at up to 80MHz operation with 1024Kb Flash memory and 96+32Kb SRAM.
configs/stm32ldiscovery configs/stm32ldiscovery
STMicro STM32L-Discovery board based on the STMicro STM32L152RB MCU. STMicro STM32L-Discovery board based on the STMicro STM32L152RB MCU.
+15 -22
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32l476vg-disco/include/board.h * configs/stm32l476vg-disco/include/board.h
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: dev@ziggurat29.com * Author: dev@ziggurat29.com
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,6 @@
#include <arch/board/stm32l476vg-disco-clocking.h> #include <arch/board/stm32l476vg-disco-clocking.h>
/* DMA Channel/Stream Selections ****************************************************/ /* DMA Channel/Stream Selections ****************************************************/
/* Stream selections are arbitrary for now but might become important in the future /* Stream selections are arbitrary for now but might become important in the future
* is we set aside more DMA channels/streams. * is we set aside more DMA channels/streams.
@@ -154,8 +153,7 @@
#endif #endif
/* /* SPI2 is used for several peripherals on the Discovery board, including
* SPI2 is used for several peripherals on the Discovery board, including
* L3GD20 - 3 axis Gyroscope * L3GD20 - 3 axis Gyroscope
* LSM303CTR - eCompass, comprising an accelerometer and magnetometer * LSM303CTR - eCompass, comprising an accelerometer and magnetometer
*/ */
@@ -164,9 +162,8 @@
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_3 #define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_3
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_3 #define GPIO_SPI2_SCK GPIO_SPI2_SCK_3
/* /* PD7; gyroscope CS */
* PD7; gyroscope CS
*/
#define GPIO_SPI_CS_GYRO_OFF \ #define GPIO_SPI_CS_GYRO_OFF \
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
GPIO_PORTD | GPIO_PIN7) GPIO_PORTD | GPIO_PIN7)
@@ -174,9 +171,8 @@
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN7) GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN7)
/* /* PE0; accelerometer CS */
* PE0; accelerometer CS
*/
#define GPIO_SPI_CS_ACCEL_OFF \ #define GPIO_SPI_CS_ACCEL_OFF \
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
GPIO_PORTE | GPIO_PIN0) GPIO_PORTE | GPIO_PIN0)
@@ -184,9 +180,8 @@
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN0) GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN0)
/* /* PC0; magnetometer CS */
* PC0; magnetometer CS
*/
#define GPIO_SPI_CS_MAGNETO_OFF \ #define GPIO_SPI_CS_MAGNETO_OFF \
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
GPIO_PORTC | GPIO_PIN0) GPIO_PORTC | GPIO_PIN0)
@@ -194,15 +189,13 @@
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_SET | GPIO_PORTC | GPIO_PIN0) GPIO_OUTPUT_SET | GPIO_PORTC | GPIO_PIN0)
/* XXX these will need to be set up when these get implemented:
/* * PD2 gyro INT1
XXX these will need to be set up when these get implemented: * PB8 gyro INT2/DRDY
PD2 gyro INT1 *
PB8 gyro INT2/DRDY * PE1 accel INT
* PC2 magneto DRDY
PE1 accel INT * PC1 magneto INT
PC2 magneto DRDY
PC1 magneto INT
*/ */
/* LEDs /* LEDs
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32l476vg-disco/include/stm32l476vg-disco-clocking.h * configs/stm32l476vg-disco/include/stm32l476vg-disco-clocking.h
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: dev@ziggurat29.com * Author: dev@ziggurat29.com
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -68,12 +68,12 @@
#define STM32L4_LSE_FREQUENCY 32768 #define STM32L4_LSE_FREQUENCY 32768
/* XXX review the STM32L4_BOARD_USEHSI usage, it has too much influence in /* XXX review the STM32L4_BOARD_USEHSI usage, it has too much influence in
stm32l4x6xx_rcc.c. I suspect it is fine for it to turn on and off that * stm32l4x6xx_rcc.c. I suspect it is fine for it to turn on and off that
ocillator, but really that's all it should do (e.g. it also controls * ocillator, but really that's all it should do (e.g. it also controls
input of teh PLLs. Also, it should be fine/desireable to support things * input of teh PLLs. Also, it should be fine/desireable to support things
like turning on both HSI and MSI, because they plausibly can both be * like turning on both HSI and MSI, because they plausibly can both be
used at the same time; currently those choices HSE/HSI16/MSI are * used at the same time; currently those choices HSE/HSI16/MSI are
mutually exclusive. * mutually exclusive.
*/ */
#define STM32L4_BOARD_USEHSI 1 #define STM32L4_BOARD_USEHSI 1
@@ -84,11 +84,11 @@
#define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1) #define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1)
/* 'main' PLL config; we use this to generate our system clock via the R /* 'main' PLL config; we use this to generate our system clock via the R
output. We set it up as * output. We set it up as 16 MHz / 1 * 10 / 2 = 80 MHz
16 MHz / 1 * 10 / 2 = 80 MHz *
XXX NOTE: currently the main PLL is implicitly turned on and is implicitly * XXX NOTE: currently the main PLL is implicitly turned on and is implicitly
the system clock; this should be configurable since not all applications may * the system clock; this should be configurable since not all applications may
want things done this way. * want things done this way.
*/ */
#define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(10) #define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(10)
@@ -100,14 +100,15 @@
#define STM32L4_PLLCFG_PLLR_ENABLED #define STM32L4_PLLCFG_PLLR_ENABLED
/* 'SAIPLL1' is used to generate the 48 MHz clock, since we can't /* 'SAIPLL1' is used to generate the 48 MHz clock, since we can't
do that with the main PLL's N value. We set N = 13, and enable * do that with the main PLL's N value. We set N = 13, and enable
the Q output (ultimately for CLK48) with /4. So, * the Q output (ultimately for CLK48) with /4. So,
16 MHz / 1 * 12 / 4 = 48 MHz * 16 MHz / 1 * 12 / 4 = 48 MHz
XXX NOTE: currently the SAIPLL /must/ be explicitly selected in the *
menuconfig, or else all this is a moot point, and the various 48 MHz * XXX NOTE: currently the SAIPLL /must/ be explicitly selected in the
peripherals will not work (RNG at present). I would suggest removing * menuconfig, or else all this is a moot point, and the various 48 MHz
that option from Kconfig altogether, and simply making it an option * peripherals will not work (RNG at present). I would suggest removing
that is selected via a #define here, like all these other params. * that option from Kconfig altogether, and simply making it an option
* that is selected via a #define here, like all these other params.
*/ */
#define STM32L4_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(12) #define STM32L4_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(12)
@@ -171,7 +172,6 @@
*/ */
/* REVISIT : this can be configured */ /* REVISIT : this can be configured */
/************************************************************************************ /************************************************************************************
* Public Data * Public Data
************************************************************************************/ ************************************************************************************/
+1 -1
View File
@@ -1,7 +1,7 @@
############################################################################ ############################################################################
# configs/stm32l476vg-disco/nsh/Make.defs # configs/stm32l476vg-disco/nsh/Make.defs
# #
# Copyright (C) 2014 Gregory Nutt. All rights reserved. # Copyright (C) 2016 Gregory Nutt. All rights reserved.
# Author: dev@ziggurat29.com # Author: dev@ziggurat29.com
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# configs/stm32l476vg-disco/nsh/setenv.sh # configs/stm32l476vg-disco/nsh/setenv.sh
# #
# Copyright (C) 2014 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>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/scripts/l476rg.ld * configs/stm32l476vg-disco/scripts/l476rg.ld
* *
* Copyright (C) 2014 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>
* Sebastien Lorquet <sebastien@lorquet.fr> * Sebastien Lorquet <sebastien@lorquet.fr>
* dev@ziggurat29.com * dev@ziggurat29.com
+1 -5
View File
@@ -46,10 +46,6 @@ ifeq ($(CONFIG_STM32_OTGFS),y)
CSRCS += stm32_usb.c CSRCS += stm32_usb.c
endif endif
ifeq ($(CONFIG_HAVE_CXX),y)
CSRCS += stm32_cxxinitialize.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y) ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += stm32_autoleds.c CSRCS += stm32_autoleds.c
else else
@@ -68,7 +64,7 @@ endif
endif endif
ifeq ($(CONFIG_NSH_LIBRARY),y) ifeq ($(CONFIG_NSH_LIBRARY),y)
CSRCS += stm32_nsh.c CSRCS += stm32_appinit.c
endif endif
include $(TOPDIR)/configs/Board.mk include $(TOPDIR)/configs/Board.mk
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/src/stm32_nsh.c * configs/stm32l476vg-disco/src/stm32_appinit.c
* *
* Copyright (C) 2014 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>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -53,18 +53,6 @@
#include "stm32l476vg-disco.h" #include "stm32l476vg-disco.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -79,7 +67,6 @@
int board_app_initialize(void) int board_app_initialize(void)
{ {
/* Configure CPU load estimation */ /* Configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION #ifdef CONFIG_SCHED_INSTRUMENTATION
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/src/stm32_autoleds.c * configs/stm32l476vg-disco/src/stm32_autoleds.c
* *
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: dev@ziggurat29.com * Author: dev@ziggurat29.com
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -70,14 +70,6 @@
# define ledvdbg(x...) # define ledvdbg(x...)
#endif #endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -89,6 +81,7 @@
void board_autoled_initialize(void) void board_autoled_initialize(void)
{ {
/* Configure LD4,5 GPIO for output */ /* Configure LD4,5 GPIO for output */
stm32l4_configgpio(GPIO_LED_RED); stm32l4_configgpio(GPIO_LED_RED);
stm32l4_configgpio(GPIO_LED_GRN); stm32l4_configgpio(GPIO_LED_GRN);
} }
@@ -106,6 +99,7 @@ void board_autoled_on(int led)
* Since the LEDs were initially all OFF and since this state only * Since the LEDs were initially all OFF and since this state only
* occurs one time, nothing need be done. * occurs one time, nothing need be done.
*/ */
default: default:
case LED_STARTED: case LED_STARTED:
case LED_HEAPALLOCATE: case LED_HEAPALLOCATE:
@@ -116,6 +110,7 @@ void board_autoled_on(int led)
* *
* This case will also occur only once. * This case will also occur only once.
*/ */
case LED_STACKCREATED: case LED_STACKCREATED:
break; break;
@@ -123,6 +118,7 @@ void board_autoled_on(int led)
* *
* This case will occur many times. * This case will occur many times.
*/ */
case LED_INIRQ: case LED_INIRQ:
case LED_SIGNAL: case LED_SIGNAL:
case LED_ASSERTION: case LED_ASSERTION:
@@ -133,6 +129,7 @@ void board_autoled_on(int led)
* *
* This case will also occur many times. * This case will also occur many times.
*/ */
case LED_PANIC: case LED_PANIC:
stm32l4_gpiowrite(GPIO_LED_GRN, false); stm32l4_gpiowrite(GPIO_LED_GRN, false);
stm32l4_gpiowrite(GPIO_LED_RED, true); stm32l4_gpiowrite(GPIO_LED_RED, true);
@@ -158,6 +155,7 @@ void board_autoled_off(int led)
* *
* These cases should never happen. * These cases should never happen.
*/ */
default: default:
case LED_STARTED: case LED_STARTED:
case LED_HEAPALLOCATE: case LED_HEAPALLOCATE:
@@ -169,6 +167,7 @@ void board_autoled_off(int led)
* *
* This case will occur many times. * This case will occur many times.
*/ */
case LED_INIRQ: case LED_INIRQ:
case LED_SIGNAL: case LED_SIGNAL:
case LED_ASSERTION: case LED_ASSERTION:
@@ -179,6 +178,7 @@ void board_autoled_off(int led)
* *
* This case will also occur many times. * This case will also occur many times.
*/ */
case LED_PANIC: case LED_PANIC:
stm32l4_gpiowrite(GPIO_LED_GRN, false); stm32l4_gpiowrite(GPIO_LED_GRN, false);
stm32l4_gpiowrite(GPIO_LED_RED, false); stm32l4_gpiowrite(GPIO_LED_RED, false);
+1 -10
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32l476vg-disco/src/stm32_boot.c * configs/stm32l476vg-disco/src/stm32_boot.c
* *
* Copyright (C) 2014-2015 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>
* dev@ziggurat29.com * dev@ziggurat29.com
* *
@@ -51,14 +51,6 @@
#include "up_arch.h" #include "up_arch.h"
#include "stm32l476vg-disco.h" #include "stm32l476vg-disco.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Private Data
************************************************************************************/
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
@@ -123,6 +115,5 @@ void board_initialize(void)
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT) #if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
board_app_initialize(); board_app_initialize();
#endif #endif
} }
#endif #endif
+19 -17
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/src/stm32_buttons.c * configs/stm32l476vg-disco/src/stm32_buttons.c
* *
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: dev@ziggurat29.com * Author: dev@ziggurat29.com
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -73,8 +73,8 @@ static int button_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
/* Pin configuration for each STM32L476 Discovery button. This array is indexed by /* Pin configuration for each STM32L476 Discovery button. This array is
* the BUTTON_* definitions in board.h * indexed by the BUTTON_* definitions in board.h
*/ */
static const uint32_t g_buttons[NUM_BUTTONS] = static const uint32_t g_buttons[NUM_BUTTONS] =
@@ -161,13 +161,14 @@ static void button_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
* *
****************************************************************************/ ****************************************************************************/
/* XXX it's not completely clear to me if this is appropriate; on the one /* XXX it's not completely clear to me if this is appropriate; on the one
hand, it seems to make sense that this would be the module to have the ISR * hand, it seems to make sense that this would be the module to have the ISR
for the buttons. On the other hand, it will conflict with things done in * for the buttons. On the other hand, it will conflict with things done in
the buttons example, which registers it's own ISR, and warns if it sees * the buttons example, which registers it's own ISR, and warns if it sees
one already there. I don't know if 'buttons' is overstepping it's bounds * one already there. I don't know if 'buttons' is overstepping it's bounds
in the interst of providing a compact example, (like the I2C app directly * in the interst of providing a compact example, (like the I2C app directly
talking to the bus), or if really that should be an expected thing to do. * talking to the bus), or if really that should be an expected thing to do.
*/ */
#if 0 #if 0
#ifdef CONFIG_ARCH_IRQBUTTONS #ifdef CONFIG_ARCH_IRQBUTTONS
static int button_handler(int irq, FAR void *context) static int button_handler(int irq, FAR void *context)
@@ -237,8 +238,10 @@ void board_button_initialize(void)
{ {
stm32l4_configgpio(g_buttons[i]); stm32l4_configgpio(g_buttons[i]);
//It's not clear if this is correct; I think so, but then there are /* It's not clear if this is correct; I think so, but then there are
//conflicts with the 'buttons' sample app. * conflicts with the 'buttons' sample app.
*/
#if 0 #if 0
#ifdef CONFIG_ARCH_IRQBUTTONS #ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t oldhandler = board_button_irq(i, button_handler); xcpt_t oldhandler = board_button_irq(i, button_handler);
@@ -250,10 +253,7 @@ void board_button_initialize(void)
} }
#endif #endif
#endif #endif
} }
} }
/**************************************************************************** /****************************************************************************
@@ -269,8 +269,7 @@ uint8_t board_buttons(void)
for (i = 0; i < NUM_BUTTONS; i++) for (i = 0; i < NUM_BUTTONS; i++)
{ {
/* A HIGH value means that the key is pressed. /* A HIGH value means that the key is pressed. */
*/
bool pressed = stm32l4_gpioread(g_buttons[i]); bool pressed = stm32l4_gpioread(g_buttons[i]);
@@ -282,8 +281,10 @@ uint8_t board_buttons(void)
} }
} }
/* if the user pressed any buttons, notify power management system we are active /* if the user pressed any buttons, notify power management system we are
* active
*/ */
#ifdef CONFIG_PM #ifdef CONFIG_PM
if ( 0 != ret ) if ( 0 != ret )
{ {
@@ -328,6 +329,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{ {
oldhandler = stm32l4_gpiosetevent(g_buttons[id], true, true, true, irqhandler); oldhandler = stm32l4_gpiosetevent(g_buttons[id], true, true, true, irqhandler);
} }
return oldhandler; return oldhandler;
} }
#endif #endif
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32l476vg-disco/src/stm32_clockconfig.c * configs/stm32l476vg-disco/src/stm32_clockconfig.c
* *
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: dev@ziggurat29.com * Author: dev@ziggurat29.com
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -44,18 +44,9 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include <arch/board/stm32l476vg-disco-clocking.h> #include <arch/board/stm32l476vg-disco-clocking.h>
#include "up_arch.h" #include "up_arch.h"
#include "stm32l476vg-disco.h" #include "stm32l476vg-disco.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
@@ -126,7 +117,8 @@ void stm32l4_board_clockconfig(void)
/* XXX The choice of clock source to PLL (all three) is independent /* XXX The choice of clock source to PLL (all three) is independent
* of the sys clock source choice, review the STM32L4_BOARD_USEHSI * of the sys clock source choice, review the STM32L4_BOARD_USEHSI
* name; probably split it into two, one for PLL source and one * name; probably split it into two, one for PLL source and one
* for sys clock source */ * for sys clock source.
*/
regval |= RCC_PLLCFG_PLLSRC_HSI; regval |= RCC_PLLCFG_PLLSRC_HSI;
putreg32(regval, STM32L4_RCC_PLLCFG); putreg32(regval, STM32L4_RCC_PLLCFG);
@@ -231,14 +223,15 @@ void stm32l4_board_clockconfig(void)
/* XXX sanity if sdmmc1 or usb or rng, then we need to set the clk48 source /* XXX sanity if sdmmc1 or usb or rng, then we need to set the clk48 source
* and then we can also do away with STM32L4_USE_CLK48, and give better * and then we can also do away with STM32L4_USE_CLK48, and give better
* warning messages */ * warning messages
/*XXX sanity if our STM32L4_CLK48_SEL is YYY then we need to have already *
* enabled ZZZ */ * XXX sanity if our STM32L4_CLK48_SEL is YYY then we need to have already
* enabled ZZZ
*/
regval = getreg32(STM32L4_RCC_CCIPR); regval = getreg32(STM32L4_RCC_CCIPR);
regval &= RCC_CCIPR_CLK48SEL_MASK; regval &= RCC_CCIPR_CLK48SEL_MASK;
regval |= STM32L4_CLK48_SEL; regval |= STM32L4_CLK48_SEL;
putreg32(regval, STM32L4_RCC_CCIPR); putreg32(regval, STM32L4_RCC_CCIPR);
} }
#endif #endif
@@ -1,154 +0,0 @@
/************************************************************************************
* configs/stm32l476vg-disco/src/stm32_cxxinitialize.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <arch/stm32l4/chip.h>
#include "chip.h"
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Debug ****************************************************************************/
/* Non-standard debug that may be enabled just for testing the static constructors */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_CXX
#endif
#ifdef CONFIG_DEBUG_CXX
# define cxxdbg dbg
# define cxxlldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cxxvdbg vdbg
# define cxxllvdbg llvdbg
# else
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
# endif
#else
# define cxxdbg(x...)
# define cxxlldbg(x...)
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
#endif
/************************************************************************************
* Private Types
************************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/************************************************************************************
* External references
************************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; This
* function defintion only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support
*
****************************************************************************/
void up_cxxinitialize(void)
{
initializer_t *initp;
cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialzation table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxdbg("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table
*/
if ((void*)initializer > (void*)&_stext && (void*)initializer < (void*)&_etext)
{
cxxdbg("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */
+1 -1
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/src/stm32_spi.c * configs/stm32l476vg-disco/src/stm32_spi.c
* *
* Copyright (C) 2014 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>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32l476vg-disco/src/stm32_userleds.c * configs/stm32l476vg-disco/src/stm32_userleds.c
* *
* Copyright (C) 2014-2015 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>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -70,10 +70,6 @@
# define ledvdbg(x...) # define ledvdbg(x...)
#endif #endif
/****************************************************************************
* Private Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
@@ -118,6 +114,7 @@ static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
case(PM_NORMAL): case(PM_NORMAL):
{ {
/* Restore normal LEDs operation */ /* Restore normal LEDs operation */
//stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0); //stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0);
//stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0); //stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0);
} }
@@ -126,6 +123,7 @@ static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
case(PM_IDLE): case(PM_IDLE):
{ {
/* Entering IDLE mode - Turn leds off */ /* Entering IDLE mode - Turn leds off */
stm32l4_gpiowrite(GPIO_LED_RED, 0); stm32l4_gpiowrite(GPIO_LED_RED, 0);
stm32l4_gpiowrite(GPIO_LED_GRN, 0); stm32l4_gpiowrite(GPIO_LED_GRN, 0);
} }
@@ -134,6 +132,7 @@ static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
case(PM_STANDBY): case(PM_STANDBY):
{ {
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */ /* Entering STANDBY mode - Logic for PM_STANDBY goes here */
stm32l4_gpiowrite(GPIO_LED_RED, 0); stm32l4_gpiowrite(GPIO_LED_RED, 0);
stm32l4_gpiowrite(GPIO_LED_GRN, 0); stm32l4_gpiowrite(GPIO_LED_GRN, 0);
} }
@@ -142,6 +141,7 @@ static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
case(PM_SLEEP): case(PM_SLEEP):
{ {
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */ /* Entering SLEEP mode - Logic for PM_SLEEP goes here */
stm32l4_gpiowrite(GPIO_LED_RED, 0); stm32l4_gpiowrite(GPIO_LED_RED, 0);
stm32l4_gpiowrite(GPIO_LED_GRN, 0); stm32l4_gpiowrite(GPIO_LED_GRN, 0);
} }
@@ -150,7 +150,6 @@ static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
default: default:
{ {
/* Should not get here */ /* Should not get here */
} }
break; break;
} }
@@ -191,6 +190,7 @@ static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
void board_userled_initialize(void) void board_userled_initialize(void)
{ {
/* Configure LD4,5 GPIO for output */ /* Configure LD4,5 GPIO for output */
stm32l4_configgpio(GPIO_LED_RED); stm32l4_configgpio(GPIO_LED_RED);
stm32l4_configgpio(GPIO_LED_GRN); stm32l4_configgpio(GPIO_LED_GRN);
} }
@@ -206,6 +206,7 @@ void board_userled(int led, bool ledon)
case BOARD_LED_RED: case BOARD_LED_RED:
stm32l4_gpiowrite(GPIO_LED_RED, ldeon); stm32l4_gpiowrite(GPIO_LED_RED, ldeon);
break; break;
case BOARD_LED_GRN: case BOARD_LED_GRN:
stm32l4_gpiowrite(GPIO_LED_GRN, ldeon); stm32l4_gpiowrite(GPIO_LED_GRN, ldeon);
break; break;
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32l476vg-disco/src/stm32l476vg-disco.h * configs/stm32l476vg-disco/src/stm32l476vg-disco.h
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Authors: Frank Bennett * Authors: Frank Bennett
* Gregory Nutt <gnutt@nuttx.org> * Gregory Nutt <gnutt@nuttx.org>
* Sebastien Lorquet <sebastien@lorquet.fr> * Sebastien Lorquet <sebastien@lorquet.fr>
@@ -53,7 +53,6 @@
************************************************************************************/ ************************************************************************************/
/* Configuration ********************************************************************/ /* Configuration ********************************************************************/
/* LED. /* LED.
* LD4: the red LED on PB2 * LD4: the red LED on PB2
* LD5: the green LED on PE8 * LD5: the green LED on PE8
@@ -63,12 +62,12 @@
*/ */
#define GPIO_LED_RED \ #define GPIO_LED_RED \
(GPIO_PORTB | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_PULLUP | \ (GPIO_PORTB | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | \
GPIO_SPEED_50MHz) GPIO_PULLUP | GPIO_SPEED_50MHz)
#define GPIO_LED_GRN \ #define GPIO_LED_GRN \
(GPIO_PORTE | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_PULLUP | \ (GPIO_PORTE | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | \
GPIO_SPEED_50MHz) GPIO_PULLUP | GPIO_SPEED_50MHz)
/* Buttons /* Buttons
* *
@@ -92,10 +91,9 @@
#define GPIO_BTN_UP \ #define GPIO_BTN_UP \
(GPIO_INPUT |GPIO_PULLDOWN |GPIO_EXTI | GPIO_PORTA | GPIO_PIN3) (GPIO_INPUT |GPIO_PULLDOWN |GPIO_EXTI | GPIO_PORTA | GPIO_PIN3)
/* SPI1 off */ /* SPI1 off */
/* XXX is this used on disco? */ /* XXX is this used on disco? */
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ #define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
GPIO_PORTE | GPIO_PIN15) GPIO_PORTE | GPIO_PIN15)
#define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ #define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
@@ -105,18 +103,15 @@
#define GPIO_SPI1_NSS_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ #define GPIO_SPI1_NSS_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
GPIO_PORTE | GPIO_PIN12) GPIO_PORTE | GPIO_PIN12)
/* Devices on the onboard I2C bus. /* Devices on the onboard I2C bus.
* *
* Note that these are unshifted addresses. * Note that these are unshifted addresses.
*/ */
/* XXX IS this 'unshifted'? */ /* XXX IS this 'unshifted'? */
#define NUCLEO_I2C_OBDEV_CS43L22 0x94 #define NUCLEO_I2C_OBDEV_CS43L22 0x94
/************************************************************************************ /************************************************************************************
* Public Data * Public Data
************************************************************************************/ ************************************************************************************/
@@ -166,5 +161,4 @@ void stm32_usbinitialize(void);
int board_adc_initialize(void); int board_adc_initialize(void);
#endif #endif
#endif /* __CONFIGS_STM32L476VG_DISCO_SRC_STM32L476VG_DISCO_H */ #endif /* __CONFIGS_STM32L476VG_DISCO_SRC_STM32L476VG_DISCO_H */