aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/drv_pwm_output.h
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-10-23 21:43:41 -0700
committerpx4dev <px4@purgatory.org>2012-10-23 23:51:13 -0700
commit3d79b9a0b057ed9bf41329ce052d0b4152cd0a1a (patch)
treea477c4ef7c88e7a6a2402207070af3160080fcf6 /apps/drivers/drv_pwm_output.h
parentc3fe915b44a1b32f05b182b3079c722b82b20fb9 (diff)
downloadpx4-firmware-3d79b9a0b057ed9bf41329ce052d0b4152cd0a1a.tar.gz
px4-firmware-3d79b9a0b057ed9bf41329ce052d0b4152cd0a1a.tar.bz2
px4-firmware-3d79b9a0b057ed9bf41329ce052d0b4152cd0a1a.zip
Tease the PWM driver out and fix some build issues after cleaning up behind the cpuload pieces.
Diffstat (limited to 'apps/drivers/drv_pwm_output.h')
-rw-r--r--apps/drivers/drv_pwm_output.h66
1 files changed, 63 insertions, 3 deletions
diff --git a/apps/drivers/drv_pwm_output.h b/apps/drivers/drv_pwm_output.h
index 340175a4b..fc458e9b0 100644
--- a/apps/drivers/drv_pwm_output.h
+++ b/apps/drivers/drv_pwm_output.h
@@ -41,14 +41,15 @@
* channel.
*/
-#ifndef _DRV_PWM_OUTPUT_H
-#define _DRV_PWM_OUTPUT_H
+#pragma once
#include <stdint.h>
#include <sys/ioctl.h>
#include "drv_orb_dev.h"
+__BEGIN_DECLS
+
/**
* Path for the default PWM output device.
*
@@ -109,4 +110,63 @@ ORB_DECLARE(output_pwm);
#define PWM_SERVO_GET(_servo) _IOC(_PWM_SERVO_BASE, 0x40 + _servo)
-#endif /* _DRV_PWM_OUTPUT_H */
+/*
+ * Low-level PWM output interface.
+ *
+ * This is the low-level API to the platform-specific PWM driver.
+ */
+
+/**
+ * Intialise the PWM servo outputs using the specified configuration.
+ *
+ * @param channel_mask Bitmask of channels (LSB = channel 0) to enable.
+ * This allows some of the channels to remain configured
+ * as GPIOs or as another function.
+ * @return OK on success.
+ */
+__EXPORT extern int up_pwm_servo_init(uint32_t channel_mask);
+
+/**
+ * De-initialise the PWM servo outputs.
+ */
+__EXPORT extern void up_pwm_servo_deinit(void);
+
+/**
+ * Arm or disarm servo outputs.
+ *
+ * When disarmed, servos output no pulse.
+ *
+ * @bug This function should, but does not, guarantee that any pulse
+ * currently in progress is cleanly completed.
+ *
+ * @param armed If true, outputs are armed; if false they
+ * are disarmed.
+ */
+__EXPORT extern void up_pwm_servo_arm(bool armed);
+
+/**
+ * Set the servo update rate
+ *
+ * @param rate The update rate in Hz to set.
+ * @return OK on success, -ERANGE if an unsupported update rate is set.
+ */
+__EXPORT extern int up_pwm_servo_set_rate(unsigned rate);
+
+/**
+ * Set the current output value for a channel.
+ *
+ * @param channel The channel to set.
+ * @param value The output pulse width in microseconds.
+ */
+__EXPORT extern int up_pwm_servo_set(unsigned channel, servo_position_t value);
+
+/**
+ * Get the current output value for a channel.
+ *
+ * @param channel The channel to read.
+ * @return The output pulse width in microseconds, or zero if
+ * outputs are not armed or not configured.
+ */
+__EXPORT extern servo_position_t up_pwm_servo_get(unsigned channel);
+
+__END_DECLS