1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\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
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
14 * -------------------------------- Arctic Core ------------------------------*/
\r
16 /** @addtogroup Pwm PWM Driver
\r
20 * API and type definitions for PWM Driver.
\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
31 * PWM094: Std_VersionInfoType shall be imported from Std_Types.h
\r
33 #include "Std_Types.h"
\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
40 * PWM064: If the PwmDevErorDetect switch is enabled, API parameter checking is
\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
47 #if PWM_DEV_ERROR_DETECT==STD_ON
\r
48 # define Pwm_ReportError(ErrorId) Det_ReportError( MODULE_ID_PWM, 0, 0, ErrorId);
\r
50 # define Pwm_ReportError(ErrorId)
\r
54 /**************************************************************
\r
56 **************************************************************/
\r
57 /** PWM002: Development error values are of type uint8 */
\r
58 typedef uint8 Pwm_ErrorType;
\r
61 * PWM058: The width of the duty cycle parameter is 16 bits
\r
63 * PWM059: The PWM module shall comply with the following scaling scheme
\r
64 * for the duty cycle:
\r
67 typedef uint16 Pwm_DutyCycleType;
\r
69 #define Pwm_100_Procent 0x8000
\r
70 #define Pwm_0_Procent 0
\r
76 } Pwm_OutputStateType;
\r
79 PWM_FALLING_EDGE = PWM_LOW,
\r
80 PWM_RISING_EDGE = PWM_HIGH,
\r
82 } Pwm_EdgeNotificationType;
\r
84 #define PWM_NO_EDGES (PWM_BOTH_EDGES + 1)
\r
87 PWM_VARIABLE_PERIOD,
\r
89 PWM_FIXED_PERIOD_SHIFTED
\r
90 } Pwm_ChannelClassType;
\r
92 typedef void (*Pwm_NotificationHandlerType)();
\r
94 #include "Pwm_Cfg.h"
\r
96 extern const Pwm_ConfigType PwmConfig;
\r
99 * With MPC551x, only the first 16 eMIOS channels are of the usable class for
\r
102 #if PWM_NUMBER_OF_CHANNELS > 16
\r
103 #error "PWM_NUMBER_OF_CHANNELS is larger than supported by the target platform."
\r
106 #if PWM_DUTYCYCLE_UPDATED_ENDPERIOD!=STD_ON
\r
107 #error "Unbuffered PWM currently not supported by this driver."
\r
110 /* DET errors that the PWM can produce. */
\r
113 PWM_E_PARAM_CONFIG = 0x10,
\r
115 PWM_E_PARAM_CHANNEL,
\r
116 PWM_E_PERIOD_UNCHANGEABLE,
\r
117 PWM_E_ALREADY_INITIALIZED
\r
120 /** API service ID's */
\r
123 PWM_INIT_ID = 0x00,
\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
135 * Implemented functions
\r
136 ****************************/
\r
137 #define PWM_MODULE_ID MODULE_ID_PWM
\r
138 #define PWM_VENDOR_ID 1
\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
145 #if ( PWM_VERSION_INFO_API == STD_ON)
\r
146 #define Pwm_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,PWM)
\r
150 void Pwm_Init(const Pwm_ConfigType* ConfigPtr);
\r
153 void Pwm_SetPeriodAndDuty(Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period,
\r
154 Pwm_DutyCycleType DutyCycle);
\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
161 * PWM085: The function Pwm_GetOutputState shall be pre compile configurable
\r
162 * ON/OFF by the configuration parameter PwmGetOutputState
\r
164 Pwm_OutputStateType Pwm_GetOutputState(Pwm_ChannelType ChannelNumber);
\r
167 * PWM113: The function EnableNotification shall be pre compile configurable
\r
168 * ON/OFF by the configuration parameter PwmNotificationSupported
\r
170 * PWM112: The function DisableNotification shall be pre compile configurable
\r
171 * ON/OFF by the configuration parameter PwmNotificationSupported
\r
173 void Pwm_DisableNotification(Pwm_ChannelType ChannelNumber);
\r
174 void Pwm_EnableNotification(Pwm_ChannelType ChannelNumber,
\r
175 Pwm_EdgeNotificationType Notification);
\r
177 #endif /* PWM_H_ */
\r