stmhal: Add "quiet timing" enter/exit functions.

They disable all interrupts except for SysTick and are useful for doing
certain low-level timing operations.
pull/1/head
Damien George 2017-06-22 16:18:42 +10:00
parent eeaab1897b
commit 8ed7155828
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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;