From 219ab05a707d8f2795dc91f5884a42f20dd6a640 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jan 2013 06:29:28 +1100 Subject: [PATCH 1/4] added PWM_SERVO_SET_UPDATE_RATE ioctl this allows apps to set the PWM update rate. APM needs this to honor the user configurable PWM rate setting for copters. --- apps/drivers/drv_pwm_output.h | 3 +++ apps/drivers/hil/hil.cpp | 4 ++++ apps/drivers/px4fmu/fmu.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/apps/drivers/drv_pwm_output.h b/apps/drivers/drv_pwm_output.h index b2fee65aca..c110cd5cbc 100644 --- a/apps/drivers/drv_pwm_output.h +++ b/apps/drivers/drv_pwm_output.h @@ -103,6 +103,9 @@ ORB_DECLARE(output_pwm); /** disarm all servo outputs (stop generating pulses) */ #define PWM_SERVO_DISARM _IOC(_PWM_SERVO_BASE, 1) +/** set update rate in Hz */ +#define PWM_SERVO_SET_UPDATE_RATE _IOC(_PWM_SERVO_BASE, 2) + /** set a single servo to a specific value */ #define PWM_SERVO_SET(_servo) _IOC(_PWM_SERVO_BASE, 0x20 + _servo) diff --git a/apps/drivers/hil/hil.cpp b/apps/drivers/hil/hil.cpp index 67b16aa42f..32bdb0776a 100644 --- a/apps/drivers/hil/hil.cpp +++ b/apps/drivers/hil/hil.cpp @@ -503,6 +503,10 @@ HIL::pwm_ioctl(file *filp, int cmd, unsigned long arg) // up_pwm_servo_arm(false); break; + case PWM_SERVO_SET_UPDATE_RATE: + g_hil->set_pwm_rate(arg); + break; + case PWM_SERVO_SET(2): case PWM_SERVO_SET(3): if (_mode != MODE_4PWM) { diff --git a/apps/drivers/px4fmu/fmu.cpp b/apps/drivers/px4fmu/fmu.cpp index a995f6214d..d5f4123c2e 100644 --- a/apps/drivers/px4fmu/fmu.cpp +++ b/apps/drivers/px4fmu/fmu.cpp @@ -470,6 +470,10 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg) up_pwm_servo_arm(false); break; + case PWM_SERVO_SET_UPDATE_RATE: + set_pwm_rate(arg); + break; + case PWM_SERVO_SET(2): case PWM_SERVO_SET(3): if (_mode != MODE_4PWM) { From 0134186420273170c14b80b8114ccd2474da1792 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jan 2013 06:31:00 +1100 Subject: [PATCH 2/4] fixup rate --- apps/drivers/px4io/px4io.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/drivers/px4io/px4io.cpp b/apps/drivers/px4io/px4io.cpp index 9f3dba047f..d313659bcb 100644 --- a/apps/drivers/px4io/px4io.cpp +++ b/apps/drivers/px4io/px4io.cpp @@ -554,6 +554,11 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg) _send_needed = true; break; + case PWM_SERVO_SET_UPDATE_RATE: + // not supported yet + ret = -EINVAL; + break; + case PWM_SERVO_SET(0) ... PWM_SERVO_SET(_max_actuators - 1): /* fake an update to the selected servo channel */ From 318609bf59083e4247dfd179a3bb36dc2eb9fb45 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jan 2013 06:31:37 +1100 Subject: [PATCH 3/4] fixed PWM_SERVO_GET this was using the wrong channel --- apps/drivers/px4fmu/fmu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/drivers/px4fmu/fmu.cpp b/apps/drivers/px4fmu/fmu.cpp index d5f4123c2e..7e78cb979d 100644 --- a/apps/drivers/px4fmu/fmu.cpp +++ b/apps/drivers/px4fmu/fmu.cpp @@ -504,7 +504,7 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg) /* FALLTHROUGH */ case PWM_SERVO_GET(0): case PWM_SERVO_GET(1): { - channel = cmd - PWM_SERVO_SET(0); + channel = cmd - PWM_SERVO_GET(0); *(servo_position_t *)arg = up_pwm_servo_get(channel); break; } From 375d3c14d742248b434c080527886a95ea1d563f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jan 2013 06:33:44 +1100 Subject: [PATCH 4/4] increase the UART buffer sizes to 256 The most critical one is the GPS serial port receive buffer size, which needs to be at least 128 to support the UBLOX protocol, but it seems a good idea for people running a FMU without a IO board to increase the UART buffer sizes generally --- nuttx/configs/px4fmu/nsh/defconfig | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nuttx/configs/px4fmu/nsh/defconfig b/nuttx/configs/px4fmu/nsh/defconfig index bc724c0063..7ff9eaa8c8 100755 --- a/nuttx/configs/px4fmu/nsh/defconfig +++ b/nuttx/configs/px4fmu/nsh/defconfig @@ -245,18 +245,18 @@ CONFIG_USART6_SERIAL_CONSOLE=n #Mavlink messages can be bigger than 128 CONFIG_USART1_TXBUFSIZE=512 -CONFIG_USART2_TXBUFSIZE=128 -CONFIG_USART3_TXBUFSIZE=128 -CONFIG_UART4_TXBUFSIZE=128 -CONFIG_UART5_TXBUFSIZE=64 +CONFIG_USART2_TXBUFSIZE=256 +CONFIG_USART3_TXBUFSIZE=256 +CONFIG_UART4_TXBUFSIZE=256 +CONFIG_UART5_TXBUFSIZE=256 CONFIG_USART6_TXBUFSIZE=128 CONFIG_USART1_RXBUFSIZE=512 -CONFIG_USART2_RXBUFSIZE=128 -CONFIG_USART3_RXBUFSIZE=128 -CONFIG_UART4_RXBUFSIZE=128 -CONFIG_UART5_RXBUFSIZE=128 -CONFIG_USART6_RXBUFSIZE=128 +CONFIG_USART2_RXBUFSIZE=256 +CONFIG_USART3_RXBUFSIZE=256 +CONFIG_UART4_RXBUFSIZE=256 +CONFIG_UART5_RXBUFSIZE=256 +CONFIG_USART6_RXBUFSIZE=256 CONFIG_USART1_BAUD=57600 CONFIG_USART2_BAUD=115200