G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_flash.h File Reference

Header file of FLASH DDL module. More...

#include "g32r4xx.h"

Go to the source code of this file.

Data Structures

struct  DDL_FLASH_OPT_InitTypeDef
 Flash Options Byte Structure definition. More...

Macros

#define FLASH_DDL_WAIT_PERIOD_0   (0x00000000UL)
#define FLASH_DDL_WAIT_PERIOD_1   (FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_2   (FLASH_CR2_RDWAIT_1)
#define FLASH_DDL_WAIT_PERIOD_3   (FLASH_CR2_RDWAIT_1 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_4   (FLASH_CR2_RDWAIT_2)
#define FLASH_DDL_WAIT_PERIOD_5   (FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_6   (FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_1)
#define FLASH_DDL_WAIT_PERIOD_7   (FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_1 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_8   (FLASH_CR2_RDWAIT_3)
#define FLASH_DDL_WAIT_PERIOD_9   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_10   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_1)
#define FLASH_DDL_WAIT_PERIOD_11   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_1 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_12   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_2)
#define FLASH_DDL_WAIT_PERIOD_13   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_WAIT_PERIOD_14   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_1)
#define FLASH_DDL_WAIT_PERIOD_15   (FLASH_CR2_RDWAIT_3 | FLASH_CR2_RDWAIT_2 | FLASH_CR2_RDWAIT_1 | FLASH_CR2_RDWAIT_0)
#define FLASH_DDL_MAIN_LOCK   (FLASH_SR_MAINUNLOCK)
#define FLASH_DDL_MAIN_KEY1   (0x96969696UL)
#define FLASH_DDL_MAIN_KEY2   (0x3C3C3C3CUL)
#define FLASH_DDL_OPT_LOCK   (FLASH_SR_OPUNLOCK)
#define FLASH_DDL_OPT_KEY1   (0xAAAABBBBUL)
#define FLASH_DDL_OPT_KEY2   (0x44556677UL)
#define FLASH_DDL_CHIP_ERASE_TYPE_SECTOR   (0x00000000UL)
#define FLASH_DDL_CHIP_ERASE_TYPE_BLOCK   (FLASH_CR1_ERTYPE_0)
#define FLASH_DDL_CHIP_ERASE_TYPE_MAIN   (FLASH_CR1_ERTYPE_1 | FLASH_CR1_ERTYPE_0)
#define DDL_FLASH_READ_PROTECTION_LEVEL_0   ((0xAAUL << FLASH_OBCR1_RDPWBF_Pos) & FLASH_OBCR1_RDPWBF_Msk)
#define DDL_FLASH_READ_PROTECTION_LEVEL_1   ((0xBBUL << FLASH_OBCR1_RDPWBF_Pos) & FLASH_OBCR1_RDPWBF_Msk)
#define DDL_FLASH_READ_PROTECTION_LEVEL_2   ((0xCCUL << FLASH_OBCR1_RDPWBF_Pos) & FLASH_OBCR1_RDPWBF_Msk)
#define DDL_FLASH_WRITE_PROTECTION_ENABLE   (FLASH_OBCR1_WLOCKENBF)
#define DDL_FLASH_WRITE_PROTECTION_DISABLE   (0x00000000UL)
#define DDL_FLASH_IWDT_ENABLE_SOFTWARE   (FLASH_OBCR1_IWDTSWBF)
#define DDL_FLASH_IWDT_ENABLE_HARDWARE   (0x00000000UL)
#define DDL_FLASH_WWDT_ENABLE_SOFTWARE   (FLASH_OBCR1_WWDTSWBF)
#define DDL_FLASH_WWDT_ENABLE_HARDWARE   (0x00000000UL)
#define DDL_FLASH_NMI_ENABLE   (FLASH_OBCR1_NMIDISWBF)
#define DDL_FLASH_NMI_DISABLE   (0x00000000UL)
#define DDL_FLASH_ADC_TRIM_SOFTWARE   (0x00000000)
#define DDL_FLASH_ADC_TRIM_HARDWARE   FLASH_OBCR1_ADTSLOADWBF
#define DDL_FLASH_SECTOR_NONE   (0x00000000)
#define DDL_FLASH_SECTOR_0_31   (FLASH_OBCR1_WLOCKBF_0)
#define DDL_FLASH_SECTOR_32_63   (FLASH_OBCR1_WLOCKBF_1)
#define DDL_FLASH_SECTOR_64_95   (FLASH_OBCR1_WLOCKBF_2)
#define DDL_FLASH_SECTOR_96_127   (FLASH_OBCR1_WLOCKBF_3)
#define DDL_FLASH_SECTOR_128_159   (FLASH_OBCR1_WLOCKBF_4)
#define DDL_FLASH_SECTOR_160_191   (FLASH_OBCR1_WLOCKBF_5)
#define DDL_FLASH_SECTOR_192_223   (FLASH_OBCR1_WLOCKBF_6)
#define DDL_FLASH_SECTOR_224_255   (FLASH_OBCR1_WLOCKBF_7)
#define DDL_FLASH_CACHE_PRELOAD_ENABLE   FLASH_CR2_PREFETCHEN
#define DDL_FLASH_CACHE_PRELOAD_DISABLE   (0x00000000UL)
#define FLASH_SECTOR_SIZE   (512UL)
#define FLASH_MAIN_SIZE   (256UL * FLASH_SECTOR_SIZE)
#define FLASH_SYSTEMINFO_BASE   (0x08020000UL)
#define FLASH_MAIN_BASE   (0x08000000UL)
#define __DDL_FLASH_CALCULATE_BOOT_ADDRESS(__BOOT_ADDR__)
#define __DDL_FLASH_IS_VALID_BOOT_ADDRESS(__TRNS_BOOT_ADDR__)
#define __DDL_FLASH_WRITE_TO_ADDRESS(__ADDR__, __DATA__)

Functions

__STATIC_INLINE void DDL_FLASH_SetWaitPeriod (uint32_t waitPeriod)
 Set flash wait period.
__STATIC_INLINE uint32_t DDL_FLASH_GetWaitPeriod (void)
 Get flash wait period.
__STATIC_INLINE void DDL_FLASH_MAIN_Lock (void)
 Lock the flash main storage area.
__STATIC_INLINE void DDL_FLASH_MAIN_UnLock (void)
 Unlock the flash main storage area.
__STATIC_INLINE void DDL_FLASH_OPT_Lock (void)
 Lock the flash opt storage area.
__STATIC_INLINE void DDL_FLASH_OPT_UnLock (void)
 Unlock the flash sysinfo storage area.
__STATIC_INLINE void DDL_FLASH_EnableErasure (void)
 Start erasure.
__STATIC_INLINE uint32_t DDL_FLASH_ErasureOngoing (void)
 Get erasure status.
__STATIC_INLINE void DDL_FLASH_SetErasureType (uint32_t type)
 Types of chip erasure configuration.
__STATIC_INLINE uint32_t DDL_FLASH_GetErasureType (void)
 Get the type of configuration chip erasure.
__STATIC_INLINE void DDL_FLASH_SetEraseTimeBase (uint32_t timeBase)
 Configuring chip erasing time base.
__STATIC_INLINE uint32_t DDL_FLASH_GetEraseTimeBase (void)
 Get chip erasing time base.
__STATIC_INLINE void DDL_FLASH_EnableProgram (void)
 Start program.
__STATIC_INLINE uint32_t DDL_FLASH_ProgramOngoing (void)
 Get program status.
__STATIC_INLINE void DDL_FLASH_SetReadProtectionCacheBit (uint32_t level)
 Set read protection cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetReadProtectionCacheBit (void)
 Get read protection cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetReadProtectionBitInOptionByte (void)
 Get the read protection bit in the option byte.
__STATIC_INLINE void DDL_FLASH_SetWriteProtectionEnableCacheBit (uint32_t isEnabled)
 Set write protection enable cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetWriteProtectionEnableCacheBit (void)
 Get write protection enable cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetWriteProtectionEnableBitInOptionByte (void)
 Get the write protection enable bit in the option byte.
__STATIC_INLINE void DDL_FLASH_SetWriteProtectionCacheBit (uint32_t sectorBlock)
 Set write protection cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetWriteProtectionCacheBit (void)
 Get write protection cache bit.
__STATIC_INLINE uint32_t DDL_FLASH_GetWriteProtectionBitInOptionByte (void)
 Get the write protection bit in the option byte.
__STATIC_INLINE void DDL_FLASH_SetNMIEnableCacheBit (uint32_t nmiEnable)
 Set NMI Pin Enable Configuration.
__STATIC_INLINE uint32_t DDL_FLASH_GetNMIEnableCacheBit (void)
 Get NMI Pin Enable Configuration.
__STATIC_INLINE uint32_t DDL_FLASH_GetNMIEnableCacheBitInOptionByte (void)
 Get NMI Pin Enable Configuration.
__STATIC_INLINE void DDL_FLASH_SetADCTRIMCacheBit (uint32_t adcTrim)
 Set ADC TRIM Configuration.
__STATIC_INLINE uint32_t DDL_FLASH_GetADCTRIMCacheBit (void)
 Get ADC TRIM Configuration.
__STATIC_INLINE uint32_t DDL_FLASH_GetADCTRIMCacheBitInOptionByte (void)
 Get ADC TRIM Configuration.
__STATIC_INLINE void DDL_FLASH_SetIWDTTriggerBySoftwareCacheBit (uint32_t isEnabled)
 Set IWDT software enables cache bits.
__STATIC_INLINE uint32_t DDL_FLASH_GetIWDTTriggerBySoftwareCacheBit (void)
 Get IWDT software enables cache bits.
__STATIC_INLINE uint32_t DDL_FLASH_GetIWDTTriggerBySoftwareInOptionByte (void)
 Get the IWDT software enables in the option byte.
__STATIC_INLINE void DDL_FLASH_SetWWDTTriggerBySoftwareCacheBit (uint32_t isEnabled)
 Set WWDT software enables cache bits.
__STATIC_INLINE uint32_t DDL_FLASH_GetWWDTTriggerBySoftwareCacheBit (void)
 Get WWDT software enables cache bits.
__STATIC_INLINE uint32_t DDL_FLASH_GetWWDTTriggerBySoftwareInOptionByte (void)
 Get the WWDT software enables in the option byte.
__STATIC_INLINE void DDL_FLASH_SetBootAddrCacheBit (uint32_t bootAddr)
 Set the write cache bit for setting BOOTADDR.
__STATIC_INLINE uint32_t DDL_FLASH_GetBootAddrCacheBit (void)
 Get the write cache bit for setting BOOTADDR.
__STATIC_INLINE uint32_t DDL_FLASH_GetBootAddrInOptionByte (void)
 Get the write cache bit for setting BOOTADDR in Option Byte.
__STATIC_INLINE uint32_t DDL_FLASH_GetBootAddrTransferActualAddress (void)
 Retrieve the data in the BOOTADDR option byte, which corresponds to the converted address.
__STATIC_INLINE void DDL_FLASH_OptionByteUpdate (void)
 Byte programming options.
__STATIC_INLINE uint32_t DDL_FLASH_OptionByteUpdateOngoing (void)
 Byte programming options Status.
__STATIC_INLINE void DDL_FLASH_OptionByteForcedUpdate (void)
 Forced update of the options byte.
__STATIC_INLINE void DDL_FLASH_CacheReset (void)
 Cache reset.
__STATIC_INLINE uint32_t DDL_FLASH_CacheResetOngoing (void)
 Cache reset.
__STATIC_INLINE void DDL_FLASH_EnableCachePreloadMode (void)
 Enable cache preload mode.
__STATIC_INLINE void DDL_FLASH_DisableCachePreloadMode (void)
 Disable cache preload mode.
__STATIC_INLINE uint32_t DDL_FLASH_CachePreloadModeIsEnabled (void)
 Get cache preload mode status.
__STATIC_INLINE void DDL_FLASH_EnableIT_ERR (void)
 Enable interruption Flash error.
__STATIC_INLINE void DDL_FLASH_DisableIT_ERR (void)
 Disable interruption Flash error.
__STATIC_INLINE uint32_t DDL_FLASH_IsEnabledIT_ERR (void)
 Get state of interruption Flash error. (0: interrupt disabled, 1: interrupt enabled).
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_WADRERR (void)
 Incorrect address write flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_WADRERR (void)
 Clear the address write error flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_WRPRTERR (void)
 Write protection error flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_WRPRTERR (void)
 Clear write protection error flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_KEYERR (void)
 Flash KEY error flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_KEYERR (void)
 Clear Flash KEY error flag.
__STATIC_INLINE void DDL_FLASH_EnableIT_EOP (void)
 Enable interruption programming or erase end.
__STATIC_INLINE void DDL_FLASH_DisableIT_EOP (void)
 Disable interruption programming or erase end.
__STATIC_INLINE uint32_t DDL_FLASH_IsEnabledIT_EOP (void)
 Get state of interruption programming or erase end. (0: interrupt disabled, 1: interrupt enabled).
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_PRD (void)
 Programming completed flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_PRD (void)
 Clear programming completed flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_ERD (void)
 Erase completed flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_ERD (void)
 Clear erase completed flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_OPUNLOCK (void)
 Locking flag for option byte area.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_MAINUNLOCK (void)
 Locking flag for main area.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_OPTERR (void)
 The option_byte does not meet the parity check flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_TRIMERR (void)
 Trim check error flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_OPBPRD (void)
 The optionbyte programming completion flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_OPBPRD (void)
 Clear optionbyte programming completion flag.
__STATIC_INLINE uint32_t DDL_FLASH_IsActiveFlag_BUSY (void)
 FLASH erasing busy flag.
__STATIC_INLINE void DDL_FLASH_ClearFlag_All (void)
 Clear all flag.
void DDL_FLASH_ReadData (uint32_t baseAddr, uint32_t *data, uint32_t length)
 Erase the systemInfo area of the flash.
void DDL_FLASH_WriteData (uint32_t baseAddr, uint32_t *data, uint32_t length)
 Erase the systemInfo area of the flash.
ErrorStatus DDL_FLASH_EraseMain (uint32_t type, uint32_t baseAddr)
 Erase the main area of the flash.
void DDL_FLASH_OPT_StructInit (DDL_FLASH_OPT_InitTypeDef *FLASH_OPT_InitStruct)
 Set each DDL_FLASH_OPT_InitTypeDef field to default value.
ErrorStatus DDL_FLASH_OptionByteProgram (DDL_FLASH_OPT_InitTypeDef *FLASH_OPT_InitStruct)
 Flash option byte programming.
ErrorStatus DDL_FLASH_MainProgram (uint32_t baseAddr, uint32_t *data, uint32_t numWords)
 Program the systemInfo area of the flash.

Detailed Description

Header file of FLASH DDL module.

Attention

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The original code has been modified by Geehy Semiconductor.

Copyright (C) 2024-2025 Geehy Semiconductor. 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.

Definition in file g32r4xx_ddl_flash.h.