diff options
author | Damien George <damien.p.george@gmail.com> | 2017-06-22 16:18:42 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-06-22 16:18:42 +1000 |
commit | 8ed7155828a44d6fc1055cc1745ec329f867ca12 (patch) | |
tree | 8f4d0dd994d4ef434db6ff328307aa4b2fab0119 | |
parent | eeaab1897b1f8eafe6cf8db12c9fe1c4a0c78532 (diff) | |
download | micropython-8ed7155828a44d6fc1055cc1745ec329f867ca12.tar.gz micropython-8ed7155828a44d6fc1055cc1745ec329f867ca12.zip |
stmhal: Add "quiet timing" enter/exit functions.
They disable all interrupts except for SysTick and are useful for doing
certain low-level timing operations.
-rw-r--r-- | stmhal/irq.h | 5 | ||||
-rw-r--r-- | stmhal/mphalport.h | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/stmhal/irq.h b/stmhal/irq.h index a56f23652e..35187520a0 100644 --- a/stmhal/irq.h +++ b/stmhal/irq.h @@ -24,6 +24,9 @@ * THE SOFTWARE. */ +#ifndef MICROPY_INCLUDED_STMHAL_IRQ_H +#define MICROPY_INCLUDED_STMHAL_IRQ_H + // these states correspond to values from query_irq, enable_irq and disable_irq #define IRQ_STATE_DISABLED (0x00000001) #define IRQ_STATE_ENABLED (0x00000000) @@ -147,4 +150,4 @@ MP_DECLARE_CONST_FUN_OBJ_0(pyb_irq_stats_obj); #define IRQ_PRI_RTC_WKUP 15 #define IRQ_SUBPRI_RTC_WKUP 0 - +#endif // MICROPY_INCLUDED_STMHAL_IRQ_H diff --git a/stmhal/mphalport.h b/stmhal/mphalport.h index 77cb0204d0..8dd95c470c 100644 --- a/stmhal/mphalport.h +++ b/stmhal/mphalport.h @@ -27,6 +27,10 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable // timing functions +#include "stmhal/irq.h" + +#define mp_hal_quiet_timing_enter() raise_irq_pri(1) +#define mp_hal_quiet_timing_exit(irq_state) restore_irq_pri(irq_state) #define mp_hal_delay_us_fast(us) mp_hal_delay_us(us) extern bool mp_hal_ticks_cpu_enabled; |