1 /* 2 * Copyright 2023 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef EMIOS_ICU_IP_DEFINES_H 8 #define EMIOS_ICU_IP_DEFINES_H 9 10 /** 11 * @file 12 * @implements Emios_Icu_Ip_Defines.h_Artifact 13 * @addtogroup emios_icu_ip EMIOS IPL 14 * @{ 15 */ 16 17 #ifdef __cplusplus 18 extern "C"{ 19 #endif 20 21 /*================================================================================================== 22 * INCLUDE FILES 23 * 1) system and project includes 24 * 2) needed interfaces from external units 25 * 3) internal and external interfaces from this unit 26 *================================================================================================*/ 27 #include "Std_Types.h" 28 #include "S32K344_EMIOS.h" 29 30 #include <zephyr/devicetree.h> 31 32 #define _PWM_NXP_S32_CAPTURE_USED(node_id) \ 33 COND_CODE_1(DT_ENUM_HAS_VALUE(node_id, pwm_mode, SAIC), (+ 1), (+ 0)) 34 35 #define PWM_NXP_S32_CAPTURE_USED(node_id) \ 36 DT_FOREACH_CHILD_STATUS_OKAY(node_id, _PWM_NXP_S32_CAPTURE_USED) 37 38 #define QDEC_NXP_S32_MCB_USED \ 39 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32), (+ 2), (+ 0)) 40 41 /*================================================================================================== 42 * SOURCE FILE VERSION INFORMATION 43 *================================================================================================*/ 44 #define EMIOS_ICU_IP_DEFINES_VENDOR_ID 43 45 #define EMIOS_ICU_IP_DEFINES_AR_RELEASE_MAJOR_VERSION 4 46 #define EMIOS_ICU_IP_DEFINES_AR_RELEASE_MINOR_VERSION 7 47 #define EMIOS_ICU_IP_DEFINES_AR_RELEASE_REVISION_VERSION 0 48 #define EMIOS_ICU_IP_DEFINES_SW_MAJOR_VERSION 3 49 #define EMIOS_ICU_IP_DEFINES_SW_MINOR_VERSION 0 50 #define EMIOS_ICU_IP_DEFINES_SW_PATCH_VERSION 0 51 52 /*================================================================================================== 53 * FILE VERSION CHECKS 54 ==================================================================================================*/ 55 /* Check if header file and Std_Types.h file are of the same Autosar version */ 56 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 57 #if ((EMIOS_ICU_IP_DEFINES_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \ 58 (EMIOS_ICU_IP_DEFINES_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)) 59 #error "AutoSar Version Numbers of Emios_Icu_Ip_Defines.h and Std_Types.h are different" 60 #endif 61 #endif 62 63 /*================================================================================================== 64 * CONSTANTS 65 ==================================================================================================*/ 66 67 /*================================================================================================== 68 * DEFINES AND MACROS 69 ==================================================================================================*/ 70 71 #define EMIOS_ICU_IP_USED (0 || (DT_FOREACH_STATUS_OKAY(nxp_s32_emios_pwm, \ 72 PWM_NXP_S32_CAPTURE_USED)) || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 73 74 #if (STD_ON == EMIOS_ICU_IP_USED) 75 76 #define EMIOS_ICU_IP_CHANNEL_24_USED (STD_OFF) 77 /** @brief The number of EMIOS instances available on platform */ 78 #define EMIOS_ICU_IP_INSTANCE_COUNT (3U) 79 80 /** @brief The number of channels available on each EMIOS instance */ 81 #define EMIOS_ICU_IP_NUM_OF_CHANNELS (24U) 82 83 /** @brief The number of eMios channels are used in configuration */ 84 #define EMIOS_ICU_IP_NUM_OF_CHANNELS_USED 0 DT_FOREACH_STATUS_OKAY(nxp_s32_emios_pwm, PWM_NXP_S32_CAPTURE_USED) + QDEC_NXP_S32_MCB_USED 85 86 #define EMIOS_ICU_IP_CHANNEL_NOT_USED ((uint8)0xFF) 87 88 #define EMIOS_ICU_IP_MASTERBUS_CHANNEL_USED ((uint8)0xFE) 89 90 /** @brief Switches the Development Error Detection and Notification on or off. */ 91 #define EMIOS_ICU_IP_DEV_ERROR_DETECT (STD_OFF) 92 #define EMIOS_ICU_IP_VALIDATE_GLOBAL_CALL (EMIOS_ICU_IP_DEV_ERROR_DETECT) 93 94 95 /** @brief Adds or removes all services related to the timestamp functionality. */ 96 #define EMIOS_ICU_IP_TIMESTAMP_API (STD_ON) 97 /** @brief Adds or removes all services related to the edge detect functionality. */ 98 #define EMIOS_ICU_IP_EDGE_DETECT_API (STD_OFF) 99 /** @brief Adds or removes all services related to the signal mesurement functionality. */ 100 #define EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API (STD_OFF || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 101 /** @brief Adds or removes all services related to the input level. */ 102 #define EMIOS_ICU_IP_GET_INPUT_LEVEL_API (STD_ON) 103 /** @brief Adds or removes all services related to the deinitialization functionality. */ 104 #define EMIOS_ICU_IP_DEINIT_API (STD_OFF) 105 /** @brief Adds or removes all services related to edge count functionality. */ 106 #define EMIOS_ICU_IP_EDGE_COUNT_API (STD_OFF || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 107 108 #define EMIOS_ICU_IP_CAPTURERGISTER_API (STD_OFF) 109 110 /** @brief Adds or Removes the code related to overflow notification */ 111 #define EMIOS_ICU_IP_OVERFLOW_NOTIFICATION_API (STD_OFF || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 112 113 /** @brief define SAIC mode if any channels not supporting IPWM or IPM mode is configured. */ 114 #define EMIOS_ICU_IP_SIGNAL_MEASUREMENT_USES_SAIC_MODE (STD_OFF) 115 116 /** @brief Adds or removes the service set Max Counter for eMios. */ 117 #define EMIOS_ICU_IP_SET_MAX_COUNTER (STD_OFF || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 118 119 /** @brief Adds or removes the service set Initial Counter for eMios. */ 120 #define EMIOS_ICU_IP_SET_INITIAL_COUNTER (STD_OFF || DT_HAS_COMPAT_STATUS_OKAY(nxp_qdec_s32)) 121 122 /** @brief Adds or removes all services related to mode set functionality. */ 123 #define EMIOS_ICU_IP_SET_MODE_API (STD_OFF) 124 125 /** @brief Adds or removes all services related to input state functionality. */ 126 #define EMIOS_ICU_IP_GET_INPUT_STATE_API (STD_OFF) 127 128 /** @brief Adds or removes all services related to dual clock edge functionality. */ 129 #define EMIOS_ICU_IP_DUAL_CLOCK_MODE_API (STD_OFF) 130 131 /** @brief Adds or removes the support measurement with DMA. */ 132 #define EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA (STD_OFF) 133 #define EMIOS_ICU_IP_TIMESTAMP_USES_DMA (STD_OFF) 134 135 /** @brief Adds or removes the support measurement with DMA in IPL */ 136 #define EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL (STD_OFF) 137 #define EMIOS_ICU_IP_DMA_MAJORLOOP_COUNT (2U) 138 #define EMIOS_ICU_IP_TIMESTAMP_USES_DMA_IPL (STD_OFF) 139 140 #define EMIOS_ICU_IP_GET_PULSE_WIDTH_API (STD_OFF) 141 /** @brief Support for User mode. 142 * If this parameter has been configured to STD_ON, the EMIOS driver code 143 * can be executed from both supervisor and user mode. */ 144 #define EMIOS_ICU_IP_ENABLE_USER_MODE_SUPPORT (STD_OFF) 145 146 /* Verification for user mode support. */ 147 #ifndef MCAL_ENABLE_USER_MODE_SUPPORT 148 #if (defined (EMIOS_ICU_IP_ENABLE_USER_MODE_SUPPORT) && (STD_ON == EMIOS_ICU_IP_ENABLE_USER_MODE_SUPPORT)) 149 #error MCAL_ENABLE_USER_MODE_SUPPORT is not enabled. For running Icu in user mode the MCAL_ENABLE_USER_MODE_SUPPORT needs to be defined 150 #endif 151 #endif 152 153 #define EMIOS_ICU_USES_MCL_DRIVER (STD_ON) 154 155 #if ((EMIOS_ICU_IP_EDGE_COUNT_API == STD_ON) || (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON) || (EMIOS_ICU_IP_TIMESTAMP_API == STD_ON)) 156 #define EMIOS_ICU_IP_COUNTER_MASK ((uint32)65535) 157 #endif 158 #define EMIOS_ICU_IP_INITIAL_INDEX_OF_CHANNELS \ 159 { \ 160 {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 16U, 17U, 18U, 19U, 20U, 21U, 22U, 255U}, \ 161 {23U, 24U, 25U, 26U, 27U, 28U, 29U, 30U, 31U, 32U, 33U, 34U, 35U, 36U, 37U, 38U, 39U, 40U, 41U, 42U, 43U, 44U, 45U, 255U}, \ 162 {46U, 47U, 48U, 49U, 50U, 51U, 52U, 53U, 54U, 55U, 56U, 57U, 58U, 59U, 60U, 61U, 62U, 63U, 64U, 65U, 66U, 67U, 68U, 255U} \ 163 } \ 164 165 166 /*================================================================================================== 167 * ENUMS 168 ==================================================================================================*/ 169 170 /*================================================================================================== 171 * STRUCTURES AND OTHER TYPEDEFS 172 ==================================================================================================*/ 173 /** 174 * @brief Implementation specific. This type shall be chosen in order to have the most efficient 175 * implementation on a specific microcontroller platform. 176 * Range: 0 to width of the timer register. 177 * Description: Width of the buffer for timestamp ticks and measured elapsed timeticks 178 */ 179 typedef uint32 eMios_Icu_ValueType; 180 /*================================================================================================== 181 * GLOBAL VARIABLE DECLARATIONS 182 ==================================================================================================*/ 183 184 /*================================================================================================== 185 * FUNCTION PROTOTYPES 186 ==================================================================================================*/ 187 188 #endif /* EMIOS_ICU_IP_USED */ 189 190 #ifdef __cplusplus 191 } 192 #endif 193 194 /** @} */ 195 196 #endif /* EMIOS_ICU_IP_DEFINES_H */ 197 198