Hotboards_eeprom.cpp - Driver to control serial (spi) eeprom memories, The memories are compatibles amount the manufactures Microchip, Atmel and ST, and of course you can control Hotboards eeprom boards (http://hotboards.org)
Dependents: Hotboards_eeprom_write_byte Hotboards_eeprom_write_array
Hotboards_eeprom.h@0:38fad00cc45b, 2016-01-29 (annotated)
- Committer:
- Hotboards
- Date:
- Fri Jan 29 00:46:08 2016 +0000
- Revision:
- 0:38fad00cc45b
Initial commit for eeprom library, pretty functional
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:38fad00cc45b | 1 | /* |
Hotboards | 0:38fad00cc45b | 2 | Hotboards_eeprom.h - Driver to control serial (spi) eeprom memories, The memories are |
Hotboards | 0:38fad00cc45b | 3 | compatibles amount the manufactures Microchip, Atmel and ST, and of course you can control |
Hotboards | 0:38fad00cc45b | 4 | Hotboards eeprom board (http://hotboards.org) |
Hotboards | 0:38fad00cc45b | 5 | Created by Diego Perez, January 16, 2016. |
Hotboards | 0:38fad00cc45b | 6 | Released into the public domain. |
Hotboards | 0:38fad00cc45b | 7 | |
Hotboards | 0:38fad00cc45b | 8 | Density: 1Kbit | 2Kbit | 4Kbit | 8Kbit | 16Kbit | 32Kbit | 64Kbit | 128Kbit | 256Kbit | 512Kbit | 1 Mbit |
Hotboards | 0:38fad00cc45b | 9 | Part: 25xx010 | 25xx020 | 25xx040 | 25xx080 | 25xx160 | 25xx320 | 25xx640 | 25xx128 | 25xx256 | 25xx512 | 25xx1024 |
Hotboards | 0:38fad00cc45b | 10 | Page/Byte: 16 | 16 | 16 | 16(32) | 16(32) | 32 | 32 | 64 | 64 | 128 | 256 |
Hotboards | 0:38fad00cc45b | 11 | Addr/Bits: 7 | 8 | 9 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
Hotboards | 0:38fad00cc45b | 12 | */ |
Hotboards | 0:38fad00cc45b | 13 | |
Hotboards | 0:38fad00cc45b | 14 | #ifndef Hotboards_eeprom_h |
Hotboards | 0:38fad00cc45b | 15 | #define Hotboards_eeprom_h |
Hotboards | 0:38fad00cc45b | 16 | |
Hotboards | 0:38fad00cc45b | 17 | #include "mbed.h" |
Hotboards | 0:38fad00cc45b | 18 | |
Hotboards | 0:38fad00cc45b | 19 | //EEPROM size in kilobits. EEPROM part numbers are usually designated in k-bits. |
Hotboards | 0:38fad00cc45b | 20 | typedef enum |
Hotboards | 0:38fad00cc45b | 21 | { |
Hotboards | 0:38fad00cc45b | 22 | HT_EEPROM25xx_1Kb = 0, |
Hotboards | 0:38fad00cc45b | 23 | HT_EEPROM25xx_2Kb, |
Hotboards | 0:38fad00cc45b | 24 | HT_EEPROM25xx_4Kb, |
Hotboards | 0:38fad00cc45b | 25 | HT_EEPROM25xx_8Kb, |
Hotboards | 0:38fad00cc45b | 26 | HT_EEPROM25xx_16Kb, |
Hotboards | 0:38fad00cc45b | 27 | HT_EEPROM25xx_32Kb, |
Hotboards | 0:38fad00cc45b | 28 | HT_EEPROM25xx_64Kb, |
Hotboards | 0:38fad00cc45b | 29 | HT_EEPROM25xx_128Kb, |
Hotboards | 0:38fad00cc45b | 30 | HT_EEPROM25xx_256Kb, |
Hotboards | 0:38fad00cc45b | 31 | HT_EEPROM25xx_512Kb, |
Hotboards | 0:38fad00cc45b | 32 | HT_EEPROM25xx_1Mb |
Hotboards | 0:38fad00cc45b | 33 | }_eEEPROM; |
Hotboards | 0:38fad00cc45b | 34 | |
Hotboards | 0:38fad00cc45b | 35 | class Hotboards_eeprom |
Hotboards | 0:38fad00cc45b | 36 | { |
Hotboards | 0:38fad00cc45b | 37 | public : |
Hotboards | 0:38fad00cc45b | 38 | Hotboards_eeprom( SPI &spi, PinName cs, uint8_t type ); |
Hotboards | 0:38fad00cc45b | 39 | void init( void ); |
Hotboards | 0:38fad00cc45b | 40 | void write( uint32_t address, uint8_t data ); |
Hotboards | 0:38fad00cc45b | 41 | void write( uint32_t address, uint8_t *data, uint16_t size ); |
Hotboards | 0:38fad00cc45b | 42 | uint8_t read( uint32_t address ); |
Hotboards | 0:38fad00cc45b | 43 | void read( uint32_t address, uint8_t *data, uint16_t size ); |
Hotboards | 0:38fad00cc45b | 44 | |
Hotboards | 0:38fad00cc45b | 45 | protected : |
Hotboards | 0:38fad00cc45b | 46 | void sendAddress( uint8_t cmd, uint32_t address ); |
Hotboards | 0:38fad00cc45b | 47 | void writePage( uint32_t address, uint8_t *data, uint16_t size ); |
Hotboards | 0:38fad00cc45b | 48 | |
Hotboards | 0:38fad00cc45b | 49 | SPI _spi; |
Hotboards | 0:38fad00cc45b | 50 | DigitalOut _cs_pin; |
Hotboards | 0:38fad00cc45b | 51 | uint8_t _type; |
Hotboards | 0:38fad00cc45b | 52 | uint16_t _page; |
Hotboards | 0:38fad00cc45b | 53 | uint32_t _density; |
Hotboards | 0:38fad00cc45b | 54 | }; |
Hotboards | 0:38fad00cc45b | 55 | |
Hotboards | 0:38fad00cc45b | 56 | #endif |