From fb643fbb53212d29cccb21fac1a9325957d13e7b Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 28 Sep 2015 17:19:08 -0300 Subject: [PATCH] AP_HAL: RCOutput: add methods to allow grouping writes --- libraries/AP_HAL/RCOutput.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL/RCOutput.h b/libraries/AP_HAL/RCOutput.h index 6ffc019fa7..96fe10170d 100644 --- a/libraries/AP_HAL/RCOutput.h +++ b/libraries/AP_HAL/RCOutput.h @@ -43,9 +43,31 @@ public: virtual void enable_ch(uint8_t ch) = 0; virtual void disable_ch(uint8_t ch) = 0; - /* Output a single channel */ + /* + * Output a single channel, possibly grouped with previous writes if + * cork() has been called before. + */ virtual void write(uint8_t ch, uint16_t period_us) = 0; + /* + * Delay subsequent calls to write() going to the underlying hardware in + * order to group related writes together. When all the needed writes are + * done, call push() to commit the changes. + * + * This method is optional: if the subclass doesn't implement it all calls + * to write() are synchronous. + */ + virtual void cork() { } + + /* + * Push pending changes to the underlying hardware. All changes between a + * call to cork() and push() are pushed together in a single transaction. + * + * This method is optional: if the subclass doesn't implement it all calls + * to write() are synchronous. + */ + virtual void push() { } + /* Read back current output state, as either single channel or * array of channels. */ virtual uint16_t read(uint8_t ch) = 0;