| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | /*! \file spyglass.h \brief Spyglass Control Panel UI Board Driver. */ |
| 2 | //***************************************************************************** |
||
| 3 | // |
||
| 4 | // File Name : 'spyglass.h' |
||
| 5 | // Title : Spyglass Control Panel UI Board Driver |
||
| 6 | // Author : Pascal Stang - Copyright (C) 2005 |
||
| 7 | // Created : 7/20/2005 |
||
| 8 | // Revised : 7/23/2005 |
||
| 9 | // Version : 0.9 |
||
| 10 | // Target MCU : Atmel AVR series |
||
| 11 | // Editor Tabs : 4 |
||
| 12 | // |
||
| 13 | /// \ingroup driver_hw |
||
| 14 | /// \defgroup spyglass Spyglass Control Panel UI Board Driver (spyglass.c) |
||
| 15 | /// \code |
||
| 16 | /// #include "lcd.h" |
||
| 17 | /// #include "i2c.h" |
||
| 18 | /// #include "spyglass.h" |
||
| 19 | /// \endcode |
||
| 20 | /// \par Overview |
||
| 21 | /// This library supports the 'Spyglass' I2C-controlled User Interface |
||
| 22 | /// board. The Spyglass board has a standard 4x20 character LCD and a |
||
| 23 | /// convenient array of pushbuttons for a user interface. The board also |
||
| 24 | /// has a user-controllable piezo beeper. All of these functions are |
||
| 25 | /// accessible via I2C bus, making it possible to have a complete user |
||
| 26 | /// interface with just 4 wires (2 I/O and 2 power wires). The Spyglass |
||
| 27 | /// board runs on 5V power. |
||
| 28 | /// |
||
| 29 | /// \par Connections: |
||
| 30 | /// - Connect power to the +5V and ground pins. |
||
| 31 | /// - Connect the SCL/SDA pins to the corresponding SCL/SDA pins of |
||
| 32 | /// your processor's I2C bus. |
||
| 33 | /// - If you wish to use the beeper, also connect +5V to pin 8. |
||
| 34 | /// |
||
| 35 | /// \code |
||
| 36 | /// SPYGLASS PINOUT for 10-pin I/O header: |
||
| 37 | /// |
||
| 38 | /// ---- |
||
| 39 | /// +5V - 1 |++| 2 - +5V |
||
| 40 | /// SCL - 3 |++| 4 - GND |
||
| 41 | /// SDA - 5 |++| 6 - GND |
||
| 42 | /// 7 |++| 8 - BEEPER PWR (+5V) |
||
| 43 | /// 9 |++| 10 |
||
| 44 | /// ---- |
||
| 45 | /// \endcode |
||
| 46 | // |
||
| 47 | // This code is distributed under the GNU Public License |
||
| 48 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
| 49 | // |
||
| 50 | //***************************************************************************** |
||
| 51 | //@{ |
||
| 52 | |||
| 53 | #ifndef SPYGLASS_H |
||
| 54 | #define SPYGLASS_H |
||
| 55 | |||
| 56 | // defines |
||
| 57 | // Base I2C node addresses |
||
| 58 | #define PCF8574_I2C_BASE_ADDR 0x40 |
||
| 59 | #define MAX517_I2C_BASE_ADDR 0x58 |
||
| 60 | |||
| 61 | // PCF8574 node addresses |
||
| 62 | #define PCF_NODE_BUTTONS 0x00 |
||
| 63 | #define PCF_NODE_LCD_DATA 0x01 |
||
| 64 | #define PCF_NODE_CONTROL 0x02 |
||
| 65 | |||
| 66 | // Control node bit-defines |
||
| 67 | #define SPYGLASS_LED0 0x01 |
||
| 68 | #define SPYGLASS_LED1 0x02 |
||
| 69 | #define SPYGLASS_BEEPER 0x04 |
||
| 70 | #define SPYGLASS_LCD_RS 0x20 |
||
| 71 | #define SPYGLASS_LCD_RW 0x40 |
||
| 72 | #define SPYGLASS_LCD_E 0x80 |
||
| 73 | |||
| 74 | // map lcd.c commands to spyglass.c LCD commands |
||
| 75 | #define lcdInit spyglassLcdInit |
||
| 76 | #define lcdHome spyglassLcdHome |
||
| 77 | #define lcdClear spyglassLcdClear |
||
| 78 | #define lcdGotoXY spyglassLcdGotoXY |
||
| 79 | #define lcdDataWrite spyglassLcdWriteChar |
||
| 80 | |||
| 81 | // functions |
||
| 82 | //! initialize the I2C bus for communication with the spyglass UI. |
||
| 83 | void spyglassInit(void); |
||
| 84 | |||
| 85 | // *********** MISC INPUT/OUTPUT commands *********** |
||
| 86 | |||
| 87 | //! Read the state of pushbuttons on the spyglass UI. |
||
| 88 | /// Returns an 8-bit number representing the state of buttons S1-S7 in bits 0-6 respectively. |
||
| 89 | /// - '0' bit value = button not pressed |
||
| 90 | /// - '1' bit value = button is pressed |
||
| 91 | u08 spyglassGetPushbuttons(void); |
||
| 92 | |||
| 93 | //! Sets the state of LEDs on the spyglass UI. |
||
| 94 | /// Argument is a 2-bit number representing the desired state of LEDs D2 & D3 respectively. |
||
| 95 | /// - '0' bit value = LED off |
||
| 96 | /// - '1' bit value = LED on |
||
| 97 | void spyglassSetLeds(u08 leds); |
||
| 98 | |||
| 99 | //! Sets the state of the beeper on the spyglass UI. |
||
| 100 | /// - '0' state => beeper off |
||
| 101 | /// - '1' state => beeper on |
||
| 102 | void spyglassSetBeeper(u08 state); |
||
| 103 | |||
| 104 | //! Sets the contrast voltage of the spyglass LCD. |
||
| 105 | /// Lower numbers are darker contrast, higher numbers are lighter contrast. |
||
| 106 | u08 spyglassSetLcdContrast(u08 contrast); |
||
| 107 | |||
| 108 | // *********** LCD commands *********** |
||
| 109 | |||
| 110 | //! Initialize LCD for operation. |
||
| 111 | void spyglassLcdInit(void); |
||
| 112 | //! Set write/cursor position to upper left. |
||
| 113 | void spyglassLcdHome(void); |
||
| 114 | //! Clear LCD display. |
||
| 115 | void spyglassLcdClear(void); |
||
| 116 | //! Set write/cursor posision on LCD display (x=col, y=line). |
||
| 117 | void spyglassLcdGotoXY(u08 x, u08 y); |
||
| 118 | //! Write control or display data to LCD. |
||
| 119 | void spyglassLcdWrite(u08 rs, u08 data); |
||
| 120 | //! Write character to LCD. |
||
| 121 | void spyglassLcdWriteChar(u08 c); |
||
| 122 | |||
| 123 | // *********** LOW-LEVEL ACCESS *********** |
||
| 124 | |||
| 125 | //! Write I/O Data to PCF8574 I2C<->Digital I/O chip. |
||
| 126 | u08 pcf8574Write(u08 nodeAddr, u08 data); |
||
| 127 | //! Read I/O Data from PCF8574 I2C<->Digital I/O chip. |
||
| 128 | u08 pcf8574Read(u08 nodeAddr); |
||
| 129 | |||
| 130 | #endif |
||
| 131 | //@} |
Powered by WebSVN v2.8.3