Digital Input / Output

Controls digital input and output. More...

Defines

#define PIN_A0   8
 Pin A0.
#define PIN_A1   9
 Pin A1.
#define PIN_A2   10
 Pin A2.
#define PIN_A3   11
 Pin A3.
#define PIN_A4   12
 Pin A4.
#define PIN_A5   13
 Pin A5.
#define PIN_A6   14
 Pin A6.
#define PIN_A7   15
 Pin A7.
#define PIN_SS   16
 Pin SS.
#define PIN_SCK   17
 Pin SCK.
#define PIN_MOSI   18
 Pin MOSI.
#define PIN_MISO   19
 Pin MISO.
#define PIN_LCD_COMMAND   20
 LCD Command Pin.
#define PIN_C0   24
 Pin C0.
#define PIN_C1   25
 Pin C1.
#define PIN_C2   26
 Pin C2.
#define PIN_C3   27
 Pin C3.
#define PIN_C4   28
 Pin C4.
#define PIN_C5   29
 Pin C5.
#define PIN_C6   30
 Pin C6.
#define PIN_C7   31
 Pin C7.
#define PIN_SCL   32
 Pin SCL.
#define PIN_SDA   33
 Pin SDA.
#define PIN_RX0   40
 Pin RX0.
#define PIN_TX0   41
 Pin TX0.
#define PIN_LCD_RESET   42
 LCD Reset Pin.
#define PIN_E6   46
 Pin E6.
#define PIN_EXT_DIO1   46
 Pin EXT_DIO1.
#define PIN_E7   47
 Pin E7.
#define PIN_EXT_DIO2   48
 Pin EXT_DIO2.
#define PIN_AN0   48
 Pin AN0.
#define PIN_ADC0   48
 Pin ADC0.
#define PIN_AN1   49
 Pin AN1.
#define PIN_ADC1   49
 Pin ADC1.
#define PIN_AN2   50
 Pin AN2.
#define PIN_ADC2   50
 Pin ADC2.
#define PIN_AN3   51
 Pin AN3.
#define PIN_ADC3   51
 Pin ADC3.
#define PIN_AN4   52
 Pin AN4.
#define PIN_ADC4   52
 Pin ADC4.
#define PIN_AN5   53
 Pin AN5.
#define PIN_ADC5   53
 Pin ADC5.
#define PIN_AN6   54
 Pin AN6.
#define PIN_ADC6   54
 Pin ADC6.
#define PIN_AN7   55
 Pin AN7.
#define PIN_ADC7   55
 Pin ADC7.
#define PIN_WHEEL   54
 Wheel Pin.
#define PIN_BATT   55
 Battery Voltage Monitor Pin.
#define PIN_BTN1   56
 button1 Pin
#define PIN_BTN2   57
 button2 Pin
#define PIN_LED1   58
 LED1 Pin.
#define PIN_BTN   PING
 Button Pin.
#define BTN2   PING1
 button2 Pin
#define BTN1   PING0
 button1 Pin

Functions

int digital_input (int)
 Read a portpin.
void digital_output (int bit, int val)
 Output to a portpin.
void digital_pull_up (int)
 Pullup a portpin.
int button1_read (void)
 Check if button1 is pressed.
int button1_click (void)
 Check if button1 is clicked.
void button1_wait (void)
 Wait until button1 is pressed.
int button2_read (void)
 Check if button2 is pressed.
int button2_click (void)
 Check if button2 is clicked.
void button2_wait (void)
 Wait until button2 is pressed.

Detailed Description

Controls digital input and output.

A general note on how port / pin numbers work:
The portpin is used to select both the bank and which pin is selected. 6 bits are used (lower 6, ex: 0b00abcdef). The first 3 (abc in this example) are used to select the bank.
A = 001
B = 010
C = 011
D = 100
E = 101
F = 110
G = 111

The bank can be found by doing portpin >> 3.

The next three (def in this example) are used to select the pin number. These three bits are just the binary representation of the pin number.

The pin number can be found by doing portpin & 0b111.

Include dio.h to access these functions.


Function Documentation

int button1_click void   ) 
 

Check if button1 is clicked.

If button1 is pressed, waits until it is released before returning. Otherwise, the function returns immediately.

Returns:
1 if button1 has been pressed, 0 otherwise
See also:
button1_read, button1_wait

int button1_read void   ) 
 

Check if button1 is pressed.

Checks if button1 is currently pressed.

Returns:
1 if button1 is pressed, 0 otherwise
See also:
button1_wait, button1_click

void button1_wait void   ) 
 

Wait until button1 is pressed.

Delays execution until button1 is pressed.

See also:
button1_read, button1_click

int button2_click void   ) 
 

Check if button2 is clicked.

If button2 is pressed, waits until it is released before returning. Otherwise, the function returns immediately.

Returns:
1 if button2 has been pressed, 0 otherwise
See also:
button2_read, button2_wait

int button2_read void   ) 
 

Check if button2 is pressed.

Checks if button2 is currently pressed.

Returns:
1 if button2 is pressed, 0 otherwise
See also:
button2_wait, button2_click

void button2_wait void   ) 
 

Wait until button2 is pressed.

Delays execution until button2 is pressed.

See also:
button2_read, button2_click

int digital_input int  portpin  ) 
 

Read a portpin.

Reads the selected portpin.

Parameters:
portpin The portpin to be read. See the general description for a description of portpins.
Returns:
1 or 0, depending on the value of the portpin.

void digital_output int  portpin,
int  val
 

Output to a portpin.

Sets portpin to the given value.

Parameters:
portpin the portpin to output to. See the general description for a discussion of portpins.
val the value to set the portpin to. 0 for off, nonzero for on.

void digital_pull_up int  portpin  ) 
 

Pullup a portpin.

Enables pullup on a pin. If it is an output pin, the pin will output 1.

Parameters:
portpin the pin to enable pullup on. See the general description for a discussion of portpins.


Generated on Fri Sep 14 15:36:18 2007 for libdragonfly by  doxygen 1.4.6