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_extra.h
22  * Description  : Flash Control Access window and swap control processing for Low Power Flash.
23  **********************************************************************************************************************/
24 
25 #ifndef R_CODEFLASH_EXTRA_H
26 #define R_CODEFLASH_EXTRA_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 /*  operation definition (FEXCR Register setting)*/
35 #define FEXCR_STARTUP      (0x81U)
36 #define FEXCR_AW           (0x82U)
37 #define FEXCR_OCDID1       (0x83U)
38 #define FEXCR_OCDID2       (0x84U)
39 #define FEXCR_OCDID3       (0x85U)
40 #define FEXCR_OCDID4       (0x86U)
41 #define FEXCR_CLEAR        (0x00U)
42 
43 #define DUMMY              (0xFFFFFFFFU)
44 #define DEFAULT_AREA       (1U)
45 #define DEFAULT_AREA_VALUE (0xFFFFU)
46 #define STARTUP_AREA_VALUE (0xFEFFU)
47 
48 #define SAS_DEFAULT_AREA   0x02U                 ///< Bit value for FSUAC register specifying DEFAULT area
49 #define SAS_ALTERNATE_AREA 0x03U                 ///< Bit value for FSUAC register specifying ALTERNATE area
50 #define SAS_PER_BTFLG_AREA 0x00U                 ///< Bit value for FSUAC register specifying use BTFLG area
51 
52 /******************************************************************************
53  * Exported global functions (to be accessed by other files)
54  ******************************************************************************/
55 
56 /**   FLASH operation command values */
57 typedef enum e_flash_command
58 {
59     FLASH_COMMAND_ACCESSWINDOW,               /**< Flash access window command */
60     FLASH_COMMAND_STARTUPAREA                 /**< Flash change startup area command */
61 } r_flash_command_t;
62 
63 ssp_err_t   HW_FLASH_LP_access_window_set (flash_lp_instance_ctrl_t * const p_ctrl, uint32_t const start_addr, uint32_t const end_addr) PLACE_IN_RAM_SECTION;
64 
65 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
66 ssp_err_t   HW_FLASH_LP_access_window_clear (flash_lp_instance_ctrl_t * const p_ctrl) PLACE_IN_RAM_SECTION;
67 
68 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
69 ssp_err_t   HW_FLASH_LP_set_startup_area_temporary (flash_lp_instance_ctrl_t * const p_ctrl, flash_startup_area_swap_t swap_type) PLACE_IN_RAM_SECTION;
70 
71 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
72 ssp_err_t   HW_FLASH_LP_set_startup_area_boot (flash_lp_instance_ctrl_t * const p_ctrl, flash_startup_area_swap_t swap_type) PLACE_IN_RAM_SECTION;
73 
74 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
75 ssp_err_t   HW_FLASH_LP_set_id_code (flash_lp_instance_ctrl_t       * const p_ctrl,
76                                      uint8_t                  const * const p_id_code,
77                                      flash_id_code_mode_t                   mode) PLACE_IN_RAM_SECTION;
78 
79 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
80 void HW_FLASH_LP_extra_operation (flash_lp_instance_ctrl_t * const p_ctrl, const uint32_t    start_addr_startup_value,
81                                          const uint32_t    end_addr,
82                                          r_flash_command_t command) PLACE_IN_RAM_SECTION;
83 
84 /*LDRA_INSPECTED 219 s - This is an allowed exception to LDRA standard 219 S "User name starts with underscore."*/
85 ssp_err_t HW_FLASH_LP_extra_check (flash_lp_instance_ctrl_t * const p_ctrl) PLACE_IN_RAM_SECTION;
86 
87 ssp_err_t HW_FLASH_LP_set_startup_area (flash_lp_instance_ctrl_t * const p_ctrl, uint32_t value) PLACE_IN_RAM_SECTION;
88 
89 /* Common macro for SSP header files. There is also a corresponding SSP_HEADER macro at the top of this file. */
90 SSP_FOOTER
91 
92 #endif /* R_CODEFLASH_EXTRA_H */
93