Paparazzi UAS  v5.15_devel-50-g4d7045d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pwm_sysfs.c File Reference

PWM servos handling using Linux sysfs. More...

#include "mcu_periph/pwm_sysfs.h"
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
+ Include dependency graph for pwm_sysfs.c:

Go to the source code of this file.

Macros

#define PWM_SYSFS_DEFAULT_PERIOD   10000000
 
#define PS_DEBUG_PRINT(...)   {}
 

Functions

static int write_file (const char *path, const char *fmt,...)
 
static int read_file (const char *path, const char *fmt,...)
 
int pwm_sysfs_init (struct PWM_Sysfs *pwm, char *base_path, char *_export, char *_enable, char *_duty, char *_period, uint8_t channel)
 
void pwm_sysfs_set_period (struct PWM_Sysfs *pwm, uint32_t period)
 
void pwm_sysfs_set_duty (struct PWM_Sysfs *pwm, uint32_t duty)
 
void pwm_sysfs_enable (struct PWM_Sysfs *pwm, bool enable)
 

Detailed Description

PWM servos handling using Linux sysfs.

Based on PWM_Sysfs driver from ardupilot released under GPL v3

Definition in file pwm_sysfs.c.

Macro Definition Documentation

#define PS_DEBUG_PRINT (   ...)    {}
#define PWM_SYSFS_DEFAULT_PERIOD   10000000

Definition at line 38 of file pwm_sysfs.c.

Referenced by pwm_sysfs_init().

Function Documentation

void pwm_sysfs_enable ( struct PWM_Sysfs pwm,
bool  enable 
)

Definition at line 114 of file pwm_sysfs.c.

References PWM_Sysfs::enable_path, PWM_Sysfs::enabled, PS_DEBUG_PRINT, and write_file().

Referenced by pwm_sysfs_set_duty().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int pwm_sysfs_init ( struct PWM_Sysfs pwm,
char *  base_path,
char *  _export,
char *  _enable,
char *  _duty,
char *  _period,
uint8_t  channel 
)

Definition at line 52 of file pwm_sysfs.c.

References PS_DEBUG_PRINT, PWM_SYSFS_DEFAULT_PERIOD, PWM_SYSFS_PATH_LEN, pwm_sysfs_set_period(), and write_file().

Referenced by actuators_disco_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void pwm_sysfs_set_duty ( struct PWM_Sysfs pwm,
uint32_t  duty 
)

Definition at line 101 of file pwm_sysfs.c.

References PWM_Sysfs::duty_cycle_fd, PWM_Sysfs::duty_cycle_nsec, PWM_Sysfs::duty_path, PWM_Sysfs::enabled, PS_DEBUG_PRINT, and pwm_sysfs_enable().

Referenced by actuators_disco_set().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void pwm_sysfs_set_period ( struct PWM_Sysfs pwm,
uint32_t  period 
)

Definition at line 91 of file pwm_sysfs.c.

References PWM_Sysfs::period_nsec, PWM_Sysfs::period_path, PS_DEBUG_PRINT, and write_file().

Referenced by pwm_sysfs_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int read_file ( const char *  path,
const char *  fmt,
  ... 
)
static

Definition at line 152 of file pwm_sysfs.c.

static int write_file ( const char *  path,
const char *  fmt,
  ... 
)
static

Definition at line 127 of file pwm_sysfs.c.

References fd.

Referenced by pwm_sysfs_enable(), pwm_sysfs_init(), and pwm_sysfs_set_period().

+ Here is the caller graph for this function: