PX4 Firmware
PX4 Autopilot Software http://px4.io
pca9685.cpp File Reference
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <drivers/device/i2c.h>
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <nuttx/clock.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <uORB/uORB.h>
#include <uORB/topics/actuator_controls.h>
#include <board_config.h>
#include <drivers/drv_io_expander.h>
Include dependency graph for pca9685.cpp:

Go to the source code of this file.

Classes

class  PCA9685
 

Macros

#define PCA9685_SUBADR1   0x2
 
#define PCA9685_SUBADR2   0x3
 
#define PCA9685_SUBADR3   0x4
 
#define PCA9685_MODE1   0x0
 
#define PCA9685_PRESCALE   0xFE
 
#define LED0_ON_L   0x6
 
#define LED0_ON_H   0x7
 
#define LED0_OFF_L   0x8
 
#define LED0_OFF_H   0x9
 
#define ALLLED_ON_L   0xFA
 
#define ALLLED_ON_H   0xFB
 
#define ALLLED_OFF_L   0xFC
 
#define ALLLED_OF
 
#define ADDR   0x40
 
#define PCA9685_DEVICE_PATH   "/dev/pca9685"
 
#define PCA9685_BUS   PX4_I2C_BUS_EXPANSION
 
#define PCA9685_PWMFREQ   60.0f
 
#define PCA9685_NCHANS   16
 
#define PCA9685_PWMMIN   150
 
#define PCA9685_PWMMAX   600
 
#define PCA9685_PWMCENTER   ((PCA9685_PWMMAX + PCA9685_PWMMIN)/2)
 
#define PCA9685_MAXSERVODEG
 
#define PCA9685_SCALE   ((PCA9685_PWMMAX - PCA9685_PWMCENTER)/(M_DEG_TO_RAD_F * PCA9685_MAXSERVODEG))
 

Functions

void pca9685_usage ()
 
__EXPORT int pca9685_main (int argc, char *argv[])
 

Macro Definition Documentation

◆ ADDR

#define ADDR   0x40

Definition at line 95 of file pca9685.cpp.

Referenced by pca9685_main(), and pca9685_usage().

◆ ALLLED_OF

#define ALLLED_OF

Definition at line 93 of file pca9685.cpp.

◆ ALLLED_OFF_L

#define ALLLED_OFF_L   0xFC

Definition at line 92 of file pca9685.cpp.

◆ ALLLED_ON_H

#define ALLLED_ON_H   0xFB

Definition at line 91 of file pca9685.cpp.

◆ ALLLED_ON_L

#define ALLLED_ON_L   0xFA

Definition at line 90 of file pca9685.cpp.

◆ LED0_OFF_H

#define LED0_OFF_H   0x9

Definition at line 88 of file pca9685.cpp.

◆ LED0_OFF_L

#define LED0_OFF_L   0x8

Definition at line 87 of file pca9685.cpp.

◆ LED0_ON_H

#define LED0_ON_H   0x7

Definition at line 86 of file pca9685.cpp.

◆ LED0_ON_L

#define LED0_ON_L   0x6

Definition at line 85 of file pca9685.cpp.

Referenced by PCA9685::setPWM().

◆ PCA9685_BUS

#define PCA9685_BUS   PX4_I2C_BUS_EXPANSION

Definition at line 98 of file pca9685.cpp.

◆ PCA9685_DEVICE_PATH

#define PCA9685_DEVICE_PATH   "/dev/pca9685"

Definition at line 97 of file pca9685.cpp.

Referenced by pca9685_main().

◆ PCA9685_MAXSERVODEG

#define PCA9685_MAXSERVODEG
Value:
90.0f /* maximal servo deflection in degrees
PCA9685_PWMMIN <--> -PCA9685_MAXSERVODEG
PCA9685_PWMMAX <--> PCA9685_MAXSERVODEG
*/

Definition at line 106 of file pca9685.cpp.

◆ PCA9685_MODE1

#define PCA9685_MODE1   0x0

Definition at line 82 of file pca9685.cpp.

Referenced by PCA9685::reset(), and PCA9685::setPWMFreq().

◆ PCA9685_NCHANS

#define PCA9685_NCHANS   16

Definition at line 100 of file pca9685.cpp.

◆ PCA9685_PRESCALE

#define PCA9685_PRESCALE   0xFE

Definition at line 83 of file pca9685.cpp.

Referenced by PCA9685::setPWMFreq().

◆ PCA9685_PWMCENTER

#define PCA9685_PWMCENTER   ((PCA9685_PWMMAX + PCA9685_PWMMIN)/2)

Definition at line 105 of file pca9685.cpp.

Referenced by PCA9685::Run().

◆ PCA9685_PWMFREQ

#define PCA9685_PWMFREQ   60.0f

Definition at line 99 of file pca9685.cpp.

Referenced by PCA9685::init(), and PCA9685::Run().

◆ PCA9685_PWMMAX

#define PCA9685_PWMMAX   600

Definition at line 103 of file pca9685.cpp.

Referenced by PCA9685::Run().

◆ PCA9685_PWMMIN

#define PCA9685_PWMMIN   150

Definition at line 102 of file pca9685.cpp.

Referenced by PCA9685::Run().

◆ PCA9685_SCALE

#define PCA9685_SCALE   ((PCA9685_PWMMAX - PCA9685_PWMCENTER)/(M_DEG_TO_RAD_F * PCA9685_MAXSERVODEG))

Definition at line 110 of file pca9685.cpp.

Referenced by PCA9685::Run().

◆ PCA9685_SUBADR1

#define PCA9685_SUBADR1   0x2

Definition at line 78 of file pca9685.cpp.

◆ PCA9685_SUBADR2

#define PCA9685_SUBADR2   0x3

Definition at line 79 of file pca9685.cpp.

◆ PCA9685_SUBADR3

#define PCA9685_SUBADR3   0x4

Definition at line 80 of file pca9685.cpp.

Function Documentation

◆ pca9685_main()

int pca9685_main ( int  argc,
char *  argv[] 
)

Definition at line 520 of file pca9685.cpp.

References ADDR, errx, fd, PCA9685::ioctl(), IOX_MODE_OFF, IOX_MODE_ON, IOX_MODE_TEST_OUT, IOX_SET_MODE, OK, PCA9685::PCA9685(), PCA9685_DEVICE_PATH, pca9685_usage(), and warnx.

Here is the call graph for this function:

◆ pca9685_usage()

void pca9685_usage ( )

Definition at line 511 of file pca9685.cpp.

References ADDR, and warnx.

Referenced by pca9685_main().

Here is the caller graph for this function: