mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 07:03:33 +08:00
IO firmware: Run critical timing operations as atomic
This is required as we might be in interrupt context on this bare-metal target.
This commit is contained in:
@@ -205,7 +205,7 @@ hrt_abstime ts_to_abstime(const struct timespec *ts)
|
|||||||
* This function is safe to use even if the timestamp is updated
|
* This function is safe to use even if the timestamp is updated
|
||||||
* by an interrupt during execution.
|
* by an interrupt during execution.
|
||||||
*/
|
*/
|
||||||
hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then)
|
hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
|
||||||
{
|
{
|
||||||
hrt_abstime delta = hrt_absolute_time() - *then;
|
hrt_abstime delta = hrt_absolute_time() - *then;
|
||||||
return delta;
|
return delta;
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ controls_tick()
|
|||||||
* If we haven't seen any new control data in 200ms, assume we
|
* If we haven't seen any new control data in 200ms, assume we
|
||||||
* have lost input.
|
* have lost input.
|
||||||
*/
|
*/
|
||||||
if (!rc_input_lost && hrt_elapsed_time(&system_state.rc_channels_timestamp_received) > 200000) {
|
if (!rc_input_lost && hrt_elapsed_time_atomic(&system_state.rc_channels_timestamp_received) > 200000) {
|
||||||
rc_input_lost = true;
|
rc_input_lost = true;
|
||||||
|
|
||||||
/* clear the input-kind flags here */
|
/* clear the input-kind flags here */
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ mixer_tick(void)
|
|||||||
|
|
||||||
/* check that we are receiving fresh data from the FMU */
|
/* check that we are receiving fresh data from the FMU */
|
||||||
if ((system_state.fmu_data_received_time == 0) ||
|
if ((system_state.fmu_data_received_time == 0) ||
|
||||||
hrt_elapsed_time(&system_state.fmu_data_received_time) > FMU_INPUT_DROP_LIMIT_US) {
|
hrt_elapsed_time_atomic(&system_state.fmu_data_received_time) > FMU_INPUT_DROP_LIMIT_US) {
|
||||||
|
|
||||||
/* too long without FMU input, time to go to failsafe */
|
/* too long without FMU input, time to go to failsafe */
|
||||||
if (r_status_flags & PX4IO_P_STATUS_FLAGS_FMU_OK) {
|
if (r_status_flags & PX4IO_P_STATUS_FLAGS_FMU_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user