]> rtime.felk.cvut.cz Git - arc.git/blob - include/Pwm.h
Dcm, Dynamic DIDs should be excluded in lookupDid.
[arc.git] / include / Pwm.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 /** @addtogroup Pwm PWM Driver\r
17  *  @{ */\r
18 \r
19 /** @file Pwm.h\r
20  * API and type definitions for PWM Driver.\r
21  */\r
22 \r
23 #ifndef PWM_H_\r
24 #define PWM_H_\r
25 \r
26 #define PWM_SW_MAJOR_VERSION    1\r
27 #define PWM_SW_MINOR_VERSION    2\r
28 #define PWM_SW_PATCH_VERSION    0\r
29 \r
30 /*\r
31  * PWM094: Std_VersionInfoType shall be imported from Std_Types.h\r
32  */\r
33 #include "Std_Types.h"\r
34 \r
35 /*\r
36  * PWM003: The detection of development errors is configurable (ON/OFF) at pre-\r
37  * compile time. The switch PwmDevErorDetect shall activate or deactivate the\r
38  * detection of all development errors.\r
39  *\r
40  * PWM064: If the PwmDevErorDetect switch is enabled, API parameter checking is\r
41  * enabled.\r
42  *\r
43  * PWM078: Detected development errors shall be reported to the Det_ReportError\r
44  * service of the Development Error Tracer (DET) if the pre-processor\r
45  * PwmDevErorDetect is set.\r
46  */\r
47 #if PWM_DEV_ERROR_DETECT==STD_ON\r
48 #       define Pwm_ReportError(ErrorId) Det_ReportError( MODULE_ID_PWM, 0, 0, ErrorId);\r
49 #else\r
50 #   define Pwm_ReportError(ErrorId)\r
51 #endif\r
52 \r
53 \r
54 /**************************************************************\r
55  *  Type definitions\r
56  **************************************************************/\r
57 /** PWM002: Development error values are of type uint8 */\r
58 typedef uint8 Pwm_ErrorType;\r
59 \r
60 /**\r
61  * PWM058: The width of the duty cycle parameter is 16 bits\r
62  *\r
63  * PWM059: The PWM module shall comply with the following scaling scheme\r
64  * for the duty cycle:\r
65  * 0x0    =   0%,\r
66  * 0x8000 = 100% */\r
67 typedef uint16 Pwm_DutyCycleType;\r
68 \r
69 #define Pwm_100_Procent         0x8000\r
70 #define Pwm_0_Procent           0\r
71 \r
72 \r
73 typedef enum {\r
74         PWM_LOW,\r
75         PWM_HIGH\r
76 } Pwm_OutputStateType;\r
77 \r
78 typedef enum {\r
79         PWM_FALLING_EDGE = PWM_LOW,\r
80         PWM_RISING_EDGE =  PWM_HIGH,\r
81         PWM_BOTH_EDGES\r
82 } Pwm_EdgeNotificationType;\r
83 \r
84 #define PWM_NO_EDGES (PWM_BOTH_EDGES + 1)\r
85 \r
86 typedef enum {\r
87         PWM_VARIABLE_PERIOD,\r
88         PWM_FIXED_PERIOD,\r
89         PWM_FIXED_PERIOD_SHIFTED\r
90 } Pwm_ChannelClassType;\r
91 \r
92 typedef void (*Pwm_NotificationHandlerType)();\r
93 \r
94 #include "Pwm_Cfg.h"\r
95 \r
96 extern const Pwm_ConfigType PwmConfig;\r
97 \r
98 /*\r
99  * With MPC551x, only the first 16 eMIOS channels are of the usable class for\r
100  * hardware PWM.\r
101  */\r
102 #if PWM_NUMBER_OF_CHANNELS > 16\r
103 #error "PWM_NUMBER_OF_CHANNELS is larger than supported by the target platform."\r
104 #endif\r
105 \r
106 #if PWM_DUTYCYCLE_UPDATED_ENDPERIOD!=STD_ON\r
107 #error "Unbuffered PWM currently not supported by this driver."\r
108 #endif\r
109 \r
110 /* DET errors that the PWM can produce. */\r
111 typedef enum\r
112 {\r
113   PWM_E_PARAM_CONFIG              = 0x10,\r
114   PWM_E_UNINIT,\r
115   PWM_E_PARAM_CHANNEL,\r
116   PWM_E_PERIOD_UNCHANGEABLE,\r
117   PWM_E_ALREADY_INITIALIZED\r
118 }Pwm_DetErrorType;\r
119 \r
120 /** API service ID's */\r
121 typedef enum\r
122 {\r
123           PWM_INIT_ID = 0x00,\r
124           PWM_DEINIT_ID,\r
125           PWM_SETDUTYCYCLE_ID,\r
126           PWM_SETPERIODANDDUTY_ID,\r
127           PWM_SETOUTPUTTOIDLE_ID,\r
128           PWM_GETOUTPUTSTATE_ID,\r
129           PWM_DISABLENOTIFICATION_ID,\r
130           PWM_ENABLENOTIFICATION_ID,\r
131           PWM_GETVERSIONINFO_ID,\r
132 }Pwm_APIServiceIDType;\r
133 \r
134 /*\r
135  * Implemented functions\r
136  ****************************/\r
137 #define PWM_MODULE_ID                   MODULE_ID_PWM\r
138 #define PWM_VENDOR_ID                   1\r
139 \r
140 #define PWM_AR_MAJOR_VERSION    2\r
141 #define PWM_AR_MINOR_VERSION    2\r
142 #define PWM_AR_PATCH_VERSION    1\r
143 \r
144 \r
145 #if ( PWM_VERSION_INFO_API == STD_ON)\r
146 #define Pwm_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,PWM)\r
147 #endif\r
148 \r
149 \r
150 void Pwm_Init(const Pwm_ConfigType* ConfigPtr);\r
151 void Pwm_DeInit();\r
152 \r
153 void Pwm_SetPeriodAndDuty(Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period,\r
154                 Pwm_DutyCycleType DutyCycle);\r
155 \r
156 void Pwm_SetDutyCycle(Pwm_ChannelType ChannelNumber, Pwm_DutyCycleType DutyCycle);\r
157 #if ( PWM_SET_OUTPUT_TO_IDLE_API == STD_ON ) || (PWM_DE_INIT_API==STD_ON)\r
158 void Pwm_SetOutputToIdle(Pwm_ChannelType ChannelNumber);\r
159 #endif\r
160 /*\r
161  * PWM085: The function Pwm_GetOutputState shall be pre compile configurable\r
162  * ON/OFF by the configuration parameter PwmGetOutputState\r
163  */\r
164 Pwm_OutputStateType Pwm_GetOutputState(Pwm_ChannelType ChannelNumber);\r
165 \r
166 /*\r
167  * PWM113: The function EnableNotification shall be pre compile configurable\r
168  * ON/OFF by the configuration parameter PwmNotificationSupported\r
169  *\r
170  * PWM112: The function DisableNotification shall be pre compile configurable\r
171  * ON/OFF by the configuration parameter PwmNotificationSupported\r
172  */\r
173 void Pwm_DisableNotification(Pwm_ChannelType ChannelNumber);\r
174 void Pwm_EnableNotification(Pwm_ChannelType ChannelNumber,\r
175                 Pwm_EdgeNotificationType Notification);\r
176 \r
177 #endif /* PWM_H_ */\r
178 /** @} */\r