mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
This driver has been tested and finished first flight
Now I've fixed style of the code
This commit is contained in:
parent
8a691d9bfb
commit
ea2a3acbd8
@ -35,9 +35,9 @@ px4_add_module(
|
||||
MAIN rpi_pca9685_pwm_out
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
PCA9685.cpp
|
||||
rpi_pca9685_pwm_out.cpp
|
||||
PCA9685.cpp
|
||||
rpi_pca9685_pwm_out.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
platforms__common
|
||||
)
|
||||
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
||||
|
||||
@ -86,7 +86,7 @@ void PCA9685::setPWMFreq(int freq)
|
||||
int fd = openfd();
|
||||
|
||||
if (fd != -1) {
|
||||
uint8_t prescale = (CLOCK_FREQ / 4096 / freq) - 1;
|
||||
uint8_t prescale = (CLOCK_FREQ / MAX_PWM_RES / freq) - 1;
|
||||
//printf ("Setting prescale value to: %d\n", prescale);
|
||||
//printf ("Using Frequency: %d\n", freq);
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
#define ALLLED_OFF_L 0xFC //load all the LEDn_OFF registers, byte 0 (turn 0-7 channels off)
|
||||
#define ALLLED_OFF_H 0xFD //load all the LEDn_OFF registers, byte 1 (turn 8-15 channels off)
|
||||
#define PRE_SCALE 0xFE //prescaler for output frequency
|
||||
#define MAX_PWM_RES 4096 //10bit精度
|
||||
#define CLOCK_FREQ 25000000.0 //25MHz default osc clock
|
||||
#define BUFFER_SIZE 0x08 //1 byte buffer
|
||||
//! Main class that exports features for PCA9685 chip
|
||||
|
||||
@ -82,7 +82,7 @@ int rpi_pca9685_pwm_out::pwm_initialize()
|
||||
/**************初始化PCA9685开始*************/
|
||||
pwm.init(1, 0x40);
|
||||
usleep(1000 * 100);
|
||||
pwm.setPWMFreq(61);
|
||||
pwm.setPWMFreq(200); //12BIT 精度输出下,好赢电调可以到200HZ刷新
|
||||
usleep(1000 * 1000);
|
||||
/**************初始化PCA9685结束************/
|
||||
return 0;
|
||||
@ -99,6 +99,7 @@ void rpi_pca9685_pwm_out::send_outputs_pwm(const uint16_t *pwm)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_PWM; ++i) {
|
||||
PX4_WARN("PWM%d:%d\n", i, *(pwm + i));
|
||||
rpi_pca9685_pwm_out::pwm.setPWM(i, *(pwm + i));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user