diff include/Utilities.h @ 33:83baffda5786 matrix_gpio

Fixed bug in Digital macros and in example project
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 11 May 2015 18:58:47 +0100
parents 182ae9367104
children 579c86316008
line wrap: on
line diff
--- a/include/Utilities.h	Mon May 11 11:45:03 2015 +0100
+++ b/include/Utilities.h	Mon May 11 18:58:47 2015 +0100
@@ -29,14 +29,18 @@
 #define getBit(word,bit) (((word)>>(bit))&1)
 #define changeBit(word,bit,value) ((clearBit((word),(bit))) | ((value)<<(bit)))
 //digital API:
-#define setDigitalDirectionFrame(pin,frame,direction) digital[(frame)]=changeBit(digital[(frame)],(pin),(direction))
-#define setDigitalDirection(pin,frame,direction) (for(int _privateI=(frame);_privateI<gNumGpioFrames;_privateI++) digital[_privateI]=changeBit(digital[(_privateI)],(pin),(direction))),void(0)
+#define setDigitalDirectionFrame(pin,frame,direction) digital[(frame)]=changeBit(digital[(frame)],(pin),(direction)),void(0)
+#define setDigitalDirection(pin,frame,direction)\
+		(({do {\
+			for(int _privateI=(frame); _privateI<numDigitalFrames; _privateI++)\
+				setDigitalDirectionFrame(pin,_privateI,direction);\
+			} while (0);}), (void)0)
 #define digitalWriteAll(frame,value) digital[(frame)]=0xffff0000*(!(!value));
 //sets the bit in the high word, clears the bit in the low word (just in case the direction was not previously set)
 #define digitalWriteFrame(pin, frame, value) digital[(frame)]=( changeBit(digital[(frame)], (pin+16), (value)) & (0xffffffff-(1<<(pin))) ) //could have been done with two subsequent assignments
 #define digitalWrite(pin, frame, value) \
 	(({do {\
-		for (int _privateI=(frame); _privateI<gNumDigitalFrames; _privateI++) \
+		for (int _privateI=(frame); _privateI<numDigitalFrames; _privateI++) \
 			digitalWriteFrame(pin,_privateI,value); \
 		} while (0);}),(void)0)\