45 #include <px4_platform_common/defines.h> 48 #include <sys/ioctl.h> 49 #include <board_config.h> 62 #define PWM_OUTPUT_BASE_DEVICE_PATH "/dev/pwm_output" 63 #define PWM_OUTPUT0_DEVICE_PATH "/dev/pwm_output0" 65 #define PWM_OUTPUT_MAX_CHANNELS 16 76 #if !defined(PX4_PWM_ALTERNATE_RANGES) 81 #define PWM_LOWEST_MIN 90 86 #define PWM_MOTOR_OFF 900 91 #define PWM_DEFAULT_MIN 1000 96 #define PWM_HIGHEST_MIN 1600 101 #define PWM_HIGHEST_MAX 2150 106 #define PWM_DEFAULT_MAX 2000 111 #define PWM_DEFAULT_TRIM 0 116 #define PWM_LOWEST_MAX 200 118 #endif // not PX4_PWM_ALTERNATE_RANGES 123 #define PWM_IGNORE_THIS_CHANNEL UINT16_MAX 153 #define _PWM_SERVO_BASE 0x2a00 156 #define PWM_SERVO_ARM _PX4_IOC(_PWM_SERVO_BASE, 0) 159 #define PWM_SERVO_DISARM _PX4_IOC(_PWM_SERVO_BASE, 1) 162 #define PWM_SERVO_GET_DEFAULT_UPDATE_RATE _PX4_IOC(_PWM_SERVO_BASE, 2) 165 #define PWM_SERVO_SET_UPDATE_RATE _PX4_IOC(_PWM_SERVO_BASE, 3) 168 #define PWM_SERVO_GET_UPDATE_RATE _PX4_IOC(_PWM_SERVO_BASE, 4) 171 #define PWM_SERVO_GET_COUNT _PX4_IOC(_PWM_SERVO_BASE, 5) 174 #define PWM_SERVO_SET_SELECT_UPDATE_RATE _PX4_IOC(_PWM_SERVO_BASE, 6) 177 #define PWM_SERVO_GET_SELECT_UPDATE_RATE _PX4_IOC(_PWM_SERVO_BASE, 7) 180 #define PWM_SERVO_SET_ARM_OK _PX4_IOC(_PWM_SERVO_BASE, 8) 183 #define PWM_SERVO_CLEAR_ARM_OK _PX4_IOC(_PWM_SERVO_BASE, 9) 186 #define DSM_BIND_START _PX4_IOC(_PWM_SERVO_BASE, 10) 189 #define DSM_BIND_POWER_UP _PX4_IOC(_PWM_SERVO_BASE, 11) 192 #define PWM_SERVO_SET_FAILSAFE_PWM _PX4_IOC(_PWM_SERVO_BASE, 12) 195 #define PWM_SERVO_GET_FAILSAFE_PWM _PX4_IOC(_PWM_SERVO_BASE, 13) 198 #define PWM_SERVO_SET_DISARMED_PWM _PX4_IOC(_PWM_SERVO_BASE, 14) 201 #define PWM_SERVO_GET_DISARMED_PWM _PX4_IOC(_PWM_SERVO_BASE, 15) 204 #define PWM_SERVO_SET_MIN_PWM _PX4_IOC(_PWM_SERVO_BASE, 16) 207 #define PWM_SERVO_GET_MIN_PWM _PX4_IOC(_PWM_SERVO_BASE, 17) 210 #define PWM_SERVO_SET_MAX_PWM _PX4_IOC(_PWM_SERVO_BASE, 18) 213 #define PWM_SERVO_GET_MAX_PWM _PX4_IOC(_PWM_SERVO_BASE, 19) 216 #define PWM_SERVO_SET_TRIM_PWM _PX4_IOC(_PWM_SERVO_BASE, 20) 219 #define PWM_SERVO_GET_TRIM_PWM _PX4_IOC(_PWM_SERVO_BASE, 21) 223 #define PWM_SERVO_SET_COUNT _PX4_IOC(_PWM_SERVO_BASE, 22) 226 #define PWM_SERVO_SET_DISABLE_LOCKDOWN _PX4_IOC(_PWM_SERVO_BASE, 23) 229 #define PWM_SERVO_GET_DISABLE_LOCKDOWN _PX4_IOC(_PWM_SERVO_BASE, 24) 232 #define PWM_SERVO_SET_FORCE_SAFETY_OFF _PX4_IOC(_PWM_SERVO_BASE, 25) 235 #define PWM_SERVO_SET_FORCE_FAILSAFE _PX4_IOC(_PWM_SERVO_BASE, 26) 238 #define PWM_SERVO_SET_TERMINATION_FAILSAFE _PX4_IOC(_PWM_SERVO_BASE, 27) 241 #define PWM_SERVO_SET_FORCE_SAFETY_ON _PX4_IOC(_PWM_SERVO_BASE, 28) 244 #define PWM_SERVO_SET_OVERRIDE_IMMEDIATE _PX4_IOC(_PWM_SERVO_BASE, 32) 247 #define PWM_SERVO_SET_SBUS_RATE _PX4_IOC(_PWM_SERVO_BASE, 33) 250 #define PWM_SERVO_MODE_NONE 0 251 #define PWM_SERVO_MODE_1PWM 1 252 #define PWM_SERVO_MODE_2PWM 2 253 #define PWM_SERVO_MODE_2PWM2CAP 3 254 #define PWM_SERVO_MODE_3PWM 4 255 #define PWM_SERVO_MODE_3PWM1CAP 5 256 #define PWM_SERVO_MODE_4PWM 6 257 #define PWM_SERVO_MODE_4PWM1CAP 7 258 #define PWM_SERVO_MODE_4PWM2CAP 8 259 #define PWM_SERVO_MODE_5PWM 9 260 #define PWM_SERVO_MODE_5PWM1CAP 10 261 #define PWM_SERVO_MODE_6PWM 11 262 #define PWM_SERVO_MODE_8PWM 12 263 #define PWM_SERVO_MODE_14PWM 13 264 #define PWM_SERVO_MODE_4CAP 14 265 #define PWM_SERVO_MODE_5CAP 15 266 #define PWM_SERVO_MODE_6CAP 16 267 #define PWM_SERVO_ENTER_TEST_MODE 17 268 #define PWM_SERVO_EXIT_TEST_MODE 18 269 #define PWM_SERVO_SET_MODE _PX4_IOC(_PWM_SERVO_BASE, 34) 280 #define PWM_SERVO_SET(_servo) _PX4_IOC(_PWM_SERVO_BASE, 0x30 + _servo) 283 #define PWM_SERVO_GET(_servo) _PX4_IOC(_PWM_SERVO_BASE, 0x50 + _servo) 288 #define PWM_SERVO_GET_RATEGROUP(_n) _PX4_IOC(_PWM_SERVO_BASE, 0x70 + _n) 291 #define PWM_RATE_ONESHOT 0u 292 #define PWM_RATE_LOWER_LIMIT 1u 293 #define PWM_RATE_UPPER_LIMIT 10000u 296 #define DSHOT1200 1200000u //Hz 297 #define DSHOT600 600000u //Hz 298 #define DSHOT300 300000u //Hz 299 #define DSHOT150 150000u //Hz 301 #define DSHOT_MAX_THROTTLE 1999 __EXPORT void up_dshot_trigger(void)
Trigger dshot data transfer.
__EXPORT servo_position_t up_pwm_servo_get(unsigned channel)
Get the current output value for a channel.
uint16_t servo_position_t
Servo output signal type, value is actual servo output pulse width in microseconds.
__EXPORT uint32_t up_pwm_servo_get_rate_group(unsigned group)
Get a bitmap of output channels assigned to a given rate group.
uORB published object driver.
RC config values for a channel.
__EXPORT void up_pwm_servo_deinit(void)
De-initialise the PWM servo outputs.
__EXPORT int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq)
Intialise the Dshot outputs using the specified configuration.
__EXPORT int up_dshot_arm(bool armed)
Arm or disarm dshot outputs (This will enable/disable complete timer for safety purpose.).
__EXPORT int up_pwm_servo_set_rate(unsigned rate)
Set the servo update rate for all rate groups.
uint16_t values[PWM_OUTPUT_MAX_CHANNELS]
__EXPORT int up_pwm_servo_set_rate_group_update(unsigned group, unsigned rate)
Set the update rate for a given rate group.
static struct actuator_armed_s armed
#define PWM_OUTPUT_MAX_CHANNELS
__EXPORT int up_pwm_servo_set(unsigned channel, servo_position_t value)
Set the current output value for a channel.
__EXPORT void up_dshot_motor_command(unsigned channel, uint16_t command, bool telemetry)
Send DShot command to a channel (motor).
__EXPORT void up_dshot_motor_data_set(unsigned channel, uint16_t throttle, bool telemetry)
Set the current dshot throttle value for a channel (motor).
__EXPORT int up_pwm_servo_init(uint32_t channel_mask)
Intialise the PWM servo outputs using the specified configuration.
__EXPORT void up_pwm_servo_arm(bool armed)
Arm or disarm servo outputs.
__EXPORT void up_pwm_update(void)
Trigger all timer's channels in Oneshot mode to fire the oneshot with updated values.