1 /*
2  * Copyright 2021-2024 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef EMIOS_PWM_IP_INIT_PBCFG_H
8 #define EMIOS_PWM_IP_INIT_PBCFG_H
9 
10 /**
11 *   @file       Emios_Pwm_Ip_Init_PBcfg.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 #include "Emios_Pwm_Ip_Types.h"
31 
32 /*==================================================================================================
33 *                                 SOURCE FILE VERSION INFORMATION
34 ==================================================================================================*/
35 #define EMIOS_PWM_IP_INIT_PB_CFG_VENDOR_ID                       43
36 #define EMIOS_PWM_IP_INIT_PB_CFG_MODULE_ID                       121
37 #define EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MAJOR_VERSION        4
38 #define EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MINOR_VERSION        7
39 #define EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_REVISION_VERSION     0
40 #define EMIOS_PWM_IP_INIT_PB_CFG_SW_MAJOR_VERSION                2
41 #define EMIOS_PWM_IP_INIT_PB_CFG_SW_MINOR_VERSION                0
42 #define EMIOS_PWM_IP_INIT_PB_CFG_SW_PATCH_VERSION                0
43 
44 /*==================================================================================================
45 *                                       FILE VERSION CHECKS
46 ==================================================================================================*/
47 /* Check if header file and Emios_Pwm_Ip_Types header file are of the same vendor */
48 #if (EMIOS_PWM_IP_INIT_PB_CFG_VENDOR_ID != EMIOS_PWM_IP_TYPES_VENDOR_ID)
49     #error "Vendor IDs of Emios_Pwm_Ip_Init_PBcfg.h and Emios_Pwm_Ip_Types.h are different."
50 #endif
51 
52 /* Check if header file and Emios_Pwm_Ip_Types header file are of the same AUTOSAR version */
53 #if ((EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MAJOR_VERSION    != EMIOS_PWM_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
54      (EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_MINOR_VERSION    != EMIOS_PWM_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
55      (EMIOS_PWM_IP_INIT_PB_CFG_AR_RELEASE_REVISION_VERSION != EMIOS_PWM_IP_TYPES_AR_RELEASE_REVISION_VERSION))
56     #error "AUTOSAR version numbers of Emios_Pwm_Ip_Init_PBcfg.h and Emios_Pwm_Ip_Types.h are different."
57 #endif
58 
59 /* Check if header file and Emios_Pwm_Ip_Types header file are of the same software version */
60 #if ((EMIOS_PWM_IP_INIT_PB_CFG_SW_MAJOR_VERSION != EMIOS_PWM_IP_TYPES_SW_MAJOR_VERSION) || \
61      (EMIOS_PWM_IP_INIT_PB_CFG_SW_MINOR_VERSION != EMIOS_PWM_IP_TYPES_SW_MINOR_VERSION) || \
62      (EMIOS_PWM_IP_INIT_PB_CFG_SW_PATCH_VERSION != EMIOS_PWM_IP_TYPES_SW_PATCH_VERSION))
63     #error "Software version numbers of Emios_Pwm_Ip_Init_PBcfg.h and Emios_Pwm_Ip_Types.h are different."
64 #endif
65 
66 /*==================================================================================================
67 *                                            CONSTANTS
68 ==================================================================================================*/
69 
70 #define DT_DRV_COMPAT                     nxp_s32_emios_pwm
71 
72 #define EMIOS_OPWFMB_MODE_USED(node_id)                                                    \
73             COND_CODE_1(DT_NODE_HAS_PROP(node_id, pwm_mode),                               \
74                        (DT_ENUM_HAS_VALUE(node_id, pwm_mode, OPWFMB)),                     \
75                        (0)) ||
76 
77 #define IS_EMIOS_OPWFMB_MODE_USED(n)                                                       \
78             DT_INST_FOREACH_CHILD_STATUS_OKAY(n, EMIOS_OPWFMB_MODE_USED)
79 
80 #define EMIOS_OPWMB_MODE_USED(node_id)                                                     \
81             COND_CODE_1(DT_NODE_HAS_PROP(node_id, pwm_mode),                               \
82                        (DT_ENUM_HAS_VALUE(node_id, pwm_mode, OPWMB)),                      \
83                        (0)) ||
84 
85 #define IS_EMIOS_OPWMB_MODE_USED(n)                                                        \
86             DT_INST_FOREACH_CHILD_STATUS_OKAY(n, EMIOS_OPWMB_MODE_USED)
87 
88 #define EMIOS_OPWMCB_MODE_USED(node_id)                                                    \
89             COND_CODE_1(DT_NODE_HAS_PROP(node_id, pwm_mode),                               \
90                        (DT_ENUM_HAS_VALUE(node_id, pwm_mode, OPWMCB_TRAIL_EDGE) ||         \
91                         DT_ENUM_HAS_VALUE(node_id, pwm_mode, OPWMCB_LEAD_EDGE)             \
92                         ),(0)) ||
93 
94 #define IS_EMIOS_OPWMCB_MODE_USED(n)                                                       \
95             DT_INST_FOREACH_CHILD_STATUS_OKAY(n, EMIOS_OPWMCB_MODE_USED)
96 
97 /* Macro to enable the mode operations. */
98 #if DT_INST_FOREACH_STATUS_OKAY(IS_EMIOS_OPWFMB_MODE_USED) 0
99 #define EMIOS_PWM_IP_MODE_OPWFMB_USED
100 #endif
101 
102 #if DT_INST_FOREACH_STATUS_OKAY(IS_EMIOS_OPWMB_MODE_USED) 0
103 #define EMIOS_PWM_IP_MODE_OPWMB_USED
104 #endif
105 
106 #if DT_INST_FOREACH_STATUS_OKAY(IS_EMIOS_OPWMCB_MODE_USED) 0
107 #define EMIOS_PWM_IP_MODE_OPWMCB_USED
108 #endif
109 
110 /*==================================================================================================
111 *                                       DEFINES AND MACROS
112 ==================================================================================================*/
113 
114 /*==================================================================================================
115 *                                              ENUMS
116 ==================================================================================================*/
117 
118 /*==================================================================================================
119 *                                  STRUCTURES AND OTHER TYPEDEFS
120 ==================================================================================================*/
121 
122 /*==================================================================================================
123 *                                  GLOBAL VARIABLE DECLARATIONS
124 ==================================================================================================*/
125 
126 /*==================================================================================================
127 *                                       FUNCTION PROTOTYPES
128 ==================================================================================================*/
129 
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 /** @} */
136 
137 #endif /* EMIOS_PWM_IP_INIT_PBCFG_H */
138 
139