Skip to content

Add support of STM32H5 serie #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bdd2c61
system(H5) add STM32H5xx HAL Drivers to v1.0.0
fpistm Apr 17, 2023
d978849
system(H5): add STM32H5xx CMSIS Drivers to v1.0.0
fpistm Apr 17, 2023
faad585
system(H5): add STM32H5xx system source files
fpistm Apr 17, 2023
f70dcb7
system(H5): update STM32H5xx hal default config
fpistm Apr 17, 2023
9fba1aa
core(H5): add top HAL include
fpistm Apr 17, 2023
6fef8ec
core(H5): add wrapped files
fpistm Apr 17, 2023
f2bc2b3
system(H5): update STM32C0xx hal default config
fpistm Apr 17, 2023
2954e51
system(H5): update STM32H5xx system
fpistm Apr 17, 2023
f6456c3
feat(stm32variant): add I3C support generation
fpistm Apr 17, 2023
9e635a7
variants(H5): add all generated STM32H5xx generic variant files
fpistm Apr 17, 2023
b0677d4
core(backup): add STM32H5xx guard
fpistm Apr 17, 2023
2c09147
feat: declare I3C PinMap array
fpistm Apr 17, 2023
de3e487
core(timer): add STM32U5xx Timer IRQ
fpistm Apr 17, 2023
802c370
core(interrupt): add STM32H5xx EXTI IRQ support
fpistm Apr 17, 2023
74fd5b5
core(analog): add STM32U5xx support
fpistm Apr 17, 2023
c711143
library(eeproom): add STM32H5xx support
fpistm May 10, 2023
f3247f9
core(USB): add STM32H5xx support
fpistm Apr 19, 2023
ee8bb5e
fix(clock): ensure selected clock is on
fpistm May 23, 2023
00022cf
variant(H5): add H563Z(G-I)T_H573ZIT generic support
fpistm Apr 17, 2023
d0f3085
variant(H5): add NUCLEO-H563ZI support
fpistm Apr 18, 2023
42458e0
variant(H5): add H563IIKxQ and STM32H573IIKxQ generic support
fpistm May 4, 2023
070d0b1
variant(H5): add STM32H573I-DK support
fpistm May 23, 2023
d782ba5
chore(cmake): update files with STM32H5xx
fpistm May 11, 2023
f5959cf
ci(cmake): add build of Nucleo H563ZI
fpistm May 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
library(eeproom): add STM32H5xx support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed May 24, 2023
commit c71114382f7042e3397de0d66a7b8c30d595c87e
67 changes: 64 additions & 3 deletions libraries/EEPROM/src/utility/stm32_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "stm32_eeprom.h"
#include "stm32yyxx_ll_utils.h"
#include <string.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -37,15 +38,19 @@ extern "C" {
#endif /* !FLASH_BANK_NUMBER */

/* Be able to change FLASH_DATA_SECTOR to use if relevant */
#if defined(FLASH_SECTOR_TOTAL)
#if defined(FLASH_SECTOR_TOTAL) || defined(FLASH_SECTOR_NB)
#if !defined(FLASH_DATA_SECTOR)
#if defined(FLASH_SECTOR_TOTAL)
#define FLASH_DATA_SECTOR ((uint32_t)(FLASH_SECTOR_TOTAL - 1))
#elif defined(FLASH_SECTOR_NB)
#define FLASH_DATA_SECTOR ((uint32_t)(FLASH_SECTOR_NB - 1))
#endif
#else
#ifndef FLASH_BASE_ADDRESS
#error "FLASH_BASE_ADDRESS have to be defined when FLASH_DATA_SECTOR is defined"
#endif
#endif /* !FLASH_DATA_SECTOR */
#endif /* FLASH_SECTOR_TOTAL */
#endif /* FLASH_SECTOR_TOTAL || FLASH_SECTOR_NB */

/* Be able to change FLASH_PAGE_NUMBER to use if relevant */
#if !defined(FLASH_PAGE_NUMBER) && defined(FLASH_PAGE_SIZE)
Expand All @@ -62,6 +67,12 @@ extern "C" {
#define FLASH_END FLASH_BANK2_END
#elif defined (FLASH_BANK1_END) && (FLASH_BANK_NUMBER == FLASH_BANK_1)
#define FLASH_END FLASH_BANK1_END
#elif defined(FLASH_DATA_SECTOR)
#if defined(FLASH_BANK_2) && (FLASH_BANK_NUMBER == FLASH_BANK_2)
#define FLASH_END ((uint32_t)(FLASH_BASE + FLASH_BANK_SIZE + (FLASH_DATA_SECTOR * FLASH_SECTOR_SIZE) + FLASH_SECTOR_SIZE - 1))
#else
#define FLASH_END ((uint32_t)(FLASH_BASE + (FLASH_DATA_SECTOR * FLASH_SECTOR_SIZE) + FLASH_SECTOR_SIZE - 1))
#endif /* FLASH_BANK_2 */
#elif defined(FLASH_BASE) && defined(FLASH_PAGE_NUMBER) && defined (FLASH_PAGE_SIZE)
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
#define FLASH_END ((uint32_t)(FLASH_BASE + (((FLASH_PAGE_NUMBER +1) * FLASH_PAGE_SIZE))-1))
Expand Down Expand Up @@ -164,7 +175,25 @@ void eeprom_buffered_write_byte(uint32_t pos, uint8_t value)
*/
void eeprom_buffer_fill(void)
{
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
bool icache_enabled = false;
if (HAL_ICACHE_IsEnabled() == 1) {
icache_enabled = true;
/* Disable instruction cache prior to internal cacheable memory update */
if (HAL_ICACHE_Disable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
memcpy(eeprom_buffer, (uint8_t *)(FLASH_BASE_ADDRESS), E2END + 1);
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
if (icache_enabled) {
/* Re-enable instruction cache */
if (HAL_ICACHE_Enable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
}

#if defined(EEPROM_RETRAM_MODE)
Expand All @@ -188,6 +217,16 @@ void eeprom_buffer_flush(void)
*/
void eeprom_buffer_flush(void)
{
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
bool icache_enabled = false;
if (HAL_ICACHE_IsEnabled() == 1) {
icache_enabled = true;
/* Disable instruction cache prior to internal cacheable memory update */
if (HAL_ICACHE_Disable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t offset = 0;
uint32_t address = FLASH_BASE_ADDRESS;
Expand Down Expand Up @@ -240,6 +279,8 @@ void eeprom_buffer_flush(void)
uint32_t SectorError = 0;
#if defined(FLASH_TYPEPROGRAM_FLASHWORD)
uint64_t data[4] = {0x0000};
#elif defined(FLASH_TYPEPROGRAM_QUADWORD)
uint32_t data[4] = {0x0000};
#else
uint32_t data = 0;
#endif
Expand All @@ -249,7 +290,9 @@ void eeprom_buffer_flush(void)
#if defined(FLASH_BANK_NUMBER)
EraseInitStruct.Banks = FLASH_BANK_NUMBER;
#endif
#if defined(FLASH_VOLTAGE_RANGE_3)
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
#endif
EraseInitStruct.Sector = FLASH_DATA_SECTOR;
EraseInitStruct.NbSectors = 1;

Expand All @@ -263,11 +306,20 @@ void eeprom_buffer_flush(void)
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, address, (uint32_t)data) == HAL_OK) {
address += 32;
offset += 32;
#else
#elif defined(FLASH_TYPEPROGRAM_QUADWORD)
/* 128 bits */
memcpy(&data, eeprom_buffer + offset, 4 * sizeof(uint32_t));
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, address, (uint32_t)data) == HAL_OK) {
address += 16;
offset += 16;
#elif defined(FLASH_TYPEPROGRAM_WORD)
memcpy(&data, eeprom_buffer + offset, sizeof(uint32_t));
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data) == HAL_OK) {
address += 4;
offset += 4;
#else
#error "Unknown FLASH Program Type."
if (0) {}
#endif
} else {
address = address_end + 1;
Expand All @@ -276,6 +328,15 @@ void eeprom_buffer_flush(void)
}
HAL_FLASH_Lock();
#endif
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
if (icache_enabled)
{
/* Re-enable instruction cache */
if (HAL_ICACHE_Enable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
}

#endif /* defined(EEPROM_RETRAM_MODE) */
Expand Down
2 changes: 1 addition & 1 deletion libraries/EEPROM/src/utility/stm32_eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern "C" {
* emulation. Anyway, all the sector size will be erased.
* So pay attention to not use this sector for other stuff.
*/
#define FLASH_PAGE_SIZE ((uint32_t)(16*1024)) /* 16kB page */
#define FLASH_PAGE_SIZE ((uint32_t)(8*1024)) /* 8kB page */
#endif

#if defined(DATA_EEPROM_BASE) || defined(FLASH_EEPROM_BASE)
Expand Down