Merge branch 'master' of bitbucket.org:nuttx/nuttx

This commit is contained in:
Gregory Nutt 2016-11-18 09:30:40 -06:00
commit cdbc66addd
7 changed files with 120 additions and 6 deletions

View File

@ -206,12 +206,15 @@
* Default is to use timer 5 (32-bit) and encoder on PA0/PA1
*/
#define GPIO_TIM5_CH1IN GPIO_TIM5_CH1IN_1
#define GPIO_TIM5_CH2IN GPIO_TIM5_CH2IN_1
#define GPIO_TIM2_CH1IN GPIO_TIM2_CH1IN_1
#define GPIO_TIM2_CH2IN GPIO_TIM2_CH2IN_1
#define GPIO_TIM3_CH1IN GPIO_TIM3_CH1IN_3
#define GPIO_TIM3_CH2IN GPIO_TIM3_CH2IN_3
#define GPIO_TIM5_CH1IN GPIO_TIM5_CH1IN_1
#define GPIO_TIM5_CH2IN GPIO_TIM5_CH2IN_1
/* PWM output for full bridge, uses config 1, because port E is N/A on QFP64
* CH1 | 1(A8) 2(E9)
* CH2 | 1(A9) 2(E11)

View File

@ -70,6 +70,10 @@ ifeq ($(CONFIG_PWM),y)
CSRCS += stm32_pwm.c
endif
ifeq ($(CONFIG_TIMER),y)
CSRCS += stm32_timer.c
endif
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += stm32_appinit.c
endif

View File

@ -351,4 +351,16 @@ int board_adc_initialize(void);
int board_ajoy_initialize(void);
#endif
/****************************************************************************
* Name: board_timer_driver_initialize
*
* Description:
* Initialize and register a timer
*
****************************************************************************/
#ifdef CONFIG_TIMER
int board_timer_driver_initialize(FAR const char *devpath, int timer);
#endif
#endif /* __CONFIGS_NUCLEO_L476RG_SRC_NUCLEO_L476RG_H */

View File

@ -205,6 +205,19 @@ int board_app_initialize(uintptr_t arg)
}
#endif
#ifdef CONFIG_TIMER
/* Initialize and register the timer driver */
ret = board_timer_driver_initialize("/dev/timer0", 2);
if (ret != OK)
{
syslog(LOG_ERR,
"ERROR: Failed to register the timer driver: %d\n",
ret);
return ret;
}
#endif
return OK;
}

View File

@ -0,0 +1,82 @@
/****************************************************************************
* config/nucleo-l476rg/src/stm32_timer.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Copied from nucleo-f303 by Sebastien Lorquet
*
* 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 "stm32l4_tim.h"
#include "nucleo-l476rg.h"
#ifdef CONFIG_TIMER
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_timer_driver_initialize
*
* 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 board_timer_driver_initialize(FAR const char *devpath, int timer)
{
return stm32l4_timer_initialize(devpath, timer);
}
#endif

View File

@ -131,7 +131,6 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value;
#endif
int ret;
DEBUGASSERT(upper != NULL);
@ -139,9 +138,9 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
#ifdef CONFIG_CAN_PASS_STRUCTS
value.sival_ptr = upper->arg;
ret = sigqueue(upper->pid, upper->signo, value);
(void)sigqueue(upper->pid, upper->signo, value);
#else
ret = sigqueue(upper->pid, upper->signo, upper->arg);
(void)sigqueue(upper->pid, upper->signo, upper->arg);
#endif
return true;

View File

@ -46,6 +46,7 @@
#include <nuttx/irq.h>
#include <nuttx/fs/ioctl.h>
#include <stdbool.h>
#include <sys/types.h>
#ifdef CONFIG_TIMER