Skip to content

Commit 241510d

Browse files
committed
fixup! Revert deleting eeprom function definition
1 parent 75fac5a commit 241510d

File tree

2 files changed

+22
-37
lines changed

2 files changed

+22
-37
lines changed

Diff for: cores/arduino/stm32/stm32_eeprom.c

+17-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) ||\
@@ -137,6 +130,8 @@ static inline uint32_t get_flash_end(void)
137130
*/
138131
#if defined(STM32L0xx)
139132
#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE))
133+
#elif defined(EEPROM_RETRAM_MODE)
134+
#define FLASH_BASE_ADDRESS EEPROM_RETRAM_START_ADDRESS
140135
#else
141136
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
142137
#endif
@@ -201,6 +196,20 @@ void eeprom_buffer_fill(void)
201196
memcpy(eeprom_buffer, (uint8_t *)(FLASH_BASE_ADDRESS), E2END + 1);
202197
}
203198

199+
#if defined(EEPROM_RETRAM_MODE)
200+
201+
/**
202+
* @brief This function writes the buffer content into the flash
203+
* @param none
204+
* @retval none
205+
*/
206+
void eeprom_buffer_flush(void)
207+
{
208+
memcpy((uint8_t *)(FLASH_BASE_ADDRESS), eeprom_buffer, E2END + 1);
209+
}
210+
211+
#else /* defined(EEPROM_RETRAM_MODE) */
212+
204213
/**
205214
* @brief This function writes the buffer content into the flash
206215
* @param none
@@ -313,36 +322,7 @@ void eeprom_buffer_flush(void)
313322
#endif
314323
}
315324

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 */
325+
#endif /* defined(EEPROM_RETRAM_MODE) */
346326

347327
#ifdef __cplusplus
348328
}

Diff for: 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)