Basic example showing how to use a M24LR64 EEPROM with the STM32746G_DISCOVERY board. This EEPROM can be found on the additional ANT7-M24LR-A daughter board.

Dependencies:   BSP_DISCO_F746NG

This example shows how to read and write data in RF EEPROM. The I2C EEPROM memory (M24LR64) is available on separate daughter board ANT7-M24LR-A, which is not provided with the STM32746G-Discovery board. To use this driver you have to connect the ANT7-M24LR-A to CN1 connector of STM32746G-Discovery board.

Committer:
jeromecoutant
Date:
Thu Jun 08 13:26:04 2017 +0000
Revision:
2:fec4ab60a7fd
Parent:
0:d5bffd99efd3
Child:
3:508424185673
Update libs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:d5bffd99efd3 1 #include "mbed.h"
bcostm 0:d5bffd99efd3 2 #include "EEPROM_DISCO_F746NG.h"
bcostm 0:d5bffd99efd3 3
bcostm 0:d5bffd99efd3 4 EEPROM_DISCO_F746NG eep;
bcostm 0:d5bffd99efd3 5
bcostm 0:d5bffd99efd3 6 DigitalOut led_green(LED1);
bcostm 0:d5bffd99efd3 7 DigitalOut led_red(LED2);
bcostm 0:d5bffd99efd3 8
bcostm 0:d5bffd99efd3 9 Serial pc(USBTX, USBRX);
bcostm 0:d5bffd99efd3 10
bcostm 0:d5bffd99efd3 11 #define BUFFER_SIZE ((uint32_t)32)
bcostm 0:d5bffd99efd3 12 #define WRITE_READ_ADDR ((uint32_t)0x0000)
bcostm 0:d5bffd99efd3 13
bcostm 0:d5bffd99efd3 14 int main()
bcostm 0:d5bffd99efd3 15 {
bcostm 0:d5bffd99efd3 16 // 12345678901234567890123456789012
bcostm 0:d5bffd99efd3 17 uint8_t WriteBuffer[BUFFER_SIZE+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
bcostm 0:d5bffd99efd3 18 uint8_t ReadBuffer[BUFFER_SIZE+1];
bcostm 0:d5bffd99efd3 19 uint16_t bytes_rd;
bcostm 0:d5bffd99efd3 20
bcostm 0:d5bffd99efd3 21 pc.printf("\n\nEEPROM demo started\n");
bcostm 0:d5bffd99efd3 22 led_red = 0;
bcostm 0:d5bffd99efd3 23
bcostm 0:d5bffd99efd3 24 // Check initialization
bcostm 0:d5bffd99efd3 25 if (eep.Init() != EEPROM_OK) {
bcostm 0:d5bffd99efd3 26 led_red = 1;
bcostm 0:d5bffd99efd3 27 error("Initialization FAILED\n");
bcostm 0:d5bffd99efd3 28 } else {
bcostm 0:d5bffd99efd3 29 pc.printf("Initialization PASSED\n");
bcostm 0:d5bffd99efd3 30 }
bcostm 0:d5bffd99efd3 31
bcostm 0:d5bffd99efd3 32 // Write buffer
bcostm 0:d5bffd99efd3 33 if (eep.WriteBuffer(WriteBuffer, WRITE_READ_ADDR, BUFFER_SIZE) != EEPROM_OK) {
bcostm 0:d5bffd99efd3 34 led_red = 1;
bcostm 0:d5bffd99efd3 35 error("Write buffer FAILED\n");
bcostm 0:d5bffd99efd3 36 } else {
bcostm 0:d5bffd99efd3 37 pc.printf("Write buffer PASSED\n");
bcostm 0:d5bffd99efd3 38 }
bcostm 0:d5bffd99efd3 39
bcostm 0:d5bffd99efd3 40 // Read buffer
bcostm 0:d5bffd99efd3 41 bytes_rd = BUFFER_SIZE;
bcostm 0:d5bffd99efd3 42 if (eep.ReadBuffer(ReadBuffer, WRITE_READ_ADDR, &bytes_rd) != EEPROM_OK) {
bcostm 0:d5bffd99efd3 43 led_red = 1;
bcostm 0:d5bffd99efd3 44 error("Read buffer FAILED\n");
bcostm 0:d5bffd99efd3 45 } else {
bcostm 0:d5bffd99efd3 46 ReadBuffer[BUFFER_SIZE] = '\0';
bcostm 0:d5bffd99efd3 47 pc.printf("Read buffer PASSED\n");
bcostm 0:d5bffd99efd3 48 pc.printf("Buffer read = [%s]\n", ReadBuffer);
bcostm 0:d5bffd99efd3 49 pc.printf("Bytes read = %d\n", bytes_rd);
bcostm 0:d5bffd99efd3 50 }
bcostm 0:d5bffd99efd3 51
bcostm 0:d5bffd99efd3 52 while(1) {
bcostm 0:d5bffd99efd3 53 led_green = !led_green;
bcostm 0:d5bffd99efd3 54 wait(1);
bcostm 0:d5bffd99efd3 55 }
bcostm 0:d5bffd99efd3 56 }