Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
#include "fsl_c40_flash.h"
#include "fsl_common.h"
#include "fsl_device_registers.h"
#include "fsl_c40_flash_features.h"


/*******************************************************************************
* Definitions
******************************************************************************/

#if !defined(FLASH) && defined(IP_FLASH)
#define FLASH IP_FLASH /* Define a local alias for C40 flash memory */
#endif
#if !defined(PFLASH) && defined(IP_PFLASH)
#define PFLASH IP_PFLASH /* Define a local alias for flash memory controller */
#endif

/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID
#define FSL_COMPONENT_ID "platform.drivers.flash_c40"
Expand Down Expand Up @@ -746,7 +754,7 @@ status_t FLASH_Init(flash_config_t *config)
return ret;
}

status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
RAMFUNC status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
{
status_t ret;
uint32_t sectorNumStart;
Expand Down Expand Up @@ -795,9 +803,9 @@ status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBy
return ret;
}

status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)
RAMFUNC status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)
{
status_t ret;
status_t ret = kStatus_FLASH_Success;
size_t chunkSize;
size_t sizeLeft = lengthInBytes;
uint8_t *src8 = (uint8_t *) src;
Expand Down Expand Up @@ -848,7 +856,7 @@ status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, ui
return ret;
}

status_t FLASH_SetSectorProtection(flash_config_t *config, uint32_t address, bool locked)
RAMFUNC status_t FLASH_SetSectorProtection(flash_config_t *config, uint32_t address, bool locked)
{
status_t ret;
uint32_t sectorNum;
Expand Down Expand Up @@ -878,4 +886,4 @@ status_t FLASH_GetSectorProtection(flash_config_t *config, uint32_t address)
}

return C40_SectorLockStatus(sectorNum);
}
}
27 changes: 27 additions & 0 deletions mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash_features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2025 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/

#ifndef FSL_C40_FLASH_FEATURES_H_
#define FSL_C40_FLASH_FEATURES_H_

#include "fsl_common.h"

/* Differences in flash array for different S32K3 variants can be added in elif conditions */
#if defined(CPU_S32K344)

/* Code flash: 4 MiB total => 4 blocks × 1 MiB each */
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE (1024 * 1024)
#define FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE (4)
/* Data flash: 256 KiB */
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_DATA (256 * 1024)
#else
#error "C40 feature macros not defined for this SoC."

#endif

#endif /* FSL_C40_FLASH_FEATURES_H_ */