From db985065ff2eec2006e5023f8c2390266b21f6fe Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 12 Jan 2018 20:15:59 +0100 Subject: [PATCH] WRITE_NC macro for non-critical (non-synchronized) access to slow ports. The WRITE macro stores the CPU bits on the stack first, then locks the interupts, reads the port, sets a bit, writes the port and then finally reverts the CPU bits. The WRITE_NC does not lock the interrupts, therefore it may only be used where it cannot be interrupted. --- Firmware/fastio.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/fastio.h b/Firmware/fastio.h index c20a6b70..e4f25ed8 100644 --- a/Firmware/fastio.h +++ b/Firmware/fastio.h @@ -66,6 +66,11 @@ #define READ(IO) _READ(IO) /// Write to a pin wrapper #define WRITE(IO, v) _WRITE(IO, v) +/// Write to a pin wrapper, non critical. +/// This macro is cheaper than WRITE(IO,v) on ports H,I,J,K,L, as _WRITE_C disables / enables interrupts +/// and stores the old CPU flags on the stack. +/// This macro should only be called, where it cannot be interrupted. +#define WRITE_NC(IO, v) _WRITE_NC(IO, v) /// toggle a pin wrapper #define TOGGLE(IO) _TOGGLE(IO)