|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
38 #define PWM_SYSFS_DEFAULT_PERIOD 10000000
42 #define PS_DEBUG_PRINT printf
44 #define PS_DEBUG_PRINT(...) {}
48 static int write_file(
const char *path,
const char *fmt, ...);
50 static int read_file(
const char *path,
const char *fmt, ...) __attribute__((unused));
53 char *_export,
char *_enable,
54 char *_duty,
char *_period,
60 if (base_path == NULL || _export == NULL || _enable == NULL ||
61 _period == NULL || _duty == NULL) {
73 export_path,
pwm->enable_path,
pwm->duty_path,
pwm->period_path);
78 pwm->duty_cycle_fd = open(
pwm->duty_path, O_RDWR | O_CLOEXEC);
79 if (
pwm->duty_cycle_fd < 0) {
98 pwm->period_nsec = period;
103 if (dprintf(
pwm->duty_cycle_fd,
"%u", duty) < 0) {
107 pwm->duty_cycle_nsec = duty;
116 int en = enable ? 1 : 0;
123 pwm->enabled = enable;
127 static int write_file(
const char *path,
const char *fmt, ...)
131 int fd = open(path, O_WRONLY | O_CLOEXEC);
139 int ret = vdprintf(
fd, fmt, args);
140 int errno_bkp = errno;
152 static int read_file(
const char *path,
const char *fmt, ...)
156 FILE *file = fopen(path,
"re");
164 int ret = vfscanf(file, fmt, args);
165 int errno_bkp = errno;
int pwm_sysfs_init(struct PWM_Sysfs *pwm, char *base_path, char *_export, char *_enable, char *_duty, char *_period, uint8_t channel)
static int read_file(const char *path, const char *fmt,...)
#define PS_DEBUG_PRINT(...)
#define PWM_SYSFS_DEFAULT_PERIOD
timer subsystem PPM input on SERVO6 pin actuators pwm(if PWM_USE_TIM1) TIM8 radio_control/ppm(if USE_PPM_TIM8)(non-advanced timers using RCC_APB2) TIM2 adc(if USE_AD_TIM2
void pwm_sysfs_set_period(struct PWM_Sysfs *pwm, uint32_t period)
static int write_file(const char *path, const char *fmt,...)
void pwm_sysfs_set_duty(struct PWM_Sysfs *pwm, uint32_t duty)
void pwm_sysfs_enable(struct PWM_Sysfs *pwm, bool enable)
#define PWM_SYSFS_PATH_LEN