39 #include <px4_platform_common/log.h> 47 PX4_WARN(
"number of outputs too large. Setting to %i",
MAX_NUM_PWM);
73 ::snprintf(path,
sizeof(path),
"%s/export",
_device);
76 PX4_ERR(
"PWM export failed");
81 ::snprintf(path,
sizeof(path),
"%s/pwm%u/enable",
_device, i);
84 PX4_ERR(
"PWM enable failed");
89 ::snprintf(path,
sizeof(path),
"%s/pwm%u/period",
_device, i);
92 PX4_ERR(
"PWM period failed");
97 ::snprintf(path,
sizeof(path),
"%s/pwm%u/duty_cycle",
_device, i);
98 _pwm_fd[i] = ::open(path, O_WRONLY | O_CLOEXEC);
101 PX4_ERR(
"PWM: Failed to open duty_cycle.");
120 for (
int i = 0; i < num_outputs; ++i) {
121 int n = ::snprintf(data,
sizeof(data),
"%u", pwm[i] * 1000);
124 if (n != write_ret) {
134 int fd = ::open(path, O_WRONLY | O_CLOEXEC);
142 n = ::snprintf(data,
sizeof(data),
"%u", value);
int pwm_write_sysfs(char *path, int value)
Namespace encapsulating all device framework classes, functions and data.
int send_output_pwm(const uint16_t *pwm, int num_outputs) override
virtual ~NavioSysfsPWMOut()
static const int FREQUENCY_PWM
static void write(bootloader_app_shared_t *pshared)
static const int MAX_NUM_PWM
NavioSysfsPWMOut(const char *device, int max_num_outputs)