diff --git a/.mxproject b/.mxproject
index 07bcb52..71bd795 100644
--- a/.mxproject
+++ b/.mxproject
@@ -1,39 +1,41 @@
[PreviousLibFiles]
-LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_bus.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_system.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_utils.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_iwdg.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_bus.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_system.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_utils.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_iwdg.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_armv8mbl.h;
+LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_bus.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_system.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_utils.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_crc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_iwdg.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_bus.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_system.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_utils.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_crc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_iwdg.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_armv8mbl.h;
[PreviousUsedMakefileFiles]
-SourceFiles=Core/Src/main.c;Core/Src/gpio.c;Core/Src/freertos.c;Core/Src/adc.c;Core/Src/dma.c;Core/Src/iwdg.c;Core/Src/spi.c;Core/Src/tim.c;Core/Src/usart.c;Core/Src/stm32f1xx_it.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core/Src/system_stm32f1xx.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core/Src/system_stm32f1xx.c;;;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;
+SourceFiles=Core/Src/main.c;Core/Src/gpio.c;Core/Src/freertos.c;Core/Src/adc.c;Core/Src/crc.c;Core/Src/dma.c;Core/Src/iwdg.c;Core/Src/spi.c;Core/Src/tim.c;Core/Src/usart.c;Core/Src/stm32f1xx_it.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core/Src/system_stm32f1xx.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core/Src/system_stm32f1xx.c;;;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c;
HeaderPath=Drivers/STM32F1xx_HAL_Driver/Inc;Middlewares/Third_Party/FreeRTOS/Source/include;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3;Drivers/CMSIS/Device/ST/STM32F1xx/Include;Drivers/CMSIS/Include;Core/Inc;
CDefines=USE_FULL_LL_DRIVER;USE_FULL_ASSERT:1U;HSE_VALUE:8000000;HSE_STARTUP_TIMEOUT:100;LSE_STARTUP_TIMEOUT:5000;LSE_VALUE:32768;HSI_VALUE:8000000;LSI_VALUE:40000;VDD_VALUE:3300;PREFETCH_ENABLE:1;STM32F103xB;USE_FULL_LL_DRIVER;USE_FULL_ASSERT:1U;HSE_VALUE:8000000;HSE_STARTUP_TIMEOUT:100;LSE_STARTUP_TIMEOUT:5000;LSE_VALUE:32768;HSI_VALUE:8000000;LSI_VALUE:40000;VDD_VALUE:3300;PREFETCH_ENABLE:1;
[PreviousGenFiles]
AdvancedFolderStructure=true
-HeaderFileListSize=11
+HeaderFileListSize=12
HeaderFiles#0=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/gpio.h
HeaderFiles#1=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/FreeRTOSConfig.h
HeaderFiles#2=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/adc.h
-HeaderFiles#3=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/dma.h
-HeaderFiles#4=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/iwdg.h
-HeaderFiles#5=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/spi.h
-HeaderFiles#6=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/tim.h
-HeaderFiles#7=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/usart.h
-HeaderFiles#8=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/stm32f1xx_it.h
-HeaderFiles#9=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/stm32_assert.h
-HeaderFiles#10=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/main.h
+HeaderFiles#3=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/crc.h
+HeaderFiles#4=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/dma.h
+HeaderFiles#5=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/iwdg.h
+HeaderFiles#6=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/spi.h
+HeaderFiles#7=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/tim.h
+HeaderFiles#8=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/usart.h
+HeaderFiles#9=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/stm32f1xx_it.h
+HeaderFiles#10=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/stm32_assert.h
+HeaderFiles#11=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc/main.h
HeaderFolderListSize=1
HeaderPath#0=/home/ondra/STM32Cube/BluepillTrouba/Core/Inc
HeaderFiles=;
-SourceFileListSize=10
+SourceFileListSize=11
SourceFiles#0=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/gpio.c
SourceFiles#1=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/freertos.c
SourceFiles#2=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/adc.c
-SourceFiles#3=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/dma.c
-SourceFiles#4=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/iwdg.c
-SourceFiles#5=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/spi.c
-SourceFiles#6=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/tim.c
-SourceFiles#7=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/usart.c
-SourceFiles#8=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/stm32f1xx_it.c
-SourceFiles#9=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/main.c
+SourceFiles#3=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/crc.c
+SourceFiles#4=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/dma.c
+SourceFiles#5=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/iwdg.c
+SourceFiles#6=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/spi.c
+SourceFiles#7=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/tim.c
+SourceFiles#8=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/usart.c
+SourceFiles#9=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/stm32f1xx_it.c
+SourceFiles#10=/home/ondra/STM32Cube/BluepillTrouba/Core/Src/main.c
SourceFolderListSize=1
SourcePath#0=/home/ondra/STM32Cube/BluepillTrouba/Core/Src
SourceFiles=;
diff --git a/BluepillTrouba.ioc b/BluepillTrouba.ioc
index 665bb6d..d4435cc 100644
--- a/BluepillTrouba.ioc
+++ b/BluepillTrouba.ioc
@@ -49,19 +49,20 @@ KeepUserPlacement=false
Mcu.CPN=STM32F103C8T6
Mcu.Family=STM32F1
Mcu.IP0=ADC1
-Mcu.IP1=DMA
-Mcu.IP10=TIM3
-Mcu.IP11=TIM4
-Mcu.IP12=USART1
-Mcu.IP2=FREERTOS
-Mcu.IP3=IWDG
-Mcu.IP4=NVIC
-Mcu.IP5=RCC
-Mcu.IP6=SPI2
-Mcu.IP7=SYS
-Mcu.IP8=TIM1
-Mcu.IP9=TIM2
-Mcu.IPNb=13
+Mcu.IP1=CRC
+Mcu.IP10=TIM2
+Mcu.IP11=TIM3
+Mcu.IP12=TIM4
+Mcu.IP13=USART1
+Mcu.IP2=DMA
+Mcu.IP3=FREERTOS
+Mcu.IP4=IWDG
+Mcu.IP5=NVIC
+Mcu.IP6=RCC
+Mcu.IP7=SPI2
+Mcu.IP8=SYS
+Mcu.IP9=TIM1
+Mcu.IPNb=14
Mcu.Name=STM32F103C(8-B)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC13-TAMPER-RTC
@@ -75,14 +76,15 @@ Mcu.Pin15=PB7
Mcu.Pin16=PB8
Mcu.Pin17=VP_ADC1_TempSens_Input
Mcu.Pin18=VP_ADC1_Vref_Input
-Mcu.Pin19=VP_FREERTOS_VS_CMSIS_V2
+Mcu.Pin19=VP_CRC_VS_CRC
Mcu.Pin2=PA1
-Mcu.Pin20=VP_IWDG_VS_IWDG
-Mcu.Pin21=VP_SYS_VS_Systick
-Mcu.Pin22=VP_TIM1_VS_ClockSourceINT
-Mcu.Pin23=VP_TIM1_VS_no_output1
-Mcu.Pin24=VP_TIM2_VS_ClockSourceINT
-Mcu.Pin25=VP_TIM3_VS_ClockSourceINT
+Mcu.Pin20=VP_FREERTOS_VS_CMSIS_V2
+Mcu.Pin21=VP_IWDG_VS_IWDG
+Mcu.Pin22=VP_SYS_VS_Systick
+Mcu.Pin23=VP_TIM1_VS_ClockSourceINT
+Mcu.Pin24=VP_TIM1_VS_no_output1
+Mcu.Pin25=VP_TIM2_VS_ClockSourceINT
+Mcu.Pin26=VP_TIM3_VS_ClockSourceINT
Mcu.Pin3=PA6
Mcu.Pin4=PB0
Mcu.Pin5=PB1
@@ -90,7 +92,7 @@ Mcu.Pin6=PB10
Mcu.Pin7=PB13
Mcu.Pin8=PB15
Mcu.Pin9=PA9
-Mcu.PinsNb=26
+Mcu.PinsNb=27
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103C8Tx
@@ -202,7 +204,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_IWDG_Init-IWDG-false-LL-true,4-MX_USART1_UART_Init-USART1-false-LL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_DMA_Init-DMA-false-LL-true,7-MX_TIM4_Init-TIM4-false-LL-true,8-MX_TIM2_Init-TIM2-false-LL-true,9-MX_TIM3_Init-TIM3-false-LL-true,10-MX_SPI2_Init-SPI2-false-LL-true,11-MX_TIM1_Init-TIM1-false-LL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_IWDG_Init-IWDG-false-LL-true,4-MX_USART1_UART_Init-USART1-false-LL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_DMA_Init-DMA-false-LL-true,7-MX_TIM4_Init-TIM4-false-LL-true,8-MX_TIM2_Init-TIM2-false-LL-true,9-MX_TIM3_Init-TIM3-false-LL-true,10-MX_SPI2_Init-SPI2-false-LL-true,11-MX_TIM1_Init-TIM1-false-LL-true,12-MX_CRC_Init-CRC-false-LL-true
RCC.ADCFreqValue=8000000
RCC.ADCPresc=RCC_ADCPCLK2_DIV8
RCC.AHBFreq_Value=64000000
@@ -271,6 +273,8 @@ VP_ADC1_TempSens_Input.Mode=IN-TempSens
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
VP_ADC1_Vref_Input.Mode=IN-Vrefint
VP_ADC1_Vref_Input.Signal=ADC1_Vref_Input
+VP_CRC_VS_CRC.Mode=CRC_Activate
+VP_CRC_VS_CRC.Signal=CRC_VS_CRC
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
diff --git a/Core/Inc/crc.h b/Core/Inc/crc.h
new file mode 100644
index 0000000..8006a4b
--- /dev/null
+++ b/Core/Inc/crc.h
@@ -0,0 +1,50 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file crc.h
+ * @brief This file contains all the function prototypes for
+ * the crc.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2023 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __CRC_H__
+#define __CRC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_CRC_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CRC_H__ */
+
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 07639ad..3c7b8aa 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -29,6 +29,7 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_ll_adc.h"
+#include "stm32f1xx_ll_crc.h"
#include "stm32f1xx_ll_dma.h"
#include "stm32f1xx_ll_iwdg.h"
#include "stm32f1xx_ll_rcc.h"
diff --git a/Core/Src/app_main.c b/Core/Src/app_main.c
index 6039ec5..69b8372 100644
--- a/Core/Src/app_main.c
+++ b/Core/Src/app_main.c
@@ -19,6 +19,7 @@
#include "app_buzzer.h"
#include "app_heater.h"
#include "cmsis_os2.h"
+#include "eeprom_emul.h"
static struct App {
float oven_temp;
@@ -84,6 +85,28 @@ static void redraw_display() {
void app_task_main(void *argument)
{
PUTS("Main task\r\n");
+
+ /* test the persistent storage */
+ EE_Init(EE_CONDITIONAL_ERASE);
+
+ uint32_t cnt = 0;
+ EE_Status eest = EE_ReadVariable32bits(1, &cnt);
+
+ PRINTF("EE rd status %d, cnt %d\r\n", eest, cnt);
+
+ cnt++;
+
+ eest = EE_WriteVariable32bits(1, cnt);
+ PRINTF("EE wr status %d\r\n", eest);
+ if (eest == EE_CLEANUP_REQUIRED) {
+ eest = EE_CleanUp();
+ PRINTF("EE cleanup status %d\r\n", eest);
+ }
+
+
+
+
+
app_analog_init();
app_buzzer_init();
app_knob_init();
diff --git a/Core/Src/crc.c b/Core/Src/crc.c
new file mode 100644
index 0000000..c604e0d
--- /dev/null
+++ b/Core/Src/crc.c
@@ -0,0 +1,49 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file crc.c
+ * @brief This file provides code for the configuration
+ * of the CRC instances.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2023 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "crc.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/* CRC init function */
+void MX_CRC_Init(void)
+{
+
+ /* USER CODE BEGIN CRC_Init 0 */
+
+ /* USER CODE END CRC_Init 0 */
+
+ /* Peripheral clock enable */
+ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_CRC);
+
+ /* USER CODE BEGIN CRC_Init 1 */
+
+ /* USER CODE END CRC_Init 1 */
+ /* USER CODE BEGIN CRC_Init 2 */
+
+ /* USER CODE END CRC_Init 2 */
+
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index b242b36..ae4f373 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -20,6 +20,7 @@
#include "main.h"
#include "cmsis_os.h"
#include "adc.h"
+#include "crc.h"
#include "dma.h"
#include "iwdg.h"
#include "spi.h"
@@ -119,6 +120,7 @@ int main(void)
MX_TIM3_Init();
MX_SPI2_Init();
MX_TIM1_Init();
+ MX_CRC_Init();
/* USER CODE BEGIN 2 */
PUTS("Start.\r\n");
diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c
index 7e8428b..859f531 100644
--- a/Core/Src/stm32f1xx_it.c
+++ b/Core/Src/stm32f1xx_it.c
@@ -62,6 +62,8 @@
/* USER CODE BEGIN EV */
+bool EE_NMI_Callback();
+
/* USER CODE END EV */
/******************************************************************************/
@@ -74,6 +76,10 @@ void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
+ if (EE_NMI_Callback()) {
+ return;
+ }
+
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
while (1)
diff --git a/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_crc.h b/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_crc.h
new file mode 100644
index 0000000..c29119e
--- /dev/null
+++ b/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_crc.h
@@ -0,0 +1,204 @@
+/**
+ ******************************************************************************
+ * @file stm32f1xx_ll_crc.h
+ * @author MCD Application Team
+ * @brief Header file of CRC LL module.
+ ******************************************************************************
+ * @attention
+ *
+ *
© Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef STM32F1xx_LL_CRC_H
+#define STM32F1xx_LL_CRC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f1xx.h"
+
+/** @addtogroup STM32F1xx_LL_Driver
+ * @{
+ */
+
+#if defined(CRC)
+
+/** @defgroup CRC_LL CRC
+ * @{
+ */
+
+/* Private types -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private constants ---------------------------------------------------------*/
+/* Private macros ------------------------------------------------------------*/
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/* Exported macro ------------------------------------------------------------*/
+/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
+ * @{
+ */
+
+/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
+ * @{
+ */
+
+/**
+ * @brief Write a value in CRC register
+ * @param __INSTANCE__ CRC Instance
+ * @param __REG__ Register to be written
+ * @param __VALUE__ Value to be written in the register
+ * @retval None
+ */
+#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
+
+/**
+ * @brief Read a value in CRC register
+ * @param __INSTANCE__ CRC Instance
+ * @param __REG__ Register to be read
+ * @retval Register value
+ */
+#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+
+/* Exported functions --------------------------------------------------------*/
+/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
+ * @{
+ */
+
+/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
+ * @{
+ */
+
+/**
+ * @brief Reset the CRC calculation unit.
+ * @note If Programmable Initial CRC value feature
+ * is available, also set the Data Register to the value stored in the
+ * CRC_INIT register, otherwise, reset Data Register to its default value.
+ * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
+ * @param CRCx CRC Instance
+ * @retval None
+ */
+__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
+{
+ SET_BIT(CRCx->CR, CRC_CR_RESET);
+}
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_LL_EF_Data_Management Data_Management
+ * @{
+ */
+
+/**
+ * @brief Write given 32-bit data to the CRC calculator
+ * @rmtoll DR DR LL_CRC_FeedData32
+ * @param CRCx CRC Instance
+ * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
+ * @retval None
+ */
+__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
+{
+ WRITE_REG(CRCx->DR, InData);
+}
+
+/**
+ * @brief Return current CRC calculation result. 32 bits value is returned.
+ * @rmtoll DR DR LL_CRC_ReadData32
+ * @param CRCx CRC Instance
+ * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
+ */
+__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
+{
+ return (uint32_t)(READ_REG(CRCx->DR));
+}
+
+/**
+ * @brief Return data stored in the Independent Data(IDR) register.
+ * @note This register can be used as a temporary storage location for one byte.
+ * @rmtoll IDR IDR LL_CRC_Read_IDR
+ * @param CRCx CRC Instance
+ * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
+ */
+__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
+{
+ return (uint32_t)(READ_REG(CRCx->IDR));
+}
+
+/**
+ * @brief Store data in the Independent Data(IDR) register.
+ * @note This register can be used as a temporary storage location for one byte.
+ * @rmtoll IDR IDR LL_CRC_Write_IDR
+ * @param CRCx CRC Instance
+ * @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
+ * @retval None
+ */
+__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
+{
+ *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
+}
+/**
+ * @}
+ */
+
+#if defined(USE_FULL_LL_DRIVER)
+/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
+ * @{
+ */
+
+ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
+
+/**
+ * @}
+ */
+#endif /* USE_FULL_LL_DRIVER */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* defined(CRC) */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* STM32F1xx_LL_CRC_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c b/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c
new file mode 100644
index 0000000..f993359
--- /dev/null
+++ b/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c
@@ -0,0 +1,108 @@
+/**
+ ******************************************************************************
+ * @file stm32f1xx_ll_crc.c
+ * @author MCD Application Team
+ * @brief CRC LL module driver.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+#if defined(USE_FULL_LL_DRIVER)
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f1xx_ll_crc.h"
+#include "stm32f1xx_ll_bus.h"
+
+#ifdef USE_FULL_ASSERT
+#include "stm32_assert.h"
+#else
+#define assert_param(expr) ((void)0U)
+#endif/* USE_FULL_ASSERT */
+
+/** @addtogroup STM32F1xx_LL_Driver
+ * @{
+ */
+
+#if defined (CRC)
+
+/** @addtogroup CRC_LL
+ * @{
+ */
+
+/* Private types -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private constants ---------------------------------------------------------*/
+/* Private macros ------------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+
+/* Exported functions --------------------------------------------------------*/
+/** @addtogroup CRC_LL_Exported_Functions
+ * @{
+ */
+
+/** @addtogroup CRC_LL_EF_Init
+ * @{
+ */
+
+/**
+ * @brief De-initialize CRC registers (Registers restored to their default values).
+ * @param CRCx CRC Instance
+ * @retval An ErrorStatus enumeration value:
+ * - SUCCESS: CRC registers are de-initialized
+ * - ERROR: CRC registers are not de-initialized
+ */
+ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
+{
+ ErrorStatus status = SUCCESS;
+
+ /* Check the parameters */
+ assert_param(IS_CRC_ALL_INSTANCE(CRCx));
+
+ if (CRCx == CRC)
+ {
+
+ /* Reset the CRC calculation unit */
+ LL_CRC_ResetCRCCalculationUnit(CRCx);
+
+ /* Reset IDR register */
+ LL_CRC_Write_IDR(CRCx, 0x00U);
+ }
+ else
+ {
+ status = ERROR;
+ }
+
+ return (status);
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* defined (CRC) */
+
+/**
+ * @}
+ */
+
+#endif /* USE_FULL_LL_DRIVER */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/Lib/EEPROM_Emul/Core/eeprom_emul.c b/Lib/EEPROM_Emul/Core/eeprom_emul.c
index acb367a..0191b5a 100644
--- a/Lib/EEPROM_Emul/Core/eeprom_emul.c
+++ b/Lib/EEPROM_Emul/Core/eeprom_emul.c
@@ -52,30 +52,19 @@
/* Includes ------------------------------------------------------------------*/
#include "eeprom_emul.h"
-/** @defgroup EEPROM_Emulation EEPROM_Emulation
- * @{
- */
-
-/* Private define -----------------------------------------------------------*/
-#ifdef DUALCORE_FLASH_SHARING
-#define HSEM_PROCESS_1 12U /* Number taken randomly to identify the process locking a semaphore in the driver context */
-#endif
-/* Private typedef -----------------------------------------------------------*/
-/** @defgroup EEPROM_Private_Structures EEPROM Private Structures
- * @{
- */
/**
* @brief EE Find Type structure definition.
*/
+
/* Type of find requested :
READ --> page in active state
WRITE --> page in receive state or active state
ERASE --> page in erased state */
typedef enum {
- FIND_READ_PAGE,
- FIND_WRITE_PAGE,
- FIND_ERASE_PAGE
+ FIND_READ_PAGE,
+ FIND_WRITE_PAGE,
+ FIND_ERASE_PAGE
} EE_Find_type;
/**
@@ -89,12 +78,12 @@ typedef enum {
ERASING --> page used during transfer, should be erased after transfer
INVALID --> page invalid state */
typedef enum {
- STATE_PAGE_ERASED,
- STATE_PAGE_RECEIVE,
- STATE_PAGE_ACTIVE,
- STATE_PAGE_VALID,
- STATE_PAGE_ERASING,
- STATE_PAGE_INVALID
+ STATE_PAGE_ERASED,
+ STATE_PAGE_RECEIVE,
+ STATE_PAGE_ACTIVE,
+ STATE_PAGE_VALID,
+ STATE_PAGE_ERASING,
+ STATE_PAGE_INVALID
} EE_State_type;
/**
@@ -134,8 +123,8 @@ typedef enum {
uint16_t uhNbWrittenElements = 0U; /*!< Nb of elements written in valid and active pages */
uint8_t ubCurrentActivePage = 0U; /*!< Current active page (can be active or receive state) */
uint32_t uwAddressNextWrite = PAGE_HEADER_SIZE; /*!< Initialize write position just after page header */
-
-/* During the cleanup phase in EE_Init, AddressRead is the address being read */
+
+/* During the cleanup phase in EE_Init, AddressRead is the address being read */
__IO uint32_t AddressRead = 0;
/* Flag equal to 1 when the cleanup phase is in progress, 0 if not */
__IO uint8_t CleanupPhase = 0;
@@ -149,30 +138,38 @@ __IO uint8_t CleanupPhase = 0;
* @{
*/
-#ifndef FLASH_LINES_128B
-static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE* pData);
+static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE *pData);
+
static EE_Status WriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data);
+
static EE_Status PagesTransfer(uint16_t VirtAddress, EE_DATA_TYPE Data, EE_Transfer_type type);
+
uint16_t CalculateCrc(EE_DATA_TYPE Data, uint16_t VirtAddress);
-#else
-static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE* pData);
-static EE_Status WriteVariable(uint16_t VirtAddress, EE_DATA_TYPE* Data);
-static EE_Status PagesTransfer(uint16_t VirtAddress, EE_DATA_TYPE* Data, EE_Transfer_type type);
-uint16_t CalculateCrc(EE_DATA_TYPE Data1, EE_DATA_TYPE Data2);
-#endif
+
static EE_Status VerifyPageFullyErased(uint32_t Address, uint32_t PageSize);
+
static uint32_t FindPage(EE_Find_type Operation);
-#if defined (DUALCORE_FLASH_SHARING)
-static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data, EE_Write_type Write_type);
-#elif defined (FLASH_LINES_128B)
-static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE* Data, EE_Write_type Write_type);
-#else
+
static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data);
-#endif
+
static EE_Status SetPageState(uint32_t Page, EE_State_type State);
+
static EE_State_type GetPageState(uint32_t Address);
+
void ConfigureCrc(void);
+
+bool EE_NMI_Callback()
+{
+ if (CleanupPhase) {
+ EE_DeleteCorruptedFlashAddress(AddressRead);
+ return true;
+ }
+ return false;
+}
+
+
+
/**
* @}
*/
@@ -196,418 +193,313 @@ void ConfigureCrc(void);
*/
EE_Status EE_Init(EE_Erase_type EraseType)
{
- EE_State_type pagestatus = STATE_PAGE_INVALID;
- uint32_t page = 0U, pageaddress = 0U, varidx = 0U,
- nbactivepage = 0U, nbactivereceivepage = 0U, nbvalidpage = 0U,
- lastvalidpage = 0U, firstvalidpage = 0U,
- recoverytransfer = 0U;
- EE_ELEMENT_TYPE addressvalue = 0U;
-#ifdef FLASH_LINES_128B
- uint32_t Address = 0U;
- EE_ELEMENT_TYPE addressvalue2 = 0U;
- EE_DATA_TYPE dummy_data[2] = {0, 0};
-#endif
- EE_State_Reliability pagestate = STATE_RELIABLE;
-
- EE_Status status = EE_OK;
-
- /* Check if the configuration is 128-bits bank or 2*64-bits bank */
- if (FI_CheckBankConfig() != EE_OK)
- {
- return EE_INVALID_BANK_CFG;
- }
-
- /***************************************************************************/
- /* Step 0: Perform initial configuration */
- /***************************************************************************/
- /* Configure CRC peripheral for eeprom emulation usage */
-
- ConfigureCrc();
-
- /***************************************************************************/
- /* Step 1: Read all lines of the flash pages of eeprom emulation to */
- /* delete corrupted lines detectable through NMI */
- /***************************************************************************/
- /* We set the flag indicating the cleanup phase is operating to 1 */
-
- CleanupPhase = 1;
-
-#ifndef STM32C031xx
- for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- for (varidx = 0U; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE)
- {
- /*
- During the cleanup phase and only during it,
- we save the address read to set its content to 0 in case it triggered an NMI (see NMI_Handler in stm32lxxx_it.c).
- In the rest of the program, we do nothing in case a NMI is triggers by a reading because no NMI should be triggered
- since we have cleanup the EEPROM emulated. By the way, there is still the CRC code associated to each EEPROM line
- that allows to verify its valid state.
- */
- AddressRead = pageaddress + varidx;
- addressvalue = (*(__IO EE_ELEMENT_TYPE*)(pageaddress + varidx));
-
-#ifdef FLASH_LINES_128B
- AddressRead = pageaddress + varidx + 8;
- addressvalue = (*(__IO EE_ELEMENT_TYPE*)(pageaddress + varidx + 8));
-#endif
+ EE_State_type pagestatus = STATE_PAGE_INVALID;
+ uint32_t page = 0U, pageaddress = 0U, varidx = 0U,
+ nbactivepage = 0U, nbactivereceivepage = 0U, nbvalidpage = 0U,
+ lastvalidpage = 0U, firstvalidpage = 0U,
+ recoverytransfer = 0U;
+ EE_ELEMENT_TYPE addressvalue = 0U;
+ EE_State_Reliability pagestate = STATE_RELIABLE;
- }
- }
-#ifdef FLASH_LINES_128B
- //If a reset occured when an ECCC was detected but not corrected
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCC))
- {
- Address=(0x8000000|(FLASH->ECCR & 0x000FFFFF)); //Recovery of address where ECC error occured
- EE_DeleteCorruptedFlashAddress(Address); //Delete corrupted address
- }
-#endif
-#endif
- /* We set the flag indicating the cleanup phase is operating to 0 because it just ended */
- CleanupPhase = 0;
-
- /***************************************************************************/
- /* Step 2: Handle case of reset during transfer with no receive page */
- /* present, by setting missing receive page state */
- /***************************************************************************/
- /* Check if no active page and no receive page present */
- /* Browse all pages */
-
- for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
+ EE_Status status = EE_OK;
- /* Search for active and receive page */
- if ((pagestatus == STATE_PAGE_ACTIVE) || (pagestatus == STATE_PAGE_RECEIVE))
- {
- nbactivereceivepage++;
- }
- /* Keep index of first valid page, and last valid page */
- else if (pagestatus == STATE_PAGE_VALID)
- {
- if (nbvalidpage == 0U)
- {
- firstvalidpage = page;
- }
- lastvalidpage = page;
- nbvalidpage++;
- }
- }
-
- /* Check if no active and no receive page have been detected */
- if (nbactivereceivepage == 0U)
- {
- /* Check if valid pages have been detected */
- if (nbvalidpage > 0U)
- {
- /* Check state of page just before first valid page.
- If it is erasing page, then page after last valid page shall be set
- to receiving state */
- if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(firstvalidpage))) == STATE_PAGE_ERASING)
- {
- if (SetPageState(FOLLOWING_PAGE(lastvalidpage), STATE_PAGE_RECEIVE) != EE_OK)
- {
- return EE_WRITE_ERROR;
+ /***************************************************************************/
+ /* Step 0: Perform initial configuration */
+ /***************************************************************************/
+ /* Configure CRC peripheral for eeprom emulation usage */
+
+ ConfigureCrc();
+
+ /***************************************************************************/
+ /* Step 1: Read all lines of the flash pages of eeprom emulation to */
+ /* delete corrupted lines detectable through NMI */
+ /***************************************************************************/
+ /* We set the flag indicating the cleanup phase is operating to 1 */
+
+ CleanupPhase = 1;
+
+ for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++) {
+ pageaddress = PAGE_ADDRESS(page);
+ for (varidx = 0U; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE) {
+ /*
+ During the cleanup phase and only during it,
+ we save the address read to set its content to 0 in case it triggered an NMI (see NMI_Handler in stm32lxxx_it.c).
+ In the rest of the program, we do nothing in case a NMI is triggers by a reading because no NMI should be triggered
+ since we have cleanup the EEPROM emulated. By the way, there is still the CRC code associated to each EEPROM line
+ that allows to verify its valid state.
+ */
+ AddressRead = pageaddress + varidx;
+ addressvalue = (*(__IO EE_ELEMENT_TYPE *) (pageaddress + varidx));
}
- }
- }
- /* Format flash pages used for eeprom emulation in case no active, no receive, no valid pages are found */
- else
- {
- return EE_Format(EE_FORCED_ERASE);
}
- }
- /*********************************************************************/
- /* Step 3: Handle case of reset during transfer, by performing */
- /* transfer recovery */
- /*********************************************************************/
+ /* We set the flag indicating the cleanup phase is operating to 0 because it just ended */
+ CleanupPhase = 0;
- /* Browse all pages */
- for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
+ /***************************************************************************/
+ /* Step 2: Handle case of reset during transfer with no receive page */
+ /* present, by setting missing receive page state */
+ /***************************************************************************/
+ /* Check if no active page and no receive page present */
+ /* Browse all pages */
- /* Check if there is receive page, meaning transfer has been interrupted */
- if (pagestatus == STATE_PAGE_RECEIVE)
- {
- /* Verify that receive page is a true one, not a corrupted page state */
- /* Check if page is not the first page of a bloc */
- if ((page != START_PAGE) && (page != (uint32_t)(START_PAGE + (PAGES_NUMBER / 2U))))
- {
- /* Check that previous page is valid state */
- if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(page))) == STATE_PAGE_VALID)
- {
- /* The receive page is a true receive page */
- pagestate = STATE_RELIABLE;
+ for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++) {
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
+
+ /* Search for active and receive page */
+ if ((pagestatus == STATE_PAGE_ACTIVE) || (pagestatus == STATE_PAGE_RECEIVE)) {
+ nbactivereceivepage++;
}
- else /* Previous page is not valid state */
- {
- /* The receive page is false receive page due to header corruption */
- pagestate = STATE_CORRUPTED;
+ /* Keep index of first valid page, and last valid page */
+ else if (pagestatus == STATE_PAGE_VALID) {
+ if (nbvalidpage == 0U) {
+ firstvalidpage = page;
+ }
+ lastvalidpage = page;
+ nbvalidpage++;
}
- }
- else /* The receive page is the first page of a bloc */
- {
- /* Check that following page is erased state */
- if (GetPageState(PAGE_ADDRESS(FOLLOWING_PAGE(page))) == STATE_PAGE_ERASED)
- {
- /* The receive page is a true receive page */
- pagestate = STATE_RELIABLE;
+ }
+
+ /* Check if no active and no receive page have been detected */
+ if (nbactivereceivepage == 0U) {
+ /* Check if valid pages have been detected */
+ if (nbvalidpage > 0U) {
+ /* Check state of page just before first valid page.
+ If it is erasing page, then page after last valid page shall be set
+ to receiving state */
+ if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(firstvalidpage))) == STATE_PAGE_ERASING) {
+ if (SetPageState(FOLLOWING_PAGE(lastvalidpage), STATE_PAGE_RECEIVE) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
+ }
}
- else /* Following page is not erased state */
- {
- /* The receive page is false receive page due to header corruption */
- pagestate = STATE_CORRUPTED;
+ /* Format flash pages used for eeprom emulation in case no active, no receive, no valid pages are found */
+ else {
+ return EE_Format(EE_FORCED_ERASE);
}
- }
+ }
- /* If the receive page is a true receive page, resume pages transfer */
- if (pagestate == STATE_RELIABLE)
- {
- /* Initialize current active page */
- ubCurrentActivePage = page;
+ /*********************************************************************/
+ /* Step 3: Handle case of reset during transfer, by performing */
+ /* transfer recovery */
+ /*********************************************************************/
- /* Resume the interrupted page transfer, using dummy new data */
-#ifndef FLASH_LINES_128B
- if (PagesTransfer(0U, 0U, EE_TRANSFER_RECOVER) != EE_CLEANUP_REQUIRED)
- {
- return EE_TRANSFER_ERROR;
- }
-#else
- if (PagesTransfer(0U, dummy_data, EE_TRANSFER_RECOVER) != EE_CLEANUP_REQUIRED)
- {
- return EE_TRANSFER_ERROR;
- }
-#endif
- /* Memorize transfer recovery occured */
- recoverytransfer = 1U;
+ /* Browse all pages */
+ for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++) {
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
- /* transfer recovery is done, then stop searching receive page */
- break;
- }
- }
- }
-
- /*********************************************************************/
- /* Step 4: Verify presence of one unique active page */
- /* If more than one active page, raise error */
- /* If no active page present, set missing active page */
- /*********************************************************************/
-
- /* Browse all pages to search for active pages */
- nbactivepage = 0U;
- for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
+ /* Check if there is receive page, meaning transfer has been interrupted */
+ if (pagestatus == STATE_PAGE_RECEIVE) {
+ /* Verify that receive page is a true one, not a corrupted page state */
+ /* Check if page is not the first page of a bloc */
+ if ((page != START_PAGE) && (page != (uint32_t) (START_PAGE + (PAGES_NUMBER / 2U)))) {
+ /* Check that previous page is valid state */
+ if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(page))) == STATE_PAGE_VALID) {
+ /* The receive page is a true receive page */
+ pagestate = STATE_RELIABLE;
+ } else /* Previous page is not valid state */
+ {
+ /* The receive page is false receive page due to header corruption */
+ pagestate = STATE_CORRUPTED;
+ }
+ } else /* The receive page is the first page of a bloc */
+ {
+ /* Check that following page is erased state */
+ if (GetPageState(PAGE_ADDRESS(FOLLOWING_PAGE(page))) == STATE_PAGE_ERASED) {
+ /* The receive page is a true receive page */
+ pagestate = STATE_RELIABLE;
+ } else /* Following page is not erased state */
+ {
+ /* The receive page is false receive page due to header corruption */
+ pagestate = STATE_CORRUPTED;
+ }
+ }
- /* Search for active page */
- if (pagestatus == STATE_PAGE_ACTIVE)
- {
- /* Verify that active page is a true one, not a corrupted page state */
- /* Check if page is not the first page of a bloc */
- if ((page != START_PAGE) && (page != (uint32_t)(START_PAGE + (PAGES_NUMBER / 2U))))
- {
- /* Check that previous page is valid state */
- if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(page))) == STATE_PAGE_VALID)
- {
- /* The active page is a true active page */
- pagestate = STATE_RELIABLE;
+ /* If the receive page is a true receive page, resume pages transfer */
+ if (pagestate == STATE_RELIABLE) {
+ /* Initialize current active page */
+ ubCurrentActivePage = page;
+
+ /* Resume the interrupted page transfer, using dummy new data */
+ if (PagesTransfer(0U, 0U, EE_TRANSFER_RECOVER) != EE_CLEANUP_REQUIRED) {
+ return EE_TRANSFER_ERROR;
+ }
+ /* Memorize transfer recovery occured */
+ recoverytransfer = 1U;
+
+ /* transfer recovery is done, then stop searching receive page */
+ break;
+ }
}
- else /* Previous page is not valid state */
- {
- /* The active page is false active page due to header corruption */
- pagestate = STATE_CORRUPTED;
+ }
+
+ /*********************************************************************/
+ /* Step 4: Verify presence of one unique active page */
+ /* If more than one active page, raise error */
+ /* If no active page present, set missing active page */
+ /*********************************************************************/
+
+ /* Browse all pages to search for active pages */
+ nbactivepage = 0U;
+ for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++) {
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
+
+ /* Search for active page */
+ if (pagestatus == STATE_PAGE_ACTIVE) {
+ /* Verify that active page is a true one, not a corrupted page state */
+ /* Check if page is not the first page of a bloc */
+ if ((page != START_PAGE) && (page != (uint32_t) (START_PAGE + (PAGES_NUMBER / 2U)))) {
+ /* Check that previous page is valid state */
+ if (GetPageState(PAGE_ADDRESS(PREVIOUS_PAGE(page))) == STATE_PAGE_VALID) {
+ /* The active page is a true active page */
+ pagestate = STATE_RELIABLE;
+ } else /* Previous page is not valid state */
+ {
+ /* The active page is false active page due to header corruption */
+ pagestate = STATE_CORRUPTED;
+ }
+ } else /* The active page is the first page of a bloc */
+ {
+ /* Check that following page is erased state */
+ if (GetPageState(PAGE_ADDRESS(FOLLOWING_PAGE(page))) == STATE_PAGE_ERASED) {
+ /* The active page is a true active page */
+ pagestate = STATE_RELIABLE;
+ } else /* Following page is not erased state */
+ {
+ /* The active page is false active page due to header corruption */
+ pagestate = STATE_CORRUPTED;
+ }
+ }
+
+ /* If the active page is a true active page, initialize global variables */
+ if (pagestate == STATE_RELIABLE) {
+ if (nbactivepage == 0U) {
+ ubCurrentActivePage = page;
+ nbactivepage++;
+ } else {
+ /* Error: More than one reliable active page is present */
+ return EE_INVALID_PAGE_SEQUENCE;
+ }
+ }
}
- }
- else /* The active page is the first page of a bloc */
- {
- /* Check that following page is erased state */
- if (GetPageState(PAGE_ADDRESS(FOLLOWING_PAGE(page))) == STATE_PAGE_ERASED)
- {
- /* The active page is a true active page */
- pagestate = STATE_RELIABLE;
+ /* Keep index of last valid page, will be required in case no active page is found */
+ else if (pagestatus == STATE_PAGE_VALID) {
+ lastvalidpage = page;
}
- else /* Following page is not erased state */
- {
- /* The active page is false active page due to header corruption */
- pagestate = STATE_CORRUPTED;
+ }
+
+ /* In case no active page is found, set page after last valid page to active state */
+ if (nbactivepage == 0U) {
+ ubCurrentActivePage = FOLLOWING_PAGE(lastvalidpage);
+ if (SetPageState(ubCurrentActivePage, STATE_PAGE_ACTIVE) != EE_OK) {
+ return EE_WRITE_ERROR;
}
- }
+ }
+
+ /*********************************************************************/
+ /* Step 5: Initialize eeprom emulation global variables relative */
+ /* to active page */
+ /*********************************************************************/
+
+ /* Initialize global variables, with elements detected in active page */
+ uhNbWrittenElements = 0U;
+ uwAddressNextWrite = PAGE_HEADER_SIZE;
- /* If the active page is a true active page, initialize global variables */
- if (pagestate == STATE_RELIABLE)
- {
- if (nbactivepage == 0U)
+ for (varidx = PAGE_HEADER_SIZE; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE) {
+ /* Check elements present in active page */
+ addressvalue = (*(__IO EE_ELEMENT_TYPE *) (PAGE_ADDRESS(ubCurrentActivePage) + varidx));
+ if (addressvalue != EE_MASK_FULL)
{
- ubCurrentActivePage = page;
- nbactivepage++;
- }
- else
+ /* Then increment uhNbWrittenElements and uwAddressNextWrite */
+ uhNbWrittenElements++;
+ uwAddressNextWrite += EE_ELEMENT_SIZE;
+ } else /* no more element in the page */
{
- /* Error: More than one reliable active page is present */
- return EE_INVALID_PAGE_SEQUENCE;
+ break;
}
- }
- }
- /* Keep index of last valid page, will be required in case no active page is found */
- else if (pagestatus == STATE_PAGE_VALID)
- {
- lastvalidpage = page;
- }
- }
-
- /* In case no active page is found, set page after last valid page to active state */
- if (nbactivepage == 0U)
- {
- ubCurrentActivePage = FOLLOWING_PAGE(lastvalidpage);
- if (SetPageState(ubCurrentActivePage, STATE_PAGE_ACTIVE) != EE_OK)
- {
- return EE_WRITE_ERROR;
- }
- }
-
- /*********************************************************************/
- /* Step 5: Initialize eeprom emulation global variables relative */
- /* to active page */
- /*********************************************************************/
-
- /* Initialize global variables, with elements detected in active page */
- uhNbWrittenElements = 0U;
- uwAddressNextWrite = PAGE_HEADER_SIZE;
-
- for (varidx = PAGE_HEADER_SIZE; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE)
- {
- /* Check elements present in active page */
- addressvalue = (*(__IO EE_ELEMENT_TYPE*)(PAGE_ADDRESS(ubCurrentActivePage) + varidx));
-#ifdef FLASH_LINES_128B
- addressvalue2 = (*(__IO EE_ELEMENT_TYPE*)(PAGE_ADDRESS(ubCurrentActivePage) + varidx + 8));
- if ((addressvalue != EE_MASK_FULL) && (addressvalue2 != EE_MASK_FULL))
-#else
- if (addressvalue != EE_MASK_FULL)
-#endif
- {
- /* Then increment uhNbWrittenElements and uwAddressNextWrite */
- uhNbWrittenElements++;
- uwAddressNextWrite += EE_ELEMENT_SIZE;
- }
- else /* no more element in the page */
- {
- break;
}
- }
-
- /*********************************************************************/
- /* Step 6: Finalize eeprom emulation global variables relative */
- /* to valid pages, and check consistency of pages sequence */
- /*********************************************************************/
-
- /* Check consistency of pages sequence: one active page, optionnally some valid pages before */
- /* Update global variable uhNbWrittenElements if valid pages are found */
- page = ubCurrentActivePage;
- firstvalidpage = ubCurrentActivePage;
- while ((page != START_PAGE) && (page != (uint32_t)(START_PAGE + (PAGES_NUMBER / 2U))))
- {
- /* Decrement page index among circular pages list */
- page = PREVIOUS_PAGE(page);
- pagestatus = GetPageState(PAGE_ADDRESS(page));
- /* Check if page is valid state */
- if (pagestatus == STATE_PAGE_VALID)
- {
- /* Update uhNbWrittenElements with number of elements in full page */
- uhNbWrittenElements += NB_MAX_ELEMENTS_BY_PAGE;
+ /*********************************************************************/
+ /* Step 6: Finalize eeprom emulation global variables relative */
+ /* to valid pages, and check consistency of pages sequence */
+ /*********************************************************************/
- /* Keep index of first valid page */
- firstvalidpage = page;
- }
- else
- {
- /* Error: Pages sequence is not consistent */
- return EE_INVALID_PAGE_SEQUENCE;
- }
- }
-
- /*********************************************************************/
- /* Step 7: Ensure empty pages are erased */
- /*********************************************************************/
-
- /* Ensure all pages after active page, until first valid page, are erased */
- page = FOLLOWING_PAGE(ubCurrentActivePage);
- pageaddress = PAGE_ADDRESS(page);
-
- while (page != firstvalidpage)
- {
- /* Check if page erase has to be forced unconditionally (default case) */
- if (EraseType == EE_FORCED_ERASE)
- {
- /* Force page erase independently of its content */
- if (FI_PageErase(page, 1U) != EE_OK)
- {
- return EE_ERASE_ERROR;
- }
- }
- else /* EraseType == EE_CONDITIONAL_ERASE */
- {
- /* Check if page is fully erased */
- if (VerifyPageFullyErased(pageaddress, PAGE_SIZE) == EE_PAGE_NOTERASED)
- {
- /* Erase pages if not fully erased */
- if (FI_PageErase(page, 1U) != EE_OK)
- {
- return EE_ERASE_ERROR;
+ /* Check consistency of pages sequence: one active page, optionnally some valid pages before */
+ /* Update global variable uhNbWrittenElements if valid pages are found */
+ page = ubCurrentActivePage;
+ firstvalidpage = ubCurrentActivePage;
+ while ((page != START_PAGE) && (page != (uint32_t) (START_PAGE + (PAGES_NUMBER / 2U)))) {
+ /* Decrement page index among circular pages list */
+ page = PREVIOUS_PAGE(page);
+ pagestatus = GetPageState(PAGE_ADDRESS(page));
+
+ /* Check if page is valid state */
+ if (pagestatus == STATE_PAGE_VALID) {
+ /* Update uhNbWrittenElements with number of elements in full page */
+ uhNbWrittenElements += NB_MAX_ELEMENTS_BY_PAGE;
+
+ /* Keep index of first valid page */
+ firstvalidpage = page;
+ } else {
+ /* Error: Pages sequence is not consistent */
+ return EE_INVALID_PAGE_SEQUENCE;
}
- }
}
- /* Increment page index among circular pages list, to get first page to erased */
- page = FOLLOWING_PAGE(page);
+ /*********************************************************************/
+ /* Step 7: Ensure empty pages are erased */
+ /*********************************************************************/
+
+ /* Ensure all pages after active page, until first valid page, are erased */
+ page = FOLLOWING_PAGE(ubCurrentActivePage);
pageaddress = PAGE_ADDRESS(page);
- }
-
- /* To keep their coherency, flush the caches if needed depending on the product */
- FI_CacheFlush();
-
- /*********************************************************************/
- /* Step 8: Perform dummy write '0' to get rid of potential */
- /* instability of line value 0xFFFFFFFF consecutive to a */
- /* reset during write here */
- /* Only needed if recovery transfer did not occured */
- /*********************************************************************/
-
-if (recoverytransfer == 0U)
- {
-
-#ifdef DUALCORE_FLASH_SHARING
- status = VerifyPagesFullWriteVariable(0U, 0U, EE_INIT_WRITE);
-
- // The dummy write can be skipped in case pages are full
- // because in this case potential instability can not happen
- if ((status != EE_OK) && (status != EE_PAGE_FULL))
- {
- return EE_WRITE_ERROR;
+
+ while (page != firstvalidpage) {
+ /* Check if page erase has to be forced unconditionally (default case) */
+ if (EraseType == EE_FORCED_ERASE) {
+ /* Force page erase independently of its content */
+ if (FI_PageErase(page, 1U) != EE_OK) {
+ return EE_ERASE_ERROR;
+ }
+ } else /* EraseType == EE_CONDITIONAL_ERASE */
+ {
+ /* Check if page is fully erased */
+ if (VerifyPageFullyErased(pageaddress, PAGE_SIZE) == EE_PAGE_NOTERASED) {
+ /* Erase pages if not fully erased */
+ if (FI_PageErase(page, 1U) != EE_OK) {
+ return EE_ERASE_ERROR;
+ }
+ }
+ }
+
+ /* Increment page index among circular pages list, to get first page to erased */
+ page = FOLLOWING_PAGE(page);
+ pageaddress = PAGE_ADDRESS(page);
}
-#else
-#ifdef FLASH_LINES_128B
- uint64_t to_write[2] = {0};
- status = VerifyPagesFullWriteVariable(0U, to_write, EE_INIT_WRITE);
-#else
- status = VerifyPagesFullWriteVariable(0U, 0U);
-#endif
- // The dummy write can be skipped in case pages are full
- // because in this case potential instability can not happen
- if ((status != EE_OK) && (status != EE_PAGE_FULL))
- {
- return EE_WRITE_ERROR;
+
+ /* To keep their coherency, flush the caches if needed depending on the product */
+ FI_CacheFlush();
+
+ /*********************************************************************/
+ /* Step 8: Perform dummy write '0' to get rid of potential */
+ /* instability of line value 0xFFFFFFFF consecutive to a */
+ /* reset during write here */
+ /* Only needed if recovery transfer did not occured */
+ /*********************************************************************/
+
+ if (recoverytransfer == 0U) {
+ status = VerifyPagesFullWriteVariable(0U, 0U);
+ // The dummy write can be skipped in case pages are full
+ // because in this case potential instability can not happen
+ if ((status != EE_OK) && (status != EE_PAGE_FULL)) {
+ return EE_WRITE_ERROR;
+ }
}
-#endif
- }
- return EE_OK;
+ return EE_OK;
}
/**
@@ -627,106 +519,46 @@ if (recoverytransfer == 0U)
*/
EE_Status EE_Format(EE_Erase_type EraseType)
{
- uint32_t page = 0U;
-
- /* Check if the configuration is 128-bits bank or 2*64-bits bank */
- if (FI_CheckBankConfig() != EE_OK)
- {
- return EE_INVALID_BANK_CFG;
- }
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON);
-#endif
-
- /* Erase All Pages */
- for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++)
- {
- /* Check if page erase has to be forced unconditionally (default case) */
- if (EraseType == EE_FORCED_ERASE)
- {
- /* Force page erase independently of its content */
- if (FI_PageErase(page, 1U) != EE_OK)
- {
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about end of Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF);
-#endif
- return EE_ERASE_ERROR;
- }
- }
- else /* EraseType == EE_CONDITIONAL_ERASE */
- {
- /* Check if Page is not yet fully erased */
- if (VerifyPageFullyErased(PAGE_ADDRESS(page), PAGE_SIZE) == EE_PAGE_NOTERASED)
- {
- /* Erase the page */
- /* If Erase operation was failed, a Flash error code is returned */
- if (FI_PageErase(page, 1U) != EE_OK)
+ uint32_t page = 0U;
+
+ /* Erase All Pages */
+ for (page = START_PAGE; page < (START_PAGE + PAGES_NUMBER); page++) {
+ /* Check if page erase has to be forced unconditionally (default case) */
+ if (EraseType == EE_FORCED_ERASE) {
+ /* Force page erase independently of its content */
+ if (FI_PageErase(page, 1U) != EE_OK) {
+ return EE_ERASE_ERROR;
+ }
+ } else /* EraseType == EE_CONDITIONAL_ERASE */
{
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about end of Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF);
-#endif
- return EE_ERASE_ERROR;
+ /* Check if Page is not yet fully erased */
+ if (VerifyPageFullyErased(PAGE_ADDRESS(page), PAGE_SIZE) == EE_PAGE_NOTERASED) {
+ /* Erase the page */
+ /* If Erase operation was failed, a Flash error code is returned */
+ if (FI_PageErase(page, 1U) != EE_OK) {
+ return EE_ERASE_ERROR;
+ }
+ }
}
- }
}
- }
-
- /* To keep their coherency, flush the caches if needed depending on the product */
- FI_CacheFlush();
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about end of Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF);
-#endif
-
- /* Set first Page in Active State */
- /* If program operation was failed, a Flash error code is returned */
- if (SetPageState(START_PAGE, STATE_PAGE_ACTIVE) != EE_OK)
- {
- return EE_WRITE_ERROR;
- }
-
- /* Reset global variables */
- uhNbWrittenElements = (uint16_t)0U;
- ubCurrentActivePage = START_PAGE;
- uwAddressNextWrite = PAGE_HEADER_SIZE; /* Initialize write position just after page header */
-
- return EE_OK;
-}
-#if defined(FLASH_LINES_128B)
-/**
- * @brief Returns the last stored variable data, if found, which correspond to
- * the passed virtual address
- * @param VirtAddress Variable virtual address on 16 bits (can't be 0x0000 or 0xFFFF)
- * @param Data 96bits data to be written pointed by a uin64_t pointer
- * @retval EE_Status
- * - EE_OK: if variable was found
- * - EE error code: if an error occurs
- */
-EE_Status EE_ReadVariable96bits(uint16_t VirtAddress, uint64_t* pData)
-{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
- EE_Status status = EE_OK;
+ /* To keep their coherency, flush the caches if needed depending on the product */
+ FI_CacheFlush();
- /* Read variable of size EE_DATA_TYPE */
- status = ReadVariable(VirtAddress, pData);
-
- return status;
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ /* Set first Page in Active State */
+ /* If program operation was failed, a Flash error code is returned */
+ if (SetPageState(START_PAGE, STATE_PAGE_ACTIVE) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
+
+ /* Reset global variables */
+ uhNbWrittenElements = (uint16_t) 0U;
+ ubCurrentActivePage = START_PAGE;
+ uwAddressNextWrite = PAGE_HEADER_SIZE; /* Initialize write position just after page header */
+
+ return EE_OK;
}
-#endif
-#if defined(EE_ACCESS_32BITS)
/**
* @brief Returns the last stored variable data, if found, which correspond to
* the passed virtual address
@@ -736,25 +568,22 @@ EE_Status EE_ReadVariable96bits(uint16_t VirtAddress, uint64_t* pData)
* - EE_OK: if variable was found
* - EE error code: if an error occurs
*/
-EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t* pData)
+EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t *pData)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
- EE_DATA_TYPE datatmp = 0U;
- EE_Status status = EE_OK;
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ EE_DATA_TYPE datatmp = 0U;
+ EE_Status status = EE_OK;
- /* Read variable of size EE_DATA_TYPE, then cast it to 32bits */
- status = ReadVariable(VirtAddress, &datatmp);
- *pData = (uint32_t) datatmp;
+ /* Read variable of size EE_DATA_TYPE, then cast it to 32bits */
+ status = ReadVariable(VirtAddress, &datatmp);
+ *pData = (uint32_t) datatmp;
- return status;
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ return status;
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
-#endif
+
/**
* @brief Returns the last stored variable data, if found, which correspond to
@@ -765,23 +594,20 @@ EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t* pData)
* - EE_OK: if variable was found
* - EE error code: if an error occurs
*/
-EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t* pData)
+EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t *pData)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
- EE_DATA_TYPE datatmp = 0U;
- EE_Status status = EE_OK;
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ EE_DATA_TYPE datatmp = 0U;
+ EE_Status status = EE_OK;
- /* Read variable of size EE_DATA_TYPE, then cast it to 16bits */
- status = ReadVariable(VirtAddress, &datatmp);
- *pData = (uint16_t) datatmp;
+ /* Read variable of size EE_DATA_TYPE, then cast it to 16bits */
+ status = ReadVariable(VirtAddress, &datatmp);
+ *pData = (uint16_t) datatmp;
- return status;
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ return status;
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
/**
@@ -793,51 +619,22 @@ EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t* pData)
* - EE_OK: if variable was found
* - EE error code: if an error occurs
*/
-EE_Status EE_ReadVariable8bits(uint16_t VirtAddress, uint8_t* pData)
+EE_Status EE_ReadVariable8bits(uint16_t VirtAddress, uint8_t *pData)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
- EE_DATA_TYPE datatmp = 0U;
- EE_Status status = EE_OK;
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ EE_DATA_TYPE datatmp = 0U;
+ EE_Status status = EE_OK;
- /* Read variable of size EE_DATA_TYPE, then cast it to 8bits */
- status = ReadVariable(VirtAddress, &datatmp);
- *pData = (uint8_t) datatmp;
-
- return status;
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
-}
+ /* Read variable of size EE_DATA_TYPE, then cast it to 8bits */
+ status = ReadVariable(VirtAddress, &datatmp);
+ *pData = (uint8_t) datatmp;
-#if defined(FLASH_LINES_128B)
-/**
- * @brief Writes/updates variable data in EEPROM.
- * Trig internal Pages transfer if half of the pages are full.
- * @warning This function is not reentrant
- * @param VirtAddress Variable virtual address on 16 bits (can't be 0x0000 or 0xFFFF)
- * @param Data 96bits data to be written pointed by a uin64_t pointer
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_CLEANUP_REQUIRED: success and user has to trig flash pages cleanup
- * - EE error code: if an error occurs
- */
-EE_Status EE_WriteVariable96bits(uint16_t VirtAddress, uint64_t* Data)
-{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
- return WriteVariable(VirtAddress, (EE_DATA_TYPE*)Data);
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ return status;
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
-#endif
-#if defined(EE_ACCESS_32BITS)
/**
* @brief Writes/updates variable data in EEPROM.
* Trig internal Pages transfer if half of the pages are full.
@@ -851,20 +648,13 @@ EE_Status EE_WriteVariable96bits(uint16_t VirtAddress, uint64_t* Data)
*/
EE_Status EE_WriteVariable32bits(uint16_t VirtAddress, uint32_t Data)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
-#ifndef FLASH_LINES_128B
- return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
-#else
- return WriteVariable(VirtAddress, (EE_DATA_TYPE*) &Data);
-#endif
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
-#endif
+
/**
* @brief Writes/updates variable data in EEPROM.
@@ -879,18 +669,11 @@ EE_Status EE_WriteVariable32bits(uint16_t VirtAddress, uint32_t Data)
*/
EE_Status EE_WriteVariable16bits(uint16_t VirtAddress, uint16_t Data)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
-#ifndef FLASH_LINES_128B
- return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
-#else
- return WriteVariable(VirtAddress, (EE_DATA_TYPE*) &Data);
-#endif
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
/**
@@ -906,18 +689,11 @@ EE_Status EE_WriteVariable16bits(uint16_t VirtAddress, uint16_t Data)
*/
EE_Status EE_WriteVariable8bits(uint16_t VirtAddress, uint8_t Data)
{
- if((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF))
- {
-#ifndef FLASH_LINES_128B
- return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
-#else
- return WriteVariable(VirtAddress, (EE_DATA_TYPE*) &Data);
-#endif
- }
- else
- {
- return EE_INVALID_VIRTUALADDRESS;
- }
+ if ((VirtAddress != 0x0000) && (VirtAddress != 0xFFFF)) {
+ return WriteVariable(VirtAddress, (EE_DATA_TYPE) Data);
+ } else {
+ return EE_INVALID_VIRTUALADDRESS;
+ }
}
/**
@@ -931,127 +707,43 @@ EE_Status EE_WriteVariable8bits(uint16_t VirtAddress, uint8_t Data)
*/
EE_Status EE_CleanUp(void)
{
- uint32_t firstpage = 0U, page = 0U;
- uint32_t firstpageaddress = 0U, pageaddress = 0U;
- EE_State_type firstpagestatus = STATE_PAGE_INVALID, pagestatus = STATE_PAGE_INVALID;
-
- /* Check first half and second half page group */
- for (firstpage = START_PAGE; firstpage < (START_PAGE + PAGES_NUMBER); firstpage += (PAGES_NUMBER / 2U))
- {
- /* Check status of first page of the group */
- firstpageaddress = PAGE_ADDRESS(firstpage);
- firstpagestatus = GetPageState(firstpageaddress);
-
- /* If first page of the group is erasing state, check that all other pages
- of the group are also erasing state */
- if (firstpagestatus == STATE_PAGE_ERASING)
- {
- for (page = (firstpage + 1U); page < (firstpage + (PAGES_NUMBER / 2U)); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
-
- /* If page is not erasing, return error */
- if (pagestatus != STATE_PAGE_ERASING)
- {
- return EE_ERROR_NOERASING_PAGE;
- }
- }
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON);
-#endif
-
- /* Erase all the pages of the group */
- /* If erase operation fails, a Flash error code is returned */
- if (FI_PageErase(firstpage, PAGES_NUMBER / 2U) != EE_OK)
- {
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about end of Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF);
-#endif
- return EE_ERASE_ERROR;
- }
- else
- {
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about end of Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF);
-#endif
-
- /* To keep their coherency, flush the caches if needed depending on the product */
- FI_CacheFlush();
-
- return EE_OK;
- }
- }
- }
-
- /* Error if no erasing pages group is found */
- return EE_ERROR_NOERASING_PAGE;
-}
-
-/**
- * @brief Erase group of pages which are erasing state, in IT mode.
- * Could be either first half or second half of total pages number.
- * @note This function should be called when EE_WriteVariableXXbits has
- * returned EE_CLEANUP_REQUIRED status (and only in that case)
- * @retval EE_Status
- * - EE_OK: in case of success
- * - EE error code: if an error occurs
- */
-EE_Status EE_CleanUp_IT(void)
-{
- uint32_t firstpage = 0U, page = 0U;
- uint32_t firstpageaddress = 0U, pageaddress = 0U;
- EE_State_type firstpagestatus = STATE_PAGE_INVALID, pagestatus = STATE_PAGE_INVALID;
-
- /* Check first half and second half page group */
- for (firstpage = START_PAGE; firstpage < (START_PAGE + PAGES_NUMBER); firstpage += (PAGES_NUMBER / 2U))
- {
- /* Check status of first page of the group */
- firstpageaddress = PAGE_ADDRESS(firstpage);
- firstpagestatus = GetPageState(firstpageaddress);
-
- /* If first page of the group is erasing state, check that all other pages
- of the group are also erasing state */
- if (firstpagestatus == STATE_PAGE_ERASING)
- {
- for (page = (firstpage + 1U); page < (firstpage + (PAGES_NUMBER / 2U)); page++)
- {
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
+ uint32_t firstpage = 0U, page = 0U;
+ uint32_t firstpageaddress = 0U, pageaddress = 0U;
+ EE_State_type firstpagestatus = STATE_PAGE_INVALID, pagestatus = STATE_PAGE_INVALID;
+
+ /* Check first half and second half page group */
+ for (firstpage = START_PAGE; firstpage < (START_PAGE + PAGES_NUMBER); firstpage += (PAGES_NUMBER / 2U)) {
+ /* Check status of first page of the group */
+ firstpageaddress = PAGE_ADDRESS(firstpage);
+ firstpagestatus = GetPageState(firstpageaddress);
+
+ /* If first page of the group is erasing state, check that all other pages
+ of the group are also erasing state */
+ if (firstpagestatus == STATE_PAGE_ERASING) {
+ for (page = (firstpage + 1U); page < (firstpage + (PAGES_NUMBER / 2U)); page++) {
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
+
+ /* If page is not erasing, return error */
+ if (pagestatus != STATE_PAGE_ERASING) {
+ return EE_ERROR_NOERASING_PAGE;
+ }
+ }
- /* If page is not erasing, return error */
- if (pagestatus != STATE_PAGE_ERASING)
- {
- return EE_ERROR_NOERASING_PAGE;
+ /* Erase all the pages of the group */
+ /* If erase operation fails, a Flash error code is returned */
+ if (FI_PageErase(firstpage, PAGES_NUMBER / 2U) != EE_OK) {
+ return EE_ERASE_ERROR;
+ } else {
+ /* To keep their coherency, flush the caches if needed depending on the product */
+ FI_CacheFlush();
+ return EE_OK;
+ }
}
- }
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Inform CPU2 about Erase Activity */
- SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON);
-#endif
-
- /* Erase all the pages of the group */
- /* If erase operation fails, a Flash error code is returned */
- if (FI_PageErase_IT(firstpage, PAGES_NUMBER / 2U) != EE_OK)
- {
- return EE_ERASE_ERROR;
- }
- else
- {
- /* To keep their coherency, flush the caches if needed depending on the product */
- FI_CacheFlush();
- return EE_OK;
- }
}
- }
- /* Error if no erasing pages group is found */
- return EE_ERROR_NOERASING_PAGE;
+ /* Error if no erasing pages group is found */
+ return EE_ERROR_NOERASING_PAGE;
}
/**
@@ -1063,19 +755,9 @@ EE_Status EE_CleanUp_IT(void)
*/
EE_Status EE_DeleteCorruptedFlashAddress(uint32_t Address)
{
- return FI_DeleteCorruptedFlashAddress(Address);
+ return FI_DeleteCorruptedFlashAddress(Address);
}
-/**
- * @brief Clean Up end of operation interrupt callback.
- * @retval None
- */
-__weak void EE_EndOfCleanup_UserCallback(void)
-{
- /* NOTE : This function should not be modified, when the callback is needed,
- the EE_EndOfCleanup_UserCallback could be implemented in the user file
- */
-}
/**
* @}
@@ -1095,97 +777,61 @@ __weak void EE_EndOfCleanup_UserCallback(void)
* - EE_OK: if variable was found
* - EE error code: if an error occurs
*/
-#ifndef FLASH_LINES_128B
-static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE* pData)
-#else
-static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE* pData)
-#endif
+
+static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE *pData)
{
- EE_ELEMENT_TYPE addressvalue = 0U;
-#ifdef FLASH_LINES_128B
- EE_ELEMENT_TYPE addressvalue2 = 0U;
-#endif
- uint32_t page = 0U, pageaddress = 0U, counter = 0U, crc = 0U;
- EE_State_type pagestate = STATE_PAGE_INVALID;
-
- /* Get active Page for read operation */
- page = FindPage(FIND_READ_PAGE);
-
- /* Check if there is no active page */
- if (page == EE_NO_PAGE_FOUND)
- {
- return EE_ERROR_NOACTIVE_PAGE;
- }
- pageaddress = PAGE_ADDRESS(page);
- pagestate = GetPageState(pageaddress);
-
- /* Search variable in active page and valid pages until erased page is found
- or in erasing pages until erased page is found */
- while ((pagestate == STATE_PAGE_ACTIVE) || (pagestate == STATE_PAGE_VALID) || (pagestate == STATE_PAGE_ERASING))
- {
- /* Set counter index to last element position in the page */
- counter = PAGE_SIZE - EE_ELEMENT_SIZE;
-
- /* Check each page address starting from end */
- while (counter >= PAGE_HEADER_SIZE)
- {
- /* Get the current location content to be compared with virtual address */
- addressvalue = (*(__IO EE_ELEMENT_TYPE*)(pageaddress + counter));
-#ifndef FLASH_LINES_128B
- if (addressvalue != EE_PAGESTAT_ERASED)
- {
- /* Compare the read address with the virtual address */
- if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress)
- {
- /* Calculate crc of variable data and virtual address */
- crc = CalculateCrc(EE_DATA_VALUE(addressvalue), EE_VIRTUALADDRESS_VALUE(addressvalue));
-
- /* if crc verification pass, data is correct and is returned.
- if crc verification fails, data is corrupted and has to be skip */
- if (crc == EE_CRC_VALUE(addressvalue))
- {
- /* Get content of variable value */
- *pData = EE_DATA_VALUE(addressvalue);
-
- return EE_OK;
- }
- }
- }
-#else
- addressvalue2 = (*(__IO EE_ELEMENT_TYPE*)(pageaddress + counter+8U));
- if ((addressvalue != EE_PAGESTAT_ERASED) && (addressvalue2 != EE_PAGESTAT_ERASED))
- {
- /* Compare the read address with the virtual address */
- if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress)
- {
- /* Calculate crc of variable data and virtual address */
- crc = CalculateCrc((uint64_t)addressvalue2,(uint64_t)addressvalue);
-
- /* if crc verification pass, data is correct and is returned.
- if crc verification fails, data is corrupted and has to be skip */
- if (crc == EE_CRC_VALUE(addressvalue))
- {
- /* Get content of variable value */
- pData[0] = (uint64_t)addressvalue2;
- pData[1] = (uint64_t)(addressvalue >> EE_DATA_SHIFT);
-
- return EE_OK;
- }
- }
- }
-#endif
- /* Next address location */
- counter -= EE_ELEMENT_SIZE;
- }
+ EE_ELEMENT_TYPE addressvalue = 0U;
+ uint32_t page = 0U, pageaddress = 0U, counter = 0U, crc = 0U;
+ EE_State_type pagestate = STATE_PAGE_INVALID;
- /* Decrement page index circularly, among pages allocated to eeprom emulation */
- page = PREVIOUS_PAGE(page);
+ /* Get active Page for read operation */
+ page = FindPage(FIND_READ_PAGE);
+
+ /* Check if there is no active page */
+ if (page == EE_NO_PAGE_FOUND) {
+ return EE_ERROR_NOACTIVE_PAGE;
+ }
pageaddress = PAGE_ADDRESS(page);
pagestate = GetPageState(pageaddress);
- }
- /* Variable is not found */
- return EE_NO_DATA;
+ /* Search variable in active page and valid pages until erased page is found
+ or in erasing pages until erased page is found */
+ while ((pagestate == STATE_PAGE_ACTIVE) || (pagestate == STATE_PAGE_VALID) || (pagestate == STATE_PAGE_ERASING)) {
+ /* Set counter index to last element position in the page */
+ counter = PAGE_SIZE - EE_ELEMENT_SIZE;
+
+ /* Check each page address starting from end */
+ while (counter >= PAGE_HEADER_SIZE) {
+ /* Get the current location content to be compared with virtual address */
+ addressvalue = (*(__IO EE_ELEMENT_TYPE *) (pageaddress + counter));
+ if (addressvalue != EE_PAGESTAT_ERASED) {
+ /* Compare the read address with the virtual address */
+ if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress) {
+ /* Calculate crc of variable data and virtual address */
+ crc = CalculateCrc(EE_DATA_VALUE(addressvalue), EE_VIRTUALADDRESS_VALUE(addressvalue));
+
+ /* if crc verification pass, data is correct and is returned.
+ if crc verification fails, data is corrupted and has to be skip */
+ if (crc == EE_CRC_VALUE(addressvalue)) {
+ /* Get content of variable value */
+ *pData = EE_DATA_VALUE(addressvalue);
+
+ return EE_OK;
+ }
+ }
+ }
+ /* Next address location */
+ counter -= EE_ELEMENT_SIZE;
+ }
+
+ /* Decrement page index circularly, among pages allocated to eeprom emulation */
+ page = PREVIOUS_PAGE(page);
+ pageaddress = PAGE_ADDRESS(page);
+ pagestate = GetPageState(pageaddress);
+ }
+
+ /* Variable is not found */
+ return EE_NO_DATA;
}
/**
@@ -1199,28 +845,19 @@ static EE_Status ReadVariable(uint16_t VirtAddress, EE_DATA_TYPE* pData)
* - EE_FLASH_USED: flash currently used by CPU2
* - EE error code: if an error occurs
*/
-#ifndef FLASH_LINES_128B
static EE_Status WriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data)
-#else
-static EE_Status WriteVariable(uint16_t VirtAddress, EE_DATA_TYPE* Data)
-#endif
{
- EE_Status status = EE_OK;
-
- /* Write the variable virtual address and value in the EEPROM, if not full */
-#if defined (DUALCORE_FLASH_SHARING) || defined (FLASH_LINES_128B)
- status = VerifyPagesFullWriteVariable(VirtAddress, Data, EE_SIMPLE_WRITE);
-#else
- status = VerifyPagesFullWriteVariable(VirtAddress, Data);
-#endif
- if (status == EE_PAGE_FULL)
- {
- /* In case the EEPROM pages are full, perform Pages transfer */
- return PagesTransfer(VirtAddress, Data, EE_TRANSFER_NORMAL);
- }
-
- /* Return last operation status */
- return status;
+ EE_Status status = EE_OK;
+
+ /* Write the variable virtual address and value in the EEPROM, if not full */
+ status = VerifyPagesFullWriteVariable(VirtAddress, Data);
+ if (status == EE_PAGE_FULL) {
+ /* In case the EEPROM pages are full, perform Pages transfer */
+ return PagesTransfer(VirtAddress, Data, EE_TRANSFER_NORMAL);
+ }
+
+ /* Return last operation status */
+ return status;
}
/**
@@ -1233,28 +870,22 @@ static EE_Status WriteVariable(uint16_t VirtAddress, EE_DATA_TYPE* Data)
*/
static EE_Status VerifyPageFullyErased(uint32_t Address, uint32_t PageSize)
{
- EE_Status readstatus = EE_PAGE_ERASED;
- uint32_t counter = 0U;
-
- /* Check each element in the page */
- while (counter < PageSize)
- {
- /* Compare the read address with the virtual address */
-#ifndef FLASH_LINES_128B
- if ((*(__IO EE_ELEMENT_TYPE*)(Address+counter)) != EE_PAGESTAT_ERASED)
-#else
- if ( ((*(__IO EE_ELEMENT_TYPE*)(Address+counter)) != EE_PAGESTAT_ERASED) && ((*(__IO EE_ELEMENT_TYPE*)(Address+counter+8U)) != EE_PAGESTAT_ERASED) )
-#endif
- {
- /* In case one element is not erased, reset readstatus flag */
- readstatus = EE_PAGE_NOTERASED;
+ EE_Status readstatus = EE_PAGE_ERASED;
+ uint32_t counter = 0U;
+
+ /* Check each element in the page */
+ while (counter < PageSize) {
+ /* Compare the read address with the virtual address */
+ if ((*(__IO EE_ELEMENT_TYPE *) (Address + counter)) != EE_PAGESTAT_ERASED) {
+ /* In case one element is not erased, reset readstatus flag */
+ readstatus = EE_PAGE_NOTERASED;
+ }
+ /* Next address location */
+ counter = counter + EE_ELEMENT_SIZE;
}
- /* Next address location */
- counter = counter + EE_ELEMENT_SIZE;
- }
- /* Return readstatus value */
- return readstatus;
+ /* Return readstatus value */
+ return readstatus;
}
/**
@@ -1272,138 +903,110 @@ static EE_Status VerifyPageFullyErased(uint32_t Address, uint32_t PageSize)
*/
static uint32_t FindPage(EE_Find_type Operation)
{
- EE_State_type currentpagestatus = STATE_PAGE_INVALID, followingpagestatus = STATE_PAGE_INVALID;
- uint32_t currentpage = 0U, followingpage = 0U, previouspage = 0U;
-
- /* Get currentpage status */
- currentpage = ubCurrentActivePage;
- currentpagestatus = GetPageState(PAGE_ADDRESS(currentpage));
-
- /* Get followingpage status */
- followingpage = FOLLOWING_PAGE(currentpage);
- followingpagestatus = GetPageState(PAGE_ADDRESS(followingpage));
-
- /* Get previouspage status */
- previouspage = PREVIOUS_PAGE(currentpage);
-
- /* Write, read or erase operation */
- switch (Operation)
- {
- case FIND_WRITE_PAGE: /* ---- Write operation ---- */
- /* Normal operation, no page transfer on going */
- if (currentpagestatus == STATE_PAGE_ACTIVE)
- {
- /* Check if active page is not full */
- if (uwAddressNextWrite < PAGE_SIZE)
- {
- /* Return current Active page */
- return currentpage;
- }
- else
- /* No more space in current active page */
- {
- /* Check if following page is erasing state */
- if (followingpagestatus == STATE_PAGE_ERASING)
- {
- /* Force Cleanup, as not yet performed by user */
- if (EE_CleanUp() != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
+ EE_State_type currentpagestatus = STATE_PAGE_INVALID, followingpagestatus = STATE_PAGE_INVALID;
+ uint32_t currentpage = 0U, followingpage = 0U, previouspage = 0U;
+
+ /* Get currentpage status */
+ currentpage = ubCurrentActivePage;
+ currentpagestatus = GetPageState(PAGE_ADDRESS(currentpage));
+
+ /* Get followingpage status */
+ followingpage = FOLLOWING_PAGE(currentpage);
+ followingpagestatus = GetPageState(PAGE_ADDRESS(followingpage));
+
+ /* Get previouspage status */
+ previouspage = PREVIOUS_PAGE(currentpage);
+
+ /* Write, read or erase operation */
+ switch (Operation) {
+ case FIND_WRITE_PAGE: /* ---- Write operation ---- */
+ /* Normal operation, no page transfer on going */
+ if (currentpagestatus == STATE_PAGE_ACTIVE) {
+ /* Check if active page is not full */
+ if (uwAddressNextWrite < PAGE_SIZE) {
+ /* Return current Active page */
+ return currentpage;
+ } else
+ /* No more space in current active page */
+ {
+ /* Check if following page is erasing state */
+ if (followingpagestatus == STATE_PAGE_ERASING) {
+ /* Force Cleanup, as not yet performed by user */
+ if (EE_CleanUp() != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+ }
+
+ /* Set current active page in valid state */
+ if (SetPageState(currentpage, STATE_PAGE_VALID) != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+
+ /* Set following page as active */
+ if (SetPageState(followingpage, STATE_PAGE_ACTIVE) != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+ uwAddressNextWrite = PAGE_HEADER_SIZE; /* Skip page header */
+ return followingpage; /* Following page is now active one */
+ }
}
- }
-
- /* Set current active page in valid state */
- if (SetPageState(currentpage, STATE_PAGE_VALID) != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
- }
-
- /* Set following page as active */
- if (SetPageState(followingpage, STATE_PAGE_ACTIVE) != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
- }
- uwAddressNextWrite = PAGE_HEADER_SIZE; /* Skip page header */
- return followingpage; /* Following page is now active one */
- }
- }
- /* Transfer is on going, page receiving data */
- else
- {
- if (currentpagestatus == STATE_PAGE_RECEIVE)
- {
- /* Check if receive page is not full */
- if (uwAddressNextWrite < PAGE_SIZE)
- {
- /* Return current receive page */
- return currentpage;
- }
- else
- /* No more space in current receive page */
- {
- /* Check if following page is erasing state */
- if (followingpagestatus == STATE_PAGE_ERASING)
- {
- /* Force Cleanup, as not yet performed by user */
- if (EE_CleanUp() != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
- }
+ /* Transfer is on going, page receiving data */
+ else {
+ if (currentpagestatus == STATE_PAGE_RECEIVE) {
+ /* Check if receive page is not full */
+ if (uwAddressNextWrite < PAGE_SIZE) {
+ /* Return current receive page */
+ return currentpage;
+ } else
+ /* No more space in current receive page */
+ {
+ /* Check if following page is erasing state */
+ if (followingpagestatus == STATE_PAGE_ERASING) {
+ /* Force Cleanup, as not yet performed by user */
+ if (EE_CleanUp() != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+ }
+
+ /* Set current receive page in valid state */
+ if (SetPageState(currentpage, STATE_PAGE_VALID) != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+
+ /* Set following page as receive */
+ if (SetPageState(followingpage, STATE_PAGE_RECEIVE) != EE_OK) {
+ return EE_NO_PAGE_FOUND;
+ }
+ uwAddressNextWrite = PAGE_HEADER_SIZE; /* Skip page header */
+ return followingpage; /* Following page is now active one */
+ }
+ } else {
+ return EE_NO_PAGE_FOUND; /* No active Page */
+ }
}
- /* Set current receive page in valid state */
- if (SetPageState(currentpage, STATE_PAGE_VALID) != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
+ case FIND_READ_PAGE: /* ---- Read operation ---- */
+ if (currentpagestatus == STATE_PAGE_ACTIVE) {
+ return currentpage;
+ } else {
+ if (currentpagestatus == STATE_PAGE_RECEIVE) {
+ return previouspage;
+ } else {
+ return EE_NO_PAGE_FOUND; /* No active Page */
+ }
}
- /* Set following page as receive */
- if (SetPageState(followingpage, STATE_PAGE_RECEIVE) != EE_OK)
- {
- return EE_NO_PAGE_FOUND;
+ case FIND_ERASE_PAGE: /* ---- Return the erased page */
+ if (followingpagestatus == STATE_PAGE_ERASED) {
+ return followingpage;
+ } else {
+ return EE_NO_PAGE_FOUND; /* No erased Page */
}
- uwAddressNextWrite = PAGE_HEADER_SIZE; /* Skip page header */
- return followingpage; /* Following page is now active one */
- }
- }
- else
- {
- return EE_NO_PAGE_FOUND; /* No active Page */
- }
- }
-
- case FIND_READ_PAGE: /* ---- Read operation ---- */
- if (currentpagestatus == STATE_PAGE_ACTIVE)
- {
- return currentpage;
- }
- else
- {
- if (currentpagestatus == STATE_PAGE_RECEIVE)
- {
- return previouspage;
- }
- else
- {
- return EE_NO_PAGE_FOUND; /* No active Page */
- }
- }
-
- case FIND_ERASE_PAGE: /* ---- Return the erased page */
- if (followingpagestatus == STATE_PAGE_ERASED)
- {
- return followingpage;
- }
- else
- {
- return EE_NO_PAGE_FOUND; /* No erased Page */
- }
-
- default:
- ;
- }
-
- return EE_NO_PAGE_FOUND;
+
+ default:;
+ }
+
+ return EE_NO_PAGE_FOUND;
}
/**
@@ -1420,249 +1023,161 @@ static uint32_t FindPage(EE_Find_type Operation)
* - EE_CLEANUP_REQUIRED: on success
* - EE error code: if an error occurs
*/
-#ifndef FLASH_LINES_128B
static EE_Status PagesTransfer(uint16_t VirtAddress, EE_DATA_TYPE Data, EE_Transfer_type Type)
-#else
-static EE_Status PagesTransfer(uint16_t VirtAddress, EE_DATA_TYPE* Data, EE_Transfer_type Type)
-#endif
{
- EE_State_type pagestatus = STATE_PAGE_INVALID;
- uint32_t pageaddress = 0U;
- uint32_t page = 0U;
- uint32_t varidx = 0U;
- EE_ELEMENT_TYPE addressvalue = 0U;
-#ifdef FLASH_LINES_128B
- EE_ELEMENT_TYPE addressvalue2 = 0U;
- uint16_t nb_dummy_lines=0U;
-#endif
- EE_Status status = EE_OK;
- EE_DATA_TYPE DataValue = 0U;
-
-
- /* Get receive Page for transfer operation */
- page = FindPage((Type == EE_TRANSFER_NORMAL?FIND_ERASE_PAGE:FIND_WRITE_PAGE));
- if (page == EE_NO_PAGE_FOUND)
- {
- return EE_ERROR_NOERASE_PAGE;
- }
-
- /* Reinitialize number of data written in the pages, and current active page */
- uhNbWrittenElements = 0U;
- ubCurrentActivePage = page;
- uwAddressNextWrite = PAGE_HEADER_SIZE;
-
- /* Mark the erased page at receive state in case of normal transfer */
- /* It is already the case in recover transfer case */
- /* If program operation was failed, a Flash error code is returned */
- if (Type == EE_TRANSFER_NORMAL)
- {
- if (SetPageState(page, STATE_PAGE_RECEIVE) != EE_OK)
- {
- return EE_WRITE_ERROR;
+ EE_State_type pagestatus = STATE_PAGE_INVALID;
+ uint32_t pageaddress = 0U;
+ uint32_t page = 0U;
+ uint32_t varidx = 0U;
+ EE_ELEMENT_TYPE addressvalue = 0U;
+ EE_Status status = EE_OK;
+ EE_DATA_TYPE DataValue = 0U;
+
+
+ /* Get receive Page for transfer operation */
+ page = FindPage((Type == EE_TRANSFER_NORMAL ? FIND_ERASE_PAGE : FIND_WRITE_PAGE));
+ if (page == EE_NO_PAGE_FOUND) {
+ return EE_ERROR_NOERASE_PAGE;
}
- }
-
- /* Set the previous active page and all previous valid pages to erasing state */
- /* In case of recover transfer, some of these pages may already be marked erasing */
- page = PREVIOUS_PAGE(page);
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
-
- if ((pagestatus == STATE_PAGE_ACTIVE) || (pagestatus == STATE_PAGE_ERASING))
- {
- /* Set active page to erasing */
- if (pagestatus == STATE_PAGE_ACTIVE)
- {
- if (SetPageState(page, STATE_PAGE_ERASING) != EE_OK)
- {
- return EE_WRITE_ERROR;
- }
+
+ /* Reinitialize number of data written in the pages, and current active page */
+ uhNbWrittenElements = 0U;
+ ubCurrentActivePage = page;
+ uwAddressNextWrite = PAGE_HEADER_SIZE;
+
+ /* Mark the erased page at receive state in case of normal transfer */
+ /* It is already the case in recover transfer case */
+ /* If program operation was failed, a Flash error code is returned */
+ if (Type == EE_TRANSFER_NORMAL) {
+ if (SetPageState(page, STATE_PAGE_RECEIVE) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
}
- /* Inspect the previous pages to set all valid pages to erasing state */
- /* In case of recover, some valid pages may be already erasing state */
+ /* Set the previous active page and all previous valid pages to erasing state */
+ /* In case of recover transfer, some of these pages may already be marked erasing */
page = PREVIOUS_PAGE(page);
pageaddress = PAGE_ADDRESS(page);
pagestatus = GetPageState(pageaddress);
- while ((pagestatus == STATE_PAGE_VALID) || (pagestatus == STATE_PAGE_ERASING))
- {
- /* Set valid page to erasing */
- if (pagestatus == STATE_PAGE_VALID)
- {
- if (SetPageState(page, STATE_PAGE_ERASING) != EE_OK)
- {
- return EE_WRITE_ERROR;
+ if ((pagestatus == STATE_PAGE_ACTIVE) || (pagestatus == STATE_PAGE_ERASING)) {
+ /* Set active page to erasing */
+ if (pagestatus == STATE_PAGE_ACTIVE) {
+ if (SetPageState(page, STATE_PAGE_ERASING) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
}
- }
- /* decrement page index */
- page = PREVIOUS_PAGE(page);
- pageaddress = PAGE_ADDRESS(page);
- pagestatus = GetPageState(pageaddress);
- }
- }
- else
- {
- if ((Type == EE_TRANSFER_RECOVER) && (pagestatus == STATE_PAGE_VALID))
- {
- /* This can happen in case of recover transfer. It indicates that previous */
- /* transfer goes far enough to fill a complete receive page at least */
- /* (valid state). Then erasing state marking was already completed */
- }
- else
- {
- /* Inconsistent previous page state */
- return EE_INVALID_PAGE_SEQUENCE;
- }
- }
-
- /* In case of recover transfer, transfer must be resumed where it has been stopped */
- /* Update global variables to reflect current transfer status */
- if (Type == EE_TRANSFER_RECOVER)
- {
-#ifdef FLASH_LINES_128B
- nb_dummy_lines=0;
-#endif
- /* Count number of elements already transferred in current receive page */
- for (varidx = PAGE_HEADER_SIZE; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE)
- {
- /* Get next element in receive page */
- addressvalue = (*(__IO EE_ELEMENT_TYPE*)(PAGE_ADDRESS(ubCurrentActivePage) + varidx));
-
-#ifdef FLASH_LINES_128B
- addressvalue2 = (*(__IO EE_ELEMENT_TYPE*)(PAGE_ADDRESS(ubCurrentActivePage) + varidx + 8));
-
- /* Check if element is valid */
- if((addressvalue == 0x0000000000000000U)&& (addressvalue2 == 0x0000000000000000U))
- {
- nb_dummy_lines++;
- uhNbWrittenElements++;
- uwAddressNextWrite += EE_ELEMENT_SIZE;
- }
- else if ((addressvalue != EE_PAGESTAT_ERASED) && (addressvalue2 != EE_PAGESTAT_ERASED)&&(addressvalue != 0x0000000000000000U)&& (addressvalue2 != 0x0000000000000000U))
-#else
- if (addressvalue != EE_PAGESTAT_ERASED)
-#endif
- {
- /* Update global variables accordingly */
- uhNbWrittenElements++;
- uwAddressNextWrite += EE_ELEMENT_SIZE;
- }
- else
- {
- break;
- }
- }
+ /* Inspect the previous pages to set all valid pages to erasing state */
+ /* In case of recover, some valid pages may be already erasing state */
+ page = PREVIOUS_PAGE(page);
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
- /* Count number of elements already transferred in previous valid pages */
- page = ubCurrentActivePage;
- for (varidx = 0U; varidx < PAGES_NUMBER; varidx++)
- {
- /* Decrement page index among circular pages list */
- page = PREVIOUS_PAGE(page);
- pagestatus = GetPageState(PAGE_ADDRESS(page));
-
- /* Check if page is valid state */
- if (pagestatus == STATE_PAGE_VALID)
- {
- /* Update uhNbWrittenElements with number of elements in page */
- uhNbWrittenElements += NB_MAX_ELEMENTS_BY_PAGE;
-#ifdef FLASH_LINES_128B
- nb_dummy_lines=nb_dummy_lines+2;
-#endif
- }
- else
- {
- break;
- }
+ while ((pagestatus == STATE_PAGE_VALID) || (pagestatus == STATE_PAGE_ERASING)) {
+ /* Set valid page to erasing */
+ if (pagestatus == STATE_PAGE_VALID) {
+ if (SetPageState(page, STATE_PAGE_ERASING) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
+ }
+
+ /* decrement page index */
+ page = PREVIOUS_PAGE(page);
+ pageaddress = PAGE_ADDRESS(page);
+ pagestatus = GetPageState(pageaddress);
+ }
+ } else {
+ if ((Type == EE_TRANSFER_RECOVER) && (pagestatus == STATE_PAGE_VALID)) {
+ /* This can happen in case of recover transfer. It indicates that previous */
+ /* transfer goes far enough to fill a complete receive page at least */
+ /* (valid state). Then erasing state marking was already completed */
+ } else {
+ /* Inconsistent previous page state */
+ return EE_INVALID_PAGE_SEQUENCE;
+ }
}
- }
-#if defined (DUALCORE_FLASH_SHARING) || defined (FLASH_LINES_128B)
- if (VerifyPagesFullWriteVariable(VirtAddress, Data, EE_TRANSFER) != EE_OK)
- {
- return EE_WRITE_ERROR;
+ /* In case of recover transfer, transfer must be resumed where it has been stopped */
+ /* Update global variables to reflect current transfer status */
+ if (Type == EE_TRANSFER_RECOVER) {
+ /* Count number of elements already transferred in current receive page */
+ for (varidx = PAGE_HEADER_SIZE; varidx < PAGE_SIZE; varidx += EE_ELEMENT_SIZE) {
+ /* Get next element in receive page */
+ addressvalue = (*(__IO EE_ELEMENT_TYPE *) (PAGE_ADDRESS(ubCurrentActivePage) + varidx));
+
+ if (addressvalue != EE_PAGESTAT_ERASED) {
+ /* Update global variables accordingly */
+ uhNbWrittenElements++;
+ uwAddressNextWrite += EE_ELEMENT_SIZE;
+ } else {
+ break;
+ }
+ }
+
+ /* Count number of elements already transferred in previous valid pages */
+ page = ubCurrentActivePage;
+ for (varidx = 0U; varidx < PAGES_NUMBER; varidx++) {
+ /* Decrement page index among circular pages list */
+ page = PREVIOUS_PAGE(page);
+ pagestatus = GetPageState(PAGE_ADDRESS(page));
+
+ /* Check if page is valid state */
+ if (pagestatus == STATE_PAGE_VALID) {
+ /* Update uhNbWrittenElements with number of elements in page */
+ uhNbWrittenElements += NB_MAX_ELEMENTS_BY_PAGE;
+ } else {
+ break;
+ }
+ }
}
- #ifdef FLASH_LINES_128B
- else
- {
- if ((Data[0]==0)&&(Data[1]==0))
- {
- nb_dummy_lines++; //One 128bit line of zeros has been written
- }
+
+ // Write the variable passed as parameter in the new active page
+ // If program operation was failed, a Flash error code is returned
+ if (VerifyPagesFullWriteVariable(VirtAddress, Data) != EE_OK) {
+ return EE_WRITE_ERROR;
}
- #endif
-#else
-
- // Write the variable passed as parameter in the new active page
- // If program operation was failed, a Flash error code is returned
- if (VerifyPagesFullWriteVariable(VirtAddress, Data) != EE_OK)
- {
- return EE_WRITE_ERROR;
- }
-
-#endif
-
-
- /* Transfer process: transfer variables from old to the new active page */
- /* First element in receive page can be any one, the following elements are */
- /* ordered from the beginning. */
- /* In case of recovery, Pre-Last element in receive page could be */
- /* corrupted if reset occured during write of this element, */
- /* and last element is dummy value that we have just written. */
- /* Transfer shall then resume from (uhNbWrittenElements-3) variable index */
-
-
-#ifdef FLASH_LINES_128B
- varidx = (uhNbWrittenElements >= 3U?(uhNbWrittenElements-3U+1U):1U);
- for (varidx = (varidx >= nb_dummy_lines?(varidx-nb_dummy_lines):1U); varidx < NB_OF_VARIABLES+1; varidx++)
-#else
- for (varidx = (uhNbWrittenElements >= 3U?(uhNbWrittenElements-3U+1U):1U); varidx < NB_OF_VARIABLES+1; varidx++)
-#endif
- {
- /* Check each variable except the one passed as parameter */
- if (varidx != VirtAddress)
- {
- /* Read the last variable updates */
- status = ReadVariable(varidx, &DataValue);
- if (status == EE_OK)
- {
- /* In case variable corresponding to the virtual address was found */
- /* Transfer the variable to the new active page */
- /* If program operation was failed, a Flash error code is returned */
- #if defined (DUALCORE_FLASH_SHARING)
- status = VerifyPagesFullWriteVariable(varidx, DataValue, EE_TRANSFER);
- #elif defined (FLASH_LINES_128B)
- status = VerifyPagesFullWriteVariable(varidx, &DataValue, EE_TRANSFER);
- #else
- status = VerifyPagesFullWriteVariable(varidx, DataValue);
- #endif
- if (status != EE_OK)
- {
- return status;
- }
- }
- else
- {
- if (status != EE_NO_DATA)
- {
- /* In case variable is not found , do nothing */
- /* Any other status is error code occurs during variable read */
- return status;
+
+
+ /* Transfer process: transfer variables from old to the new active page */
+ /* First element in receive page can be any one, the following elements are */
+ /* ordered from the beginning. */
+ /* In case of recovery, Pre-Last element in receive page could be */
+ /* corrupted if reset occured during write of this element, */
+ /* and last element is dummy value that we have just written. */
+ /* Transfer shall then resume from (uhNbWrittenElements-3) variable index */
+
+
+ for (varidx = (uhNbWrittenElements >= 3U ? (uhNbWrittenElements - 3U + 1U) : 1U); varidx < NB_OF_VARIABLES + 1; varidx++) {
+ /* Check each variable except the one passed as parameter */
+ if (varidx != VirtAddress) {
+ /* Read the last variable updates */
+ status = ReadVariable(varidx, &DataValue);
+ if (status == EE_OK) {
+ /* In case variable corresponding to the virtual address was found */
+ /* Transfer the variable to the new active page */
+ /* If program operation was failed, a Flash error code is returned */
+ status = VerifyPagesFullWriteVariable(varidx, DataValue);
+ if (status != EE_OK) {
+ return status;
+ }
+ } else {
+ if (status != EE_NO_DATA) {
+ /* In case variable is not found , do nothing */
+ /* Any other status is error code occurs during variable read */
+ return status;
+ }
+ }
}
- }
}
- }
- /* Transfer is now done, mark the receive state page as active */
- if (SetPageState(ubCurrentActivePage, STATE_PAGE_ACTIVE) != EE_OK)
- {
- return EE_WRITE_ERROR;
- }
+ /* Transfer is now done, mark the receive state page as active */
+ if (SetPageState(ubCurrentActivePage, STATE_PAGE_ACTIVE) != EE_OK) {
+ return EE_WRITE_ERROR;
+ }
- /* Return last operation flash status */
- return EE_CLEANUP_REQUIRED;
+ /* Return last operation flash status */
+ return EE_CLEANUP_REQUIRED;
}
/**
@@ -1677,90 +1192,46 @@ static EE_Status PagesTransfer(uint16_t VirtAddress, EE_DATA_TYPE* Data, EE_Tran
* - EE_FLASH_USED: flash currently used by CPU2
* - EE error code: if an error occurs
*/
-#if defined (DUALCORE_FLASH_SHARING)
-static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data, EE_Write_type Write_type)
-#elif defined (FLASH_LINES_128B)
-static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE* Data, EE_Write_type Write_type)
-#else
+
static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE Data)
-#endif
{
-#ifndef FLASH_LINES_128B
- uint32_t crc = 0U;
-#else
- uint64_t pData64[2] = {0,0};
- uint64_t crc = 0U;
-#endif
-
- /* Check if pages are full, i.e. max number of written elements achieved */
- if (uhNbWrittenElements >= NB_MAX_WRITTEN_ELEMENTS)
- {
- return EE_PAGE_FULL;
- }
-
- /* Get active Page for write operation */
- uint32_t activepage = FindPage(FIND_WRITE_PAGE);
- uint32_t activepageaddress = 0U;
-
- /* Check if there is no active page */
- if (activepage == EE_NO_PAGE_FOUND)
- {
- return EE_ERROR_NOACTIVE_PAGE;
- }
-
- activepageaddress = PAGE_ADDRESS(activepage);
-
- /* Force crc to 0 in case of Data/VirtAddress are 0*/
-#ifndef FLASH_LINES_128B
- if ((Data == 0U) && (VirtAddress == 0U))
-#else
- if ((Data[0] == 0U) && (Data[1] == 0U) && (VirtAddress == 0U))
-
-#endif
- {
- crc = 0U;
- }
- else
- {
-#ifndef FLASH_LINES_128B
- /* Calculate crc of variable data and virtual address */
- crc = CalculateCrc(Data, VirtAddress);
-#else
- pData64[0] = (uint64_t)((Data[1] << EE_DATA_SHIFT) | VirtAddress);
- /* Calculate crc of variable data and virtual address */
- crc = CalculateCrc(Data[0], pData64[0]);
-#endif
- }
-
-
-#if defined (DUALCORE_FLASH_SHARING)
- /* Program variable data + virtual address + crc */
- /* If program operation was failed, a Flash error code or the information
- about the semaphore monitoring flash being taken is returned */
- EE_Status ee_status = FI_WriteDoubleWord(activepageaddress+uwAddressNextWrite, EE_ELEMENT_VALUE(VirtAddress,Data,crc), Write_type);
- if (ee_status != EE_OK) return ee_status;
-#elif defined (FLASH_LINES_128B)
- pData64[0] = 0;
- pData64[1] = 0;
- pData64[0] = (uint64_t)((Data[1]<< EE_DATA_SHIFT) | (crc << EE_CRC_SHIFT) | VirtAddress);
- pData64[1] = (uint64_t)Data[0];
-
- EE_Status ee_status = FI_WriteDoubleWord(activepageaddress+uwAddressNextWrite, pData64, Write_type);
- if (ee_status != EE_OK) return ee_status;
-#else
- /* Program variable data + virtual address + crc */
- /* If program operation was failed, a Flash error code is returned */
- if (FI_WriteDoubleWord(activepageaddress+uwAddressNextWrite, EE_ELEMENT_VALUE(VirtAddress,Data,crc)) != HAL_OK)
- {
- return EE_WRITE_ERROR;
- }
-#endif
-
- /* Increment global variables relative to write operation done*/
- uwAddressNextWrite += EE_ELEMENT_SIZE;
- uhNbWrittenElements++;
-
- return EE_OK;
+ uint32_t crc = 0U;
+
+ /* Check if pages are full, i.e. max number of written elements achieved */
+ if (uhNbWrittenElements >= NB_MAX_WRITTEN_ELEMENTS) {
+ return EE_PAGE_FULL;
+ }
+
+ /* Get active Page for write operation */
+ uint32_t activepage = FindPage(FIND_WRITE_PAGE);
+ uint32_t activepageaddress = 0U;
+
+ /* Check if there is no active page */
+ if (activepage == EE_NO_PAGE_FOUND) {
+ return EE_ERROR_NOACTIVE_PAGE;
+ }
+
+ activepageaddress = PAGE_ADDRESS(activepage);
+
+ /* Force crc to 0 in case of Data/VirtAddress are 0*/
+ if ((Data == 0U) && (VirtAddress == 0U)) {
+ crc = 0U;
+ } else {
+ /* Calculate crc of variable data and virtual address */
+ crc = CalculateCrc(Data, VirtAddress);
+ }
+
+ /* Program variable data + virtual address + crc */
+ /* If program operation was failed, a Flash error code is returned */
+ if (FI_WriteDoubleWord(activepageaddress + uwAddressNextWrite, EE_ELEMENT_VALUE(VirtAddress, Data, crc)) != 0) {
+ return EE_WRITE_ERROR;
+ }
+
+ /* Increment global variables relative to write operation done*/
+ uwAddressNextWrite += EE_ELEMENT_SIZE;
+ uhNbWrittenElements++;
+
+ return EE_OK;
}
/**
@@ -1773,140 +1244,50 @@ static EE_Status VerifyPagesFullWriteVariable(uint16_t VirtAddress, EE_DATA_TYPE
*/
static EE_Status SetPageState(uint32_t Page, EE_State_type State)
{
- uint32_t header1 = 0U, header2 = 0U, header3 = 0U, header4 = 0U;
-
- header1 = PAGE_ADDRESS(Page);
- header2 = PAGE_ADDRESS(Page) + EE_ELEMENT_SIZE;
- header3 = PAGE_ADDRESS(Page) + (EE_ELEMENT_SIZE*2U);
- header4 = PAGE_ADDRESS(Page) + (EE_ELEMENT_SIZE*3U);
-
-#if defined (DUALCORE_FLASH_SHARING)
- EE_Status ee_status;
- switch(State)
- {
- case STATE_PAGE_RECEIVE:
- {
- /* Set new Page status to STATE_PAGE_RECEIVE status */
- ee_status = FI_WriteDoubleWord(header1, EE_PAGESTAT_RECEIVE, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_ACTIVE:
- {
- /* Set new Page status to STATE_PAGE_ACTIVE status */
- ee_status = FI_WriteDoubleWord(header2, EE_PAGESTAT_ACTIVE, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_VALID:
- {
- /* Set new Page status to STATE_PAGE_VALID status */
- ee_status = FI_WriteDoubleWord(header3, EE_PAGESTAT_VALID, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- }
- break;
- case STATE_PAGE_ERASING:
- {
- /* Set new Page status to STATE_PAGE_ERASING status */
- ee_status = FI_WriteDoubleWord(header4, EE_PAGESTAT_ERASING, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- }
- break;
- default:
- break;
- }
-#elif defined (FLASH_LINES_128B)
- EE_Status ee_status;
- uint64_t pagestat = 0;
- switch(State)
- {
- case STATE_PAGE_RECEIVE:
- {
- /* Set new Page status to STATE_PAGE_RECEIVE status */
- pagestat = EE_PAGESTAT_RECEIVE;
- ee_status = FI_WriteDoubleWord(header1, &pagestat, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_ACTIVE:
- {
- /* Set new Page status to STATE_PAGE_ACTIVE status */
- pagestat = EE_PAGESTAT_ACTIVE;
- ee_status = FI_WriteDoubleWord(header2, &pagestat, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_VALID:
- {
- /* Set new Page status to STATE_PAGE_VALID status */
- pagestat = EE_PAGESTAT_VALID;
- ee_status = FI_WriteDoubleWord(header3, &pagestat, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- }
- break;
- case STATE_PAGE_ERASING:
- {
- /* Set new Page status to STATE_PAGE_ERASING status */
- pagestat = EE_PAGESTAT_ERASING;
- ee_status = FI_WriteDoubleWord(header4, &pagestat, EE_SET_PAGE);
- if (ee_status != EE_OK) return ee_status;
- }
- break;
- default:
- break;
- }
-#else
- switch(State)
- {
- case STATE_PAGE_RECEIVE:
- {
- /* Set new Page status to STATE_PAGE_RECEIVE status */
- if (FI_WriteDoubleWord(header1, EE_PAGESTAT_RECEIVE) != HAL_OK)
- {
- return EE_WRITE_ERROR;
- }
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_ACTIVE:
- {
- /* Set new Page status to STATE_PAGE_ACTIVE status */
- if (FI_WriteDoubleWord(header2, EE_PAGESTAT_ACTIVE) != HAL_OK)
- {
- return EE_WRITE_ERROR;
- }
- ubCurrentActivePage = Page;
- }
- break;
- case STATE_PAGE_VALID:
- {
- /* Set new Page status to STATE_PAGE_VALID status */
- if (FI_WriteDoubleWord(header3, EE_PAGESTAT_VALID) != HAL_OK)
- {
- return EE_WRITE_ERROR;
- }
- }
- break;
- case STATE_PAGE_ERASING:
- {
- /* Set new Page status to STATE_PAGE_ERASING status */
- if (FI_WriteDoubleWord(header4, EE_PAGESTAT_ERASING) != HAL_OK)
- {
- return EE_WRITE_ERROR;
- }
+ uint32_t header1 = 0U, header2 = 0U, header3 = 0U, header4 = 0U;
+
+ header1 = PAGE_ADDRESS(Page);
+ header2 = PAGE_ADDRESS(Page) + EE_ELEMENT_SIZE;
+ header3 = PAGE_ADDRESS(Page) + (EE_ELEMENT_SIZE * 2U);
+ header4 = PAGE_ADDRESS(Page) + (EE_ELEMENT_SIZE * 3U);
+
+ switch (State) {
+ case STATE_PAGE_RECEIVE: {
+ /* Set new Page status to STATE_PAGE_RECEIVE status */
+ if (FI_WriteDoubleWord(header1, EE_PAGESTAT_RECEIVE) != SUCCESS) {
+ return EE_WRITE_ERROR;
+ }
+ ubCurrentActivePage = Page;
+ }
+ break;
+ case STATE_PAGE_ACTIVE: {
+ /* Set new Page status to STATE_PAGE_ACTIVE status */
+ if (FI_WriteDoubleWord(header2, EE_PAGESTAT_ACTIVE) != SUCCESS) {
+ return EE_WRITE_ERROR;
+ }
+ ubCurrentActivePage = Page;
+ }
+ break;
+ case STATE_PAGE_VALID: {
+ /* Set new Page status to STATE_PAGE_VALID status */
+ if (FI_WriteDoubleWord(header3, EE_PAGESTAT_VALID) != SUCCESS) {
+ return EE_WRITE_ERROR;
+ }
+ }
+ break;
+ case STATE_PAGE_ERASING: {
+ /* Set new Page status to STATE_PAGE_ERASING status */
+ if (FI_WriteDoubleWord(header4, EE_PAGESTAT_ERASING) != SUCCESS) {
+ return EE_WRITE_ERROR;
+ }
+ }
+ break;
+ default:
+ break;
}
- break;
- default:
- break;
- }
-#endif
-
- /* Return last operation flash status */
- return EE_OK;
+
+ /* Return last operation flash status */
+ return EE_OK;
}
/**
@@ -1914,88 +1295,40 @@ static EE_Status SetPageState(uint32_t Page, EE_State_type State)
* @param Address Address of the FLASH Memory page
* @retval State State of the page
*/
-#ifndef FLASH_LINES_128B
static EE_State_type GetPageState(uint32_t Address)
{
- EE_ELEMENT_TYPE status1 = 0U, status2 = 0U, status3 = 0U, status4 = 0U;
-
- /* Get page state information from page header (3 first elements) */
- status1 = (*(__IO EE_ELEMENT_TYPE*)Address);
- status2 = (*(__IO EE_ELEMENT_TYPE*)(Address + EE_ELEMENT_SIZE));
- status3 = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*2U)));
- status4 = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*3U)));
-
- /* Return erasing status, if element4 is not EE_PAGESTAT_ERASED value */
- if (status4 != EE_PAGESTAT_ERASED)
- {
- return STATE_PAGE_ERASING;
- }
-
- /* Return valid status, if element3 is not EE_PAGESTAT_ERASED value */
- if (status3 != EE_PAGESTAT_ERASED)
- {
- return STATE_PAGE_VALID;
- }
-
- /* Return active status, if element2 is not EE_PAGESTAT_ERASED value */
- if (status2 != EE_PAGESTAT_ERASED)
- {
- return STATE_PAGE_ACTIVE;
- }
-
- /* Return receive status, if element1 is not EE_PAGESTAT_ERASED value */
- if (status1 != EE_PAGESTAT_ERASED)
- {
- return STATE_PAGE_RECEIVE;
- }
-
- /* Return erased status, if 4 first elements are EE_PAGESTAT_ERASED value */
- return STATE_PAGE_ERASED;
+ EE_ELEMENT_TYPE status1 = 0U, status2 = 0U, status3 = 0U, status4 = 0U;
+
+ /* Get page state information from page header (3 first elements) */
+ status1 = (*(__IO EE_ELEMENT_TYPE *) Address);
+ status2 = (*(__IO EE_ELEMENT_TYPE *) (Address + EE_ELEMENT_SIZE));
+ status3 = (*(__IO EE_ELEMENT_TYPE *) (Address + (EE_ELEMENT_SIZE * 2U)));
+ status4 = (*(__IO EE_ELEMENT_TYPE *) (Address + (EE_ELEMENT_SIZE * 3U)));
+
+ /* Return erasing status, if element4 is not EE_PAGESTAT_ERASED value */
+ if (status4 != EE_PAGESTAT_ERASED) {
+ return STATE_PAGE_ERASING;
+ }
+
+ /* Return valid status, if element3 is not EE_PAGESTAT_ERASED value */
+ if (status3 != EE_PAGESTAT_ERASED) {
+ return STATE_PAGE_VALID;
+ }
+
+ /* Return active status, if element2 is not EE_PAGESTAT_ERASED value */
+ if (status2 != EE_PAGESTAT_ERASED) {
+ return STATE_PAGE_ACTIVE;
+ }
+
+ /* Return receive status, if element1 is not EE_PAGESTAT_ERASED value */
+ if (status1 != EE_PAGESTAT_ERASED) {
+ return STATE_PAGE_RECEIVE;
+ }
+
+ /* Return erased status, if 4 first elements are EE_PAGESTAT_ERASED value */
+ return STATE_PAGE_ERASED;
}
-#else
-static EE_State_type GetPageState(uint32_t Address)
-{
- EE_ELEMENT_TYPE status1 = 0U, status2 = 0U, status3 = 0U, status4 = 0U;
- EE_ELEMENT_TYPE status1bis = 0U, status2bis = 0U, status3bis = 0U, status4bis = 0U;
-
- /* Get page state information from page header (3 first elements) */
- status1 = (*(__IO EE_ELEMENT_TYPE*)Address);
- status2 = (*(__IO EE_ELEMENT_TYPE*)(Address + EE_ELEMENT_SIZE));
- status3 = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*2U)));
- status4 = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*3U)));
- status1bis = (*(__IO EE_ELEMENT_TYPE*)(Address + 8));
- status2bis = (*(__IO EE_ELEMENT_TYPE*)(Address + EE_ELEMENT_SIZE + 8));
- status3bis = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*2U) + 8));
- status4bis = (*(__IO EE_ELEMENT_TYPE*)(Address + (EE_ELEMENT_SIZE*3U) + 8));
-
- /* Return erasing status, if element4 is not EE_PAGESTAT_ERASED value */
- if ((status4 != EE_PAGESTAT_ERASED) && (status4bis != EE_PAGESTAT_ERASED))
- {
- return STATE_PAGE_ERASING;
- }
-
- /* Return valid status, if element3 is not EE_PAGESTAT_ERASED value */
- if ((status3 != EE_PAGESTAT_ERASED) && (status3bis != EE_PAGESTAT_ERASED))
- {
- return STATE_PAGE_VALID;
- }
-
- /* Return active status, if element2 is not EE_PAGESTAT_ERASED value */
- if ((status2 != EE_PAGESTAT_ERASED) && (status2bis != EE_PAGESTAT_ERASED))
- {
- return STATE_PAGE_ACTIVE;
- }
-
- /* Return receive status, if element1 is not EE_PAGESTAT_ERASED value */
- if ((status1 != EE_PAGESTAT_ERASED) && (status1bis != EE_PAGESTAT_ERASED))
- {
- return STATE_PAGE_RECEIVE;
- }
-
- /* Return erased status, if 4 first elements are EE_PAGESTAT_ERASED value */
- return STATE_PAGE_ERASED;
-}
-#endif
+
/**
* @brief This function configures CRC Instance.
@@ -2010,26 +1343,8 @@ static EE_State_type GetPageState(uint32_t Address)
*/
void ConfigureCrc(void)
{
- /* (1) Enable peripheral clock for CRC */
- LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_CRC);
-
- /* (2) Configure CRC functional parameters */
-
- /* Configure CRC calculation unit with user defined polynomial */
- LL_CRC_SetPolynomialCoef(CRC, CRC_POLYNOMIAL_VALUE);
- LL_CRC_SetPolynomialSize(CRC, CRC_POLYNOMIAL_LENGTH);
-
- /* Initialize default CRC initial value */
- /* Reset value is LL_CRC_DEFAULT_CRC_INITVALUE */
- /* LL_CRC_SetInitialData(CRC, LL_CRC_DEFAULT_CRC_INITVALUE);*/
-
- /* Set input data inversion mode : No inversion*/
- /* Reset value is LL_CRC_INDATA_REVERSE_NONE */
- /* LL_CRC_SetInputDataReverseMode(CRC, LL_CRC_INDATA_REVERSE_NONE); */
-
- /* Set output data inversion mode : No inversion */
- /* Reset value is LL_CRC_OUTDATA_REVERSE_NONE */
- /* LL_CRC_SetOutputDataReverseMode(CRC, LL_CRC_OUTDATA_REVERSE_NONE); */
+ /* (1) Enable peripheral clock for CRC */
+ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_CRC);
}
/**
@@ -2038,29 +1353,18 @@ void ConfigureCrc(void)
* @param VirtAddress address of the eeprom variable.
* @retval 16-bit CRC value computed on Data and Virtual Address.
*/
-#ifndef FLASH_LINES_128B
uint16_t CalculateCrc(EE_DATA_TYPE Data, uint16_t VirtAddress)
-#else
-uint16_t CalculateCrc(EE_DATA_TYPE Data1, EE_DATA_TYPE Data2)
-#endif
{
- /* Reset CRC calculation unit */
- LL_CRC_ResetCRCCalculationUnit(CRC);
-
- /* Feed Data and Virtual Address */
-#ifndef FLASH_LINES_128B
- LL_CRC_FeedData32(CRC, Data);
- LL_CRC_FeedData16(CRC, VirtAddress);
-#else
- LL_CRC_FeedData32(CRC, ((uint32_t)Data1));
- LL_CRC_FeedData32(CRC, ((uint32_t)(Data1>>32)));
- LL_CRC_FeedData32(CRC, ((uint32_t)((Data2 & 0xFFFFFFFF00000000)>>32)));
- LL_CRC_FeedData16(CRC, ((uint16_t)Data2));
-
-#endif
-
- /* Return computed CRC value */
- return(LL_CRC_ReadData16(CRC));
+ /* Reset CRC calculation unit */
+ LL_CRC_ResetCRCCalculationUnit(CRC);
+
+ /* Feed Data and Virtual Address */
+ LL_CRC_FeedData32(CRC, Data);
+ LL_CRC_FeedData32(CRC, VirtAddress);
+
+ /* Return computed CRC value */
+ uint32_t crc32 = LL_CRC_ReadData32(CRC);
+ return (crc32 & 0xFFFF) ^ ((crc32 & 0xFFFF0000) >> 16); // get 16 bit from 32bit
}
/**
diff --git a/Lib/EEPROM_Emul/Core/eeprom_emul.h b/Lib/EEPROM_Emul/Core/eeprom_emul.h
index d94e6b2..d4c9d1c 100644
--- a/Lib/EEPROM_Emul/Core/eeprom_emul.h
+++ b/Lib/EEPROM_Emul/Core/eeprom_emul.h
@@ -23,29 +23,23 @@
#define __EEPROM_EMUL_H
/* Includes ------------------------------------------------------------------*/
+#include
+#include
+
+#define __IO volatile
+#define __weak __attribute__((weak))
+
#include "eeprom_emul_conf.h"
#include "eeprom_emul_types.h"
#include "flash_interface.h"
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private constants ---------------------------------------------------------*/
-/** @defgroup EEPROM_Private_Constants EEPROM Private Constants
- * @{
- */
-
-/** @defgroup Private_Other_Constants Private Other Constants
- * @{
- */
/* Page definitions */
#define PAGE_SIZE FLASH_PAGE_SIZE /*!< Page size */
-#define PAGE_HEADER_SIZE EE_ELEMENT_SIZE * 4U /*!< Page Header is 4 elements to save page state */
+#define PAGE_HEADER_SIZE (EE_ELEMENT_SIZE * 4U) /*!< Page Header is 4 elements to save page state */
#define NB_MAX_ELEMENTS_BY_PAGE ((PAGE_SIZE - PAGE_HEADER_SIZE) / EE_ELEMENT_SIZE) /*!< Max number of elements by page */
#define PAGES_NUMBER (((((NB_OF_VARIABLES + NB_MAX_ELEMENTS_BY_PAGE) / NB_MAX_ELEMENTS_BY_PAGE) * 2U) * CYCLES_NUMBER) + GUARD_PAGES_NUMBER)
- /*!< Number of consecutives pages used by the application */
+/*!< Number of consecutives pages used by the application */
#define NB_MAX_WRITTEN_ELEMENTS ((NB_MAX_ELEMENTS_BY_PAGE * PAGES_NUMBER) / 2U) /*!< Max number of elements written before triggering pages transfer */
#define START_PAGE PAGE(START_PAGE_ADDRESS) /*!< Page index of the 1st page used for EEPROM emul, in the bank */
#define END_EEPROM_ADDRESS (START_PAGE_ADDRESS + (PAGES_NUMBER * FLASH_PAGE_SIZE) - 1) /*!< Last address of EEPROM emulation flash pages */
@@ -53,89 +47,44 @@
/* No page define */
#define EE_NO_PAGE_FOUND ((uint32_t)0xFFFFFFFFU)
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @defgroup EEPROM_Private_Macros EEPROM Private Macros
- * @{
- */
-
-/** @defgroup Macros_Pages Macros to manipulate pages
- * @{
- */
-
/* Macros to manipulate pages */
-#ifdef SECURE_FEATURES
- #define PAGE_ADDRESS(__PAGE__) (uint32_t)(FLASH_BASE_NS + (__PAGE__) * PAGE_SIZE + ((START_PAGE_ADDRESS - FLASH_BASE_NS) / BANK_SIZE) * BANK_SIZE) /*!< Get page address from page index */
- #define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE_NS) % BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */
-#else
- #define PAGE_ADDRESS(__PAGE__) (uint32_t)(FLASH_BASE + (__PAGE__) * PAGE_SIZE + ((START_PAGE_ADDRESS - FLASH_BASE) / BANK_SIZE) * BANK_SIZE) /*!< Get page address from page index */
- #define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE) % BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */
-#endif
+#define PAGE_ADDRESS(__PAGE__) (uint32_t)(FLASH_BASE + (__PAGE__) * PAGE_SIZE + ((START_PAGE_ADDRESS - FLASH_BASE) / BANK_SIZE) * BANK_SIZE) /*!< Get page address from page index */
+#define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE) % BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */
#define PREVIOUS_PAGE(__PAGE__) (uint32_t)((((__PAGE__) - START_PAGE - 1U + PAGES_NUMBER) % PAGES_NUMBER) + START_PAGE) /*!< Get page index of previous page, among circular page list */
#define FOLLOWING_PAGE(__PAGE__) (uint32_t)((((__PAGE__) - START_PAGE + 1U) % PAGES_NUMBER) + START_PAGE) /*!< Get page index of following page, among circular page list */
-/**
- * @}
- */
-
-/** @defgroup Macros_Elements Macros to manipulate elements
- * @{
- */
-
/* Macros to manipulate elements */
#define EE_VIRTUALADDRESS_VALUE(__ELEMENT__) (EE_VIRTUALADDRESS_TYPE)((__ELEMENT__) & EE_MASK_VIRTUALADDRESS) /*!< Get virtual address value from element value */
#define EE_DATA_VALUE(__ELEMENT__) (EE_DATA_TYPE)(((__ELEMENT__) & EE_MASK_DATA) >> EE_DATA_SHIFT) /*!< Get Data value from element value */
#define EE_CRC_VALUE(__ELEMENT__) (EE_CRC_TYPE)(((__ELEMENT__) & EE_MASK_CRC) >> EE_CRC_SHIFT) /*!< Get Crc value from element value */
-#define EE_ELEMENT_VALUE(__VIRTADDR__,__DATA__,__CRC__) (((EE_ELEMENT_TYPE)(__DATA__) << EE_DATA_SHIFT) | (__CRC__) << EE_CRC_SHIFT | (__VIRTADDR__)) /*!< Get element value from virtual addr, data and crc values */
-
-/**
- * @}
- */
+#define EE_ELEMENT_VALUE(__VIRTADDR__, __DATA__, __CRC__) (((EE_ELEMENT_TYPE)(__DATA__) << EE_DATA_SHIFT) | (__CRC__) << EE_CRC_SHIFT | (__VIRTADDR__)) /*!< Get element value from virtual addr, data and crc values */
-/**
- * @}
- */
-
-/* Exported constants --------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-/** @defgroup EEPROM_Exported_Functions EEPROM Exported Functions
- * @{
- */
EE_Status EE_Format(EE_Erase_type EraseType);
+
EE_Status EE_Init(EE_Erase_type EraseType);
-#if defined(EE_ACCESS_32BITS)
-EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t* pData);
+
+EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t *pData);
+
EE_Status EE_WriteVariable32bits(uint16_t VirtAddress, uint32_t Data);
-#endif
-#if defined(FLASH_LINES_128B)
-EE_Status EE_ReadVariable96bits(uint16_t VirtAddress, uint64_t* pData);
-EE_Status EE_WriteVariable96bits(uint16_t VirtAddress, uint64_t* Data);
-#endif
-EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t* pData);
+
+EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t *pData);
+
EE_Status EE_WriteVariable16bits(uint16_t VirtAddress, uint16_t Data);
-EE_Status EE_ReadVariable8bits(uint16_t VirtAddress, uint8_t* pData);
+
+EE_Status EE_ReadVariable8bits(uint16_t VirtAddress, uint8_t *pData);
+
EE_Status EE_WriteVariable8bits(uint16_t VirtAddress, uint8_t Data);
+
EE_Status EE_CleanUp(void);
-EE_Status EE_CleanUp_IT(void);
-EE_Status EE_DeleteCorruptedFlashAddress(uint32_t Address);
-void EE_EndOfCleanup_UserCallback(void);
-/**
- * @}
- */
+EE_Status EE_DeleteCorruptedFlashAddress(uint32_t Address);
/**
- * @}
- */
+ * Callback from NMI.
+ *
+ * @return true if handled by this library
+ */
+bool EE_NMI_Callback();
#endif /* __EEPROM_EMUL_H */
diff --git a/Lib/EEPROM_Emul/Core/eeprom_emul_conf_template.h b/Lib/EEPROM_Emul/Core/eeprom_emul_conf.h
similarity index 61%
rename from Lib/EEPROM_Emul/Core/eeprom_emul_conf_template.h
rename to Lib/EEPROM_Emul/Core/eeprom_emul_conf.h
index 35c610a..36ef8c3 100644
--- a/Lib/EEPROM_Emul/Core/eeprom_emul_conf_template.h
+++ b/Lib/EEPROM_Emul/Core/eeprom_emul_conf.h
@@ -27,64 +27,17 @@
#ifndef __EEPROM_EMUL_CONF_H
#define __EEPROM_EMUL_CONF_H
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @defgroup Private_Configuration_Constants Private Configuration Constants
- * @{
- */
-
/* Configuration of eeprom emulation in flash, can be custom */
-#define START_PAGE_ADDRESS 0x08080000U /*!< Start address of the 1st page in flash, for EEPROM emulation */
+#define START_PAGE_ADDRESS 0x800E000U /*!< Start address of the 1st page in flash, for EEPROM emulation */
+
#define CYCLES_NUMBER 1U /*!< Number of 10Kcycles requested, minimum 1 for 10Kcycles (default),
for instance 10 to reach 100Kcycles. This factor will increase
pages number */
-#define GUARD_PAGES_NUMBER 2U /*!< Number of guard pages avoiding frequent transfers (must be multiple of 2): 0,2,4.. */
-
-/* Configuration of crc calculation for eeprom emulation in flash */
-#define CRC_POLYNOMIAL_LENGTH LL_CRC_POLYLENGTH_16B /* CRC polynomial lenght 16 bits */
-#define CRC_POLYNOMIAL_VALUE 0x8005U /* Polynomial to use for CRC calculation */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup EEPROM_Exported_Constants EEPROM Exported Constants
- * @{
- */
+#define GUARD_PAGES_NUMBER 2U /*!< Number of guard pages avoiding frequent transfers (must be multiple of 2): 0,2,4.. */
-/** @defgroup Exported_Configuration_Constants Exported Configuration Constants
- * @{
- */
#define NB_OF_VARIABLES 1000U /*!< Number of variables to handle in eeprom */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
#endif /* __EEPROM_EMUL_CONF_H */
diff --git a/Lib/EEPROM_Emul/Core/eeprom_emul_types.h b/Lib/EEPROM_Emul/Core/eeprom_emul_types.h
index f5fee32..374ec8e 100644
--- a/Lib/EEPROM_Emul/Core/eeprom_emul_types.h
+++ b/Lib/EEPROM_Emul/Core/eeprom_emul_types.h
@@ -17,7 +17,7 @@
*
******************************************************************************
*/
-
+
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __EEPROM_EMUL_TYPES_H
#define __EEPROM_EMUL_TYPES_H
@@ -67,7 +67,7 @@ typedef enum {
/* External return code : action required */
EE_CLEANUP_REQUIRED = 0x100U,
-
+
#ifdef DUALCORE_FLASH_SHARING
/* Value returned when a program or erase operation is requested but
* the flash is already used by CPU2 */
diff --git a/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.c
deleted file mode 100644
index 03ea298..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32C0/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-#ifdef FLASH_BANK_2
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t page_error = 0U;
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
-
-#ifdef FLASH_BANK_2
- uint32_t bank = GetBankNumber(PAGE_ADDRESS(Page));
- s_eraseinit.Banks = bank;
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* No flush needed. There is no D-Cache for the STM32G0x0 and STM32G0x1 products. */
- return;
-}
-
-#ifdef FLASH_BANK_2
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (OB_USER_DUALBANK_SWAP_DISABLE)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
-#if defined(FLASH_DBANK_SUPPORT)
- uint32_t bank = GetBankNumber(Address);
- if(bank == FLASH_BANK_1)
- {
- while(FLASH->SR & FLASH_SR_BSY1)
- {
- }
- }
- else
- {
- while(FLASH->SR & FLASH_SR_BSY2)
- {
- }
- }
-#else
- while(FLASH->SR & FLASH_SR_BSY1)
- {
- }
-#endif
-
- /* Check if error occured */
- if((FLASH->SR & FLASH_SR_OPERR) || (FLASH->SR & FLASH_SR_PROGERR) ||
- (FLASH->SR & FLASH_SR_WRPERR) || (FLASH->SR & FLASH_SR_PGAERR) ||
- (FLASH->SR & FLASH_SR_SIZERR) || (FLASH->SR & FLASH_SR_PGSERR))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (FLASH->SR & FLASH_SR_EOP)
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_DBANK_SUPPORT)
- EE_Status status;
-
- /* Check the value of the DBANK user option byte */
- if (OB_USER_DUALBANK_ENABLE)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.h
deleted file mode 100644
index 0a35740..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32C0/flash_interface.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32C0/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32c0xx_hal.h"
-#include "stm32c0xx_ll_crc.h"
-#include "stm32c0xx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.c
new file mode 100644
index 0000000..07d1739
--- /dev/null
+++ b/Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.c
@@ -0,0 +1,173 @@
+/**
+ ******************************************************************************
+ * @file EEPROM_Emul/Porting/STM32L4/flash_interface.c
+ * @author MCD Application Team
+ * @brief This file provides all the EEPROM emulation flash interface functions.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2020 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "eeprom_emul.h"
+#include "flash_interface.h"
+#include "snprintf.h"
+#include
+
+
+static inline void FI_Raw_ProgramHalfword(uint32_t Address, uint16_t value)
+{
+ *(__IO uint16_t *) (Address) = value;
+
+ /* Wait programmation completion */
+ while (FLASH->SR & FLASH_SR_BSY) {
+ }
+}
+
+static inline void FI_Raw_ProgramWord(uint32_t Address, uint32_t value)
+{
+ FI_Raw_ProgramHalfword(Address, value & 0xFFFF);
+ FI_Raw_ProgramHalfword(Address + 2, value >> 16);
+}
+
+static void FI_Raw_ProgramDoubleWord(uint32_t Address, uint64_t value)
+{
+ FI_Raw_ProgramWord(Address, value & 0xFFFFFFFFUL);
+ FI_Raw_ProgramWord(Address + 4, value >> 32);
+}
+
+
+/** @addtogroup EEPROM_Private_Functions
+ * @{
+ */
+
+static void UnlockFlash()
+{
+ FLASH->KEYR = 0x45670123;
+ FLASH->KEYR = 0xCDEF89AB;
+}
+
+static void LockFlash()
+{
+ FLASH->CR |= FLASH_CR_LOCK;
+}
+
+/**
+ * @brief Write a double word at the given address in Flash
+ * @param Address Where to write
+ * @param Data What to write
+ * @retval EE_Status
+ * - EE_OK: on success
+ * - EE_WRITE_ERROR: if an error occurs
+ */
+EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
+{
+ PRINTF("FI wr %p, val %016"PRIx64"\r\n", (void *) Address, Data);
+
+ EE_Status status = EE_OK;
+
+ if (FLASH->CR & FLASH_CR_LOCK) {
+ UnlockFlash();
+ }
+
+ /* Set FLASH Programmation bit */
+ FLASH->CR |= FLASH_CR_PG;
+
+ /* Program double word of value 0 */
+ FI_Raw_ProgramDoubleWord(Address, Data);
+
+ /* Check if error occured */
+ if (FLASH->SR & (FLASH_SR_WRPRTERR | FLASH_SR_PGERR)) {
+ PUTS("Flash write error\r\n");
+ status = EE_WRITE_ERROR;
+ }
+
+ /* Check FLASH End of Operation flag */
+ if (FLASH->SR & FLASH_SR_EOP) {
+ /* Clear FLASH End of Operation pending bit */
+ FLASH->SR = FLASH_SR_EOP;
+ }
+
+ /* Clear FLASH Programmation bit */
+ FLASH->CR &= ~FLASH_CR_PG;
+
+ LockFlash();
+
+ return status;
+}
+
+/**
+ * @brief Erase a page in polling mode
+ * @param Page Page number
+ * @param NbPages Number of pages to erase
+ * @retval EE_Status
+ * - EE_OK: on success
+ * - EE error code: if an error occurs
+ */
+EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
+{
+ PRINTF("FI erase page %d, nbr %d\r\n", Page, NbPages);
+
+ EE_Status status = EE_OK;
+
+ if (FLASH->CR & FLASH_CR_LOCK) {
+ UnlockFlash();
+ }
+
+ /* Set FLASH Programmation bit */
+ FLASH->CR |= FLASH_CR_PER;
+
+ while (NbPages-- > 0) {
+ FLASH->AR = Page * FLASH_PAGE_SIZE;
+
+ FLASH->CR |= FLASH_CR_STRT;
+
+ /* Wait programmation completion */
+ while (FLASH->SR & FLASH_SR_BSY) {
+ }
+
+ Page++;
+ }
+
+ FLASH->CR &= ~FLASH_CR_PER;
+ LockFlash();
+
+ return status;
+}
+
+/**
+ * @brief Flush the caches if needed to keep coherency when the flash content is modified
+ */
+void FI_CacheFlush()
+{
+ // f1 doesn't have cache
+}
+
+
+/**
+ * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
+ * @param Address Address of the FLASH Memory to delete
+ * @retval EE_Status
+ * - EE_OK: on success
+ * - EE error code: if an error occurs
+ */
+EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
+{
+ EE_Status rv = FI_WriteDoubleWord(Address, 0);
+ if (rv == EE_WRITE_ERROR) {
+ rv = EE_DELETE_ERROR;
+ }
+
+ return rv;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.h
similarity index 81%
rename from Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.h
rename to Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.h
index 41a793a..d8adc2f 100644
--- a/Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.h
+++ b/Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.h
@@ -27,9 +27,29 @@
#endif
/* Includes ------------------------------------------------------------------*/
-#include "stm32l4xx_hal.h"
-#include "stm32l4xx_ll_crc.h"
-#include "stm32l4xx_ll_bus.h"
+#include
+
+#include "stm32f1xx.h"
+#include "stm32f103xb.h"
+#include "stm32f1xx_ll_crc.h"
+#include "stm32f1xx_ll_bus.h"
+
+
+/** @defgroup FLASHEx_Page_Size Page Size
+ * @{
+ */
+#if (defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6) || defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB))
+#define FLASH_PAGE_SIZE 0x400U
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
+ /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
+
+#if (defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC))
+#define FLASH_PAGE_SIZE 0x800U
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
+ /* STM32F101xG || STM32F103xG */
+ /* STM32F105xC || STM32F107xC */
+
+#define FLASH_BANK_SIZE (FLASH_BANK1_END - FLASH_BASE)
/** @addtogroup EEPROM_Emulation
* @{
@@ -100,11 +120,9 @@
/** @addtogroup EEPROM_Private_Functions
* @{
*/
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
+EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
void FI_CacheFlush(void);
/**
diff --git a/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.c
deleted file mode 100644
index 0c3c02c..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32G0/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-#ifdef FLASH_BANK_2
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t page_error = 0U;
-
-#ifdef FLASH_BANK_2
- uint32_t bank = GetBankNumber(PAGE_ADDRESS(Page));
- s_eraseinit.Banks = bank;
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
-
-#ifdef FLASH_BANK_2
- uint32_t bank = GetBankNumber(PAGE_ADDRESS(Page));
- s_eraseinit.Banks = bank;
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* No flush needed. There is no D-Cache for the STM32G0x0 and STM32G0x1 products. */
- return;
-}
-
-#ifdef FLASH_BANK_2
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (OB_USER_DUALBANK_SWAP_DISABLE)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
-#if defined(FLASH_DBANK_SUPPORT)
- uint32_t bank = GetBankNumber(Address);
- if(bank == FLASH_BANK_1)
- {
- while(FLASH->SR & FLASH_SR_BSY1)
- {
- }
- }
- else
- {
- while(FLASH->SR & FLASH_SR_BSY2)
- {
- }
- }
-#else
- while(FLASH->SR & FLASH_SR_BSY1)
- {
- }
-#endif
-
- /* Check if error occured */
- if((FLASH->SR & FLASH_SR_OPERR) || (FLASH->SR & FLASH_SR_PROGERR) ||
- (FLASH->SR & FLASH_SR_WRPERR) || (FLASH->SR & FLASH_SR_PGAERR) ||
- (FLASH->SR & FLASH_SR_SIZERR) || (FLASH->SR & FLASH_SR_PGSERR))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (FLASH->SR & FLASH_SR_EOP)
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_DBANK_SUPPORT)
- EE_Status status;
-
- /* Check the value of the DBANK user option byte */
- if (OB_USER_DUALBANK_ENABLE)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.h
deleted file mode 100644
index e6391ab..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32G0/flash_interface.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32G0/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32g0xx_hal.h"
-#include "stm32g0xx_ll_crc.h"
-#include "stm32g0xx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.c
deleted file mode 100644
index 4d8e738..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32G4/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-#if defined(FLASH_BANK_2)
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1, page_error = 0U;
-
-#if defined(FLASH_BANK_2)
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
-
- uint32_t bank = FLASH_BANK_1;
-
-#if defined(FLASH_BANK_2)
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* To keep its coherency, flush the D-Cache: its content is not updated after a flash erase. */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- __HAL_FLASH_DATA_CACHE_RESET();
- __HAL_FLASH_DATA_CACHE_ENABLE();
-}
-
-#if defined(FLASH_BANK_2)
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE) == 0U)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- uint32_t dcachetoreactivate = 0U;
- EE_Status status = EE_OK;
-
- /* Deactivate the data cache if they are activated to avoid data misbehavior */
- if(READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) != RESET)
- {
- /* Disable data cache */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- dcachetoreactivate = 1U;
- }
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY))
- {
- }
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Flush the caches to be sure of the data consistency */
- if(dcachetoreactivate == 1U)
- {
- /* Reset data cache */
- __HAL_FLASH_DATA_CACHE_RESET();
- /* Enable data cache */
- __HAL_FLASH_DATA_CACHE_ENABLE();
- }
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- sOBCfg.PCROPConfig = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.h
deleted file mode 100644
index ef78feb..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32G4/flash_interface.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32G4/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32g4xx_hal.h"
-#include "stm32g4xx_ll_crc.h"
-#include "stm32g4xx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.c
deleted file mode 100644
index 8b04f80..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32L4/flash_interface.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32L4/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-#if defined(FLASH_BANK_2)
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1, page_error = 0U;
-
-#if defined(FLASH_BANK_2)
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1;
-
-#if defined(FLASH_BANK_2)
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* To keep its coherency, flush the D-Cache: its content is not updated after a flash erase. */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- __HAL_FLASH_DATA_CACHE_RESET();
- __HAL_FLASH_DATA_CACHE_ENABLE();
-}
-
-#if defined(FLASH_BANK_2)
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE) == 0U)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- uint32_t dcachetoreactivate = 0U;
- EE_Status status = EE_OK;
-
- /* Deactivate the data cache if they are activated to avoid data misbehavior */
- if(READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) != RESET)
- {
- /* Disable data cache */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- dcachetoreactivate = 1U;
- }
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY))
- {
- }
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Flush the caches to be sure of the data consistency */
- if(dcachetoreactivate == 1U)
- {
- /* Reset data cache */
- __HAL_FLASH_DATA_CACHE_RESET();
- /* Enable data cache */
- __HAL_FLASH_DATA_CACHE_ENABLE();
- }
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- sOBCfg.PCROPConfig = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.c
deleted file mode 100644
index d39fc90..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32L5/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-#ifdef FLASH_BANK_2
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
- /* If TrustZone secure activated -> return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD_NS, Address, Data); */
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1, page_error = 0U;
-
-#ifdef FLASH_BANK_2
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; /* if TrustZone secure activated -> FLASH_TYPEERASE_PAGES_NS; */
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1;
-
-#ifdef FLASH_BANK_2
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; /* if TrustZone secure activated -> FLASH_TYPEERASE_PAGES_NS; */
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* No flush needed. EEPROM flash area is defined as non-cacheable thanks to the MPU in main.c. */
- return;
-}
-
-#ifdef FLASH_BANK_2
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (READ_BIT(FLASH->OPTR, FLASH_OPTR_SWAP_BANK) == 0U)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Wait for previous programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_NSSR_NSBSY))
- {
- }
-
- /* Clear previous non-secure error programming flag */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->NSCR, FLASH_NSCR_NSPG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_NSSR_NSBSY))
- {
- }
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->NSCR, FLASH_NSCR_NSPG);
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.h
deleted file mode 100644
index c082239..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32L5/flash_interface.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32L5/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l5xx_hal.h"
-#include "stm32l5xx_ll_crc.h"
-#include "stm32l5xx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-#define SECURE_FEATURE /*!< Informs the driver about the security features of the flash interface */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.c
deleted file mode 100644
index 8788e27..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32L5/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-uint64_t FlashWord[2] =
-{
- 0x0, 0x0
-};
-uint8_t FlashWord_status = 0; /* 0 is FlashWord is empty, 1 it is full */
-const uint32_t QuadWord[4] =
-{
-0x00000000,
-0x00000000,
-0x00000000,
-0x00000000
-};
-/* Private function prototypes -----------------------------------------------*/
-#ifdef FLASH_BANK_2
-static uint32_t GetBankNumber(uint32_t Address);
-#endif
-
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a quad word at the given address in Flash (function is called FI_WriteDoubleWord to respect legacy for X-CUBE-EEPROM)
- * @param Address Where to write
- * @param Data What to write
- * @param Write_type Type of writing on going (see EE_Write_type)
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- * - EE_FLASH_USED: flash currently used by CPU2
- */
-EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t* Data, EE_Write_type Write_type)
-{
- EE_Status status = EE_OK;
-
- if(Write_type == EE_SET_PAGE)
- {
- FlashWord[0] = Data[0];
- FlashWord[1] = Data[0];
- }
- else
- {
- FlashWord[0] = Data[0];
- FlashWord[1] = Data[1];
- }
-
- if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, Address, ((uint32_t)FlashWord)) != HAL_OK)
- {
- status = EE_WRITE_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1, page_error = 0U;
-
-#ifdef FLASH_BANK_2
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; /* if TrustZone secure activated -> FLASH_TYPEERASE_PAGES_NS; */
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t bank = FLASH_BANK_1;
-
-#ifdef FLASH_BANK_2
- bank = GetBankNumber(PAGE_ADDRESS(Page));
-#endif
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; /* if TrustZone secure activated -> FLASH_TYPEERASE_PAGES_NS; */
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
- s_eraseinit.Banks = bank;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* No flush needed. EEPROM flash area is defined as non-cacheable thanks to the MPU in main.c. */
- return;
-}
-
-#ifdef FLASH_BANK_2
-/**
- * @brief Gets the bank of a given address
- * @param Address Address of the FLASH Memory
- * @retval Bank_Number The bank of a given address
- */
-static uint32_t GetBankNumber(uint32_t Address)
-{
- uint32_t bank = 0U;
-
- if (READ_BIT(FLASH->OPTR, FLASH_OPTR_SWAP_BANK) == 0U)
- {
- /* No Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_1;
- }
- else
- {
- bank = FLASH_BANK_2;
- }
- }
- else
- {
- /* Bank swap */
- if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
- {
- bank = FLASH_BANK_2;
- }
- else
- {
- bank = FLASH_BANK_1;
- }
- }
-
- return bank;
-}
-#endif
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Wait for previous programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_NSSR_BSY))
- {
- }
-
- /* Clear previous non-secure error programming flag */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->NSCR, FLASH_NSCR_PG);
-
- /* Program quad word of value 0 */
- // HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, Address, ((uint32_t)QuadWord));
- *(__IO uint64_t*)(Address) = (uint64_t)0U;
- *(__IO uint64_t*)(Address+8U) = (uint64_t)0U;
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_NSSR_BSY))
- {
- }
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->NSCR, FLASH_NSCR_PG);
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.h
deleted file mode 100644
index 8f49b7b..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32U5/flash_interface.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32L5/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32u5xx_hal.h"
-#include "stm32u5xx_ll_crc.h"
-#include "stm32u5xx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions */
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 16 Bytes (128 bits) element in flash */
-/* Bit: 127 64 63 48 47 0 */
-/* <--- Data Value -----> <-CRC-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 16U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint64_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint64_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFFFFFFFFFFU
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-#define SECURE_FEATURE /*!< Informs the driver about the security features of the flash interface */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t* Data, EE_Write_type Write_type);
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.c
deleted file mode 100644
index b13c4e8..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32WB/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-#include "stm32wbxx_nucleo.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-#ifdef DUALCORE_FLASH_SHARING
-#define HSEM_PROCESS_1 12U /* Number taken randomly to identify the process locking a semaphore in the driver context */
-#endif
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-#ifdef DUALCORE_FLASH_SHARING
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @param Write_type Type of writing on going (see EE_Write_type)
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- * - EE_FLASH_USED: flash currently used by CPU2
- */
-EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t Data, EE_Write_type Write_type)
-{
- EE_Status ee_status = EE_OK;
-
- /* We enter a critical section */
- UTILS_ENTER_CRITICAL_SECTION();
-
- /* When the ongoing writing operation is a direct one (no transfer is required,
- we are not in init process, and we do not write the state of a page) */
- if(Write_type == EE_SIMPLE_WRITE)
- {
- /* Wait for the semaphore to be free */
- while( HAL_HSEM_IsSemTaken(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) );
-
- /* Take the HW 7 semaphore */
- if(HAL_HSEM_Take(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1) == HAL_OK)
- {
- if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data) != HAL_OK)
- {
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- ee_status = EE_WRITE_ERROR;
- }
- /* Release the HW Semaphore */
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- ee_status = EE_OK;
- }
- else
- {
- /* If flash is used by CPU2, the semaphore release interrupt is activated so as to raise a notification when
- the semaphore will be unlocked (user can do other operations while waiting) */
- HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID));
- ee_status = EE_FLASH_USED;
- }
- }
- /* This is when the function call comes from a writing operation other than a direct one */
- else
- {
- /* Wait for the semaphore 7 to be free and take it when it is */
- while(HAL_HSEM_Take(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1) != HAL_OK)
- {
- while( HAL_HSEM_IsSemTaken(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) ) ;
- }
-
- if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data) != HAL_OK)
- {
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- ee_status = EE_WRITE_ERROR;
- }
- /* Release the HW Semaphore */
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- ee_status = EE_OK;
- }
-
- /* We exit the critical section */
- UTILS_EXIT_CRITICAL_SECTION();
- return ee_status;
-}
-#else
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-#endif
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
-
-#ifdef DUALCORE_FLASH_SHARING
-
- /* Wait for last operation to be completed */
- while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) ;
-
- /* Because we want to share flash between CPU1 and 2, we erase each page individually
- * and we take then release the associated semaphore for each page erasings.
- * By doing this, we allow CPU2 to do urgent works between page erasings. */
- for (uint32_t index = Page; index < (Page + NbPages); index++)
- {
- /* We enter a critical section */
- UTILS_ENTER_CRITICAL_SECTION();
-
- /* Wait for the semaphore 7 to be free and take it when it is */
- while(HAL_HSEM_Take(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1) != HAL_OK)
- {
- while( HAL_HSEM_IsSemTaken(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) ) ;
- }
-
- /* Start erase page */
- FLASH_PageErase(index);
- /* Release the HW Semaphore */
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- /* We exit the critical section */
- UTILS_EXIT_CRITICAL_SECTION();
-
- /* Wait for last operation to be completed */
- while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) ;
- }
-
- /* If operation is completed or interrupted, disable the Page Erase Bit */
- CLEAR_BIT(FLASH->CR, (FLASH_CR_PER | FLASH_CR_PNB));
-
- /* Flush the caches to be sure of the data consistency */
- /* Flush instruction cache */
- if (READ_BIT(FLASH->ACR, FLASH_ACR_ICEN) == FLASH_ACR_ICEN)
- {
- /* Disable instruction cache */
- __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
- /* Reset instruction cache */
- __HAL_FLASH_INSTRUCTION_CACHE_RESET();
- /* Enable instruction cache */
- __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
- }
-
- /* Flush data cache */
- if (READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) == FLASH_ACR_DCEN)
- {
- /* Disable data cache */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- /* Reset data cache */
- __HAL_FLASH_DATA_CACHE_RESET();
- /* Enable data cache */
- __HAL_FLASH_DATA_CACHE_ENABLE();
- }
-
-#else
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t page_error = 0U;
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
-#endif
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
-#ifdef DUALCORE_FLASH_SHARING
- /* We enter a critical section */
- UTILS_ENTER_CRITICAL_SECTION();
-
- /* Wait for the semaphore 7 to be free and take it when it is */
- while(HAL_HSEM_Take(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1) != HAL_OK)
- {
- while( HAL_HSEM_IsSemTaken(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) ) ;
- }
-#endif
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Release the HW Semaphore */
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- /* We exit the critical section */
- UTILS_EXIT_CRITICAL_SECTION();
-#endif
-
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* To keep its coherency, flush the D-Cache: its content is not updated after a flash erase. */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- __HAL_FLASH_DATA_CACHE_RESET();
- __HAL_FLASH_DATA_CACHE_ENABLE();
-}
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
-#ifdef DUALCORE_FLASH_SHARING
- /* We enter a critical section */
- UTILS_ENTER_CRITICAL_SECTION();
-
- /* Wait for the semaphore 7 to be free and take it when it is */
- while(HAL_HSEM_Take(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1) != HAL_OK)
- {
- while( HAL_HSEM_IsSemTaken(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) ) ;
- }
-#endif
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
-#ifdef DUALCORE_FLASH_SHARING
- /* Release the HW Semaphore */
- HAL_HSEM_Release(CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID, HSEM_PROCESS_1);
- /* We exit the critical section */
- UTILS_EXIT_CRITICAL_SECTION();
-#endif
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) ;
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- sOBCfg.PCROPConfig = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.h
deleted file mode 100644
index b6386ed..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32WB/flash_interface.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32WB/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "stm32wbxx_hal.h"
-#include "stm32wbxx_ll_crc.h"
-#include "stm32wbxx_ll_bus.h"
-#ifdef DUALCORE_FLASH_SHARING
-#include "utilities_conf.h"
-#include "hw_conf.h"
-#include "shci.h"
-#endif
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-#ifdef DUALCORE_FLASH_SHARING
-#define EE_SEM_WAIT_TIMEOUT 5000U /*!< Take semaphore attempts timeout, 5s */
-#endif
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/** @defgroup Macros_Flash Macros to access flash
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-#ifdef DUALCORE_FLASH_SHARING
-EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t Data, EE_Write_type Write_type);
-#else
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-#endif
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.c b/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.c
deleted file mode 100644
index f62f24d..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32WL/flash_interface.c
- * @author MCD Application Team
- * @brief This file provides all the EEPROM emulation flash interface functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "flash_interface.h"
-#include "stm32wlxx_nucleo.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-
-/**
- * @brief Write a double word at the given address in Flash
- * @param Address Where to write
- * @param Data What to write
- * @retval EE_Status
- * - EE_OK: on success
- * - EE_WRITE_ERROR: if an error occurs
- */
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
-{
- return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
-}
-
-/**
- * @brief Erase a page in polling mode
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
- uint32_t page_error = 0U;
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
- return status;
-}
-
-/**
- * @brief Erase a page with interrupt enabled
- * @param Page Page number
- * @param NbPages Number of pages to erase
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
-{
- EE_Status status = EE_OK;
- FLASH_EraseInitTypeDef s_eraseinit;
-
- s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
- s_eraseinit.NbPages = NbPages;
- s_eraseinit.Page = Page;
-
- /* Erase the Page: Set Page status to ERASED status */
- if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
- {
- status = EE_ERASE_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Flush the caches if needed to keep coherency when the flash content is modified
- */
-void FI_CacheFlush()
-{
- /* To keep its coherency, flush the D-Cache: its content is not updated after a flash erase. */
- __HAL_FLASH_DATA_CACHE_DISABLE();
- __HAL_FLASH_DATA_CACHE_RESET();
- __HAL_FLASH_DATA_CACHE_ENABLE();
-}
-
-/**
- * @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
- * @param Address Address of the FLASH Memory to delete
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
-{
- EE_Status status = EE_OK;
-
- /* Set FLASH Programmation bit */
- SET_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Program double word of value 0 */
- *(__IO uint32_t*)(Address) = (uint32_t)0U;
- *(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
-
- /* Wait programmation completion */
- while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) ;
-
- /* Check if error occured */
- if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
- (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
- {
- status = EE_DELETE_ERROR;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- /* Clear FLASH Programmation bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
-
- /* Clear FLASH ECCD bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
-
- return status;
-}
-
-/**
- * @brief Check if the configuration is 128-bits bank or 2*64-bits bank
- * @param None
- * @retval EE_Status
- * - EE_OK: on success
- * - EE error code: if an error occurs
- */
-EE_Status FI_CheckBankConfig(void)
-{
-#if defined (FLASH_OPTR_DBANK)
- FLASH_OBProgramInitTypeDef sOBCfg;
- EE_Status status;
-
- /* Request the Option Byte configuration :
- - User and RDP level are always returned
- - WRP and PCROP are not requested */
- sOBCfg.WRPArea = 0xFF;
- sOBCfg.PCROPConfig = 0xFF;
- HAL_FLASHEx_OBGetConfig(&sOBCfg);
-
- /* Check the value of the DBANK user option byte */
- if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
- {
- status = EE_OK;
- }
- else
- {
- status = EE_INVALID_BANK_CFG;
- }
-
- return status;
-#else
- /* No feature 128-bits single bank, so always 64-bits dual bank */
- return EE_OK;
-#endif
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.h b/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.h
deleted file mode 100644
index 2941723..0000000
--- a/Lib/EEPROM_Emul/Porting/STM32WL/flash_interface.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM_Emul/Porting/STM32WL/flash_interface.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation flash interface.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __FLASH_INTERFACE_H
-#define __FLASH_INTERFACE_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-#include "stm32wlxx_hal.h"
-#include "stm32wlxx_ll_crc.h"
-#include "stm32wlxx_ll_bus.h"
-
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Constants
- * @{
- */
-
-/** @addtogroup Private_Other_Constants
- * @{
- */
-
-#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
-#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
-
-/* Page state header */
-#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
-#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
-#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
-#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
-#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
-
-/* Description of the 8 Bytes (64 bits) element in flash */
-/* Bit: 63 32 31 16 15 0 */
-/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
-#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
-#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
-#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
-#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
-#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
-#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
-#define EE_DATA_TYPE uint32_t /*!< Type of Data */
-#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
-#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
-#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
-#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
-#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Macros
- * @{
- */
-
-/** @defgroup Macros_Flash Macros to access flash
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup EEPROM_Private_Functions
- * @{
- */
-#ifdef DUALCORE_FLASH_SHARING
-EE_Status FI_WriteDoubleWord(uint32_t Address, uint64_t Data, EE_Write_type Write_type);
-#else
-HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
-#endif
-EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
-EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
-EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
-EE_Status FI_CheckBankConfig(void);
-void FI_CacheFlush(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
- */
-
-#endif /* __FLASH_INTERFACE_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Makefile b/Makefile
index f94a3f5..2bb949e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
##########################################################################################################################
-# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Mon Mar 13 00:15:21 CET 2023]
+# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Tue Mar 14 20:49:50 CET 2023]
##########################################################################################################################
# ------------------------------------------------
@@ -72,6 +72,8 @@ Lib/ufb/Src/fb_7seg.c \
Lib/ufb/Src/fb_text.c \
Lib/snprintf/snprintf.c \
Core/Src/dma.c \
+Lib/EEPROM_Emul/Core/eeprom_emul.c \
+Lib/EEPROM_Emul/Porting/STM32F1/flash_interface.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c \
@@ -81,7 +83,9 @@ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c \
-Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c
+Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c \
+Core/Src/crc.c \
+Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c
# ASM sources
ASM_SOURCES = \
@@ -156,7 +160,9 @@ C_INCLUDES = \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include \
-ILib/ufb/Inc \
--ILib/snprintf
+-ILib/snprintf \
+-ILib/EEPROM_Emul/Core \
+-ILib/EEPROM_Emul/Porting/STM32F1
# compile gcc flags
diff --git a/STM32F103C8Tx_FLASH.ld b/STM32F103C8Tx_FLASH.ld
index 3850058..5c8752b 100644
--- a/STM32F103C8Tx_FLASH.ld
+++ b/STM32F103C8Tx_FLASH.ld
@@ -63,7 +63,7 @@ MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 56K
-EEPROM_EMU (rx) : ORIGIN = ORIGIN(FLASH) + LENGTH(FLASH), LENGTH = 8K
+EEPROM_EMU (rx) : ORIGIN = 0x800E000, LENGTH = 8K
}
/* Define output sections */