mirror of https://github.com/ArduPilot/ardupilot
AP_HAL_FLYMAPLE: added documentation about safety of noInterrupts()/interrupts()
This commit is contained in:
parent
ab71f2e535
commit
4cd952446d
|
@ -110,6 +110,29 @@ LIBMAPLE_PATH = $(HOME)/libmaple
|
||||||
# Also, the ARM compiler tools MUST be in your current PATH
|
# Also, the ARM compiler tools MUST be in your current PATH
|
||||||
#config.mk END
|
#config.mk END
|
||||||
|
|
||||||
|
Interrupt disabling on ARM
|
||||||
|
|
||||||
|
On AVR, ISRs run by default with the global interrupt enable flag disabled,
|
||||||
|
whereas mainline code runs by default with global interrupt enable flag
|
||||||
|
*enabled*. Which means that cli()/sei() in an ISR will have a different effect
|
||||||
|
to cli()sei() in mainline code. Thats why code that *might* run in an ISR must
|
||||||
|
use the special idiom: so that it restores the flag to the state it was before
|
||||||
|
the critical block
|
||||||
|
|
||||||
|
On ARM, the global interrupt disable flag PRIMASK is not altered behind your
|
||||||
|
back by hardware. By default its always clear (ie enabled) even in ISRs. A
|
||||||
|
different mechanism prevents ISRs from being reinterrupted. This means that
|
||||||
|
non-nested noInterrupts()/interrupts() will always leave the PRIMASK as it was
|
||||||
|
(interrupts enabled) when the critical block started, whether in ISRs or
|
||||||
|
mainline code.
|
||||||
|
|
||||||
|
Conclusion:
|
||||||
|
|
||||||
|
On AVR, cli()/sei() is dangerous both in ISRs *and* when nested.
|
||||||
|
|
||||||
|
On ARM, noInterrupts()/interrupts() is only dangerous when nested.
|
||||||
|
|
||||||
|
|
||||||
Remaining issues:
|
Remaining issues:
|
||||||
|
|
||||||
1. For reasons I do not yet understand, the magnetic heading reported by
|
1. For reasons I do not yet understand, the magnetic heading reported by
|
||||||
|
|
|
@ -1,30 +1,17 @@
|
||||||
/*
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
Flymaple port by Mike McCauley
|
|
||||||
*/
|
|
||||||
#include <AP_HAL.h>
|
|
||||||
|
|
||||||
#if CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
|
|
||||||
|
|
||||||
// Scheduler.cpp
|
// Scheduler.cpp
|
||||||
//
|
//
|
||||||
// Flymaple Scheduler.
|
// Flymaple Scheduler.
|
||||||
// We use systick interrupt for the 1kHz ordinary timers.
|
// We use systick interrupt for the 1kHz ordinary timers.
|
||||||
// We use a slightly higher priority HardwareTimer 2 for the failsafe callbacks
|
// We use a slightly higher priority HardwareTimer 2 for the failsafe callbacks
|
||||||
// so a hung timer wont prevent the failsafe timer interrupt running
|
// so a hung timer wont prevent the failsafe timer interrupt running
|
||||||
|
//
|
||||||
|
// Use of noInterrupts()/interrupts() on FLymaple ARM processor.
|
||||||
|
// Please see the notes in FlymaplePortingNotes.txt in this directory for
|
||||||
|
// information about disabling interrupts on Flymaple
|
||||||
|
|
||||||
|
#include <AP_HAL.h>
|
||||||
|
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
|
||||||
|
|
||||||
#include "Scheduler.h"
|
#include "Scheduler.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue