PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Public Member Functions | |
PCA9685 (int bus=PCA9685_BUS, uint8_t address=ADDR) | |
virtual | ~PCA9685 ()=default |
virtual int | init () |
virtual int | ioctl (struct file *filp, int cmd, unsigned long arg) |
virtual int | info () |
virtual int | reset () |
bool | is_running () |
Private Member Functions | |
void | Run () override |
Set to true after the first call of i2cpwm in mode IOX_MODE_ON. More... | |
int | setPWMFreq (float freq) |
Helper function to set the pwm frequency. More... | |
int | setPWM (uint8_t num, uint16_t on, uint16_t off) |
Helper function to set the demanded pwm value. More... | |
int | setPin (uint8_t num, uint16_t val, bool invert=false) |
Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off. More... | |
int | read8 (uint8_t addr, uint8_t &value) |
int | write8 (uint8_t addr, uint8_t value) |
Private Attributes | |
enum IOX_MODE | _mode |
bool | _running |
uint64_t | _i2cpwm_interval |
bool | _should_run |
perf_counter_t | _comms_errors |
uint8_t | _msg [6] |
int | _actuator_controls_sub |
struct actuator_controls_s | _actuator_controls |
uint16_t | _current_values [actuator_controls_s::NUM_ACTUATOR_CONTROLS] |
stores the current pwm output values as sent to the setPin() More... | |
bool | _mode_on_initialized |
Definition at line 114 of file pca9685.cpp.
PCA9685::PCA9685 | ( | int | bus = PCA9685_BUS , |
uint8_t | address = ADDR |
||
) |
Definition at line 185 of file pca9685.cpp.
References _current_values, and _msg.
Referenced by pca9685_main().
|
virtualdefault |
|
virtual |
Definition at line 272 of file pca9685.cpp.
References _mode, is_running(), OK, and warnx.
|
virtual |
Definition at line 202 of file pca9685.cpp.
References ToneAlarmInterface::init(), OK, PCA9685_PWMFREQ, reset(), and setPWMFreq().
|
virtual |
Definition at line 223 of file pca9685.cpp.
References _mode, _running, IOX_MODE_OFF, IOX_MODE_ON, IOX_MODE_TEST_OUT, IOX_SET_MODE, OK, and warnx.
Referenced by pca9685_main().
|
inline |
Definition at line 125 of file pca9685.cpp.
Referenced by info().
|
private |
Definition at line 459 of file pca9685.cpp.
References _comms_errors, DEVICE_LOG, OK, and perf_count().
Referenced by setPWMFreq().
|
virtual |
Definition at line 486 of file pca9685.cpp.
References PCA9685_MODE1, warnx, and write8().
Referenced by init().
|
overrideprivate |
Set to true after the first call of i2cpwm in mode IOX_MODE_ON.
Main loop function.
Definition at line 290 of file pca9685.cpp.
References _actuator_controls, _actuator_controls_sub, _current_values, _i2cpwm_interval, _mode, _mode_on_initialized, _running, _should_run, actuator_controls_s::control, DEVICE_DEBUG, f(), IOX_MODE_OFF, IOX_MODE_TEST_OUT, M_PI_F, orb_check(), orb_copy(), ORB_ID, orb_set_interval(), orb_subscribe(), PCA9685_PWMCENTER, PCA9685_PWMFREQ, PCA9685_PWMMAX, PCA9685_PWMMIN, PCA9685_SCALE, and setPin().
|
private |
Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off.
Optional invert parameter supports inverting the pulse for sinking to ground.
num | pwm output number |
val | should be a value from 0 to 4095 inclusive. |
Definition at line 371 of file pca9685.cpp.
References setPWM().
Referenced by Run().
|
private |
Helper function to set the demanded pwm value.
num | pwm output number |
Definition at line 349 of file pca9685.cpp.
References _comms_errors, _msg, DEVICE_LOG, LED0_ON_L, OK, and perf_count().
Referenced by setPin().
|
private |
Helper function to set the pwm frequency.
Definition at line 409 of file pca9685.cpp.
References f(), OK, PCA9685_MODE1, PCA9685_PRESCALE, read8(), and write8().
Referenced by init().
|
private |
Definition at line 494 of file pca9685.cpp.
References _comms_errors, _msg, DEVICE_LOG, OK, and perf_count().
Referenced by reset(), and setPWMFreq().
|
private |
Definition at line 138 of file pca9685.cpp.
Referenced by Run().
|
private |
Definition at line 137 of file pca9685.cpp.
Referenced by Run().
|
private |
Definition at line 133 of file pca9685.cpp.
|
private |
stores the current pwm output values as sent to the setPin()
Definition at line 139 of file pca9685.cpp.
|
private |
Definition at line 131 of file pca9685.cpp.
Referenced by Run().
|
private |
Definition at line 129 of file pca9685.cpp.
|
private |
Definition at line 142 of file pca9685.cpp.
Referenced by Run().
|
private |
Definition at line 135 of file pca9685.cpp.
|
private |
Definition at line 130 of file pca9685.cpp.
|
private |
Definition at line 132 of file pca9685.cpp.
Referenced by Run().