Main Page   Modules   File List   Globals  

gp3lib.c File Reference

This is the main part of the GP3 library. More...

#include <stdio.h>
#include "gp3lib.h"

Go to the source code of this file.

Defines

#define DEMO   1
 If DEMO is set, the library will include a test main.


Functions

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)
 Decrement the internal argument.

unsigned int gp3check (void)
 Check the GP3 status.

void pause ()
 This is part of the optional demo program and just prompts the user to press enter to continue.

int main (int argc, char *argv[])
 The example main program.


Detailed Description

This is the main part of the GP3 library.

It contains the portable code and an optional demo program. This library supports the GP3 I/O board (http://www.awce.com/gp3.htm)

Author:
Al Williams alw@al-williams.com
Version:
1.1
Date:
17 Feb 2004
As shipped this code is meant to compile under Linux or Cygwin. However, if you port the following functions at the head of this file, the code should work for nearly any standard C compiler:

gp3openport - Open a com port (returns -1 for error) gp3closeport - Close the com port gp3write - Write a byte to the serial port (returns 1 for success) gp3read - Read a byte from the serial port (returns byte or -1 for error) gp3ready - (Optional) read handshake from GP3 (return 1 for ready, 0 not ready)

To do this, compile in one of the other C files included with this distribution. For example: gp3linux.c, gp3cygwin.c, etc. You must compile and link only one of these files!

For more info on the other routines see the GP3 documentation http://www.awce.com/gp3.pdf

Definition in file gp3lib.c.


Define Documentation

#define DEMO   1
 

If DEMO is set, the library will include a test main.

for normal compiles this should be set to 0.

Definition at line 33 of file gp3lib.c.


Generated on Wed Feb 18 00:34:20 2004 for GP3LIB by doxygen1.2.18