Mercurial > hg > beaglert
comparison include/Utilities.h @ 72:d837fb676977
Documentation updates and include Arduino-type constants in Utilities.h
author | andrewm |
---|---|
date | Fri, 17 Jul 2015 20:09:50 +0100 |
parents | 59edd5780fef |
children | c529505203ee |
comparison
equal
deleted
inserted
replaced
71:53e57276ac1a | 72:d837fb676977 |
---|---|
12 | 12 |
13 #ifndef UTILITIES_H_ | 13 #ifndef UTILITIES_H_ |
14 #define UTILITIES_H_ | 14 #define UTILITIES_H_ |
15 | 15 |
16 #include "BeagleRT.h" | 16 #include "BeagleRT.h" |
17 | |
18 #define HIGH 0x1 | |
19 #define LOW 0x0 | |
20 | |
21 #define INPUT 0x0 | |
22 #define OUTPUT 0x1 | |
17 | 23 |
18 /// Set the given bit in \c word to 1. | 24 /// Set the given bit in \c word to 1. |
19 #define setBit(word,bit) ((word) | (1 << (bit))) | 25 #define setBit(word,bit) ((word) | (1 << (bit))) |
20 | 26 |
21 /// Clear the given bit in \c word to 0. | 27 /// Clear the given bit in \c word to 0. |
70 * | 76 * |
71 * This function sets the value of an analog output, at the time indicated by \c frame. Valid | 77 * This function sets the value of an analog output, at the time indicated by \c frame. Valid |
72 * values are between 0 and 1, corresponding to the range 0 to 5V. | 78 * values are between 0 and 1, corresponding to the range 0 to 5V. |
73 * | 79 * |
74 * Unlike analogWriteFrame(), the value written will affect \b only the frame specified, with | 80 * Unlike analogWriteFrame(), the value written will affect \b only the frame specified, with |
75 * future values unchanged. This is more efficient than analogWriteFrame() so is better suited | 81 * future values unchanged. This is faster than analogWriteFrame() so is better suited |
76 * to applications where every frame will be written to a different value. If | 82 * to applications where every frame will be written to a different value. If |
77 * BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST is not set within context->flags, then | 83 * BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST is not set within context->flags, then |
78 * analogWriteFrameOnce() and analogWriteFrame() are equivalent. | 84 * analogWriteFrameOnce() and analogWriteFrame() are equivalent. |
79 * | 85 * |
80 * \param context The I/O data structure which is passed by BeagleRT to render(). | 86 * \param context The I/O data structure which is passed by BeagleRT to render(). |
84 * (context->analogChannels - 1), typically 0 to 7 by default. | 90 * (context->analogChannels - 1), typically 0 to 7 by default. |
85 * \param value Value to write to the output, range 0 to 1. | 91 * \param value Value to write to the output, range 0 to 1. |
86 */ | 92 */ |
87 void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value); | 93 void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value); |
88 | 94 |
95 /** | |
96 * \brief Read a digital input, specifying the frame number (when to read) and the pin. | |
97 * | |
98 * This function returns the value of a digital input, at the time indicated by \c frame. | |
99 * The value is 0 if the pin is low, and nonzero if the pin is high (3.3V). | |
100 * | |
101 * \param context The I/O data structure which is passed by BeagleRT to render(). | |
102 * \param frame Which frame (i.e. what time) to read the digital input. Valid values range | |
103 * from 0 to (context->digitalFrames - 1). | |
104 * \param channel Which digital pin to read. 16 pins across the P8 and P9 headers of the | |
105 * BeagleBone Black are available. See the constants P8_xx and P9_xx defined in | |
106 * digital_gpio_mapping.h. | |
107 * \return Value of the digital input. | |
108 */ | |
89 int digitalReadFrame(BeagleRTContext *context, int frame, int channel); | 109 int digitalReadFrame(BeagleRTContext *context, int frame, int channel); |
110 | |
111 /** | |
112 * \brief Write a digital output, specifying the frame number (when to write) and the pin. | |
113 * | |
114 * This function sets the value of a digital output, at the time indicated by \c frame. | |
115 * A value of 0 sets the pin low; any other value sets the pin high (3.3V). | |
116 * | |
117 * The value written will persist for all future frames. | |
118 * | |
119 * \param context The I/O data structure which is passed by BeagleRT to render(). | |
120 * \param frame Which frame (i.e. what time) to write the digital output. Valid values range | |
121 * from 0 to (context->digitalFrames - 1). | |
122 * \param channel Which digital output to write. 16 pins across the P8 and P9 headers of the | |
123 * BeagleBone Black are available. See the constants P8_xx and P9_xx defined in | |
124 * digital_gpio_mapping.h. | |
125 * \param value Value to write to the output. | |
126 */ | |
90 void digitalWriteFrame(BeagleRTContext *context, int frame, int channel, int value); | 127 void digitalWriteFrame(BeagleRTContext *context, int frame, int channel, int value); |
128 | |
129 /** | |
130 * \brief Write a digital output, specifying the frame number (when to write) and the pin. | |
131 * | |
132 * This function sets the value of a digital output, at the time indicated by \c frame. | |
133 * A value of 0 sets the pin low; any other value sets the pin high (3.3V). | |
134 * | |
135 * Unlike digitalWriteFrame(), the value written will affect \b only the frame specified, with | |
136 * future values unchanged. This is faster than digitalWriteFrame() so is better suited | |
137 * to applications where every frame will be written to a different value. | |
138 * | |
139 * \param context The I/O data structure which is passed by BeagleRT to render(). | |
140 * \param frame Which frame (i.e. what time) to write the digital output. Valid values range | |
141 * from 0 to (context->digitalFrames - 1). | |
142 * \param channel Which digital output to write. 16 pins across the P8 and P9 headers of the | |
143 * BeagleBone Black are available. See the constants P8_xx and P9_xx defined in | |
144 * digital_gpio_mapping.h. | |
145 * \param value Value to write to the output. | |
146 */ | |
91 void digitalWriteFrameOnce(BeagleRTContext *context, int frame, int channel, int value); | 147 void digitalWriteFrameOnce(BeagleRTContext *context, int frame, int channel, int value); |
92 | 148 |
149 /** | |
150 * \brief Set the direction of a digital pin to input or output. | |
151 * | |
152 * This function sets the direction of a digital pin, at the time indicated by \c frame. | |
153 * Valid values are \c INPUT and \c OUTPUT. All pins begin as inputs by default. | |
154 * | |
155 * The value written will persist for all future frames. | |
156 * | |
157 * \param context The I/O data structure which is passed by BeagleRT to render(). | |
158 * \param frame Which frame (i.e. what time) to set the pin direction. Valid values range | |
159 * from 0 to (context->digitalFrames - 1). | |
160 * \param channel Which digital output to write. 16 pins across the P8 and P9 headers of the | |
161 * BeagleBone Black are available. See the constants P8_xx and P9_xx defined in | |
162 * digital_gpio_mapping.h. | |
163 * \param value Direction of the pin (\c INPUT or \c OUTPUT). | |
164 */ | |
93 void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode); | 165 void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode); |
166 | |
167 /** | |
168 * \brief Set the direction of a digital pin to input or output. | |
169 * | |
170 * This function sets the direction of a digital pin, at the time indicated by \c frame. | |
171 * Valid values are \c INPUT and \c OUTPUT. All pins begin as inputs by default. | |
172 * | |
173 * The value written will affect only the specified frame. | |
174 * | |
175 * \param context The I/O data structure which is passed by BeagleRT to render(). | |
176 * \param frame Which frame (i.e. what time) to set the pin direction. Valid values range | |
177 * from 0 to (context->digitalFrames - 1). | |
178 * \param channel Which digital output to write. 16 pins across the P8 and P9 headers of the | |
179 * BeagleBone Black are available. See the constants P8_xx and P9_xx defined in | |
180 * digital_gpio_mapping.h. | |
181 * \param value Direction of the pin (\c INPUT or \c OUTPUT). | |
182 */ | |
94 void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode); | 183 void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode); |
95 | 184 |
96 #else | 185 #else |
97 | 186 |
98 // Macros for accessing the analog values: usable _only_ within render() | 187 // Macros for accessing the analog values: usable _only_ within render() |