configs/olimex-stm32-e407: Add timer driver support.

This commit is contained in:
Juan Flores 2019-07-12 07:47:46 -06:00 committed by Gregory Nutt
parent 3174bf4165
commit 324969142b
11 changed files with 299 additions and 105 deletions

View File

@ -60,7 +60,7 @@ Configurations
Configures the NuttShell (nsh) located at examples/nsh. This
configuration is focused on network testing.
BMP180:
bmp180:
------
This is a configuration example for the BMP180 barometer sensor. This
sensor works with I2C, you need to do the next connections:
@ -77,7 +77,7 @@ Configurations
you should see a device called "press0". Now execute the app
BMP180 to see the ambient pressure value.
DAC:
dac:
---
This is a configuration example to use the DAC1 of the board.The DAC1 is attached
to the PA4 pin (Arduino header D10).
@ -89,7 +89,7 @@ Configurations
you should see a device called "dac0". Now execute the app
dac put a value at the output.
INA219:
ina219:
------
This is a configuration example for the INA219 DC current sensor. This
sensor works with I2C, you need to do the next connections:
@ -106,3 +106,13 @@ Configurations
you should see a device called "ina219". Now execute the app
ina219 to see the ambient pressure value.
timer:
-----
This configuration set the proper configuration to use the timer1 of the board.
This example is configured to work with the USBNSH instead of UART NSH, so
the console will be shown over the USB_OTG1 connector.
On the console, type "ls /dev " and if the registration process goes fine,
you should see a device called "timer1".

View File

@ -92,5 +92,9 @@ ifeq ($(CONFIG_SENSORS_INA219),y)
CSRCS += stm32_ina219.c
endif
ifeq ($(CONFIG_TIMER),y)
CSRCS += stm32_timer.c
endif
include $(TOPDIR)/configs/Board.mk

View File

@ -233,13 +233,13 @@ int stm32_bringup(void);
void weak_function stm32_usbinitialize(void);
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_adc_setup
*
* Description:
* Initialize ADC and register the ADC driver.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_ADC
int stm32_adc_setup(void);
@ -269,7 +269,7 @@ int stm32_sdio_initialize(void);
int stm32_can_setup(void);
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_bmp180initialize
*
* Description:
@ -281,13 +281,13 @@ int stm32_can_setup(void);
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
int stm32_bmp180initialize(FAR const char *devpath);
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_dac_setup
*
* Description:
@ -299,13 +299,13 @@ int stm32_bmp180initialize(FAR const char *devpath);
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_DAC)
int stm32_dac_setup(void);
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_ina219initialize
*
* Description:
@ -317,11 +317,32 @@ int stm32_dac_setup(void);
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_INA219)
int stm32_ina219initialize(FAR const char *devpath);
#endif
/****************************************************************************
* Name: stm32_timer_driver_setup
*
* Description:
* Configure the timer driver.
*
* Input Parameters:
* devpath - The full path to the timer device. This should be of the
* form /dev/timer0
* timer - The timer's number.
*
* Returned Values:
* Zero (OK) is returned on success; A negated errno value is returned
* to indicate the nature of any failure.
*
****************************************************************************/
#ifdef CONFIG_TIMER
int stm32_timer_driver_setup(FAR const char *devpath, int timer);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_OLIMEX_STM32_E407_SRC_INTERNAL_H */

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/olimex-stm32-e407/src/stm32_adc.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -52,11 +52,12 @@
#ifdef CONFIG_ADC
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
/* Configuration ************************************************************/
/* Configuration ********************************************************************/
/* Up to 3 ADC interfaces are supported */
#if STM32_NADC < 3
@ -80,9 +81,10 @@
#define ADC1_NCHANNELS 1//14
/************************************************************************************
/****************************************************************************
* Private Data
************************************************************************************/
****************************************************************************/
/* The Olimex STM32-P405 has a 10 Kohm potentiometer AN_TR connected to PC0
* ADC123_IN10
*/
@ -105,21 +107,17 @@ static const uint8_t g_chanlist[ADC1_NCHANNELS] = {1};
static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN1};
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: stm32_adc_setup
*
* Description:
* Initialize ADC and register the ADC driver.
*
************************************************************************************/
****************************************************************************/
int stm32_adc_setup(void)
{
@ -171,3 +169,4 @@ int stm32_adc_setup(void)
#endif /* CONFIG_STM32_ADC1 || CONFIG_STM32_ADC2 || CONFIG_STM32_ADC3 */
#endif /* CONFIG_ADC */

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/olimex-stm32-e407/src/stm32_bmp180.c
*
* Copyright (C) 2019 Acutronics Robotics. All rights reserved.
@ -32,11 +32,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -52,17 +52,17 @@
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
#define BMP180_I2C_PORTNO 1 /* On I2C1 */
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: stm32_bmp180initialize
*
* Description:
@ -74,7 +74,7 @@
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
************************************************************************************/
****************************************************************************/
int stm32_bmp180initialize(FAR const char *devpath)
{
@ -104,3 +104,4 @@ int stm32_bmp180initialize(FAR const char *devpath)
}
#endif /* CONFIG_I2C && CONFIG_SENSORS_BMP180 && CONFIG_STM32_I2C1 */

View File

@ -249,6 +249,20 @@ int stm32_bringup(void)
}
#endif
#if defined(CONFIG_TIMER)
/*Initialize the timer, at this moment it's only Timer 1,2,3*/
#if defined(CONFIG_STM32_TIM1)
stm32_timer_driver_setup("/dev/timer1", 1);
#endif
#if defined(CONFIG_STM32_TIM2)
stm32_timer_driver_setup("/dev/timer2", 2);
#endif
#if defined(CONFIG_STM32_TIM3)
stm32_timer_driver_setup("/dev/timer3", 3);
#endif
#endif
UNUSED(ret);
return OK;
}

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/olimex-stm32-405/src/stm32_can.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -51,10 +51,11 @@
#ifdef CONFIG_CAN
/************************************************************************************
/*****************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration ********************************************************************/
****************************************************************************/
/* Configuration ************************************************************/
#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2)
# warning "Both CAN1 and CAN2 are enabled. Only CAN1 is used."
@ -67,9 +68,9 @@
# define CAN_PORT 2
#endif
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/****************************************************************************
* Name: stm32_can_setup

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/olimex-stm32-e407/src/stm32_ina219.c
*
* Copyright (C) 2018 Erle Robotics (Juan Flores Muñoz). All rights reserved.
@ -32,11 +32,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -52,17 +52,17 @@
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_INA219)
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
#define INA219_I2C_PORTNO 1 /* On I2C1 */
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: stm32_ina219initialize
*
* Description:
@ -74,7 +74,7 @@
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
************************************************************************************/
****************************************************************************/
int stm32_ina219initialize(FAR const char *devpath)
{

View File

@ -0,0 +1,78 @@
/****************************************************************************
* config/olimex-stm32-e407/src/stm32_timer.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Modified by: Acutronics Robotics (Juan Flores) <juan@erlerobotics.com>
*
* 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 <nuttx/timers/timer.h>
#include <debug.h>
#include "stm32_tim.h"
#include "olimex-stm32-e407.h"
#ifdef CONFIG_TIMER
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_timer_driver_setup
*
* Description:
* Configure the timer driver.
*
* Input Parameters:
* devpath - The full path to the timer device. This should be of the
* form /dev/timer0
* timer - The timer's number.
*
* Returned Values:
* Zero (OK) is returned on success; A negated errno value is returned
* to indicate the nature of any failure.
*
****************************************************************************/
int stm32_timer_driver_setup(FAR const char *devpath, int timer)
{
return stm32_timer_initialize(devpath, timer);
}
#endif

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/stm32f4discovery/src/stm32_usb.c
*
* Copyright (C) 2012-2013, 2015-2017 Gregory Nutt. All rights reserved.
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -59,9 +59,9 @@
#ifdef CONFIG_STM32_OTGFS
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_USBDEV) || defined(CONFIG_USBHOST)
# define HAVE_USB 1
@ -78,25 +78,25 @@
# define CONFIG_STM32F4DISCO_USBHOST_STACKSIZE 1024
#endif
/************************************************************************************
/****************************************************************************
* Private Data
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBHOST
static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
/****************************************************************************
* Private Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: usbhost_waiter
*
* Description:
* Wait for USB devices to be connected.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
@ -127,18 +127,18 @@ static int usbhost_waiter(int argc, char *argv[])
}
#endif
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: stm32_usbinitialize
*
* Description:
* Called from stm32_usbinitialize very early in inialization to setup USB-related
* GPIO pins for the STM32F4Discovery board.
* Called from stm32_usbinitialize very early in inialization to setup
* USB-related GPIO pins for the STM32F4Discovery board.
*
************************************************************************************/
****************************************************************************/
void stm32_usbinitialize(void)
{
@ -153,15 +153,15 @@ void stm32_usbinitialize(void)
#endif
}
/***********************************************************************************
/***************************************************************************
* Name: stm32_usbhost_initialize
*
* Description:
* Called at application startup time to initialize the USB host functionality.
* This function will start a thread that will monitor for device
*nnnn connection/disconnection events.
* Called at application startup time to initialize the USB host
* functionality. This function will start a thread that will monitor
* for device connection/disconnection events.
*
***********************************************************************************/
***************************************************************************/
#ifdef CONFIG_USBHOST
int stm32_usbhost_initialize(void)
@ -248,31 +248,34 @@ int stm32_usbhost_initialize(void)
}
#endif
/***********************************************************************************
/****************************************************************************
* Name: stm32_usbhost_vbusdrive
*
* Description:
* Enable/disable driving of VBUS 5V output. This function must be provided be
* each platform that implements the STM32 OTG FS host interface
* Enable/disable driving of VBUS 5V output. This function must be
* provided be each platform that implements the STM32 OTG FS host
* interface
*
* "On-chip 5 V VBUS generation is not supported. For this reason, a charge pump
* or, if 5 V are available on the application board, a basic power switch, must
* be added externally to drive the 5 V VBUS line. The external charge pump can
* be driven by any GPIO output. When the application decides to power on VBUS
* using the chosen GPIO, it must also set the port power bit in the host port
* control and status register (PPWR bit in OTG_FS_HPRT).
* "On-chip 5 V VBUS generation is not supported. For this reason, a
* charge pump or, if 5 V are available on the application board, a
* basic power switch, must be added externally to drive the 5 V VBUS
* line. The external charge pump can be driven by any GPIO output.
* When the application decides to power on VBUS using the chosen GPIO,
* it must also set the port power bit in the host port control and
* status register (PPWR bit in OTG_FS_HPRT).
*
* "The application uses this field to control power to this port, and the core
* clears this bit on an overcurrent condition."
* "The application uses this field to control power to this port, andi
* the core clears this bit on an overcurrent condition."
*
* Input Parameters:
* iface - For future growth to handle multiple USB host interface. Should be zero.
* iface - For future growth to handle multiple USB host interface.
* Should be zero.
* enable - true: enable VBUS power; false: disable VBUS power
*
* Returned Value:
* None
*
***********************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBHOST
void stm32_usbhost_vbusdrive(int iface, bool enable)
@ -294,22 +297,22 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
}
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_setup_overcurrent
*
* Description:
* Setup to receive an interrupt-level callback if an overcurrent condition is
* detected.
* Setup to receive an interrupt-level callback if an overcurrent
* condition is detected.
*
* Input Parameters:
* handler - New overcurrent interrupt handler
* arg - The argument provided for the interrupt handler
*
* Returned Value:
* Zero (OK) is returned on success. Otherwise, a negated errno value is returned
* to indicate the nature of the failure.
* Zero (OK) is returned on success. Otherwise, a negated errno value is
* returned to indicate the nature of the failure.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBHOST
int stm32_setup_overcurrent(xcpt_t handler, void *arg)
@ -318,16 +321,16 @@ int stm32_setup_overcurrent(xcpt_t handler, void *arg)
}
#endif
/************************************************************************************
/****************************************************************************
* Name: stm32_usbsuspend
*
* Description:
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is
* used. This function is called whenever the USB enters or leaves suspend mode.
* This is an opportunity for the board logic to shutdown clocks, power, etc.
* while the USB is suspended.
* Board logic must provide the stm32_usbsuspend logic if the USBDEV
* driver is used. This function is called whenever the USB enters or
* leaves suspend mode. This is an opportunity for the board logic to
* shutdown clocks, power, etc. while the USB is suspended.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBDEV
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
@ -337,3 +340,4 @@ void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
#endif
#endif /* CONFIG_STM32_OTGFS */

View File

@ -0,0 +1,62 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_ARCH_FPU is not set
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="olimex-stm32-e407"
CONFIG_ARCH_BOARD_OLIMEX_STM32E407=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP_STM32=y
CONFIG_ARCH_CHIP_STM32F407ZG=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=114688
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32_JTAG_SW_ENABLE=y
CONFIG_STM32_OTGFS=y
CONFIG_STM32_PWR=y
CONFIG_STM32_TIM1=y
CONFIG_STM32_USART3=y
CONFIG_SYSTEM_NSH=y
CONFIG_TIMER=y
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_TXBUFSIZE=128
CONFIG_USBDEV=y
CONFIG_USER_ENTRYPOINT="nsh_main"