]> rtime.felk.cvut.cz Git - arc.git/blob - examples/pwm_node2/config/mpc5516it/Pwm_Cfg.h
Starting 'pdur2' branch with copied content from remote repository.
[arc.git] / examples / pwm_node2 / config / mpc5516it / Pwm_Cfg.h
1 /*\r
2 * Configuration of module: Pwm (Pwm_Cfg.h)\r
3 *\r
4 * Created by:              Arccore AB\r
5 * Copyright:               \r
6 *\r
7 * Configured for (MCU):    MPC551x\r
8 *\r
9 * Module vendor:           ArcCore\r
10 * Generator version:       2.0.1\r
11 *\r
12 * Generated by Arctic Studio (http://arccore.com) \r
13 *           on Thu Mar 10 09:37:44 CET 2011\r
14 */\r
15 \r
16
17 #if !(((PWM_SW_MAJOR_VERSION == 1) && (PWM_SW_MINOR_VERSION == 0)) )\r
18 #error Pwm: Configuration file expected BSW module version to be 1.0.*\r
19 #endif
20
21 \r
22 #ifndef PWM_CFG_H_\r
23 #define PWM_CFG_H_\r
24 \r
25 /****************************************************************************\r
26  * Global configuration options and defines\r
27  */\r
28 \r
29 #define ON 1\r
30 #define OFF 0\r
31 \r
32 // PWM003\r
33 #define PWM_DEV_EROR_DETECT ON\r
34 #define PWM_NOTIFICATION_SUPPORTED OFF\r
35 \r
36 // PWM132. Currently only ON is supported.\r
37 #define PWM_DUTYCYCLE_UPDATED_ENDPERIOD ON\r
38 #define PWM_PERIOD_UPDATED_ENDPERIOD ON\r
39 \r
40 // Define what functions to enable.\r
41 #define PWM_GET_OUTPUT_STATE ON\r
42 #define PWM_SET_PERIOD_AND_DUTY ON\r
43 #define PWM_DEINIT ON\r
44 #define PWM_DUTYCYCLE ON\r
45 #define PWM_SET_OUTPUT_TO_IDLE ON\r
46 #define PWM_VERSION_INFO_API ON\r
47 \r
48 \r
49 \r
50 \r
51 /****************************************************************************\r
52  * Not defined in AUTOSAR.\r
53  */\r
54 #define PWM_ISR_PRIORITY 1\r
55 #define PWM_PRESCALER 1\r
56 \r
57 /*\r
58  * Setting to ON freezes the current output state of a PWM channel when in\r
59  * debug mode.\r
60  */\r
61 #define PWM_FREEZE_ENABLE ON\r
62 \r
63 /****************************************************************************\r
64  * Enumeration of channels\r
65  * Maps a symbolic name to a hardware channel\r
66  */\r
67 typedef enum {\r
68         PWM_CHANNEL_1 = 13,\r
69     PWM_NUMBER_OF_CHANNELS = 1\r
70 } Pwm_NamedChannelsType;\r
71 \r
72 \r
73 \r
74 /*\r
75  * PWM106: This is implementation specific but not all values may be valid\r
76  * within the type. This shall be chosen in order to have the most efficient\r
77  * implementation on a specific microcontroller platform.\r
78  *\r
79  * PWM106 => Pwm_ChannelType == eemios channel id.\r
80  */\r
81 typedef uint8 Pwm_ChannelType;\r
82 \r
83 /*\r
84  * PWM070: All time units used within the API services of the PWM module shall\r
85  * be of the unit ticks.\r
86  */\r
87 typedef uint16 Pwm_PeriodType;\r
88 \r
89 typedef enum {\r
90         PWM_CHANNEL_PRESCALER_1=0,\r
91         PWM_CHANNEL_PRESCALER_2,\r
92         PWM_CHANNEL_PRESCALER_3,\r
93         PWM_CHANNEL_PRESCALER_4,\r
94 } Pwm_ChannelPrescalerType;\r
95 \r
96 /*\r
97  * Since the AUTOSAR PWM specification uses a different unit for the duty,\r
98  * the following macro can be used to convert between that format and the\r
99  * mpc5516 format.\r
100  */\r
101 #define DUTY_AND_PERIOD(_duty,_period) .duty = (_duty*_period)>>15, .period = _period\r
102 \r
103 #if defined(CFG_MPC5516)\r
104         /* Mode is buffered PWM output (OPWM) */\r
105         /* Mode is buffered Output PW and frequency modulation mode */\r
106 #define PWM_EMIOS_OPWM 0x5A\r
107 #elif defined(CFG_MPC5567)\r
108         /* Mode is buffered OPWM with frequency modulation (allows change of\r
109          * period) */\r
110 #define PWM_EMIOS_OPWM 0x19\r
111 #endif\r
112 \r
113 \r
114 typedef struct {\r
115         /* Number of duty ticks */\r
116         uint32_t                 duty:32;\r
117         /* Length of period, in ticks */\r
118         uint32_t                 period:32;\r
119         /* Counter */\r
120         uint32_t                 counter:32;\r
121         /* Enable freezing the channel when in debug mode */\r
122         uint32_t                 freezeEnable:1;\r
123         /* Disable output */\r
124         uint32_t                 outputDisable:1;\r
125         /* Select which bus disables the bus\r
126          * TODO: Figure out how this works, i.e. what bus does it refer to? */\r
127         uint32_t                                 outputDisableSelect:2;\r
128         /* Prescale the emios clock some more? */\r
129         Pwm_ChannelPrescalerType prescaler:2;\r
130         /* Prescale the emios clock some more? */\r
131         uint32_t                                 usePrescaler:1;\r
132         /* Whether to use DMA. Currently unsupported */\r
133         uint32_t                                 useDma:1;\r
134         uint32_t                                 reserved_2:1;\r
135         /* Input filter. Ignored in output mode. */\r
136         uint32_t                                 inputFilter:4;\r
137         /* Input filter clock source. Ignored in output mode */\r
138         uint32_t                                 filterClockSelect:1;\r
139         /* Enable interrupts/flags on this channel? Required for DMA as well. */\r
140         uint32_t                                 flagEnable:1;\r
141         uint32_t                                 reserved_3:3;\r
142         /* Trigger a match on channel A */\r
143         uint32_t                                 forceMatchA:1;\r
144         /* Triggers a match on channel B */\r
145         uint32_t                                 forceMatchB:1;\r
146         uint32_t                                 reserved_4:1;\r
147         /* We can use different buses for the counter. Use the internal counter */\r
148         uint32_t                                 busSelect:2;\r
149         /* What edges to flag on? */\r
150         uint32_t                                 edgeSelect:1;\r
151         /* Polarity of the channel */\r
152         uint32_t                                 edgePolarity:1;\r
153         /* EMIOS mode. 0x58 for buffered output PWM */\r
154         uint32_t                                 mode:7;\r
155 } Pwm_ChannelRegisterType;\r
156 \r
157 typedef struct {\r
158         Pwm_ChannelRegisterType r;\r
159         Pwm_ChannelType channel;\r
160 } Pwm_ChannelConfigurationType;\r
161 \r
162 \r
163 typedef struct {\r
164         Pwm_ChannelConfigurationType Channels[PWM_NUMBER_OF_CHANNELS];\r
165 #if PWM_NOTIFICATION_SUPPORTED==STD_ON\r
166         Pwm_NotificationHandlerType NotificationHandlers[PWM_NUMBER_OF_CHANNELS];\r
167 #endif\r
168 } Pwm_ConfigType;\r
169 \r
170 // Channel configuration macro.\r
171 #define PWM_CHANNEL_CONFIG(_hwchannel, _period, _duty, _prescaler, _polarity) \\r
172     {\\r
173         .channel = _hwchannel,\\r
174         .r = {\\r
175             DUTY_AND_PERIOD(_duty, _period),\\r
176             .freezeEnable = 1,\\r
177             .outputDisable = 0,\\r
178             .usePrescaler = 1,\\r
179             .prescaler = _prescaler,\\r
180             .useDma = 0,\\r
181             .flagEnable = 0, /* See PWM052 */ \\r
182             .busSelect = 3, /* Use the internal counter bus */\\r
183             .edgePolarity = _polarity,\\r
184             .mode = PWM_EMIOS_OPWM\\r
185         }\\r
186     }\r
187 \r
188 #endif /* PWM_CFG_H_ */\r