# HG changeset patch # User Giulio Moro # Date 1437997615 -3600 # Node ID 04f894424a8ce40b0ae48fdd6d68baf638d7f321 # Parent b697e82ebb25059cc6c3f6238c591f26b10f9c65# Parent c529505203eeeee31cd3a33e4ec7f3981cc2b8a5 Merge diff -r b697e82ebb25 -r 04f894424a8c include/Utilities.h --- a/include/Utilities.h Mon Jul 27 12:44:55 2015 +0100 +++ b/include/Utilities.h Mon Jul 27 12:46:55 2015 +0100 @@ -15,12 +15,36 @@ #include "BeagleRT.h" +/** + * \defgroup iofunctions I/O functions and constants + * + * These functions and macros are used for audio, analog and digital I/O. All the + * I/O functions require the BeagleRTContext data structure from render() to be passed + * in. This means that these functions are, by design, \b only usable from within + * the rendering thread. + * + * The naming conventions are loosely derived from the Arduino environment, and the + * syntax is similar. Unlike Arduino, the I/O functions require the frame number at which + * the read or write should take place, since all I/O happens synchronously with the + * audio clock. + * + * @{ + */ + #define HIGH 0x1 #define LOW 0x0 #define INPUT 0x0 #define OUTPUT 0x1 +/** @} */ + +/** + * \ingroup wiring + * + * @{ + */ + /// Set the given bit in \c word to 1. #define setBit(word,bit) ((word) | (1 << (bit))) @@ -33,6 +57,14 @@ /// Set/clear the given bit in \c word to \c value. #define changeBit(word,bit,value) ((clearBit((word),(bit))) | ((value) << (bit))) +/** @} */ + +/** + * \ingroup iofunctions + * + * @{ + */ + #if 1 // Note: pinMode(), analogWrite() and digitalWrite() should be able to be called from setup() // Likewise, thread launch should be able to be called from setup() @@ -182,6 +214,8 @@ */ void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode); +/** @} */ + #else // Macros for accessing the analog values: usable _only_ within render() @@ -219,6 +253,15 @@ #endif /** + * \defgroup wiring Wiring language support + * + * These are functions found in the Wiring (Arduino) language which are not directly + * related to I/O but are provided as a convenience. + * + * @{ + */ + +/** * \brief Linearly rescale a number from one range of values to another. * * This function linearly scales values of \c x such that the range in_min to @@ -256,4 +299,6 @@ */ float constrain(float x, float min_val, float max_val); +/** @} */ + #endif /* UTILITIES_H_ */