|
24 | 24 | * Microchip's 24LC or ATMEL's AT24C ranges
|
25 | 25 | *
|
26 | 26 | * @code
|
| 27 | + * // Here's an example using a 24LC256 on a GR PEACH |
27 | 28 | * #include "mbed.h"
|
28 | 29 | * #include "I2CEEBlockDevice.h"
|
29 |
| - * |
30 |
| - * // Create 24LC device with 32Kbytes of memory |
31 |
| - * I2CEEBlockDevice flash(D14, D15, 0xa0, 32*1024); |
32 |
| - * |
| 30 | + * |
| 31 | + * // Create EEPROM device on I2C bus with 32kbytes of memory |
| 32 | + * I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024); |
| 33 | + * |
33 | 34 | * int main() {
|
34 |
| - * printf("flash test\n"); |
35 |
| - * mx52r.init(); |
36 |
| - * printf("flash size: %llu\n", flash.size()); |
37 |
| - * printf("flash read size: %llu\n", flash.get_read_size()); |
38 |
| - * printf("flash program size: %llu\n", flash.get_program_size()); |
39 |
| - * printf("flash erase size: %llu\n", flash.get_erase_size()); |
40 |
| - * |
41 |
| - * uint8_t *buffer = malloc(flash.get_erase_size()); |
| 35 | + * printf("i2cee test\n"); |
| 36 | + * |
| 37 | + * // Initialize the device and print the memory layout |
| 38 | + * i2cee.init(); |
| 39 | + * printf("i2cee size: %llu\n", i2cee.size()); |
| 40 | + * printf("i2cee read size: %llu\n", i2cee.get_read_size()); |
| 41 | + * printf("i2cee program size: %llu\n", i2cee.get_program_size()); |
| 42 | + * printf("i2cee erase size: %llu\n", i2cee.get_erase_size()); |
| 43 | + * |
| 44 | + * // Write "Hello World!" to the first block |
| 45 | + * char *buffer = (char*)malloc(i2cee.get_erase_size()); |
42 | 46 | * sprintf(buffer, "Hello World!\n");
|
43 |
| - * flash.erase(0, flash.get_erase_size()); |
44 |
| - * flash.program(buffer, 0, flash.get_erase_size()); |
45 |
| - * flash.read(buffer, 0, flash.get_erase_size()); |
| 47 | + * i2cee.erase(0, i2cee.get_erase_size()); |
| 48 | + * i2cee.program(buffer, 0, i2cee.get_erase_size()); |
| 49 | + * |
| 50 | + * // Read back what was stored |
| 51 | + * i2cee.read(buffer, 0, i2cee.get_erase_size()); |
46 | 52 | * printf("%s", buffer);
|
47 |
| - * |
48 |
| - * flash.deinit(); |
| 53 | + * |
| 54 | + * // Deinitialize the device |
| 55 | + * i2cee.deinit(); |
49 | 56 | * }
|
| 57 | + * @endcode |
50 | 58 | */
|
51 | 59 | class I2CEEBlockDevice : public BlockDevice {
|
52 | 60 | public:
|
|
0 commit comments