Skip to content

Commit 8ed7155

Browse files
committed
stmhal: Add "quiet timing" enter/exit functions.
They disable all interrupts except for SysTick and are useful for doing certain low-level timing operations.
1 parent eeaab18 commit 8ed7155

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

stmhal/irq.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#ifndef MICROPY_INCLUDED_STMHAL_IRQ_H
28+
#define MICROPY_INCLUDED_STMHAL_IRQ_H
29+
2730
// these states correspond to values from query_irq, enable_irq and disable_irq
2831
#define IRQ_STATE_DISABLED (0x00000001)
2932
#define IRQ_STATE_ENABLED (0x00000000)
@@ -147,4 +150,4 @@ MP_DECLARE_CONST_FUN_OBJ_0(pyb_irq_stats_obj);
147150
#define IRQ_PRI_RTC_WKUP 15
148151
#define IRQ_SUBPRI_RTC_WKUP 0
149152

150-
153+
#endif // MICROPY_INCLUDED_STMHAL_IRQ_H

stmhal/mphalport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable
2727

2828
// timing functions
2929

30+
#include "stmhal/irq.h"
31+
32+
#define mp_hal_quiet_timing_enter() raise_irq_pri(1)
33+
#define mp_hal_quiet_timing_exit(irq_state) restore_irq_pri(irq_state)
3034
#define mp_hal_delay_us_fast(us) mp_hal_delay_us(us)
3135

3236
extern bool mp_hal_ticks_cpu_enabled;

0 commit comments

Comments
 (0)