Skip to content

Commit 89d27dc

Browse files
committed
fixup! Revert deleting eeprom function definition
1 parent 35a2c1a commit 89d27dc

File tree

2 files changed

+24
-37
lines changed

2 files changed

+24
-37
lines changed

cores/arduino/stm32/stm32_eeprom.c

+19-37
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@
3939
extern "C" {
4040
#endif
4141

42-
#ifndef EEPROM_RETRAM_MODE /* Buffering not needed in RETRAM mode */
43-
44-
static void eeprom_buffer_fill();
45-
static void eeprom_buffer_flush();
46-
static uint8_t eeprom_buffered_read_byte(const uint32_t pos);
47-
static void eeprom_buffered_write_byte(uint32_t pos, uint8_t value);
48-
4942
/* Be able to change FLASH_BANK_NUMBER to use if relevant */
5043
#if !defined(FLASH_BANK_NUMBER) &&\
5144
(defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32G4xx) ||\
@@ -122,6 +115,8 @@ static inline uint32_t get_flash_end(void)
122115
defined(STM32WBxx)
123116
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
124117
#define FLASH_END ((uint32_t)(FLASH_BASE + (((FLASH_PAGE_NUMBER +1) * FLASH_PAGE_SIZE))-1))
118+
#elif defined(EEPROM_RETRAM_MODE)
119+
#define FLASH_END ((uint32_t)(EEPROM_RETRAM_START_ADDRESS + EEPROM_RETRAM_MODE_SIZE -1))
125120
#endif
126121
#ifndef FLASH_END
127122
#error "FLASH_END could not be defined"
@@ -137,6 +132,8 @@ static inline uint32_t get_flash_end(void)
137132
*/
138133
#if defined(STM32L0xx)
139134
#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE))
135+
#elif defined(EEPROM_RETRAM_MODE)
136+
#define FLASH_BASE_ADDRESS EEPROM_RETRAM_START_ADDRESS
140137
#else
141138
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
142139
#endif
@@ -201,6 +198,20 @@ void eeprom_buffer_fill(void)
201198
memcpy(eeprom_buffer, (uint8_t *)(FLASH_BASE_ADDRESS), E2END + 1);
202199
}
203200

201+
#if defined(EEPROM_RETRAM_MODE)
202+
203+
/**
204+
* @brief This function writes the buffer content into the flash
205+
* @param none
206+
* @retval none
207+
*/
208+
void eeprom_buffer_flush(void)
209+
{
210+
memcpy((uint8_t *)(FLASH_BASE_ADDRESS), eeprom_buffer, E2END + 1);
211+
}
212+
213+
#else /* defined(EEPROM_RETRAM_MODE) */
214+
204215
/**
205216
* @brief This function writes the buffer content into the flash
206217
* @param none
@@ -313,36 +324,7 @@ void eeprom_buffer_flush(void)
313324
#endif
314325
}
315326

316-
#else /* EEPROM_RETRAM_MODE */
317-
/**
318-
* @brief Function reads a byte from emulated eeprom (flash)
319-
* @param pos : address to read
320-
* @retval byte : data read from eeprom
321-
*/
322-
uint8_t eeprom_read_byte(const uint32_t pos)
323-
{
324-
uint8_t tmp;
325-
if (pos > E2END) {
326-
return 0;
327-
}
328-
memcpy(&tmp, (uint8_t *)(EEPROM_RETRAM_START_ADDRESS + pos), sizeof(uint8_t));
329-
return tmp;
330-
}
331-
332-
/**
333-
* @brief Function writes a byte to emulated eeprom (flash)
334-
* @param pos : address to write
335-
* @param value : value to write
336-
* @retval none
337-
*/
338-
void eeprom_write_byte(uint32_t pos, uint8_t value)
339-
{
340-
if (pos > E2END) {
341-
return;
342-
}
343-
memcpy((uint8_t *)(EEPROM_RETRAM_START_ADDRESS + pos), &value, sizeof(uint8_t));
344-
}
345-
#endif /* EEPROM_RETRAM_MODE */
327+
#endif /* defined(EEPROM_RETRAM_MODE) */
346328

347329
#ifdef __cplusplus
348330
}

cores/arduino/stm32/stm32_eeprom.h

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ extern "C" {
8989
uint8_t eeprom_read_byte(const uint32_t pos);
9090
void eeprom_write_byte(uint32_t pos, uint8_t value);
9191

92+
void eeprom_buffer_fill();
93+
void eeprom_buffer_flush();
94+
uint8_t eeprom_buffered_read_byte(const uint32_t pos);
95+
void eeprom_buffered_write_byte(uint32_t pos, uint8_t value);
96+
9297
#ifdef __cplusplus
9398
}
9499
#endif

0 commit comments

Comments
 (0)