-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fest(flysky): Flysky Gimbal 2.0 Sync Sampling Support #5869
base: main
Are you sure you want to change the base?
Conversation
3d0a61f
to
be0b0ee
Compare
d42f76f
to
886d3f0
Compare
aa547f3
to
71408e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked the protocol itself, only the sync trigger / wait for now.
@@ -58,8 +66,21 @@ static const etx_serial_port_t _fs_gimbal_serial_port = { | |||
|
|||
static STRUCT_HALL HallProtocol = { 0 }; | |||
|
|||
static uint8_t _fs_hall_command[8] __DMA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFINE_STM32_SERIAL_PORT()
already provides for TX DMA buffers in the last parameter. Please use that instead. This will declare the buffer with the proper memory type (here __DMA_NO_CACHE
), which is important for H7 targets.
// Need to put all in a group to ensure DMA transfer will not affect ADC sampling | ||
#if defined(FLYSKY_GIMBAL) && !defined(SIMU) | ||
flysky_gimbal_start_read(); | ||
#endif | ||
#if defined(FLYSKY_GIMBAL) && !defined(SIMU) | ||
flysky_gimbal_wait_completion(); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this should be encapsulated in a way that does not require conditional compilation (no #if defined(...)
). One way would be craft a special ADC driver, or providing new hooks, either in the mixer and/or in generic ADC code.
if(_fs_gimbal_detected && _fs_gimbal_version > GIMBAL_V1 && _fs_gimbal_mode != V1_MODE) { | ||
auto timeout = timersGetUsTick(); | ||
while(!_fs_gimbal_cmd_finished) { | ||
// busy wait | ||
if ((uint32_t)(timersGetUsTick() - timeout) >= SAMPLING_TIMEOUT_US) { | ||
// TRACE("Gimbal timeout"); | ||
return; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really prevent busy waits in mixer task. This will add additional time during which the mixer is hogging the MCU and preventing other tasks to run.
Flysky works out a new version of firmware that can support sync sampling:
The gimbal driver changes:
Testing: