mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Merge branch 'master' of bitbucket.org:nuttx/nuttx
This commit is contained in:
@@ -206,12 +206,15 @@
|
|||||||
* Default is to use timer 5 (32-bit) and encoder on PA0/PA1
|
* 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_CH1IN GPIO_TIM2_CH1IN_1
|
||||||
#define GPIO_TIM2_CH2IN GPIO_TIM2_CH2IN_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
|
/* PWM output for full bridge, uses config 1, because port E is N/A on QFP64
|
||||||
* CH1 | 1(A8) 2(E9)
|
* CH1 | 1(A8) 2(E9)
|
||||||
* CH2 | 1(A9) 2(E11)
|
* CH2 | 1(A9) 2(E11)
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_TIMER),y)
|
||||||
|
CSRCS += stm32_timer.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||||
CSRCS += stm32_appinit.c
|
CSRCS += stm32_appinit.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -351,4 +351,16 @@ int board_adc_initialize(void);
|
|||||||
int board_ajoy_initialize(void);
|
int board_ajoy_initialize(void);
|
||||||
#endif
|
#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 */
|
#endif /* __CONFIGS_NUCLEO_L476RG_SRC_NUCLEO_L476RG_H */
|
||||||
|
|||||||
@@ -205,6 +205,19 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -131,7 +131,6 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
|
||||||
|
|
||||||
DEBUGASSERT(upper != NULL);
|
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
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
value.sival_ptr = upper->arg;
|
value.sival_ptr = upper->arg;
|
||||||
ret = sigqueue(upper->pid, upper->signo, value);
|
(void)sigqueue(upper->pid, upper->signo, value);
|
||||||
#else
|
#else
|
||||||
ret = sigqueue(upper->pid, upper->signo, upper->arg);
|
(void)sigqueue(upper->pid, upper->signo, upper->arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef CONFIG_TIMER
|
#ifdef CONFIG_TIMER
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user