Changes from review of last PR
This commit is contained in:
parent
b089e98a83
commit
9ceba8cd8f
@ -25,7 +25,7 @@ config ARCH_BOARD_ARDUINO_MEGA2560
|
||||
depends on ARCH_CHIP_ATMEGA2560
|
||||
---help---
|
||||
This option selects the Arduino Mega 2560 board featuring the Atmel
|
||||
Atmega2560 MCU running at 16 MHz.
|
||||
Atmega2560 MCU running at 16 MHz.
|
||||
|
||||
config ARCH_BOARD_ARDUINO_DUE
|
||||
bool "Arduino Due"
|
||||
@ -970,7 +970,7 @@ config ARCH_BOARD_STM32F746G_DISCO
|
||||
select ARCH_HAVE_BUTTONS
|
||||
select ARCH_HAVE_IRQBUTTONS
|
||||
---help---
|
||||
STMicro STM32F746G-DISCO development board featuring the STM32F746NGH6
|
||||
STMicro STM32F746G-DISCO development board featuring the STM32F746NGH6
|
||||
MCU. The STM32F746NGH6 is a 216MHz Cortex-M7 operation with 1024Kb Flash
|
||||
memory and 300Kb SRAM.
|
||||
|
||||
@ -981,7 +981,7 @@ config ARCH_BOARD_STM32L476VG_DISCO
|
||||
select ARCH_HAVE_BUTTONS
|
||||
select ARCH_HAVE_IRQBUTTONS
|
||||
---help---
|
||||
STMicro STM32L476VG_DISCO development board featuring the STM32L476VG
|
||||
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.
|
||||
|
||||
@ -1428,7 +1428,7 @@ config ARCH_BOARD
|
||||
default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD
|
||||
default "cc3200-launchpad" if ARCH_BOARD_CC3200_LAUNCHPAD
|
||||
default "twr-k60n512" if ARCH_BOARD_TWR_K60N512
|
||||
default "u-blox-c027" if ARCH_BOARD_U_BLOX_C027
|
||||
default "u-blox-c027" if ARCH_BOARD_U_BLOX_C027
|
||||
default "ubw32" if ARCH_BOARD_UBW32
|
||||
default "us7032evb1" if ARCH_BOARD_US7032EVB1
|
||||
default "viewtool-stm32f107" if ARCH_BOARD_VIEWTOOL_STM32F107
|
||||
|
@ -648,6 +648,11 @@ configs/stm32f746g-disco
|
||||
MCU. The STM32F746NGH6 is a 216MHz Cortex-M7 operation with 1024Kb Flash
|
||||
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
|
||||
STMicro STM32L-Discovery board based on the STMicro STM32L152RB MCU.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -55,7 +55,6 @@
|
||||
|
||||
#include <arch/board/stm32l476vg-disco-clocking.h>
|
||||
|
||||
|
||||
/* DMA Channel/Stream Selections ****************************************************/
|
||||
/* Stream selections are arbitrary for now but might become important in the future
|
||||
* is we set aside more DMA channels/streams.
|
||||
@ -63,7 +62,7 @@
|
||||
|
||||
/* Values defined in arch/arm/src/stm32l4/chip/stm32l4x6xx_dma.h */
|
||||
|
||||
/*XXX are these used on disco? */
|
||||
/* XXX are these used on disco? */
|
||||
|
||||
#if 0
|
||||
|
||||
@ -125,7 +124,7 @@
|
||||
|
||||
/*
|
||||
* XXX Is I2C2 used on Disco?
|
||||
*/
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
@ -143,7 +142,7 @@
|
||||
|
||||
/*
|
||||
* XXX is SPI1 used on Disco?
|
||||
*/
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
@ -154,19 +153,17 @@
|
||||
#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
|
||||
* LSM303CTR - eCompass, comprising an accelerometer and magnetometer
|
||||
*/
|
||||
*/
|
||||
|
||||
#define GPIO_SPI2_MISO GPIO_SPI2_MISO_3
|
||||
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_3
|
||||
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_3
|
||||
|
||||
/*
|
||||
* PD7; gyroscope CS
|
||||
*/
|
||||
/* PD7; gyroscope CS */
|
||||
|
||||
#define GPIO_SPI_CS_GYRO_OFF \
|
||||
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
|
||||
GPIO_PORTD | GPIO_PIN7)
|
||||
@ -174,9 +171,8 @@
|
||||
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN7)
|
||||
|
||||
/*
|
||||
* PE0; accelerometer CS
|
||||
*/
|
||||
/* PE0; accelerometer CS */
|
||||
|
||||
#define GPIO_SPI_CS_ACCEL_OFF \
|
||||
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
|
||||
GPIO_PORTE | GPIO_PIN0)
|
||||
@ -184,9 +180,8 @@
|
||||
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN0)
|
||||
|
||||
/*
|
||||
* PC0; magnetometer CS
|
||||
*/
|
||||
/* PC0; magnetometer CS */
|
||||
|
||||
#define GPIO_SPI_CS_MAGNETO_OFF \
|
||||
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
|
||||
GPIO_PORTC | GPIO_PIN0)
|
||||
@ -194,16 +189,14 @@
|
||||
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTC | GPIO_PIN0)
|
||||
|
||||
|
||||
/*
|
||||
XXX these will need to be set up when these get implemented:
|
||||
PD2 gyro INT1
|
||||
PB8 gyro INT2/DRDY
|
||||
|
||||
PE1 accel INT
|
||||
PC2 magneto DRDY
|
||||
PC1 magneto INT
|
||||
*/
|
||||
/* XXX these will need to be set up when these get implemented:
|
||||
* PD2 gyro INT1
|
||||
* PB8 gyro INT2/DRDY
|
||||
*
|
||||
* PE1 accel INT
|
||||
* PC2 magneto DRDY
|
||||
* PC1 magneto INT
|
||||
*/
|
||||
|
||||
/* LEDs
|
||||
*
|
||||
@ -233,13 +226,13 @@
|
||||
*
|
||||
* SYMBOL Meaning BOARD_LED_GRN BOARD_LED_RED
|
||||
* ------------------- ----------------------- ----------- ------------
|
||||
* LED_STARTED NuttX has been started
|
||||
* LED_HEAPALLOCATE Heap has been allocated
|
||||
* LED_IRQSENABLED Interrupts enabled
|
||||
* LED_STACKCREATED Idle stack created
|
||||
* LED_INIRQ In an interrupt
|
||||
* LED_SIGNAL In a signal handler
|
||||
* LED_ASSERTION An assertion failed
|
||||
* LED_STARTED NuttX has been started
|
||||
* LED_HEAPALLOCATE Heap has been allocated
|
||||
* LED_IRQSENABLED Interrupts enabled
|
||||
* LED_STACKCREATED Idle stack created
|
||||
* LED_INIRQ In an interrupt
|
||||
* LED_SIGNAL In a signal handler
|
||||
* LED_ASSERTION An assertion failed
|
||||
* LED_PANIC The system has crashed Blinking
|
||||
* LED_IDLE MCU is is sleep mode ON
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -68,12 +68,12 @@
|
||||
#define STM32L4_LSE_FREQUENCY 32768
|
||||
|
||||
/* 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
|
||||
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
|
||||
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
|
||||
mutually exclusive.
|
||||
* 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
|
||||
* 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
|
||||
* used at the same time; currently those choices HSE/HSI16/MSI are
|
||||
* mutually exclusive.
|
||||
*/
|
||||
|
||||
#define STM32L4_BOARD_USEHSI 1
|
||||
@ -84,11 +84,11 @@
|
||||
#define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1)
|
||||
|
||||
/* 'main' PLL config; we use this to generate our system clock via the R
|
||||
output. We set it up as
|
||||
16 MHz / 1 * 10 / 2 = 80 MHz
|
||||
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
|
||||
want things done this way.
|
||||
* output. We set it up as 16 MHz / 1 * 10 / 2 = 80 MHz
|
||||
*
|
||||
* 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
|
||||
* want things done this way.
|
||||
*/
|
||||
|
||||
#define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(10)
|
||||
@ -100,14 +100,15 @@
|
||||
#define STM32L4_PLLCFG_PLLR_ENABLED
|
||||
|
||||
/* '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
|
||||
the Q output (ultimately for CLK48) with /4. So,
|
||||
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
|
||||
peripherals will not work (RNG at present). I would suggest removing
|
||||
that option from Kconfig altogether, and simply making it an option
|
||||
that is selected via a #define here, like all these other params.
|
||||
* do that with the main PLL's N value. We set N = 13, and enable
|
||||
* the Q output (ultimately for CLK48) with /4. So,
|
||||
* 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
|
||||
* peripherals will not work (RNG at present). I would suggest removing
|
||||
* 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)
|
||||
@ -171,7 +172,6 @@
|
||||
*/
|
||||
/* REVISIT : this can be configured */
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# 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
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
# 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>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
* Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
* dev@ziggurat29.com
|
||||
|
@ -46,10 +46,6 @@ ifeq ($(CONFIG_STM32_OTGFS),y)
|
||||
CSRCS += stm32_usb.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
CSRCS += stm32_cxxinitialize.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += stm32_autoleds.c
|
||||
else
|
||||
@ -68,7 +64,7 @@ endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_LIBRARY),y)
|
||||
CSRCS += stm32_nsh.c
|
||||
CSRCS += stm32_appinit.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
@ -1,90 +1,77 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_nsh.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 <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include <stm32l4.h>
|
||||
#include <stm32l4_uart.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_app_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_app_initialize(void)
|
||||
{
|
||||
|
||||
/* Configure CPU load estimation */
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
cpuload_initialize_once();
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_appinit.c
|
||||
*
|
||||
* Copyright (C) 2016 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 <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include <stm32l4.h>
|
||||
#include <stm32l4_uart.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_app_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_app_initialize(void)
|
||||
{
|
||||
/* Configure CPU load estimation */
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
cpuload_initialize_once();
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -70,14 +70,6 @@
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -89,6 +81,7 @@
|
||||
void board_autoled_initialize(void)
|
||||
{
|
||||
/* Configure LD4,5 GPIO for output */
|
||||
|
||||
stm32l4_configgpio(GPIO_LED_RED);
|
||||
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
|
||||
* occurs one time, nothing need be done.
|
||||
*/
|
||||
|
||||
default:
|
||||
case LED_STARTED:
|
||||
case LED_HEAPALLOCATE:
|
||||
@ -116,6 +110,7 @@ void board_autoled_on(int led)
|
||||
*
|
||||
* This case will also occur only once.
|
||||
*/
|
||||
|
||||
case LED_STACKCREATED:
|
||||
break;
|
||||
|
||||
@ -123,6 +118,7 @@ void board_autoled_on(int led)
|
||||
*
|
||||
* This case will occur many times.
|
||||
*/
|
||||
|
||||
case LED_INIRQ:
|
||||
case LED_SIGNAL:
|
||||
case LED_ASSERTION:
|
||||
@ -133,11 +129,12 @@ void board_autoled_on(int led)
|
||||
*
|
||||
* This case will also occur many times.
|
||||
*/
|
||||
|
||||
case LED_PANIC:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, false);
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, true);
|
||||
break;
|
||||
|
||||
|
||||
case LED_IDLE:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, true);
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, false);
|
||||
@ -158,6 +155,7 @@ void board_autoled_off(int led)
|
||||
*
|
||||
* These cases should never happen.
|
||||
*/
|
||||
|
||||
default:
|
||||
case LED_STARTED:
|
||||
case LED_HEAPALLOCATE:
|
||||
@ -169,6 +167,7 @@ void board_autoled_off(int led)
|
||||
*
|
||||
* This case will occur many times.
|
||||
*/
|
||||
|
||||
case LED_INIRQ:
|
||||
case LED_SIGNAL:
|
||||
case LED_ASSERTION:
|
||||
@ -179,11 +178,12 @@ void board_autoled_off(int led)
|
||||
*
|
||||
* This case will also occur many times.
|
||||
*/
|
||||
|
||||
case LED_PANIC:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, false);
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, false);
|
||||
break;
|
||||
|
||||
|
||||
case LED_IDLE:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, false);
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* 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>
|
||||
* dev@ziggurat29.com
|
||||
*
|
||||
@ -51,14 +51,6 @@
|
||||
#include "up_arch.h"
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
@ -123,6 +115,5 @@ void board_initialize(void)
|
||||
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
|
||||
board_app_initialize();
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
/* Pin configuration for each STM32L476 Discovery button. This array is indexed by
|
||||
* the BUTTON_* definitions in board.h
|
||||
/* Pin configuration for each STM32L476 Discovery button. This array is
|
||||
* indexed by the BUTTON_* definitions in board.h
|
||||
*/
|
||||
|
||||
static const uint32_t g_buttons[NUM_BUTTONS] =
|
||||
@ -100,7 +100,7 @@ static struct pm_callback_s g_buttonscb =
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: button_pm_notify
|
||||
*
|
||||
@ -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
|
||||
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
|
||||
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
|
||||
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.
|
||||
* 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
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
static int button_handler(int irq, FAR void *context)
|
||||
@ -237,8 +238,10 @@ void board_button_initialize(void)
|
||||
{
|
||||
stm32l4_configgpio(g_buttons[i]);
|
||||
|
||||
//It's not clear if this is correct; I think so, but then there are
|
||||
//conflicts with the 'buttons' sample app.
|
||||
/* It's not clear if this is correct; I think so, but then there are
|
||||
* conflicts with the 'buttons' sample app.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t oldhandler = board_button_irq(i, button_handler);
|
||||
@ -250,10 +253,7 @@ void board_button_initialize(void)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -269,26 +269,27 @@ uint8_t board_buttons(void)
|
||||
|
||||
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]);
|
||||
|
||||
/* Accumulate the set of depressed (not released) keys */
|
||||
/* Accumulate the set of depressed (not released) keys */
|
||||
|
||||
if (pressed)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
}
|
||||
if (pressed)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
if ( 0 != ret )
|
||||
{
|
||||
pm_activity ( CONFIG_PM_BUTTON_ACTIVITY );
|
||||
}
|
||||
{
|
||||
pm_activity(CONFIG_PM_BUTTON_ACTIVITY);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -44,18 +44,9 @@
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/board/stm32l476vg-disco-clocking.h>
|
||||
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
@ -79,7 +70,7 @@ void stm32l4_board_clockconfig(void)
|
||||
uint32_t regval;
|
||||
|
||||
/* Enable Internal High-Speed Clock (HSI) */
|
||||
|
||||
|
||||
regval = getreg32(STM32L4_RCC_CR);
|
||||
regval |= RCC_CR_HSION; /* Enable HSI */
|
||||
putreg32(regval, STM32L4_RCC_CR);
|
||||
@ -91,7 +82,7 @@ void stm32l4_board_clockconfig(void)
|
||||
}
|
||||
|
||||
/* Set the HCLK source/divider */
|
||||
|
||||
|
||||
regval = getreg32(STM32L4_RCC_CFGR);
|
||||
regval &= ~RCC_CFGR_HPRE_MASK;
|
||||
regval |= STM32L4_RCC_CFGR_HPRE;
|
||||
@ -126,7 +117,8 @@ void stm32l4_board_clockconfig(void)
|
||||
/* XXX The choice of clock source to PLL (all three) is independent
|
||||
* of the sys clock source choice, review the STM32L4_BOARD_USEHSI
|
||||
* 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;
|
||||
putreg32(regval, STM32L4_RCC_PLLCFG);
|
||||
@ -229,16 +221,17 @@ void stm32l4_board_clockconfig(void)
|
||||
stm32l4_rcc_enablelse();
|
||||
#endif
|
||||
|
||||
/*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
|
||||
* warning messages */
|
||||
/*XXX sanity if our STM32L4_CLK48_SEL is YYY then we need to have already
|
||||
* enabled ZZZ */
|
||||
* warning messages
|
||||
*
|
||||
* XXX sanity if our STM32L4_CLK48_SEL is YYY then we need to have already
|
||||
* enabled ZZZ
|
||||
*/
|
||||
|
||||
regval = getreg32(STM32L4_RCC_CCIPR);
|
||||
regval &= RCC_CCIPR_CLK48SEL_MASK;
|
||||
regval |= STM32L4_CLK48_SEL;
|
||||
putreg32(regval, STM32L4_RCC_CCIPR);
|
||||
|
||||
}
|
||||
#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,271 +1,271 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_spi.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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include <up_arch.h>
|
||||
#include <chip.h>
|
||||
#include <stm32l4.h>
|
||||
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Enables debug output from this file */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_SPI
|
||||
# undef CONFIG_DEBUG_VERBOSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_SPI
|
||||
# define spidbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define spivdbg lldbg
|
||||
# else
|
||||
# define spivdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define spidbg(x...)
|
||||
# define spivdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
/* Global driver instances */
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
xxx
|
||||
struct spi_dev_s *g_spi1;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
yyy
|
||||
struct spi_dev_s *g_spi2;
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the Nucleo-F401RE and
|
||||
* Nucleo-F411RE boards.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function stm32_spiinitialize(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi1 = up_spiinitialize(1);
|
||||
if (!g_spi1)
|
||||
{
|
||||
spidbg("[boot] FAILED to initialize SPI port 1\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
stm32_configgpio(GPIO_SPI_CS_WIFI);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi2 = up_spiinitialize(2);
|
||||
|
||||
/* Setup CS, EN & IRQ line IOs */
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
stm32_configgpio(GPIO_WIFI_CS);
|
||||
stm32_configgpio(GPIO_WIFI_EN);
|
||||
stm32_configgpio(GPIO_WIFI_INT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status must be
|
||||
* provided by board-specific logic. They are implementations of the select
|
||||
* and status methods of the SPI interface defined by struct spi_ops_s (see
|
||||
* include/nuttx/spi/spi.h). All other methods (including up_spiinitialize())
|
||||
* are provided by common STM32 logic. To use this common SPI logic on your
|
||||
* board:
|
||||
*
|
||||
* 1. Provide logic in stm32_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to up_spiinitialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by up_spiinitialize() may then be used to bind the
|
||||
* SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
if (devid == SPIDEV_WIRELESS)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_SPI_CS_WIFI, !selected);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_MMCSD
|
||||
if (devid == SPIDEV_MMCSD)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_SPI_CS_SD_CARD, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
if (devid == SPIDEV_WIRELESS)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_WIFI_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1cmddata
|
||||
*
|
||||
* Description:
|
||||
* Set or clear the SH1101A A0 or SD1306 D/C n bit to select data (true)
|
||||
* or command (false). This function must be provided by platform-specific
|
||||
* logic. This is an implementation of the cmddata method of the SPI
|
||||
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* spi - SPI device that controls the bus the device that requires the CMD/
|
||||
* DATA selection.
|
||||
* devid - If there are multiple devices on the bus, this selects which one
|
||||
* to select cmd or data. NOTE: This design restricts, for example,
|
||||
* one one SPI display per SPI bus.
|
||||
* cmd - true: select command; false: select data
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
int stm32_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
int stm32_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CMDDATA */
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 || CONFIG_STM32_SPI3 */
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_spi.c
|
||||
*
|
||||
* Copyright (C) 2016 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include <up_arch.h>
|
||||
#include <chip.h>
|
||||
#include <stm32l4.h>
|
||||
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Enables debug output from this file */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_SPI
|
||||
# undef CONFIG_DEBUG_VERBOSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_SPI
|
||||
# define spidbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define spivdbg lldbg
|
||||
# else
|
||||
# define spivdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define spidbg(x...)
|
||||
# define spivdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
/* Global driver instances */
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
xxx
|
||||
struct spi_dev_s *g_spi1;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
yyy
|
||||
struct spi_dev_s *g_spi2;
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the Nucleo-F401RE and
|
||||
* Nucleo-F411RE boards.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function stm32_spiinitialize(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi1 = up_spiinitialize(1);
|
||||
if (!g_spi1)
|
||||
{
|
||||
spidbg("[boot] FAILED to initialize SPI port 1\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
stm32_configgpio(GPIO_SPI_CS_WIFI);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi2 = up_spiinitialize(2);
|
||||
|
||||
/* Setup CS, EN & IRQ line IOs */
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
stm32_configgpio(GPIO_WIFI_CS);
|
||||
stm32_configgpio(GPIO_WIFI_EN);
|
||||
stm32_configgpio(GPIO_WIFI_INT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status must be
|
||||
* provided by board-specific logic. They are implementations of the select
|
||||
* and status methods of the SPI interface defined by struct spi_ops_s (see
|
||||
* include/nuttx/spi/spi.h). All other methods (including up_spiinitialize())
|
||||
* are provided by common STM32 logic. To use this common SPI logic on your
|
||||
* board:
|
||||
*
|
||||
* 1. Provide logic in stm32_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to up_spiinitialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by up_spiinitialize() may then be used to bind the
|
||||
* SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
if (devid == SPIDEV_WIRELESS)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_SPI_CS_WIFI, !selected);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_MMCSD
|
||||
if (devid == SPIDEV_MMCSD)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_SPI_CS_SD_CARD, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#ifdef CONFIG_WL_CC3000
|
||||
if (devid == SPIDEV_WIRELESS)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_WIFI_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1cmddata
|
||||
*
|
||||
* Description:
|
||||
* Set or clear the SH1101A A0 or SD1306 D/C n bit to select data (true)
|
||||
* or command (false). This function must be provided by platform-specific
|
||||
* logic. This is an implementation of the cmddata method of the SPI
|
||||
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* spi - SPI device that controls the bus the device that requires the CMD/
|
||||
* DATA selection.
|
||||
* devid - If there are multiple devices on the bus, this selects which one
|
||||
* to select cmd or data. NOTE: This design restricts, for example,
|
||||
* one one SPI display per SPI bus.
|
||||
* cmd - true: select command; false: select data
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
int stm32_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
int stm32_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CMDDATA */
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 || CONFIG_STM32_SPI3 */
|
||||
|
@ -1,240 +1,241 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_userleds.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32l4.h"
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
|
||||
* with CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LEDS
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* LED Power Management */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct pm_callback_s g_ledscb =
|
||||
{
|
||||
.notify = led_pm_notify,
|
||||
.prepare = led_pm_prepare,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_notify
|
||||
*
|
||||
* Description:
|
||||
* Notify the driver of new power state. This callback is called after
|
||||
* all drivers have had the opportunity to prepare for the new power state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
switch (pmstate)
|
||||
{
|
||||
case(PM_NORMAL):
|
||||
{
|
||||
/* Restore normal LEDs operation */
|
||||
//stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0);
|
||||
//stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_IDLE):
|
||||
{
|
||||
/* Entering IDLE mode - Turn leds off */
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_STANDBY):
|
||||
{
|
||||
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_SLEEP):
|
||||
{
|
||||
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_prepare
|
||||
*
|
||||
* Description:
|
||||
* Request the driver to prepare for a new power state. This is a warning
|
||||
* that the system is about to enter into a new power state. The driver
|
||||
* should begin whatever operations that may be required to enter power
|
||||
* state. The driver may abort the state change mode by returning a
|
||||
* non-zero value from the callback function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LEDs driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_initialize(void)
|
||||
{
|
||||
/* Configure LD4,5 GPIO for output */
|
||||
stm32l4_configgpio(GPIO_LED_RED);
|
||||
stm32l4_configgpio(GPIO_LED_GRN);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
switch ( led )
|
||||
{
|
||||
case BOARD_LED_RED:
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, ldeon);
|
||||
break;
|
||||
case BOARD_LED_GRN:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, ldeon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_all
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_all(uint8_t ledset)
|
||||
{
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_led_pminitialize
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void stm32_led_pminitialize(void)
|
||||
{
|
||||
/* Register to receive power management callbacks */
|
||||
|
||||
int ret = pm_register(&g_ledscb);
|
||||
DEBUGASSERT(ret == OK);
|
||||
UNUSED(ret);
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
||||
/****************************************************************************
|
||||
* configs/stm32l476vg-disco/src/stm32_userleds.c
|
||||
*
|
||||
* Copyright (C) 2016 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32l4.h"
|
||||
#include "stm32l476vg-disco.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
|
||||
* with CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LEDS
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* LED Power Management */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct pm_callback_s g_ledscb =
|
||||
{
|
||||
.notify = led_pm_notify,
|
||||
.prepare = led_pm_prepare,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_notify
|
||||
*
|
||||
* Description:
|
||||
* Notify the driver of new power state. This callback is called after
|
||||
* all drivers have had the opportunity to prepare for the new power state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
switch (pmstate)
|
||||
{
|
||||
case(PM_NORMAL):
|
||||
{
|
||||
/* Restore normal LEDs operation */
|
||||
|
||||
//stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0);
|
||||
//stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_IDLE):
|
||||
{
|
||||
/* Entering IDLE mode - Turn leds off */
|
||||
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_STANDBY):
|
||||
{
|
||||
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_SLEEP):
|
||||
{
|
||||
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_prepare
|
||||
*
|
||||
* Description:
|
||||
* Request the driver to prepare for a new power state. This is a warning
|
||||
* that the system is about to enter into a new power state. The driver
|
||||
* should begin whatever operations that may be required to enter power
|
||||
* state. The driver may abort the state change mode by returning a
|
||||
* non-zero value from the callback function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LEDs driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_initialize(void)
|
||||
{
|
||||
/* Configure LD4,5 GPIO for output */
|
||||
|
||||
stm32l4_configgpio(GPIO_LED_RED);
|
||||
stm32l4_configgpio(GPIO_LED_GRN);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
switch (led)
|
||||
{
|
||||
case BOARD_LED_RED:
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, ldeon);
|
||||
break;
|
||||
|
||||
case BOARD_LED_GRN:
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, ldeon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_all
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_all(uint8_t ledset)
|
||||
{
|
||||
stm32l4_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED_RED_BIT) != 0);
|
||||
stm32l4_gpiowrite(GPIO_LED_GRN, (ledset & BOARD_LED_GRN_BIT) != 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_led_pminitialize
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void stm32_led_pminitialize(void)
|
||||
{
|
||||
/* Register to receive power management callbacks */
|
||||
|
||||
int ret = pm_register(&g_ledscb);
|
||||
DEBUGASSERT(ret == OK);
|
||||
UNUSED(ret);
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* 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
|
||||
* Gregory Nutt <gnutt@nuttx.org>
|
||||
* Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
@ -53,7 +53,6 @@
|
||||
************************************************************************************/
|
||||
/* Configuration ********************************************************************/
|
||||
|
||||
|
||||
/* LED.
|
||||
* LD4: the red LED on PB2
|
||||
* LD5: the green LED on PE8
|
||||
@ -63,19 +62,19 @@
|
||||
*/
|
||||
|
||||
#define GPIO_LED_RED \
|
||||
(GPIO_PORTB | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_PULLUP | \
|
||||
GPIO_SPEED_50MHz)
|
||||
(GPIO_PORTB | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | \
|
||||
GPIO_PULLUP | GPIO_SPEED_50MHz)
|
||||
|
||||
#define GPIO_LED_GRN \
|
||||
(GPIO_PORTE | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_PULLUP | \
|
||||
GPIO_SPEED_50MHz)
|
||||
(GPIO_PORTE | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PUSHPULL | \
|
||||
GPIO_PULLUP | GPIO_SPEED_50MHz)
|
||||
|
||||
/* Buttons
|
||||
*
|
||||
* There is a 4 way d-pad 'joystick' with center button
|
||||
* There is a 4 way d-pad 'joystick' with center button
|
||||
* connected to PA0,1,5,2,3
|
||||
* C L D R U
|
||||
*/
|
||||
*/
|
||||
|
||||
#define MIN_IRQBUTTON BUTTON_CENTER
|
||||
#define MAX_IRQBUTTON BUTTON_UP
|
||||
@ -92,10 +91,9 @@
|
||||
#define GPIO_BTN_UP \
|
||||
(GPIO_INPUT |GPIO_PULLDOWN |GPIO_EXTI | GPIO_PORTA | GPIO_PIN3)
|
||||
|
||||
|
||||
|
||||
/* SPI1 off */
|
||||
/* XXX is this used on disco? */
|
||||
|
||||
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||
GPIO_PORTE | GPIO_PIN15)
|
||||
#define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||
@ -105,18 +103,15 @@
|
||||
#define GPIO_SPI1_NSS_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||
GPIO_PORTE | GPIO_PIN12)
|
||||
|
||||
|
||||
|
||||
/* Devices on the onboard I2C bus.
|
||||
*
|
||||
* Note that these are unshifted addresses.
|
||||
*/
|
||||
|
||||
/* XXX IS this 'unshifted'? */
|
||||
|
||||
#define NUCLEO_I2C_OBDEV_CS43L22 0x94
|
||||
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
@ -166,5 +161,4 @@ void stm32_usbinitialize(void);
|
||||
int board_adc_initialize(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CONFIGS_STM32L476VG_DISCO_SRC_STM32L476VG_DISCO_H */
|
||||
|
Loading…
Reference in New Issue
Block a user