PWMTimerCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
146 #ifndef ti_driver_pwm_PWMTimerCC32XX__include
147 #define ti_driver_pwm_PWMTimerCC32XX__include
148 
149 #ifdef __cplusplus
150 extern "C" {
151 #endif
152 
153 #include <stdbool.h>
154 #include <ti/drivers/PWM.h>
155 
157 /*
158  * PWMTimer port/pin defines for pin configuration.
159  *
160  * The timer id (0, 1, 2, or 3) is stored in bits 31 - 28
161  * The timer half (0 = A, 1 = B) is stored in bits 27 - 24
162  * The GPIO port (0, 1, 2, or 3) is stored in bits 23 - 20
163  * The GPIO pin index within the port (0 - 7) is stored in bits 19 - 16
164  * The pin mode is stored in bits 11 - 8
165  * The pin number is stored in bits 7 - 0
166  *
167  *
168  * 31 - 28 27 - 24 23 - 20 19 - 16 11 - 8 7 - 0
169  * -----------------------------------------------------------------------
170  * | Timer id | Timer half | GPIO port | GPIO pin index | pin mode | pin |
171  * -----------------------------------------------------------------------
172  *
173  * The CC32XX has fixed GPIO assignments and pin modes for a given pin.
174  * A PWM pin mode for a given pin has a fixed timer/timer-half.
175  */
176 #define PWMTimerCC32XX_T0A (0x00 << 24)
177 #define PWMTimerCC32XX_T0B (0x01 << 24)
178 #define PWMTimerCC32XX_T1A (0x10 << 24)
179 #define PWMTimerCC32XX_T1B (0x11 << 24)
180 #define PWMTimerCC32XX_T2A (0x20 << 24)
181 #define PWMTimerCC32XX_T2B (0x21 << 24)
182 #define PWMTimerCC32XX_T3A (0x30 << 24)
183 #define PWMTimerCC32XX_T3B (0x31 << 24)
184 
185 #define PWMTimerCC32XX_GPIO0 (0x00 << 16)
186 #define PWMTimerCC32XX_GPIO1 (0x01 << 16)
187 #define PWMTimerCC32XX_GPIO2 (0x02 << 16)
188 #define PWMTimerCC32XX_GPIO3 (0x03 << 16)
189 #define PWMTimerCC32XX_GPIO4 (0x04 << 16)
190 #define PWMTimerCC32XX_GPIO5 (0x05 << 16)
191 #define PWMTimerCC32XX_GPIO6 (0x06 << 16)
192 #define PWMTimerCC32XX_GPIO7 (0x07 << 16)
193 #define PWMTimerCC32XX_GPIO8 (0x10 << 16)
194 #define PWMTimerCC32XX_GPIO9 (0x11 << 16)
195 #define PWMTimerCC32XX_GPIO10 (0x12 << 16)
196 #define PWMTimerCC32XX_GPIO11 (0x13 << 16)
197 #define PWMTimerCC32XX_GPIO12 (0x14 << 16)
198 #define PWMTimerCC32XX_GPIO13 (0x15 << 16)
199 #define PWMTimerCC32XX_GPIO14 (0x16 << 16)
200 #define PWMTimerCC32XX_GPIO15 (0x17 << 16)
201 #define PWMTimerCC32XX_GPIO16 (0x20 << 16)
202 #define PWMTimerCC32XX_GPIO17 (0x21 << 16)
203 #define PWMTimerCC32XX_GPIO18 (0x22 << 16)
204 #define PWMTimerCC32XX_GPIO19 (0x23 << 16)
205 #define PWMTimerCC32XX_GPIO20 (0x24 << 16)
206 #define PWMTimerCC32XX_GPIO21 (0x25 << 16)
207 #define PWMTimerCC32XX_GPIO22 (0x26 << 16)
208 #define PWMTimerCC32XX_GPIO23 (0x27 << 16)
209 #define PWMTimerCC32XX_GPIO24 (0x30 << 16)
210 #define PWMTimerCC32XX_GPIO25 (0x31 << 16)
211 #define PWMTimerCC32XX_GPIO26 (0x32 << 16)
212 #define PWMTimerCC32XX_GPIO27 (0x33 << 16)
213 #define PWMTimerCC32XX_GPIO28 (0x34 << 16)
214 #define PWMTimerCC32XX_GPIO29 (0x35 << 16)
215 #define PWMTimerCC32XX_GPIO30 (0x36 << 16)
216 #define PWMTimerCC32XX_GPIO31 (0x37 << 16)
217 
218 #define PWMTimerCC32XX_GPIONONE (0xFF << 16)
219 
229 #define PWMTimerCC32XX_PIN_01 PWMTimerCC32XX_T3A | PWMTimerCC32XX_GPIO10 | 0x0300
235 #define PWMTimerCC32XX_PIN_02 PWMTimerCC32XX_T3B | PWMTimerCC32XX_GPIO11 | 0x0301
241 #define PWMTimerCC32XX_PIN_17 PWMTimerCC32XX_T0A | PWMTimerCC32XX_GPIO24 | 0x0510
247 #define PWMTimerCC32XX_PIN_19 PWMTimerCC32XX_T1B | PWMTimerCC32XX_GPIO_NONE | 0x0812
253 #define PWMTimerCC32XX_PIN_21 PWMTimerCC32XX_T1A | PWMTimerCC32XX_GPIO25 | 0x0914
259 #define PWMTimerCC32XX_PIN_64 PWMTimerCC32XX_T2B | PWMTimerCC32XX_GPIO9 | 0x033F
273 /* Add PWMTimerCC32XX_STATUS_* macros here */
274 
287 /* Add PWMTimerCC32XX_CMD_* macros here */
288 
291 /* PWM function table pointer */
293 
315 typedef struct PWMTimerCC32XX_HWAttrsV2 {
316  uint32_t pwmPin;
319 
325 typedef struct PWMTimerCC32XX_Object {
327  uint32_t duty; /* Current duty cycle in Duty_Unites */
328  uint32_t period; /* Current period PERIOD_Units */
329  PWM_Duty_Units dutyUnits; /* Current duty cycle unit */
330  PWM_Period_Units periodUnits; /* Current period unit */
331  PWM_IdleLevel idleLevel; /* PWM idle level when stopped / not started */
332  bool pwmStarted; /* Used to gate Power_set/releaseConstraint() calls */
333  bool isOpen; /* open flag used to check if PWM is opened */
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif /* ti_driver_pwm_PWMTimerCC32XX__include */
uint32_t duty
Definition: PWMTimerCC32XX.h:327
PWM_IdleLevel idleLevel
Definition: PWMTimerCC32XX.h:331
bool pwmStarted
Definition: PWMTimerCC32XX.h:332
Power notify object structure.
Definition: Power.h:113
bool isOpen
Definition: PWMTimerCC32XX.h:333
PWM driver interface.
uint32_t pwmPin
Definition: PWMTimerCC32XX.h:316
The definition of a PWM function table that contains the required set of functions to control a speci...
Definition: PWM.h:407
PWMTimerCC32XX Hardware attributes.
Definition: PWMTimerCC32XX.h:315
struct PWMTimerCC32XX_HWAttrsV2 PWMTimerCC32XX_HWAttrsV2
PWMTimerCC32XX Hardware attributes.
const PWM_FxnTable PWMTimerCC32XX_fxnTable
enum PWM_Period_Units_ PWM_Period_Units
PWM period unit definitions. Refer to device specific implementation if using PWM_PERIOD_COUNTS (raw ...
PWMTimerCC32XX Object.
Definition: PWMTimerCC32XX.h:325
enum PWM_IdleLevel_ PWM_IdleLevel
Idle output level when PWM is not running (stopped / not started).
uint32_t period
Definition: PWMTimerCC32XX.h:328
PWM_Period_Units periodUnits
Definition: PWMTimerCC32XX.h:330
struct PWMTimerCC32XX_Object PWMTimerCC32XX_Object
PWMTimerCC32XX Object.
Power_NotifyObj postNotify
Definition: PWMTimerCC32XX.h:326
PWM_Duty_Units dutyUnits
Definition: PWMTimerCC32XX.h:329
enum PWM_Duty_Units_ PWM_Duty_Units
PWM duty cycle unit definitions. Refer to device specific implementation if using PWM_DUTY_COUNTS (ra...
Copyright 2017, Texas Instruments Incorporated