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
SPIEEPROM.h@2:bb0f631a6068, 2013-06-06 (annotated)
- Committer:
- RichardE
- Date:
- Thu Jun 06 20:11:28 2013 +0000
- Revision:
- 2:bb0f631a6068
More code brought in from Maple version. Now uses fancy character set and displays Robotric logo. Started re-writing I2C EEPROM code as SPI EEPROM code since now using an SPI EEPROM but not finished yet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RichardE | 2:bb0f631a6068 | 1 | /* |
RichardE | 2:bb0f631a6068 | 2 | * SOURCE FILE : SPIEEPROM.h |
RichardE | 2:bb0f631a6068 | 3 | * |
RichardE | 2:bb0f631a6068 | 4 | * Definition of class SPIEEPROM. |
RichardE | 2:bb0f631a6068 | 5 | * Rountines for communicating with a serial EEPROM over an SPI link. |
RichardE | 2:bb0f631a6068 | 6 | * EEPROM in question is a Microchip 25AA256. |
RichardE | 2:bb0f631a6068 | 7 | * |
RichardE | 2:bb0f631a6068 | 8 | */ |
RichardE | 2:bb0f631a6068 | 9 | |
RichardE | 2:bb0f631a6068 | 10 | #ifndef SPIEEPROMDefined |
RichardE | 2:bb0f631a6068 | 11 | |
RichardE | 2:bb0f631a6068 | 12 | #define SPIEEPROMDefined |
RichardE | 2:bb0f631a6068 | 13 | |
RichardE | 2:bb0f631a6068 | 14 | #include "Types.h" |
RichardE | 2:bb0f631a6068 | 15 | #include "mbed.h" // for SPI |
RichardE | 2:bb0f631a6068 | 16 | |
RichardE | 2:bb0f631a6068 | 17 | class SPIEEPROM { |
RichardE | 2:bb0f631a6068 | 18 | |
RichardE | 2:bb0f631a6068 | 19 | public : |
RichardE | 2:bb0f631a6068 | 20 | |
RichardE | 2:bb0f631a6068 | 21 | /***************/ |
RichardE | 2:bb0f631a6068 | 22 | /* CONSTRUCTOR */ |
RichardE | 2:bb0f631a6068 | 23 | /***************/ |
RichardE | 2:bb0f631a6068 | 24 | // Pass pointer to an SPI object in spiLink. |
RichardE | 2:bb0f631a6068 | 25 | // Pass pointer to output used as chip select in chipSelect. |
RichardE | 2:bb0f631a6068 | 26 | SPIEEPROM( SPI *spi, DigitalOut *cs ); |
RichardE | 2:bb0f631a6068 | 27 | |
RichardE | 2:bb0f631a6068 | 28 | /**************/ |
RichardE | 2:bb0f631a6068 | 29 | /* DESTRUCTOR */ |
RichardE | 2:bb0f631a6068 | 30 | /**************/ |
RichardE | 2:bb0f631a6068 | 31 | virtual ~SPIEEPROM(); |
RichardE | 2:bb0f631a6068 | 32 | |
RichardE | 2:bb0f631a6068 | 33 | /*************************************/ |
RichardE | 2:bb0f631a6068 | 34 | /* ATTEMPT TO READ A NUMBER OF BYTES */ |
RichardE | 2:bb0f631a6068 | 35 | /*************************************/ |
RichardE | 2:bb0f631a6068 | 36 | // Pass address within EEPROM in address. |
RichardE | 2:bb0f631a6068 | 37 | // Pass pointer to buffer for bytes read in buffer. |
RichardE | 2:bb0f631a6068 | 38 | // Pass number of bytes to read in count. |
RichardE | 2:bb0f631a6068 | 39 | // Returns true if successful, false if not. |
RichardE | 2:bb0f631a6068 | 40 | bool ReadBytes( UInt16 address, UInt8 *buffer, UInt16 count ); |
RichardE | 2:bb0f631a6068 | 41 | |
RichardE | 2:bb0f631a6068 | 42 | /**************************************/ |
RichardE | 2:bb0f631a6068 | 43 | /* ATTEMPT TO WRITE A NUMBER OF BYTES */ |
RichardE | 2:bb0f631a6068 | 44 | /**************************************/ |
RichardE | 2:bb0f631a6068 | 45 | // Pass address within EEPROM in address. |
RichardE | 2:bb0f631a6068 | 46 | // Pass pointer to buffer of bytes to write in buffer. |
RichardE | 2:bb0f631a6068 | 47 | // Pass number of bytes to write in count. |
RichardE | 2:bb0f631a6068 | 48 | // Returns true if successful, false if not. |
RichardE | 2:bb0f631a6068 | 49 | bool WriteBytes( UInt16 address, const UInt8 *buffer, UInt16 count ); |
RichardE | 2:bb0f631a6068 | 50 | |
RichardE | 2:bb0f631a6068 | 51 | private : |
RichardE | 2:bb0f631a6068 | 52 | |
RichardE | 2:bb0f631a6068 | 53 | // Pointer to SPI object used for communication. |
RichardE | 2:bb0f631a6068 | 54 | SPI *spi; |
RichardE | 2:bb0f631a6068 | 55 | |
RichardE | 2:bb0f631a6068 | 56 | // Pointer to digital output used as chip select. |
RichardE | 2:bb0f631a6068 | 57 | DigitalOut *cs; |
RichardE | 2:bb0f631a6068 | 58 | |
RichardE | 2:bb0f631a6068 | 59 | /**************************************/ |
RichardE | 2:bb0f631a6068 | 60 | /* ATTEMPT TO WRITE A CHUNK TO EEPROM */ |
RichardE | 2:bb0f631a6068 | 61 | /**************************************/ |
RichardE | 2:bb0f631a6068 | 62 | // Pass address within EEPROM in address. |
RichardE | 2:bb0f631a6068 | 63 | // Pass pointer to buffer of bytes to write in buffer. |
RichardE | 2:bb0f631a6068 | 64 | // Pass number of bytes to write in count. |
RichardE | 2:bb0f631a6068 | 65 | // Returns true if successful, false if not. |
RichardE | 2:bb0f631a6068 | 66 | // The number of bytes written must not exceed WIRE_BUFSIZ - 2. |
RichardE | 2:bb0f631a6068 | 67 | bool WriteChunk( UInt16 address, const UInt8 *buffer, UInt8 count ); |
RichardE | 2:bb0f631a6068 | 68 | |
RichardE | 2:bb0f631a6068 | 69 | }; |
RichardE | 2:bb0f631a6068 | 70 | |
RichardE | 2:bb0f631a6068 | 71 | #endif |
RichardE | 2:bb0f631a6068 | 72 | |
RichardE | 2:bb0f631a6068 | 73 | /* END of SPIEEPROM.h */ |
RichardE | 2:bb0f631a6068 | 74 |