HAL_SITL: make cork/push safe to call nested

This commit is contained in:
Andrew Tridgell 2017-04-18 09:40:27 +10:00
parent 351304ebcb
commit f257a869ac
1 changed files with 8 additions and 4 deletions

View File

@ -69,14 +69,18 @@ void RCOutput::read(uint16_t* period_us, uint8_t len)
void RCOutput::cork(void)
{
memcpy(_pending, _sitlState->pwm_output, SITL_NUM_CHANNELS * sizeof(uint16_t));
_corked = true;
if (!_corked) {
memcpy(_pending, _sitlState->pwm_output, SITL_NUM_CHANNELS * sizeof(uint16_t));
_corked = true;
}
}
void RCOutput::push(void)
{
memcpy(_sitlState->pwm_output, _pending, SITL_NUM_CHANNELS * sizeof(uint16_t));
_corked = false;
if (_corked) {
memcpy(_sitlState->pwm_output, _pending, SITL_NUM_CHANNELS * sizeof(uint16_t));
_corked = false;
}
}
#endif