Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

spyglass.h

Go to the documentation of this file.
00001 /*! \file spyglass.h \brief Spyglass Control Panel UI Board Driver. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'spyglass.h'
00005 // Title        : Spyglass Control Panel UI Board Driver
00006 // Author       : Pascal Stang - Copyright (C) 2005
00007 // Created      : 7/20/2005
00008 // Revised      : 7/23/2005
00009 // Version      : 0.9
00010 // Target MCU   : Atmel AVR series
00011 // Editor Tabs  : 4
00012 //
00013 /// \ingroup driver_hw
00014 /// \defgroup spyglass Spyglass Control Panel UI Board Driver (spyglass.c)
00015 /// \code
00016 ///     #include "lcd.h"
00017 ///     #include "i2c.h"
00018 ///     #include "spyglass.h"
00019 /// \endcode
00020 /// \par Overview
00021 ///     This library supports the 'Spyglass' I2C-controlled User Interface
00022 ///     board.  The Spyglass board has a standard 4x20 character LCD and a
00023 ///     convenient array of pushbuttons for a user interface.  The board also
00024 ///     has a user-controllable piezo beeper.  All of these functions are
00025 ///     accessible via I2C bus, making it possible to have a complete user
00026 ///     interface with just 4 wires (2 I/O and 2 power wires).  The Spyglass
00027 ///     board runs on 5V power.
00028 ///
00029 /// \par Connections:
00030 ///     - Connect power to the +5V and ground pins.
00031 ///     - Connect the SCL/SDA pins to the corresponding SCL/SDA pins of
00032 ///          your processor's I2C bus.
00033 ///     - If you wish to use the beeper, also connect +5V to pin 8.
00034 ///
00035 /// \code
00036 ///  SPYGLASS PINOUT for 10-pin I/O header:
00037 ///
00038 ///             ----
00039 ///     +5V - 1 |++| 2 - +5V
00040 ///     SCL - 3 |++| 4 - GND
00041 ///     SDA - 5 |++| 6 - GND
00042 ///           7 |++| 8 - BEEPER PWR (+5V)
00043 ///           9 |++| 10
00044 ///             ----
00045 /// \endcode
00046 //
00047 // This code is distributed under the GNU Public License
00048 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00049 //
00050 //*****************************************************************************
00051 //@{
00052 
00053 #ifndef SPYGLASS_H
00054 #define SPYGLASS_H
00055 
00056 // defines
00057 // Base I2C node addresses
00058 #define PCF8574_I2C_BASE_ADDR   0x40
00059 #define MAX517_I2C_BASE_ADDR    0x58
00060 
00061 // PCF8574 node addresses
00062 #define PCF_NODE_BUTTONS        0x00
00063 #define PCF_NODE_LCD_DATA       0x01
00064 #define PCF_NODE_CONTROL        0x02
00065 
00066 // Control node bit-defines
00067 #define SPYGLASS_LED0       0x01
00068 #define SPYGLASS_LED1       0x02
00069 #define SPYGLASS_BEEPER     0x04
00070 #define SPYGLASS_LCD_RS     0x20
00071 #define SPYGLASS_LCD_RW     0x40
00072 #define SPYGLASS_LCD_E      0x80
00073 
00074 // map lcd.c commands to spyglass.c LCD commands
00075 #define lcdInit         spyglassLcdInit
00076 #define lcdHome         spyglassLcdHome
00077 #define lcdClear        spyglassLcdClear
00078 #define lcdGotoXY       spyglassLcdGotoXY
00079 #define lcdDataWrite    spyglassLcdWriteChar
00080 
00081 // functions
00082 //! initialize the I2C bus for communication with the spyglass UI.
00083 void spyglassInit(void);
00084 
00085 // *********** MISC INPUT/OUTPUT commands ***********
00086 
00087 //! Read the state of pushbuttons on the spyglass UI.
00088 /// Returns an 8-bit number representing the state of buttons S1-S7 in bits 0-6 respectively.
00089 ///  - '0' bit value = button not pressed
00090 ///  - '1' bit value = button is pressed
00091 u08 spyglassGetPushbuttons(void);
00092 
00093 //! Sets the state of LEDs on the spyglass UI.
00094 /// Argument is a 2-bit number representing the desired state of LEDs D2 & D3 respectively.
00095 ///  - '0' bit value = LED off
00096 ///  - '1' bit value = LED on
00097 void spyglassSetLeds(u08 leds);
00098 
00099 //! Sets the state of the beeper on the spyglass UI.
00100 /// - '0' state => beeper off
00101 /// - '1' state => beeper on
00102 void spyglassSetBeeper(u08 state);
00103 
00104 //! Sets the contrast voltage of the spyglass LCD.
00105 /// Lower numbers are darker contrast, higher numbers are lighter contrast.
00106 u08 spyglassSetLcdContrast(u08 contrast);
00107 
00108 // *********** LCD commands ***********
00109 
00110 //! Initialize LCD for operation.
00111 void spyglassLcdInit(void);
00112 //! Set write/cursor position to upper left. 
00113 void spyglassLcdHome(void);
00114 //! Clear LCD display.
00115 void spyglassLcdClear(void);
00116 //! Set write/cursor posision on LCD display (x=col, y=line).
00117 void spyglassLcdGotoXY(u08 x, u08 y);
00118 //! Write control or display data to LCD.
00119 void spyglassLcdWrite(u08 rs, u08 data);
00120 //! Write character to LCD.
00121 void spyglassLcdWriteChar(u08 c);
00122 
00123 // *********** LOW-LEVEL ACCESS ***********
00124 
00125 //! Write I/O Data to PCF8574 I2C<->Digital I/O chip.
00126 u08 pcf8574Write(u08 nodeAddr, u08 data);
00127 //! Read I/O Data from PCF8574 I2C<->Digital I/O chip.
00128 u08 pcf8574Read(u08 nodeAddr);
00129 
00130 #endif
00131 //@}

Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by  doxygen 1.4.2