#include <stdio.h>
#include <fcntl.h>
#include <asm/termios.h>
#include "gp3lib.h"
Go to the source code of this file.
Defines | |
#define | BAUDRATE B57600 |
#define | DEMO 1 |
#define | DEBUGOUT 0 |
#define | DEBUG(tag, x) |
Functions | |
int | gp3openport (char *port) |
void | gp3closeport () |
Close the GP3 port. | |
int | gp3write (int byte) |
Write a byte to the GP3. | |
unsigned int | gp3read (void) |
Read a byte from the GP3. | |
int | gp3ready (void) |
Optional function reads the CTS input to determine if the GP3 is ready. | |
unsigned int | gp3readword (void) |
Read a 16-bit word from the GP3. | |
void | gp3setLED (int onoff) |
Set the GP3's onboard LED. | |
unsigned int | gp3a2d (int chan) |
Read an analog channel. | |
void | gp3high (int pin) |
Set a GP3 pin High The pin is automatically made an output. | |
void | gp3low (int pin) |
Set a GP3 pin Low The pin is automatically made an output. | |
void | gp3toggle (int pin) |
Toggle a GP3 output pin (that is set from low to high or high to low) The pin is automatically made an output. | |
int | gp3input (int pin) |
Read a GP3 input pin. | |
void | gp3settris (int tris) |
Set the GP3 direction register. | |
unsigned int | gp3gettris (void) |
Get the GP3 direction register. | |
void | gp3setpins (int byte) |
Set all output pins at once (does not affect input pins). | |
unsigned int | gp3getpins (void) |
Read all input pins at once. | |
void | gp3writeee (int address, int byte) |
Write to EEPROM. | |
unsigned int | gp3readee (int address) |
Read from EEPROM. | |
void | gp3pwm (int chan, int dc, int dfreq) |
Generate PWM. | |
unsigned int | gp3count (int pin, unsigned int ms) |
Count transitions on a digital input. | |
unsigned int | gp3rctime (int pin, int state) |
Read an RC charge/discharge time. | |
unsigned int | gp3pulsein (int pin, int state) |
Measure a single pulse. | |
void | gp3pulseout (int pin, int duration) |
Generate a single pulse. | |
void | gp3freq (int pin, int ms, int freq) |
Generate a psuedo sine wave. | |
void | gp3setcounter (int prescale, int ext) |
Set hardware counter options. | |
unsigned int | gp3counter (void) |
Read hardware counter and reset to 0. | |
void | gp3resetall (void) |
Reset GP3 to power up state. | |
void | gp3reset (void) |
Reset GP3's communicatios state. | |
void | gp3repeat (int count) |
Repeat next command. | |
void | gp3argincr (void) |
Increment the internal argument. | |
void | gp3argdecr (void) |
Deccrement the internal argument. | |
unsigned int | gp3check (void) |
Check the GP3 status. | |
void | pause () |
int | main (int argc, char *argv[]) |
|
Definition at line 31 of file gp3libx.c. Referenced by gp3openport(). |
|
|
|
|
|
|
|
Read an analog channel.
Definition at line 154 of file gp3libx.c. References gp3readword(), and gp3write(). Referenced by main(). |
|
Deccrement the internal argument. You should not need to call this function under normal circumstances. Definition at line 304 of file gp3libx.c. References gp3write(). |
|
Increment the internal argument. You should not need to call this function under normal circumstances. Definition at line 298 of file gp3libx.c. References gp3write(). |
|
Check the GP3 status. If the GP3 is ready and connected it will return a version number (currently 0x33).
Definition at line 309 of file gp3libx.c. References gp3read(), and gp3write(). |
|
Count transitions on a digital input. The pin automatically becomes an input. This command always counts rising edges. Sampling occurs every 4uS.
Definition at line 226 of file gp3libx.c. References gp3readword(), and gp3write(). |
|
Read hardware counter and reset to 0.
Definition at line 275 of file gp3libx.c. References gp3readword(), and gp3write(). |
|
Generate a psuedo sine wave.
Definition at line 252 of file gp3libx.c. References gp3write(). |
|
Read all input pins at once.
Definition at line 199 of file gp3libx.c. References gp3read(), and gp3write(). |
|
Get the GP3 direction register. The tris parameter has 8 bits that each correspond to a GP3 digital I/O pin A 0 in a tris bit indicates an output bit and a 1 indicates an input bit
Definition at line 187 of file gp3libx.c. References gp3read(), and gp3write(). |
|
Set a GP3 pin High The pin is automatically made an output.
Definition at line 160 of file gp3libx.c. References gp3write(). Referenced by main(). |
|
Read a GP3 input pin. The pin is automatically made an input.
Definition at line 175 of file gp3libx.c. References gp3read(), and gp3write(). |
|
Set a GP3 pin Low The pin is automatically made an output.
Definition at line 165 of file gp3libx.c. References gp3write(). Referenced by main(). |
|
Definition at line 49 of file gp3libx.c. References BAUDRATE. |
|
Measure a single pulse.
Definition at line 240 of file gp3libx.c. References gp3readword(), and gp3write(). |
|
Generate a single pulse. This command inverts the output pin's state for the specified duration.
Definition at line 246 of file gp3libx.c. References gp3write(). |
|
Generate PWM.
Definition at line 219 of file gp3libx.c. References gp3write(). Referenced by main(). |
|
Read an RC charge/discharge time. This command allows you to read the amount of time required for an RC (resistor/capacitor) network to charge or discharge. It is useful for measuring resistive or capacitive sensors like thermistors, pots, etc.
Definition at line 233 of file gp3libx.c. References gp3readword(), and gp3write(). |
|
Read from EEPROM.
Definition at line 212 of file gp3libx.c. References gp3read(), and gp3write(). |
|
Read a 16-bit word from the GP3.
Definition at line 140 of file gp3libx.c. References gp3read(). |
|
Repeat next command. Eligible commands include gp3a2d, gp3input, gp3rctime,gp3getpins, gp3gettris, and gp3pulsein If you set the count to 100, for example, and then issued one gp3a2d command, you'd follow it with 99 gp3readword calls to fetch the other 99 A/D samples.
Definition at line 291 of file gp3libx.c. References gp3write(). |
|
Reset GP3's communicatios state.
Definition at line 286 of file gp3libx.c. References gp3write(). |
|
Reset GP3 to power up state.
Definition at line 281 of file gp3libx.c. References gp3write(). |
|
Set hardware counter options.
Definition at line 261 of file gp3libx.c. References gp3write(). |
|
Set the GP3's onboard LED.
Definition at line 149 of file gp3libx.c. References gp3write(). Referenced by main(). |
|
Set all output pins at once (does not affect input pins).
Definition at line 193 of file gp3libx.c. References gp3write(). |
|
Set the GP3 direction register. The tris parameter has 8 bits that each correspond to a GP3 digital I/O pin A 0 in a tris bit indicates an output bit and a 1 indicates an input bit This overrides previous calls to gp3high, gp3low, gp3input, etc.
Definition at line 181 of file gp3libx.c. References gp3write(). |
|
Toggle a GP3 output pin (that is set from low to high or high to low) The pin is automatically made an output.
Definition at line 170 of file gp3libx.c. References gp3write(). |
|
Write to EEPROM.
Definition at line 205 of file gp3libx.c. References gp3write(). |
|
Definition at line 328 of file gp3libx.c. References gp3a2d(), gp3check(), gp3closeport(), gp3high(), gp3low(), gp3openport(), gp3pwm(), gp3ready(), gp3resetall(), gp3setLED(), and pause(). |
|
|