PX4 Firmware
PX4 Autopilot Software http://px4.io
|
PWM input driver based on earlier driver from Evan Slatyer, which in turn was based on drv_hrt.c. More...
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/time.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <sys/types.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <time.h>
#include <queue.h>
#include <errno.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <board_config.h>
#include <drivers/drv_pwm_input.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_range_finder.h>
#include "chip.h"
#include "up_internal.h"
#include "up_arch.h"
#include "stm32_gpio.h"
#include "stm32_tim.h"
#include <systemlib/err.h>
#include <uORB/uORB.h>
#include <uORB/topics/pwm_input.h>
#include <drivers/drv_device.h>
#include <drivers/device/device.h>
#include <drivers/device/ringbuffer.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "timer_registers.h"
Go to the source code of this file.
Classes | |
class | PWMIN |
Macros | |
#define | GPIO_VDD_RANGEFINDER_EN GPIO_GPIO5_OUTPUT |
#define | INPUT_TIMER PWMIN_TIMER |
#define | PWMIN_TIMER_BASE TIMER_BASE |
#define | PWMIN_TIMER_CLOCK TIMER_CLOCK |
#define | PWMIN_TIMER_POWER_REG TIMER_CLOCK_POWER_REG |
#define | PWMIN_TIMER_POWER_BIT TIMER_CLOCK_POWER_BIT |
#define | PWMIN_TIMER_VECTOR TIMER_IRQ_REG |
#define | REG(_reg) (*(volatile uint32_t *)(PWMIN_TIMER_BASE + _reg)) |
#define | rCR1 REG(STM32_GTIM_CR1_OFFSET) |
#define | rCR2 REG(STM32_GTIM_CR2_OFFSET) |
#define | rSMCR REG(STM32_GTIM_SMCR_OFFSET) |
#define | rDIER REG(STM32_GTIM_DIER_OFFSET) |
#define | rSR REG(STM32_GTIM_SR_OFFSET) |
#define | rEGR REG(STM32_GTIM_EGR_OFFSET) |
#define | rCCMR1 REG(STM32_GTIM_CCMR1_OFFSET) |
#define | rCCMR2 REG(STM32_GTIM_CCMR2_OFFSET) |
#define | rCCER REG(STM32_GTIM_CCER_OFFSET) |
#define | rCNT REG(STM32_GTIM_CNT_OFFSET) |
#define | rPSC REG(STM32_GTIM_PSC_OFFSET) |
#define | rARR REG(STM32_GTIM_ARR_OFFSET) |
#define | rCCR1 REG(STM32_GTIM_CCR1_OFFSET) |
#define | rCCR2 REG(STM32_GTIM_CCR2_OFFSET) |
#define | rCCR3 REG(STM32_GTIM_CCR3_OFFSET) |
#define | rCCR4 REG(STM32_GTIM_CCR4_OFFSET) |
#define | rDCR REG(STM32_GTIM_DCR_OFFSET) |
#define | rDMAR REG(STM32_GTIM_DMAR_OFFSET) |
#define | TIMEOUT_POLL 300000 /* reset after no response over this time in microseconds [0.3s] */ |
#define | TIMEOUT_READ 200000 /* don't reset if the last read is back more than this time in microseconds [0.2s] */ |
Functions | |
static int | pwmin_tim_isr (int irq, void *context, void *arg) |
static void | pwmin_start () |
static void | pwmin_info (void) |
static void | pwmin_test (void) |
static void | pwmin_reset (void) |
static void | pwmin_usage (void) |
int | pwm_input_main (int argc, char *argv[]) |
Variables | |
static PWMIN * | g_dev |
PWM input driver based on earlier driver from Evan Slatyer, which in turn was based on drv_hrt.c.
Definition in file pwm_input.cpp.
#define GPIO_VDD_RANGEFINDER_EN GPIO_GPIO5_OUTPUT |
Definition at line 87 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init(), PWMIN::_turn_off(), and PWMIN::_turn_on().
#define INPUT_TIMER PWMIN_TIMER |
Definition at line 98 of file pwm_input.cpp.
#define PWMIN_TIMER_BASE TIMER_BASE |
Definition at line 100 of file pwm_input.cpp.
#define PWMIN_TIMER_CLOCK TIMER_CLOCK |
Definition at line 101 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define PWMIN_TIMER_POWER_BIT TIMER_CLOCK_POWER_BIT |
Definition at line 103 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define PWMIN_TIMER_POWER_REG TIMER_CLOCK_POWER_REG |
Definition at line 102 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define PWMIN_TIMER_VECTOR TIMER_IRQ_REG |
Definition at line 104 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rARR REG(STM32_GTIM_ARR_OFFSET) |
Definition at line 129 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rCCER REG(STM32_GTIM_CCER_OFFSET) |
Definition at line 126 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rCCMR1 REG(STM32_GTIM_CCMR1_OFFSET) |
Definition at line 124 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rCCMR2 REG(STM32_GTIM_CCMR2_OFFSET) |
Definition at line 125 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rCCR1 REG(STM32_GTIM_CCR1_OFFSET) |
Definition at line 130 of file pwm_input.cpp.
#define rCCR2 REG(STM32_GTIM_CCR2_OFFSET) |
Definition at line 131 of file pwm_input.cpp.
#define rCCR3 REG(STM32_GTIM_CCR3_OFFSET) |
Definition at line 132 of file pwm_input.cpp.
#define rCCR4 REG(STM32_GTIM_CCR4_OFFSET) |
Definition at line 133 of file pwm_input.cpp.
#define rCNT REG(STM32_GTIM_CNT_OFFSET) |
Definition at line 127 of file pwm_input.cpp.
#define rCR1 REG(STM32_GTIM_CR1_OFFSET) |
Definition at line 118 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rCR2 REG(STM32_GTIM_CR2_OFFSET) |
Definition at line 119 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rDCR REG(STM32_GTIM_DCR_OFFSET) |
Definition at line 134 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rDIER REG(STM32_GTIM_DIER_OFFSET) |
Definition at line 121 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rDMAR REG(STM32_GTIM_DMAR_OFFSET) |
Definition at line 135 of file pwm_input.cpp.
#define REG | ( | _reg | ) | (*(volatile uint32_t *)(PWMIN_TIMER_BASE + _reg)) |
Definition at line 116 of file pwm_input.cpp.
#define rEGR REG(STM32_GTIM_EGR_OFFSET) |
Definition at line 123 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rPSC REG(STM32_GTIM_PSC_OFFSET) |
Definition at line 128 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rSMCR REG(STM32_GTIM_SMCR_OFFSET) |
Definition at line 120 of file pwm_input.cpp.
Referenced by PWMIN::_timer_init().
#define rSR REG(STM32_GTIM_SR_OFFSET) |
Definition at line 122 of file pwm_input.cpp.
Referenced by pwmin_tim_isr().
#define TIMEOUT_POLL 300000 /* reset after no response over this time in microseconds [0.3s] */ |
Definition at line 170 of file pwm_input.cpp.
Referenced by PWMIN::_freeze_test(), and PWMIN::init().
#define TIMEOUT_READ 200000 /* don't reset if the last read is back more than this time in microseconds [0.2s] */ |
Definition at line 171 of file pwm_input.cpp.
Referenced by PWMIN::_freeze_test().
int pwm_input_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 585 of file pwm_input.cpp.
References pwmin_info(), pwmin_reset(), pwmin_start(), pwmin_test(), and pwmin_usage().
|
static |
Definition at line 566 of file pwm_input.cpp.
References PWMIN::print_info().
Referenced by pwm_input_main().
|
static |
Definition at line 546 of file pwm_input.cpp.
References cdev::CDev::close(), errx, fd, PWMIN::hard_reset(), PWMIN::ioctl(), OK, PWMIN::open(), PWMIN0_DEVICE_PATH, and SENSORIOCRESET.
Referenced by pwm_input_main().
|
static |
Definition at line 490 of file pwm_input.cpp.
References errx, PWMIN::init(), OK, and PWMIN::PWMIN().
Referenced by pwm_input_main().
|
static |
Definition at line 512 of file pwm_input.cpp.
References cdev::CDev::close(), pwm_input_s::error_count, errx, fd, hrt_absolute_time(), PWMIN::open(), pwm_input_s::period, pwm_input_s::pulse_width, PWMIN0_DEVICE_PATH, and PWMIN::read().
Referenced by pwm_input_main().
|
static |
Definition at line 471 of file pwm_input.cpp.
References OK, pwm_input_s::period, PWMIN::publish(), pwm_input_s::pulse_width, rSR, and status.
Referenced by PWMIN::_timer_init().
|
static |
Definition at line 577 of file pwm_input.cpp.
Referenced by pwm_input_main().
|
static |
Definition at line 216 of file pwm_input.cpp.