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:
Jerome Coutant
Date:
Wed Nov 20 13:56:28 2019 +0100
Revision:
3:508424185673
Parent:
0:d5bffd99efd3
Update with STM32Cube_FW_F7_V1.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:d5bffd99efd3 1 #include "mbed.h"
Jerome Coutant 3:508424185673 2 #include "stm32746g_discovery_eeprom.h"
bcostm 0:d5bffd99efd3 3
bcostm 0:d5bffd99efd3 4
bcostm 0:d5bffd99efd3 5 #define BUFFER_SIZE ((uint32_t)32)
bcostm 0:d5bffd99efd3 6 #define WRITE_READ_ADDR ((uint32_t)0x0000)
bcostm 0:d5bffd99efd3 7
bcostm 0:d5bffd99efd3 8 int main()
bcostm 0:d5bffd99efd3 9 {
Jerome Coutant 3:508424185673 10 // 12345678901234567890123456789012
Jerome Coutant 3:508424185673 11 uint8_t WriteBuffer[BUFFER_SIZE + 1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
Jerome Coutant 3:508424185673 12 uint8_t ReadBuffer[BUFFER_SIZE + 1];
bcostm 0:d5bffd99efd3 13 uint16_t bytes_rd;
bcostm 0:d5bffd99efd3 14
Jerome Coutant 3:508424185673 15 printf("\n\nEEPROM demo started\n");
Jerome Coutant 3:508424185673 16 printf("NB: you have to connect the RF EEPROM ANT7-M24LR-A to CN1 connector of STM32746G-Discovery board\n");
bcostm 0:d5bffd99efd3 17
bcostm 0:d5bffd99efd3 18 // Check initialization
Jerome Coutant 3:508424185673 19 if (BSP_EEPROM_Init() != EEPROM_OK) {
bcostm 0:d5bffd99efd3 20 error("Initialization FAILED\n");
bcostm 0:d5bffd99efd3 21 } else {
Jerome Coutant 3:508424185673 22 printf("Initialization PASSED\n");
bcostm 0:d5bffd99efd3 23 }
bcostm 0:d5bffd99efd3 24
bcostm 0:d5bffd99efd3 25 // Write buffer
Jerome Coutant 3:508424185673 26 if (BSP_EEPROM_WriteBuffer(WriteBuffer, WRITE_READ_ADDR, BUFFER_SIZE) != EEPROM_OK) {
bcostm 0:d5bffd99efd3 27 error("Write buffer FAILED\n");
bcostm 0:d5bffd99efd3 28 } else {
Jerome Coutant 3:508424185673 29 printf("Write buffer PASSED\n");
bcostm 0:d5bffd99efd3 30 }
bcostm 0:d5bffd99efd3 31
bcostm 0:d5bffd99efd3 32 // Read buffer
bcostm 0:d5bffd99efd3 33 bytes_rd = BUFFER_SIZE;
Jerome Coutant 3:508424185673 34 if (BSP_EEPROM_ReadBuffer(ReadBuffer, WRITE_READ_ADDR, &bytes_rd) != EEPROM_OK) {
bcostm 0:d5bffd99efd3 35 error("Read buffer FAILED\n");
bcostm 0:d5bffd99efd3 36 } else {
bcostm 0:d5bffd99efd3 37 ReadBuffer[BUFFER_SIZE] = '\0';
Jerome Coutant 3:508424185673 38 printf("Read buffer PASSED\n");
Jerome Coutant 3:508424185673 39 printf("Buffer read = [%s]\n", ReadBuffer);
Jerome Coutant 3:508424185673 40 printf("Bytes read = %d\n", bytes_rd);
bcostm 0:d5bffd99efd3 41 }
bcostm 0:d5bffd99efd3 42 }