Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.

Dependencies:   25LCxxx_SPI CommonTypes Gameduino mbed

Revision:
0:5fa232ee5fdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2CEEPROM.h	Tue Jun 04 20:16:33 2013 +0000
@@ -0,0 +1,113 @@
+/*
+ * SOURCE FILE : I2CEEPROM.h
+ *
+ * Definition of class I2CEEPROM.
+ * Rountines for communicating with a serial EEPROM over an I2C link.
+ * EEPROM in question is a Microchip 24AA512.
+ * Remember you need pullup resistors on the SCL, SDA and WP lines.
+ *
+ */
+
+#ifndef I2CEEPROMDefined
+
+  #define I2CEEPROMDefined
+
+    #include "Types.h"
+    // #include "CDFWire.h"        // tweaked version of Wire library
+    
+  class I2CEEPROM {
+
+  public :
+
+    /***************/
+    /* CONSTRUCTOR */
+    /***************/
+    I2CEEPROM();
+        
+    /**************/
+    /* DESTRUCTOR */
+    /**************/
+    virtual ~I2CEEPROM();
+
+        /**************************************/
+        /* PREPARE TO COMMUNICATE WITH EEPROM */
+        /**************************************/
+        // Pass pointer to TwoWire object to use for I2C communications.
+        // Pass 3 bit address of EEPROM (as set by A0, A1 and A2 pins) in ea.
+        // Pass pin number to use for write protect in wp.
+        // void Open( TwoWire *wire, UInt8 ea, UInt8 wp );
+        
+        /*********************************************/
+        /* SHUT DOWN COMMUNICATIONS LINK WITH EEPROM */
+        /*********************************************/
+        void Close( void );
+        
+        /*****************************************/
+        /* DETERMINE IF LINK WITH EEPROM IS OPEN */
+        /*****************************************/
+        // Returns true if link is open.
+        bool IsOpen( void ) {
+            return isOpen;
+        }
+        
+        /*************************************/
+        /* ATTEMPT TO READ A NUMBER OF BYTES */
+        /*************************************/
+        // Pass address within EEPROM in address.
+        // Pass pointer to buffer for bytes read in buffer.
+        // Pass number of bytes to read in count.
+        // Returns true if successful, false if not.
+        bool ReadBytes( UInt16 address, UInt8 *buffer, UInt16 count );
+
+        /**************************************/
+        /* ATTEMPT TO WRITE A NUMBER OF BYTES */
+        /**************************************/
+        // Pass address within EEPROM in address.
+        // Pass pointer to buffer of bytes to write in buffer.
+        // Pass number of bytes to write in count.
+        // Returns true if successful, false if not.
+        bool WriteBytes( UInt16 address, const UInt8 *buffer, UInt16 count );
+        
+private :
+
+        // Indicates connection with EEPROM is open.
+        bool isOpen;
+
+        // Pointer to object that does I2C communications.
+        // TwoWire *wire;
+        
+        // Slave address consisting of three bits that identify the
+        // particular EEPROM on the I2C bus, plus bits 3 to 7 are
+        // set to 01010 binary (see 24AA512 dtasheet).
+        UInt8 slaveAddress;
+        
+        // Pin number for write protect pin.
+        UInt8 wp;
+
+        /************************************/
+        /* ATTEMPT TO READ A CHUNK OF BYTES */
+        /************************************/
+        // Pass address within EEPROM in address.
+        // Pass pointer to buffer for bytes read in buffer.
+        // Returns false if a failure occurred whilst reading EEPROM.
+        // Pass number of bytes to read in count.
+        // Returns true if successful, false if not.
+        // The number of bytes read must not exceed CHUNK_SIZE.
+        bool ReadChunk( UInt16 address, UInt8 *buffer, UInt8 count );
+
+        /**************************************/
+        /* ATTEMPT TO WRITE A CHUNK TO EEPROM */
+        /**************************************/
+        // Pass address within EEPROM in address.
+        // Pass pointer to buffer of bytes to write in buffer.
+        // Pass number of bytes to write in count.
+        // Returns true if successful, false if not.
+        // The number of bytes written must not exceed WIRE_BUFSIZ - 2.
+        bool WriteChunk( UInt16 address, const UInt8 *buffer, UInt8 count );
+
+  };
+
+#endif
+
+/* END of I2CEEPROM.h */
+