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
Diff: SPIEEPROM.h
- Revision:
- 2:bb0f631a6068
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SPIEEPROM.h Thu Jun 06 20:11:28 2013 +0000 @@ -0,0 +1,74 @@ +/* + * SOURCE FILE : SPIEEPROM.h + * + * Definition of class SPIEEPROM. + * Rountines for communicating with a serial EEPROM over an SPI link. + * EEPROM in question is a Microchip 25AA256. + * + */ + +#ifndef SPIEEPROMDefined + + #define SPIEEPROMDefined + + #include "Types.h" + #include "mbed.h" // for SPI + + class SPIEEPROM { + + public : + + /***************/ + /* CONSTRUCTOR */ + /***************/ + // Pass pointer to an SPI object in spiLink. + // Pass pointer to output used as chip select in chipSelect. + SPIEEPROM( SPI *spi, DigitalOut *cs ); + + /**************/ + /* DESTRUCTOR */ + /**************/ + virtual ~SPIEEPROM(); + + /*************************************/ + /* 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 : + + // Pointer to SPI object used for communication. + SPI *spi; + + // Pointer to digital output used as chip select. + DigitalOut *cs; + + /**************************************/ + /* 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 SPIEEPROM.h */ +