PX4 Firmware
PX4 Autopilot Software http://px4.io
PWMIN Class Reference
Inheritance diagram for PWMIN:
Collaboration diagram for PWMIN:

Public Member Functions

 PWMIN ()
 
virtual ~PWMIN ()
 
virtual int init ()
 
virtual int open (struct file *filp)
 
virtual ssize_t read (struct file *filp, char *buffer, size_t buflen)
 
virtual int ioctl (struct file *filp, int cmd, unsigned long arg)
 
void publish (uint16_t status, uint32_t period, uint32_t pulse_width)
 
void print_info (void)
 
void hard_reset ()
 

Private Member Functions

void _timer_init (void)
 
void _turn_on ()
 
void _turn_off ()
 
void _freeze_test ()
 
- Private Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
 CDev (const CDev &)=delete
 
CDevoperator= (const CDev &)=delete
 
 CDev (CDev &&)=delete
 
CDevoperator= (CDev &&)=delete
 
virtual ~CDev ()
 
virtual int open (file_t *filep)
 Handle an open of the device. More...
 
virtual int close (file_t *filep)
 Handle a close of the device. More...
 
virtual ssize_t read (file_t *filep, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual ssize_t write (file_t *filep, const char *buffer, size_t buflen)
 Perform a write to the device. More...
 
virtual off_t seek (file_t *filep, off_t offset, int whence)
 Perform a logical seek operation on the device. More...
 
virtual int ioctl (file_t *filep, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
virtual int poll (file_t *filep, px4_pollfd_struct_t *fds, bool setup)
 Perform a poll setup/teardown operation. More...
 
const char * get_devname () const
 Get the device name. More...
 
virtual pollevent_t poll_state (file_t *filep)
 Check the current state of the device for poll events from the perspective of the file. More...
 
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events)
 Internal implementation of poll_notify. More...
 
virtual int open_first (file_t *filep)
 Notification of the first open. More...
 
virtual int close_last (file_t *filep)
 Notification of the last close. More...
 
virtual int register_class_devname (const char *class_devname)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
virtual int unregister_class_devname (const char *class_devname, unsigned class_instance)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
void lock ()
 Take the driver lock. More...
 
void unlock ()
 Release the driver lock. More...
 
int unregister_driver_and_memory ()
 First, unregisters the driver. More...
 

Private Attributes

uint32_t _error_count
 
uint32_t _pulses_captured
 
uint32_t _last_period
 
uint32_t _last_width
 
hrt_abstime _last_poll_time
 
hrt_abstime _last_read_time
 
ringbuffer::RingBuffer * _reports
 
bool _timer_started
 
hrt_call _hard_reset_call
 
hrt_call _freeze_test_call
 
- Private Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Additional Inherited Members

- Static Private Attributes inherited from cdev::CDev
static const px4_file_operations_t fops = {}
 Pointer to the default cdev file operations table; useful for registering clone devices etc. More...
 

Detailed Description

Definition at line 173 of file pwm_input.cpp.

Constructor & Destructor Documentation

◆ PWMIN()

PWMIN::PWMIN ( )

Definition at line 218 of file pwm_input.cpp.

Referenced by pwmin_start().

Here is the caller graph for this function:

◆ ~PWMIN()

PWMIN::~PWMIN ( )
virtual

Definition at line 229 of file pwm_input.cpp.

References _reports.

Member Function Documentation

◆ _freeze_test()

void PWMIN::_freeze_test ( )
private

Definition at line 327 of file pwm_input.cpp.

References _last_poll_time, _last_read_time, hard_reset(), hrt_elapsed_time(), TIMEOUT_POLL, and TIMEOUT_READ.

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _timer_init()

void PWMIN::_timer_init ( void  )
private

Definition at line 264 of file pwm_input.cpp.

References _timer_started, GPIO_VDD_RANGEFINDER_EN, pwmin_tim_isr(), PWMIN_TIMER_CLOCK, PWMIN_TIMER_POWER_BIT, PWMIN_TIMER_POWER_REG, PWMIN_TIMER_VECTOR, rARR, rCCER, rCCMR1, rCCMR2, rCR1, rCR2, rDCR, rDIER, rEGR, rPSC, and rSMCR.

Referenced by ioctl(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _turn_off()

void PWMIN::_turn_off ( )
private

Definition at line 344 of file pwm_input.cpp.

References GPIO_VDD_RANGEFINDER_EN.

Referenced by hard_reset().

Here is the caller graph for this function:

◆ _turn_on()

void PWMIN::_turn_on ( )
private

Definition at line 337 of file pwm_input.cpp.

References GPIO_VDD_RANGEFINDER_EN.

Referenced by hard_reset().

Here is the caller graph for this function:

◆ hard_reset()

void PWMIN::hard_reset ( )

Definition at line 351 of file pwm_input.cpp.

References _hard_reset_call, _turn_off(), _turn_on(), and hrt_call_after().

Referenced by _freeze_test(), ioctl(), and pwmin_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

int PWMIN::init ( )
virtual

Reimplemented from cdev::CDev.

Definition at line 243 of file pwm_input.cpp.

References _freeze_test(), _freeze_test_call, _reports, hrt_call_every(), ToneAlarmInterface::init(), OK, and TIMEOUT_POLL.

Referenced by pwmin_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ioctl()

int PWMIN::ioctl ( struct file filp,
int  cmd,
unsigned long  arg 
)
virtual

Definition at line 382 of file pwm_input.cpp.

References _timer_init(), hard_reset(), OK, and SENSORIOCRESET.

Referenced by pwmin_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

int PWMIN::open ( struct file filp)
virtual

Definition at line 362 of file pwm_input.cpp.

References _timer_init(), _timer_started, and OK.

Referenced by pwmin_reset(), and pwmin_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_info()

void PWMIN::print_info ( void  )

Definition at line 454 of file pwm_input.cpp.

References _last_period, _last_width, _pulses_captured, and _timer_started.

Referenced by pwmin_info().

Here is the caller graph for this function:

◆ publish()

void PWMIN::publish ( uint16_t  status,
uint32_t  period,
uint32_t  pulse_width 
)

Definition at line 432 of file pwm_input.cpp.

References _error_count, _last_poll_time, _reports, pwm_input_s::error_count, hrt_absolute_time(), pwm_input_s::period, pwm_input_s::pulse_width, and pwm_input_s::timestamp.

Referenced by pwmin_tim_isr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

ssize_t PWMIN::read ( struct file filp,
char *  buffer,
size_t  buflen 
)
virtual

Definition at line 405 of file pwm_input.cpp.

References _last_read_time, _reports, and hrt_absolute_time().

Referenced by pwmin_test().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _error_count

uint32_t PWMIN::_error_count
private

Definition at line 189 of file pwm_input.cpp.

Referenced by publish().

◆ _freeze_test_call

hrt_call PWMIN::_freeze_test_call
private

Definition at line 199 of file pwm_input.cpp.

Referenced by init().

◆ _hard_reset_call

hrt_call PWMIN::_hard_reset_call
private

Definition at line 198 of file pwm_input.cpp.

Referenced by hard_reset().

◆ _last_period

uint32_t PWMIN::_last_period
private

Definition at line 191 of file pwm_input.cpp.

Referenced by print_info().

◆ _last_poll_time

hrt_abstime PWMIN::_last_poll_time
private

Definition at line 193 of file pwm_input.cpp.

Referenced by _freeze_test(), and publish().

◆ _last_read_time

hrt_abstime PWMIN::_last_read_time
private

Definition at line 194 of file pwm_input.cpp.

Referenced by _freeze_test(), and read().

◆ _last_width

uint32_t PWMIN::_last_width
private

Definition at line 192 of file pwm_input.cpp.

Referenced by print_info().

◆ _pulses_captured

uint32_t PWMIN::_pulses_captured
private

Definition at line 190 of file pwm_input.cpp.

Referenced by print_info().

◆ _reports

ringbuffer::RingBuffer* PWMIN::_reports
private

Definition at line 195 of file pwm_input.cpp.

Referenced by init(), publish(), read(), and ~PWMIN().

◆ _timer_started

bool PWMIN::_timer_started
private

Definition at line 196 of file pwm_input.cpp.

Referenced by _timer_init(), open(), and print_info().


The documentation for this class was generated from the following file: