JeeLib
An easy interface to the port headers, the RF12 driver library, timers, low-power code, and more.
 All Classes Files Functions Variables Enumerations Macros Pages
Port Class Reference

Interface for JeeNode Ports - see the wiki docs for JeeNodes and pinouts. More...

#include <Ports.h>

Inheritance diagram for Port:
BlinkPlug H48C HM55B InfraredPlug InputPlug PIR PortI2C RemotePort SHT11

Public Member Functions

 Port (uint8_t num)
 Contructor for a Port.
 
void mode (uint8_t value) const
 Set the pin mode of a Port's D pin. More...
 
uint8_t digiRead () const
 Reads the value of a Port's D pin. More...
 
void digiWrite (uint8_t value) const
 Write High or Low to a Port's D pin. More...
 
void anaWrite (uint8_t val) const
 Writes a PWM value to a Port's D pin.
 
uint32_t pulse (uint8_t state, uint32_t timeout=1000000L) const
 Applies the Arduino pulseIn() function on a Port's D pin. More...
 
void mode2 (uint8_t value) const
 Set the pin mode of a Port's A pin. More...
 
uint16_t anaRead () const
 Reads an analog value from a Port's A pin. More...
 
uint8_t digiRead2 () const
 Reads the value of a Port's A pin. More...
 
void digiWrite2 (uint8_t value) const
 Write High or Low to a Port's A pin. More...
 
uint32_t pulse2 (uint8_t state, uint32_t timeout=1000000L) const
 Applies the Arduino pulseIn() function on a Port's A pin. More...
 
void shift (uint8_t bitOrder, uint8_t value) const
 Does Arduino shiftOut() with data on D and clock on A pin of the Port. More...
 
uint16_t shiftRead (uint8_t bitOrder, uint8_t count=8) const
 Shift a number of bites in to read them. More...
 
void shiftWrite (uint8_t bitOrder, uint16_t value, uint8_t count=8) const
 The shiftWrite() call is similar but more general than the shift() call in that it allows an adjustable number of bits to be sent, not just 8. More...
 

Static Public Member Functions

static void mode3 (uint8_t value)
 Set the pin mode of the I pin on all Ports. More...
 
static uint8_t digiRead3 ()
 Reads the value of the I pin on all Ports. More...
 
static void digiWrite3 (uint8_t value)
 Writes the value of the I pin on all Ports. More...
 
static void anaWrite3 (uint8_t val)
 Writes a PWM value to the I pin of all Ports.
 

Protected Member Functions

uint8_t digiPin () const
 
uint8_t digiPin2 () const
 
uint8_t anaPin () const
 

Static Protected Member Functions

static uint8_t digiPin3 ()
 

Protected Attributes

uint8_t portNum
 The port number is a small integer mathing the hardware port used. More...
 

Detailed Description

Interface for JeeNode Ports - see the wiki docs for JeeNodes and pinouts.

The Ports class is a thin wrapper around the Arduino's digitalRead(), digitalWrite(), analogRead(), etc. functions. It was designed to simplify the use of the four standard port headers on JeeNodes.

Member Function Documentation

uint8_t Port::anaPin ( ) const
inlineprotected
Returns
Arduino analog pin number of a Port's A pin (uint8_t).
uint16_t Port::anaRead ( ) const
inline

Reads an analog value from a Port's A pin.

Returns
int [0..1023]
uint8_t Port::digiPin ( ) const
inlineprotected
Returns
Arduino digital pin number of a Port's D pin (uint8_t).
uint8_t Port::digiPin2 ( ) const
inlineprotected
Returns
Arduino digital pin number of a Port's A pin (uint8_t).
static uint8_t Port::digiPin3 ( )
inlinestaticprotected
Returns
Arduino digital pin number of the I pin on all Ports (uint8_t).
uint8_t Port::digiRead ( ) const
inline

Reads the value of a Port's D pin.

Returns
High or Low.
uint8_t Port::digiRead2 ( ) const
inline

Reads the value of a Port's A pin.

Returns
High or Low.
static uint8_t Port::digiRead3 ( )
inlinestatic

Reads the value of the I pin on all Ports.

Returns
High or Low.
void Port::digiWrite ( uint8_t  value) const
inline

Write High or Low to a Port's D pin.

Parameters
valueHigh or Low.
void Port::digiWrite2 ( uint8_t  value) const
inline

Write High or Low to a Port's A pin.

Parameters
valueHigh or Low.
static void Port::digiWrite3 ( uint8_t  value)
inlinestatic

Writes the value of the I pin on all Ports.

Parameters
valueHigh or Low.
void Port::mode ( uint8_t  value) const
inline

Set the pin mode of a Port's D pin.

The mode() function member sets the I/O data direction of the DIO pin associated with a specific port.

Parameters
valueINPUT or OUTPUT.
void Port::mode2 ( uint8_t  value) const
inline

Set the pin mode of a Port's A pin.

The mode2() function member sets the I/O data direction of the AIO pin associated with a specific port.

Parameters
valueINPUT or OUTPUT.
static void Port::mode3 ( uint8_t  value)
inlinestatic

Set the pin mode of the I pin on all Ports.

The mode3() function member sets the I/O direction of the IRQ pin associated with a specific port. Note that this is the same pin on all ports.

Parameters
valueINPUT or OUTPUT.
uint32_t Port::pulse ( uint8_t  state,
uint32_t  timeout = 1000000L 
) const
inline

Applies the Arduino pulseIn() function on a Port's D pin.

Measure the length of a pulse in microseconds on the DIO (pulse) or AIO (pulse2) line. The optional timeout value specifies how many microseconds to wait for a pulse - of none is received, 0 is returned.

Parameters
statePolarity of the pulse to wait for - HIGH (1) or LOW (0).
timeoutMax number of microseconds to wait. Default is 1,000,000, i.e. 1 second.
See Also
http://arduino.cc/en/Reference/pulseIn for more details.
uint32_t Port::pulse2 ( uint8_t  state,
uint32_t  timeout = 1000000L 
) const
inline

Applies the Arduino pulseIn() function on a Port's A pin.

See Also
http://arduino.cc/en/Reference/pulseIn for more details.
void Port::shift ( uint8_t  bitOrder,
uint8_t  value 
) const
inline

Does Arduino shiftOut() with data on D and clock on A pin of the Port.

This can be used to send out a pulse sequence of bits or to read such a pulse sequence in. The AIO line is cycled while the value bits are "shifted" and written out to (shift, shiftWrite) or read in from (shiftRead) the DIO pin.

Parameters
bitOrderHow to shift bits in or out: either LSBFIRST (0) or MSBFIRST (1), where LSB stands for Least Significant Bit and MSB for Most Significant Bit.
valueThe value to shift out, with as many lower bits as needed. This argument is a byte for shift() and a word for the more general shiftWrite() function.
See Also
http://arduino.cc/en/Tutorial/ShiftOut
uint16_t Port::shiftRead ( uint8_t  bitOrder,
uint8_t  count = 8 
) const

Shift a number of bites in to read them.

Parameters
bitOrderHow to shift bits in or out: either LSBFIRST (0) or MSBFIRST (1), where LSB stands for Least Significant Bit and MSB for Most Significant Bit.
countThe number of bits to shift in or out. Must be in the range 1 .. 16, the default is 8.
See Also
shift()
void Port::shiftWrite ( uint8_t  bitOrder,
uint16_t  value,
uint8_t  count = 8 
) const

The shiftWrite() call is similar but more general than the shift() call in that it allows an adjustable number of bits to be sent, not just 8.

Parameters
bitOrderHow to shift bits in or out: either LSBFIRST (0) or MSBFIRST (1), where LSB stands for Least Significant Bit and MSB for Most Significant Bit.
valueThe value to shift out, with as many lower bits as needed. This argument is a byte for shift() and a word for the more general shiftWrite() function.
countThe number of bits to shift in or out. Must be in the range 1 .. 16, the default is 8.
See Also
shift()

Member Data Documentation

uint8_t Port::portNum
protected

The port number is a small integer mathing the hardware port used.

Port 0 is special, it designates the I2C hardware pins on a JeeNode.


The documentation for this class was generated from the following files: