1 /***********************************************************************************************************************
2  * Copyright [2015-2017] Renesas Electronics Corporation and/or its licensors. All Rights Reserved.
3  *
4  * This file is part of Renesas SynergyTM Software Package (SSP)
5  *
6  * The contents of this file (the "contents") are proprietary and confidential to Renesas Electronics Corporation
7  * and/or its licensors ("Renesas") and subject to statutory and contractual protections.
8  *
9  * This file is subject to a Renesas SSP license agreement. Unless otherwise agreed in an SSP license agreement with
10  * Renesas: 1) you may not use, copy, modify, distribute, display, or perform the contents; 2) you may not use any name
11  * or mark of Renesas for advertising or publicity purposes or in connection with your use of the contents; 3) RENESAS
12  * MAKES NO WARRANTY OR REPRESENTATIONS ABOUT THE SUITABILITY OF THE CONTENTS FOR ANY PURPOSE; THE CONTENTS ARE PROVIDED
13  * "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14  * PARTICULAR PURPOSE, AND NON-INFRINGEMENT; AND 4) RENESAS SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, OR
15  * CONSEQUENTIAL DAMAGES, INCLUDING DAMAGES RESULTING FROM LOSS OF USE, DATA, OR PROJECTS, WHETHER IN AN ACTION OF
16  * CONTRACT OR TORT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE CONTENTS. Third-party contents
17  * included in this file may be subject to different terms.
18  **********************************************************************************************************************/
19 
20 /**********************************************************************************************************************
21  * File Name    : hw_codeflash.h
22  * Description  : Code Flash Control processing for Low Power Flash
23  **********************************************************************************************************************/
24 
25 #ifndef R_CODEFLASH_H
26 #define R_CODEFLASH_H
27 
28 /* Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. */
29 SSP_HEADER
30 
31 /******************************************************************************
32  * Macro definitions
33  ******************************************************************************/
34 
35 /*  flash mode definition (FENTRYR Register setting)*/
36 #define FENTRYR_CODEFLASH_PE_MODE (0xAA01U)
37 #define FENTRYR_READ_MODE         (0xAA00U)
38 
39 /*  flash mode definition (FPMCR Register setting)*/
40 #define DISCHARGE_1       (0x12U)
41 #define DISCHARGE_2       (0x92U)
42 #define CODEFLASH_PE_MODE (0x82U)
43 #define READ_MODE         (0x08U)
44 #define LVPE_MODE         (0x40U)
45 
46 /*  operation definition (FCR Register setting)*/
47 #define FCR_WRITE             (0x81U)
48 #define FCR_ERASE             (0x84U)
49 #define FCR_BLANKCHECK        (0x83U)
50 #define FCR_CLEAR             (0x00U)
51 
52 #define OPCCR_HIGH_SPEED_MODE (0x00U)
53 
54 /******************************************************************************
55  * Typedef definitions
56  ******************************************************************************/
57 typedef struct R_CODEFLASH_DATA_T
58 {
59     uint32_t  start_addr;   /* start address (Erase) or Ram Source for Write, Dest for read */
60     uint32_t  end_addr;     /* end address (Erase), or Flash Start address which will be read/written */
61     uint32_t  write_cnt;    /* units remaining to do */
62 } r_codeflash_data_t;
63 
64 /******************************************************************************
65  * Exported global variables
66  ******************************************************************************/
67 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
68 void      HW_FLASH_LP_codeflash_enter_pe_mode (flash_lp_instance_ctrl_t * const p_ctrl) PLACE_IN_RAM_SECTION;
69 
70 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
71 ssp_err_t HW_FLASH_LP_codeflash_enter_read_mode (flash_lp_instance_ctrl_t * const p_ctrl) PLACE_IN_RAM_SECTION;
72 
73 void      HW_FLASH_LP_codeflash_erase (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t start_addr,
74                                        const uint32_t num_blocks,
75                                        uint32_t block_size) PLACE_IN_RAM_SECTION;
76 
77 void      HW_FLASH_LP_codeflash_erase_operation (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t start_addr,
78                                                  uint32_t block_size) PLACE_IN_RAM_SECTION;
79 
80 ssp_err_t HW_FLASH_LP_codeflash_erase_monitor (flash_lp_instance_ctrl_t * const p_ctrl, uint32_t block_size) PLACE_IN_RAM_SECTION;
81 
82 void      HW_FLASH_LP_codeflash_write (flash_lp_instance_ctrl_t * const p_ctrl, uint32_t const src_start_address,
83                                        uint32_t       dest_start_address,
84                                        uint32_t       num_bytes,
85                                        uint32_t       min_program_size) PLACE_IN_RAM_SECTION;
86 
87 void      HW_FLASH_LP_codeflash_write_operation (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t psrc_addr,
88                                                  const uint32_t dest_addr,
89                                                  uint32_t       min_program_size) PLACE_IN_RAM_SECTION;
90 
91 ssp_err_t HW_FLASH_LP_codeflash_write_monitor (flash_lp_instance_ctrl_t * const p_ctrl, uint32_t min_program_size) PLACE_IN_RAM_SECTION;
92 
93 ssp_err_t HW_FLASH_LP_codeflash_blank_check (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t start_addr, uint32_t num_bytes) PLACE_IN_RAM_SECTION;
94 
95 void      HW_FLASH_LP_codeflash_blank_check_operation (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t start_addr, uint32_t num_bytes) PLACE_IN_RAM_SECTION;
96 
97 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
98 ssp_err_t HW_FLASH_LP_codeflash_blank_check_monitor (flash_lp_instance_ctrl_t * const p_ctrl) PLACE_IN_RAM_SECTION;
99 
100 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
101 void      HW_FLASH_LP_code_flash_set_flash_settings (current_parameters_t * const p_current_parameters) PLACE_IN_RAM_SECTION;
102 
103 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
104 ssp_err_t HW_FLASH_LP_code_get_macro_info (uint32_t const address, uint32_t num_bytes, flash_lp_macro_info_t * const p_macro) PLACE_IN_RAM_SECTION;
105 
106 
107 /* Common macro for SSP header files. There is also a corresponding SSP_HEADER macro at the top of this file. */
108 SSP_FOOTER
109 
110 #endif /* R_CODEFLASH_H */
111