Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F429ZI EEPROM_DISCO_F429ZI mbed
main.cpp
00001 #include "mbed.h" 00002 #include "EEPROM_DISCO_F429ZI.h" 00003 00004 EEPROM_DISCO_F429ZI eep; 00005 00006 DigitalOut led_green(LED1); 00007 DigitalOut led_red(LED2); 00008 00009 Serial pc(USBTX, USBRX); 00010 00011 #define BUFFER_SIZE ((uint32_t)32) 00012 #define WRITE_READ_ADDR ((uint32_t)0x50) 00013 00014 int main() 00015 { 00016 // 12345678901234567890123456789012 00017 uint8_t WriteBuffer[BUFFER_SIZE+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"; 00018 uint8_t ReadBuffer[BUFFER_SIZE+1]; 00019 uint16_t bytes_rd; 00020 00021 pc.printf("\n\n*** EEPROM demo started ***\n"); 00022 led_red = 0; 00023 00024 // Check initialization 00025 if (eep.Init() != EEPROM_OK) { 00026 led_red = 1; 00027 error("Initialization FAILED\n"); 00028 } else { 00029 pc.printf("Initialization PASSED\n"); 00030 } 00031 00032 // Write buffer 00033 if (eep.WriteBuffer(WriteBuffer, WRITE_READ_ADDR, BUFFER_SIZE) != EEPROM_OK) { 00034 led_red = 1; 00035 error("Write buffer FAILED\n"); 00036 } else { 00037 pc.printf("Write buffer PASSED\n"); 00038 } 00039 00040 eep.WaitEepromStandbyState(); 00041 00042 // Read buffer 00043 bytes_rd = BUFFER_SIZE; 00044 if (eep.ReadBuffer(ReadBuffer, WRITE_READ_ADDR, &bytes_rd) != EEPROM_OK) { 00045 led_red = 1; 00046 error("Read buffer FAILED\n"); 00047 } else { 00048 ReadBuffer[BUFFER_SIZE] = '\0'; 00049 pc.printf("Read buffer PASSED\n"); 00050 pc.printf("Buffer read = [%s]\n", ReadBuffer); 00051 pc.printf("Bytes read = %d\n", bytes_rd); 00052 } 00053 00054 eep.WaitEepromStandbyState(); 00055 00056 while(1) { 00057 led_green = !led_green; 00058 wait(1); 00059 } 00060 }
Generated on Sun Jul 24 2022 00:18:55 by
1.7.2