Browse Source

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.

bubnikv 6 years ago
parent
commit
db985065ff
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Firmware/fastio.h

+ 5 - 0
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)