1 /* 2 * Copyright 2021-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef EMIOS_PWM_IP_CFG_H 8 #define EMIOS_PWM_IP_CFG_H 9 10 /** 11 * @file Emios_Pwm_Ip_Cfg.h 12 * 13 * @addtogroup emios_pwm_ip Emios Pwm IPL 14 * @{ 15 */ 16 17 #ifdef __cplusplus 18 extern "C"{ 19 #endif 20 21 22 /*================================================================================================== 23 * INCLUDE FILES 24 * 1) system and project includes 25 * 2) needed interfaces from external units 26 * 3) internal and external interfaces from this unit 27 ==================================================================================================*/ 28 #include <zephyr/devicetree.h> 29 30 /* Standard Types */ 31 #include "Std_Types.h" 32 33 /* DevAssert implementation */ 34 #include "Devassert.h" 35 36 /* Register definitions */ 37 #include "S32Z2_EMIOS.h" 38 39 /* Include all variants header files. */ 40 #include "Emios_Pwm_Ip_Init_PBcfg.h" 41 42 /*================================================================================================== 43 * SOURCE FILE VERSION INFORMATION 44 ==================================================================================================*/ 45 #define EMIOS_PWM_IP_CFG_VENDOR_ID 43 46 #define EMIOS_PWM_IP_CFG_MODULE_ID 121 47 #define EMIOS_PWM_IP_CFG_AR_RELEASE_MAJOR_VERSION 4 48 #define EMIOS_PWM_IP_CFG_AR_RELEASE_MINOR_VERSION 7 49 #define EMIOS_PWM_IP_CFG_AR_RELEASE_REVISION_VERSION 0 50 #define EMIOS_PWM_IP_CFG_SW_MAJOR_VERSION 2 51 #define EMIOS_PWM_IP_CFG_SW_MINOR_VERSION 0 52 #define EMIOS_PWM_IP_CFG_SW_PATCH_VERSION 0 53 54 /*================================================================================================== 55 * FILE VERSION CHECKS 56 ==================================================================================================*/ 57 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 58 /* Check if header file and Std_Types.h are of the same AUTOSAR version */ 59 #if ((EMIOS_PWM_IP_CFG_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \ 60 (EMIOS_PWM_IP_CFG_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)) 61 #error "AUTOSAR Version Numbers of Emios_Pwm_Ip_Cfg.h and Std_Types.h are different" 62 #endif 63 64 /* Check if header file and Devassert.h are of the same AUTOSAR version */ 65 #if ((EMIOS_PWM_IP_CFG_AR_RELEASE_MAJOR_VERSION != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \ 66 (EMIOS_PWM_IP_CFG_AR_RELEASE_MINOR_VERSION != DEVASSERT_AR_RELEASE_MINOR_VERSION)) 67 #error "AUTOSAR Version Numbers of Emios_Pwm_Ip_Cfg.h and Devassert.h are different" 68 #endif 69 #endif 70 71 /* Check if header file and Emios_Pwm_Ip_Init_PBcfg header file are of the same vendor */ 72 #if (EMIOS_PWM_IP_CFG_VENDOR_ID != EMIOS_PWM_IP_INIT_PB_CFG_VENDOR_ID) 73 #error "Vendor IDs of Emios_Pwm_Ip_Cfg.h and Emios_Pwm_Ip_Init_PBcfg.h are different." 74 #endif 75 76 /* Check if header file and Emios_Pwm_Ip_Init_PBcfg header file are of the same AUTOSAR version */ 77 #if ((EMIOS_PWM_IP_CFG_AR_RELEASE_MAJOR_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MAJOR_VERSION) || \ 78 (EMIOS_PWM_IP_CFG_AR_RELEASE_MINOR_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MINOR_VERSION) || \ 79 (EMIOS_PWM_IP_CFG_AR_RELEASE_REVISION_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_REVISION_VERSION)) 80 #error "AUTOSAR version numbers of Emios_Pwm_Ip_Cfg.h and Emios_Pwm_Ip_Init_PBcfg.h are different." 81 #endif 82 83 /* Check if header file and Emios_Pwm_Ip_Init_PBcfg header file are of the same software version */ 84 #if ((EMIOS_PWM_IP_CFG_SW_MAJOR_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_SW_MAJOR_VERSION) || \ 85 (EMIOS_PWM_IP_CFG_SW_MINOR_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_SW_MINOR_VERSION) || \ 86 (EMIOS_PWM_IP_CFG_SW_PATCH_VERSION != EMIOS_PWM_IP_INIT_PB_CFG_SW_PATCH_VERSION)) 87 #error "Software version numbers of Emios_Pwm_Ip_Cfg.h and Emios_Pwm_Ip_Init_PBcfg.h are different." 88 #endif 89 90 /*================================================================================================== 91 * CONSTANTS 92 ==================================================================================================*/ 93 94 /*================================================================================================== 95 * DEFINES AND MACROS 96 ==================================================================================================*/ 97 #define DT_DRV_COMPAT nxp_s32_emios_pwm 98 99 #define NUM_CHANNEL_USED(node_id) COND_CODE_1(DT_ENUM_HAS_VALUE(node_id, pwm_mode, SAIC), (+ 0), (+ 1)) 100 #define EMIOS_NUM_CHANNELS_USED(n) DT_INST_FOREACH_CHILD_STATUS_OKAY(n, NUM_CHANNEL_USED) 101 102 #define SET_INITIAL_MODE(node_id) IF_ENABLED(UTIL_NOT(DT_ENUM_HAS_VALUE(node_id, pwm_mode, SAIC)), \ 103 (EMIOS_PWM_IP_MODE_NODEFINE,)) 104 #define EMIOS_PWM_IP_SET_INITIAL_MODE(n) DT_INST_FOREACH_CHILD_STATUS_OKAY(n, SET_INITIAL_MODE) 105 106 /** @brief Enable the Emios Ip */ 107 #define EMIOS_PWM_IP_USED (STD_ON) 108 109 /** @brief Switch to enable the development error detection. */ 110 #define EMIOS_PWM_IP_DEV_ERROR_DETECT (STD_OFF) 111 112 /** @brief The number of Emios instances available on platform */ 113 #define EMIOS_PWM_IP_INSTANCE_COUNT (eMIOS_INSTANCE_COUNT) 114 /** @brief The number of channels available on each Emios instance */ 115 #define EMIOS_PWM_IP_CHANNEL_COUNT (eMIOS_CH_UC_UC_COUNT) 116 117 /** @brief The number of PWM modes implemented in hardware */ 118 #define EMIOS_PWM_IP_MODES (8U) 119 /** @brief Mapping between available channels and the PWM mode supported by each of them */ 120 #define EMIOS_PWM_IP_CHANNEL_MODES {\ 121 {0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL},\ 122 {0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL, 0xFFFF00FFUL},\ 123 } 124 /** @brief Min counter value for PWM modes */ 125 #define EMIOS_PWM_IP_MIN_CNT_VAL (0x0001UL) 126 /** @brief Max counter value for PWM modes */ 127 #define EMIOS_PWM_IP_MAX_CNT_VAL (0xFFFFFFUL) 128 129 /** @brief Counter bus channel number */ 130 #define EMIOS_PWM_IP_COUNTER_BUS_A (23U) 131 #define EMIOS_PWM_IP_COUNTER_BUS_BCDE (248U) 132 #define EMIOS_PWM_IP_COUNTER_BUS_F (22U) 133 134 /* @brief Define if global variables need to be placed in non-cache area or not */ 135 #define EMIOS_PWM_IP_NO_CACHE_NEEDED (STD_OFF) 136 137 /** @brief Arrays to store the channel logic Index State */ 138 #define EMIOS_PWM_IP_USED_CHANNELS \ 139 { \ 140 {0U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U}, \ 141 {255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U} \ 142 } 143 144 /** @brief Calculate the supported eMios channels */ 145 #define EMIOS_PWM_IP_NUM_OF_CHANNELS_USED_U8 0 DT_INST_FOREACH_STATUS_OKAY(EMIOS_NUM_CHANNELS_USED) 146 147 #define EMIOS_PWM_IP_INITIAL_MODES \ 148 { \ 149 DT_INST_FOREACH_STATUS_OKAY(EMIOS_PWM_IP_SET_INITIAL_MODE) \ 150 } 151 152 /*================================================================================================== 153 * ENUMS 154 ==================================================================================================*/ 155 156 /*================================================================================================== 157 * STRUCTURES AND OTHER TYPEDEFS 158 ==================================================================================================*/ 159 /* Redefine eMIOS_Type from header file to comply with coding guidelines */ 160 typedef eMIOS_Type Emios_Pwm_Ip_HwAddrType; 161 /** 162 * @brief PWM Period type (the value of the period is platform dependent and thus configurable) 163 */ 164 typedef uint32 Emios_Pwm_Ip_PeriodType; 165 166 /** 167 * @brief PWM Duty type (the value of the period is platform dependent and thus configurable) 168 */ 169 typedef uint32 Emios_Pwm_Ip_DutyType; 170 171 /*================================================================================================== 172 * GLOBAL VARIABLE DECLARATIONS 173 ==================================================================================================*/ 174 175 /*================================================================================================== 176 * FUNCTION PROTOTYPES 177 ==================================================================================================*/ 178 179 180 #ifdef __cplusplus 181 } 182 #endif 183 184 /** @} */ 185 186 #endif /* EMIOS_PWM_IP_CFG_H */ 187 188