|
| 1 | +/*********************************************************************************************************************** |
| 2 | +* Copyright (c) 2013 - 2025 Renesas Electronics Corporation and/or its affiliates |
| 3 | +* |
| 4 | +* SPDX-License-Identifier: BSD-3-Clause |
| 5 | +***********************************************************************************************************************/ |
| 6 | +/*********************************************************************************************************************** |
| 7 | +* File Name : r_iwdt_rx_if.h |
| 8 | +* Description : Functions for using IWDT on RX devices. |
| 9 | +***********************************************************************************************************************/ |
| 10 | +/*********************************************************************************************************************** |
| 11 | +* History : DD.MM.YYYY Version Description |
| 12 | +* 07.06.2013 1.00 First Release |
| 13 | +* 06.09.2013 1.10 Change enumeration name |
| 14 | +* 19.03.2014 1.20 Removed unnecessary #includes. Added #ifdef to e_iwdt_timeout. Changed version number. |
| 15 | +* 30.12.2014 1.30 Added support for RX113. |
| 16 | +* 06.03.2015 1.40 Added support for RX64M & RX71M |
| 17 | +* 02.06.2015 1.50 Added support for RX231 |
| 18 | +* 01.03.2016 1.51 Added support for RX130, RX230 and RX23T |
| 19 | +* 30.06.2016 1.60 Added support for RX65N |
| 20 | +* 19.12.2016 1.70 Added support for RX24U, RX24T(512KB) |
| 21 | +* 21.07.2017 1.80 Added support for RX130_512KB, RX65N-2M |
| 22 | +* 31.10.2017 1.81 Added the demo for RX65N, RX65N-2M |
| 23 | +* 28.09.2018 1.90 Added support for RX66T |
| 24 | +* 16.11.2018 1.91 Added XML document number |
| 25 | +* 01.02.2019 2.00 Added support for RX72T, RX65N-64pin. |
| 26 | +* Bug fix: R_WDT_Open(), R_IWDT_Open() invalidated if either module is in auto-start mode. |
| 27 | +* 20.05.2019 3.00 Added support for GNUC and ICCRX. |
| 28 | +* 28.06.2019 3.10 Added support for RX23W. |
| 29 | +* 15.08.2019 3.20 Added support for RX72M. |
| 30 | +* 25.11.2019 3.30 Added support for RX13T. |
| 31 | +* Removed support for Generation 1 devices. |
| 32 | +* Fixed to comply with GSCE Coding Standards Rev.6.00. |
| 33 | +* 30.12.2019 3.40 Added support for RX66N, RX72N. |
| 34 | +* 31.03.2020 3.50 Added support for RX23E-A. |
| 35 | +* 30.06.2020 3.60 Changed revision to reflect demo upgrade. |
| 36 | +* 31.03.2021 3.70 Added support for RX671. |
| 37 | +* 15.04.2021 3.80 Added support for RX140. |
| 38 | +* 13.09.2021 3.90 Added the demo for RX671. |
| 39 | +* 14.03.2022 4.00 Added support for RX66T-48Pin. |
| 40 | +* 31.03.2022 4.10 Added support for RX660. |
| 41 | +* 28.06.2022 4.20 Updated demo projects. |
| 42 | +* 15.08.2022 4.30 Added support for RX26T. |
| 43 | +* Fixed to comply with GSCE Coding Standards Rev.6.5.0 |
| 44 | +* 29.05.2023 4.40 Added support for RX23E-B. |
| 45 | +* Fixed to comply with GSCE Coding Standards Rev.6.5.0 |
| 46 | +* 28.06.2024 4.50 Added support for RX260, RX261. |
| 47 | +* 15.03.2025 4.51 Updated disclaimer |
| 48 | +***********************************************************************************************************************/ |
| 49 | + |
| 50 | +#ifndef IWDT_RX_IF_H |
| 51 | +#define IWDT_RX_IF_H |
| 52 | + |
| 53 | +/*********************************************************************************************************************** |
| 54 | +Includes <System Includes> , "Project Includes" |
| 55 | +***********************************************************************************************************************/ |
| 56 | +#include "platform.h" |
| 57 | +/* Used for configuring the IWDT code */ |
| 58 | +#include "r_iwdt_rx_config.h" |
| 59 | + |
| 60 | +/*********************************************************************************************************************** |
| 61 | +Macro definitions |
| 62 | +***********************************************************************************************************************/ |
| 63 | +#if R_BSP_VERSION_MAJOR < 5 |
| 64 | + #error "This module must use BSP module of Rev.5.00 or higher. Please use the BSP module of Rev.5.00 or higher." |
| 65 | +#endif |
| 66 | +/* Version Number of API. */ |
| 67 | +#define IWDT_RX_VERSION_MAJOR (4) |
| 68 | +#define IWDT_RX_VERSION_MINOR (51) |
| 69 | + |
| 70 | +#define OFS0_IWDT_DISABLED (0x00000002) |
| 71 | + |
| 72 | +/*********************************************************************************************************************** |
| 73 | +Typedef definitions |
| 74 | +***********************************************************************************************************************/ |
| 75 | + |
| 76 | +/* API ERROR RETURN CODES */ |
| 77 | + |
| 78 | +#define IWDT_STAT_REFRESH_ERR_MASK (0x8000) |
| 79 | +#define IWDT_STAT_UNDERFLOW_ERR_MASK (0x4000) |
| 80 | +#define IWDT_STAT_ERROR_MASK (0xC000) |
| 81 | +#define IWDT_STAT_COUNTER_MASK (0x3FFF) |
| 82 | + |
| 83 | +typedef enum e_iwdt_err // IWDT API error codes |
| 84 | +{ |
| 85 | + IWDT_SUCCESS=0, |
| 86 | + IWDT_ERR_OPEN_IGNORED, // The module has already been Open |
| 87 | + IWDT_ERR_INVALID_ARG, // Argument is not valid for parameter |
| 88 | + IWDT_ERR_NULL_PTR, // Received null pointer or missing required argument |
| 89 | + IWDT_ERR_NOT_OPENED, // Open function has not yet been called |
| 90 | + IWDT_ERR_BUSY, // IWDT resource locked |
| 91 | +} iwdt_err_t; |
| 92 | + |
| 93 | + |
| 94 | +/* Open() DEFINITIONS */ |
| 95 | + |
| 96 | +typedef enum e_iwdt_timeout // IWDT Time-Out Period |
| 97 | +{ |
| 98 | +#if defined(BSP_MCU_RX11_ALL) || defined(BSP_MCU_RX130) || defined(BSP_MCU_RX13T) || defined(BSP_MCU_RX23_ALL) \ |
| 99 | + || defined(BSP_MCU_RX24U)|| defined(BSP_MCU_RX140) || defined(BSP_MCU_RX260) || defined(BSP_MCU_RX261) |
| 100 | + IWDT_TIMEOUT_128 =0x0000u, // 128 (cycles) |
| 101 | + IWDT_TIMEOUT_512 =0x0001u, // 512 (cycles) |
| 102 | + IWDT_TIMEOUT_1024=0x0002u, // 1024 (cycles) |
| 103 | + IWDT_TIMEOUT_2048=0x0003u, // 2048 (cycles) |
| 104 | +#else /* RX64M, RX71M, RX65N, RX66T, RX66N, RX72T, RX72M, RX72N, RX671, RX660, RX26T */ |
| 105 | + IWDT_TIMEOUT_1024 =0x0000u, // 1024 (cycles) |
| 106 | + IWDT_TIMEOUT_4096 =0x0001u, // 4096 (cycles) |
| 107 | + IWDT_TIMEOUT_8192 =0x0002u, // 8192 (cycles) |
| 108 | + IWDT_TIMEOUT_16384=0x0003u, // 16,384 (cycles) |
| 109 | +#endif |
| 110 | + IWDT_NUM_TIMEOUTS |
| 111 | +} iwdt_timeout_t; |
| 112 | + |
| 113 | +typedef enum e_iwdt_clock_div // IWDT Clock Division Ratio |
| 114 | +{ |
| 115 | + IWDT_CLOCK_DIV_1 =0x0000u, // IWDTCLK/1 |
| 116 | + IWDT_CLOCK_DIV_16 =0x0020u, // IWDTCLK/16 |
| 117 | + IWDT_CLOCK_DIV_32 =0x0030u, // IWDTCLK/32 |
| 118 | + IWDT_CLOCK_DIV_64 =0x0040u, // IWDTCLK/64 |
| 119 | + IWDT_CLOCK_DIV_128=0x00F0u, // IWDTCLK/128 |
| 120 | + IWDT_CLOCK_DIV_256=0x0050u // IWDTCLK/256 |
| 121 | +} iwdt_clock_div_t; |
| 122 | + |
| 123 | +typedef enum e_iwdt_window_end // Window End Position |
| 124 | +{ |
| 125 | + IWDT_WINDOW_END_75=0x0000u, // 75% |
| 126 | + IWDT_WINDOW_END_50=0x0100u, // 50% |
| 127 | + IWDT_WINDOW_END_25=0x0200u, // 25% |
| 128 | + IWDT_WINDOW_END_0 =0x0300u // 0% (window end position is not specified) |
| 129 | +} iwdt_window_end_t; |
| 130 | + |
| 131 | +typedef enum e_iwdt_window_start // Window Start Position |
| 132 | +{ |
| 133 | + IWDT_WINDOW_START_25 =0x0000u, // 25% |
| 134 | + IWDT_WINDOW_START_50 =0x1000u, // 50% |
| 135 | + IWDT_WINDOW_START_75 =0x2000u, // 75% |
| 136 | + IWDT_WINDOW_START_100=0x3000u // 100% (window start position is not specified) |
| 137 | +} iwdt_window_start_t; |
| 138 | + |
| 139 | +typedef enum e_iwdt_timeout_control // Signal control when Time-out and Refresh error |
| 140 | +{ |
| 141 | + IWDT_TIMEOUT_NMI =0x00u, // Non-maskable interrupt request output is enabled |
| 142 | + IWDT_TIMEOUT_RESET=0x80u // Reset output is enabled |
| 143 | +} iwdt_timeout_control_t; |
| 144 | + |
| 145 | +typedef enum e_iwdt_count_stop // Sleep mode count stop |
| 146 | +{ |
| 147 | + IWDT_COUNT_STOP_DISABLE=0x00u, // 0: Count stop is disabled |
| 148 | + IWDT_COUNT_STOP_ENABLE =0x80u // 1: Count stop is enabled |
| 149 | +} iwdt_count_stop_t; |
| 150 | + |
| 151 | +typedef struct st_iwdt_config // IWDT configuration options used in Open function |
| 152 | +{ |
| 153 | + iwdt_timeout_t timeout; // Time-out period |
| 154 | + iwdt_clock_div_t iwdtclk_div; // IWDT clock division ratio |
| 155 | + iwdt_window_start_t window_start; // Window start position |
| 156 | + iwdt_window_end_t window_end; // Window end position |
| 157 | + iwdt_timeout_control_t timeout_control; // Reset or NMI output when time-out |
| 158 | + iwdt_count_stop_t count_stop_enable;// Sleep mode count stop function |
| 159 | +} iwdt_config_t; |
| 160 | + |
| 161 | + |
| 162 | +/* Control() DEFINITIONS */ |
| 163 | + |
| 164 | +typedef enum e_iwdt_cmd // Command used in Control and GetStatus function |
| 165 | +{ |
| 166 | + IWDT_CMD_GET_STATUS, // Get IWDT status |
| 167 | + IWDT_CMD_REFRESH_COUNTING // Refresh the counter |
| 168 | +} iwdt_cmd_t; |
| 169 | + |
| 170 | +/*********************************************************************************************************************** |
| 171 | +Public Functions |
| 172 | +***********************************************************************************************************************/ |
| 173 | +#if ((BSP_CFG_OFS0_REG_VALUE & OFS0_IWDT_DISABLED) == OFS0_IWDT_DISABLED) /* Register start mode */ |
| 174 | +/****************************************************************************** |
| 175 | + * Function Name: R_IWDT_Open |
| 176 | + * Description : Initializes the IWDT counter options by initializing the associated registers |
| 177 | + * Argument : p_cfg |
| 178 | + * Return Value : . |
| 179 | + *****************************************************************************/ |
| 180 | +iwdt_err_t R_IWDT_Open (void * const p_cfg); |
| 181 | +#endif |
| 182 | +/****************************************************************************** |
| 183 | + * Function Name: R_IWDT_Control |
| 184 | + * Description : Getting the IWDT status and refreshing the down-counter of IWDT |
| 185 | + * Arguments : cmd |
| 186 | + * : p_status |
| 187 | + * Return Value : . |
| 188 | + *****************************************************************************/ |
| 189 | +iwdt_err_t R_IWDT_Control (iwdt_cmd_t const cmd, uint16_t * p_status); |
| 190 | + |
| 191 | +/****************************************************************************** |
| 192 | + * Function Name: R_IWDT_GetVersion |
| 193 | + * Description : Returns the version number of the module |
| 194 | + * Return Value : . |
| 195 | + *****************************************************************************/ |
| 196 | +uint32_t R_IWDT_GetVersion (void); |
| 197 | + |
| 198 | +#endif /* IWDT_RX_IF_H */ |
0 commit comments