PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
#include <libpropeller/libpropeller/pin/pin.h>
Public Member Functions | |
Pin () | |
Pin (int pin) | |
int | getPin (void) |
void | high (void) |
void | low (void) |
void | toggle (void) |
int | input (void) |
void | output (int setting) |
bool | isOutput (void) |
void | pwm (const int decihz, const bool useCTRA=true, Pin *alternatePin=NULL) |
Pin class to allow access to single pins
What's with the attribute((always_inline))? SRLM found that the forced inlining is essential to performance. Without it GCC would not inline a function (even if marked) if it was used more than two or three times. This has a rather drastic performance impact. It does come at the expense of some space, however. For example, the high() function expands to 5 instructions:
mov r7, OUTA rdlong r6, r3 or r7, r6 mov OUTA, r7 or DIRA,r6
If you use high() in many places the total could add up. On the other hand, the forced inlining may give the optimizer more chances to make things small. You should try it both ways and compare.
The original source for this class was posted by David Michael Betz, and modified by SRLM.
INLINE libpropeller::Pin::Pin | ( | ) |
INLINE libpropeller::Pin::Pin | ( | int | pin | ) |
INLINE int libpropeller::Pin::getPin | ( | void | ) |
INLINE void libpropeller::Pin::high | ( | void | ) |
INLINE int libpropeller::Pin::input | ( | void | ) |
INLINE bool libpropeller::Pin::isOutput | ( | void | ) |
INLINE void libpropeller::Pin::low | ( | void | ) |
INLINE void libpropeller::Pin::output | ( | int | setting | ) |
void libpropeller::Pin::pwm | ( | const int | decihz, |
const bool | useCTRA = true , |
||
Pin * | alternatePin = NULL |
||
) |
Output a PWM wave on a pin.
decihz | The frequency to PWM at. A parameter of 0 disables the PWM. |
useCTRA | Explicitly specify which counter to use. True for CTRA, false for CTRB |
alternatePin | Specify a pin to have an alternating PWM on. That pin will be the logical inverse of whatever this pin is. |
Definition at line 112 of file pin.h.
INLINE void libpropeller::Pin::toggle | ( | void | ) |