diff include/Utilities.h @ 45:579c86316008 newapi

Major API overhaul. Moved to a single data structure for handling render functions. Functionally, generally similar except for scheduling within PRU loop function, which now uses interrupts from the PRU rather than polling. This requires an updated kernel.
author andrewm
date Thu, 28 May 2015 14:35:55 -0400
parents 83baffda5786
children 3c3a1357657d
line wrap: on
line diff
--- a/include/Utilities.h	Wed May 13 12:23:37 2015 +0100
+++ b/include/Utilities.h	Thu May 28 14:35:55 2015 -0400
@@ -8,8 +8,30 @@
 #ifndef UTILITIES_H_
 #define UTILITIES_H_
 
-extern int gNumAudioChannels;	// How many audio channels are present
-extern int gNumAnalogChannels;	// How many analog channels are present
+#include "BeagleRT.h"
+
+#define setBit(word,bit) 			((word) | (1 << (bit)))
+#define clearBit(word,bit) 			((word) &~ (1 << (bit)))
+#define getBit(word,bit) 			(((word) >> (bit)) & 1)
+#define changeBit(word,bit,value) 	((clearBit((word),(bit))) | ((value) << (bit)))
+
+#if 1
+// Note: pinMode(), analogWrite() and digitalWrite() should be able to be called from initialise_render()
+// Likewise, thread launch should be able to be called from initialise_render()
+// Also, make volume change functions callable from render() thread -- as an aux task?
+
+float analogReadFrame(BeagleRTContext *context, int frame, int channel);
+void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value);
+void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value);
+
+int digitalReadFrame(BeagleRTContext *context, int frame, int channel);
+void digitalWriteFrame(BeagleRTContext *context, int frame, int channel, int value);
+void digitalWriteFrameOnce(BeagleRTContext *context, int frame, int channel, int value);
+
+void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode);
+void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode);
+
+#else
 
 // Macros for accessing the analog values: usable _only_ within render()
 
@@ -24,10 +46,7 @@
 	}\
 	} while (0);}),(void)0)\
 
-#define setBit(word,bit) ((word)|(1<<(bit)))
-#define clearBit(word,bit) ((word)&~(1<<(bit)))
-#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)),void(0)
 #define setDigitalDirection(pin,frame,direction)\
@@ -46,6 +65,8 @@
 
 #define digitalRead(pin, frame) ( getBit(digital[(frame)], pin+16) )
 
+#endif
+
 float map(float x, float in_min, float in_max, float out_min, float out_max);
 float constrain(float x, float min_val, float max_val);