|
| 1 | +/* |
| 2 | +* Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates |
| 3 | +* |
| 4 | +* SPDX-License-Identifier: BSD-3-Clause |
| 5 | +*/ |
| 6 | + |
| 7 | +#ifndef R_MRAM_H |
| 8 | +#define R_MRAM_H |
| 9 | + |
| 10 | +/*******************************************************************************************************************//** |
| 11 | + * @addtogroup MRAM |
| 12 | + * @{ |
| 13 | + **********************************************************************************************************************/ |
| 14 | + |
| 15 | +/*********************************************************************************************************************** |
| 16 | + * Includes |
| 17 | + **********************************************************************************************************************/ |
| 18 | +#include "bsp_api.h" |
| 19 | +#include "r_flash_api.h" |
| 20 | +#include "r_mram_cfg.h" |
| 21 | + |
| 22 | +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ |
| 23 | +FSP_HEADER |
| 24 | + |
| 25 | +/*********************************************************************************************************************** |
| 26 | + * Macro definitions |
| 27 | + **********************************************************************************************************************/ |
| 28 | + |
| 29 | +/* If Code Flash programming is enabled, then all API functions must execute out of RAM. */ |
| 30 | +#if defined(__ICCARM__) |
| 31 | + #pragma section=".ram_from_flash" |
| 32 | +#endif |
| 33 | +#if defined(__ARMCC_VERSION) || defined(__GNUC__) |
| 34 | + #define PLACE_IN_RAM_SECTION __attribute__((noinline)) BSP_PLACE_IN_SECTION(".ram_from_flash") |
| 35 | +#else |
| 36 | + #define PLACE_IN_RAM_SECTION BSP_PLACE_IN_SECTION(".ram_from_flash") |
| 37 | +#endif |
| 38 | + |
| 39 | +/*********************************************************************************************************************** |
| 40 | + * Typedef definitions |
| 41 | + **********************************************************************************************************************/ |
| 42 | + |
| 43 | +/** MRAM instance control block. DO NOT INITIALIZE. */ |
| 44 | +typedef struct st_mram_instance_ctrl |
| 45 | +{ |
| 46 | + uint32_t opened; // To check whether api has been opened or not. |
| 47 | + flash_cfg_t const * p_cfg; |
| 48 | + |
| 49 | + uint32_t timeout_mram_write; |
| 50 | + uint32_t timeout_arc_increment; |
| 51 | + uint32_t timeout_arc_read; |
| 52 | + uint32_t timeout_configuration_set; |
| 53 | + uint32_t timeout_maci_command; |
| 54 | +} mram_instance_ctrl_t; |
| 55 | + |
| 56 | +/********************************************************************************************************************** |
| 57 | + * Exported global variables |
| 58 | + **********************************************************************************************************************/ |
| 59 | + |
| 60 | +/** @cond INC_HEADER_DEFS_SEC */ |
| 61 | +/** Filled in Interface API structure for this Instance. */ |
| 62 | +extern const flash_api_t g_flash_on_mram; |
| 63 | + |
| 64 | +/** @endcond */ |
| 65 | + |
| 66 | +fsp_err_t R_MRAM_Open(flash_ctrl_t * const p_api_ctrl, flash_cfg_t const * const p_cfg); |
| 67 | + |
| 68 | +fsp_err_t R_MRAM_Write(flash_ctrl_t * const p_api_ctrl, |
| 69 | + uint32_t const src_address, |
| 70 | + uint32_t mram_address, |
| 71 | + uint32_t const num_bytes) PLACE_IN_RAM_SECTION; |
| 72 | + |
| 73 | +fsp_err_t R_MRAM_Erase(flash_ctrl_t * const p_api_ctrl, uint32_t const address, uint32_t const num_blocks); |
| 74 | + |
| 75 | +fsp_err_t R_MRAM_BlankCheck(flash_ctrl_t * const p_api_ctrl, |
| 76 | + uint32_t const address, |
| 77 | + uint32_t num_bytes, |
| 78 | + flash_result_t * blank_check_result); |
| 79 | + |
| 80 | +fsp_err_t R_MRAM_Close(flash_ctrl_t * const p_api_ctrl); |
| 81 | + |
| 82 | +fsp_err_t R_MRAM_StatusGet(flash_ctrl_t * const p_api_ctrl, flash_status_t * const p_status); |
| 83 | + |
| 84 | +fsp_err_t R_MRAM_AccessWindowSet(flash_ctrl_t * const p_api_ctrl, uint32_t const start_addr, uint32_t const end_addr); |
| 85 | + |
| 86 | +fsp_err_t R_MRAM_AccessWindowClear(flash_ctrl_t * const p_api_ctrl); |
| 87 | + |
| 88 | +fsp_err_t R_MRAM_IdCodeSet(flash_ctrl_t * const p_api_ctrl, uint8_t const * const p_id_code, flash_id_code_mode_t mode); |
| 89 | + |
| 90 | +fsp_err_t R_MRAM_Reset(flash_ctrl_t * const p_api_ctrl); |
| 91 | + |
| 92 | +fsp_err_t R_MRAM_UpdateFlashClockFreq(flash_ctrl_t * const p_api_ctrl); |
| 93 | + |
| 94 | +fsp_err_t R_MRAM_StartUpAreaSelect(flash_ctrl_t * const p_api_ctrl, |
| 95 | + flash_startup_area_swap_t swap_type, |
| 96 | + bool is_temporary); |
| 97 | +fsp_err_t R_MRAM_CallbackSet(flash_ctrl_t * const p_api_ctrl, |
| 98 | + void ( * p_callback)(flash_callback_args_t *), |
| 99 | + void * const p_context, |
| 100 | + flash_callback_args_t * const p_callback_memory); |
| 101 | +fsp_err_t R_MRAM_BankSwap(flash_ctrl_t * const p_api_ctrl); |
| 102 | +fsp_err_t R_MRAM_InfoGet(flash_ctrl_t * const p_api_ctrl, flash_info_t * const p_info); |
| 103 | +fsp_err_t R_MRAM_AntiRollbackCounterIncrement(flash_ctrl_t * const p_api_ctrl, flash_arc_t counter); |
| 104 | +fsp_err_t R_MRAM_AntiRollbackCounterRefresh(flash_ctrl_t * const p_api_ctrl, flash_arc_t counter); |
| 105 | +fsp_err_t R_MRAM_AntiRollbackCounterRead(flash_ctrl_t * const p_api_ctrl, flash_arc_t counter, |
| 106 | + uint32_t * const p_count); |
| 107 | +fsp_err_t R_MRAM_UserLockableAreaWrite(flash_ctrl_t * const p_api_ctrl, |
| 108 | + uint32_t const src_address, |
| 109 | + uint32_t mram_address, |
| 110 | + uint32_t const num_bytes); |
| 111 | + |
| 112 | +/*******************************************************************************************************************//** |
| 113 | + * @} (end defgroup MRAM) |
| 114 | + **********************************************************************************************************************/ |
| 115 | + |
| 116 | +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ |
| 117 | +FSP_FOOTER |
| 118 | + |
| 119 | +#endif |
0 commit comments