1 /* 2 * Copyright 2023 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 "S32K344_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 3 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 Pwm_EnvCfg 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 Pwm_EnvCfg 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 ((DT_INST_FOREACH_STATUS_OKAY(EMIOS_NUM_CHANNELS_USED)) || 0) 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 (5U) 119 /** @brief Mapping between available channels and the PWM mode supported by each of them */ 120 #define EMIOS_PWM_IP_CHANNEL_MODES {\ 121 {0x00C101FFUL, 0x000000FEUL, 0x00FFFFFFUL, 0x00FFFFFFUL, 0x0000FEFEUL},\ 122 {0x00C10101UL, 0x00000000UL, 0x00FFFFFFUL, 0x00FFFFFFUL, 0x0000FEFEUL},\ 123 {0x00C10101UL, 0x00000000UL, 0x00FFFFFFUL, 0x00FFFFFFUL, 0x0000FEFEUL},\ 124 } 125 /** @brief Min counter value for PWM modes */ 126 #define EMIOS_PWM_IP_MIN_CNT_VAL (0x0001UL) 127 /** @brief Max counter value for PWM modes */ 128 #define EMIOS_PWM_IP_MAX_CNT_VAL (0xFFFFUL) 129 130 /** @brief Counter bus channel number */ 131 #define EMIOS_PWM_IP_COUNTER_BUS_A (23U) 132 #define EMIOS_PWM_IP_COUNTER_BUS_BCDE (248U) 133 #define EMIOS_PWM_IP_COUNTER_BUS_F (22U) 134 135 /** @brief Arrays to store the channel logic Index State */ 136 #define EMIOS_PWM_IP_USED_CHANNELS {\ 137 {255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U}, \ 138 {255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U}, \ 139 {255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U} \ 140 } 141 142 #define EMIOS_PWM_IP_NUM_OF_CHANNELS_USED 0 DT_INST_FOREACH_STATUS_OKAY(EMIOS_NUM_CHANNELS_USED) 143 144 #define EMIOS_PWM_IP_INITIAL_MODES \ 145 { \ 146 DT_INST_FOREACH_STATUS_OKAY(EMIOS_PWM_IP_SET_INITIAL_MODE) \ 147 } 148 149 /*================================================================================================== 150 * ENUMS 151 ==================================================================================================*/ 152 153 /*================================================================================================== 154 * STRUCTURES AND OTHER TYPEDEFS 155 ==================================================================================================*/ 156 /* Redefine eMIOS_Type from header file to comply with coding guidelines */ 157 typedef eMIOS_Type Emios_Pwm_Ip_HwAddrType; 158 /** 159 * @brief PWM Period type (the value of the period is platform dependent and thus configurable) 160 */ 161 typedef uint16 Emios_Pwm_Ip_PeriodType; 162 163 /** 164 * @brief PWM Duty type (the value of the period is platform dependent and thus configurable) 165 */ 166 typedef uint16 Emios_Pwm_Ip_DutyType; 167 168 /*================================================================================================== 169 * GLOBAL VARIABLE DECLARATIONS 170 ==================================================================================================*/ 171 172 /*================================================================================================== 173 * FUNCTION PROTOTYPES 174 ==================================================================================================*/ 175 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 /** @} */ 182 183 #endif /* EMIOS_PWM_IP_CFG_H */