CaptureCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019, 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  */
32 /*!*****************************************************************************
33  * @file CaptureCC32XX.h
34  * @brief Capture driver interface for CC32XX devices
35  *
36  * # Operation #
37  * This driver uses a general purpose timer hardware peripheral to implement
38  * the capture functionality. The capture driver only uses half of a timer
39  * peripheral (16-bit timer). This is not a software limitation but due to the
40  * general purpose timer hardware implementation. For CC32XX devices, the
41  * system clock is 80 MHz. A 16-bit timer peripheral has 24-bits of
42  * resolution when the prescaler register is used as an 8-bit linear extension.
43  *
44  * # Resource Allocation #
45  * Each general purpose timer block contains two timers, Timer A and Timer B,
46  * that can be configured to operate independently. This behavior is managed
47  * through a set of resource allocation APIs. For example, the
48  * TimerCC32XX_allocateTimerResource API will allocate a timer for exclusive
49  * use. Any attempt to re-allocate this resource by the TimerCC32XX, PWMCC32XX,
50  * or CaptureCC32xx drivers will result in a false value being returned from
51  * the allocation API. To free a timer resource, the
52  * TimerCC32XX_freeTimerResource is used. The application is not responsible
53  * for calling these allocation APIs directly.
54  *
55  * # Capture Modes #
56  * This device implementation only works with the following modes for
57  * #Capture_Mode :
58  * - #Capture_RISING_EDGE
59  * - #Capture_FALLING_EDGE
60  * - #Capture_ANY_EDGE
61  * All other modes will fail.
62  *******************************************************************************
63  */
64 #ifndef ti_drivers_capture_CaptureCC32XX__include
65 #define ti_drivers_capture_CaptureCC32XX__include
66 
67 #include <stdbool.h>
68 #include <stdint.h>
69 
70 #include <ti/drivers/Capture.h>
71 #include <ti/drivers/Power.h>
72 #include <ti/drivers/dpl/HwiP.h>
73 #include <ti/devices/cc32xx/inc/hw_ints.h>
74 #include <ti/devices/cc32xx/inc/hw_ocp_shared.h>
75 
76 #ifdef __cplusplus
77 extern "C"
78 {
79 #endif
80 
82 /*
83  * Capture port/pin defines for pin configuration.
84  *
85  * The timer id (0, 1, 2, or 3) is stored in bits 31 - 30
86  * The timer half (1 = A, 2 = B) is stored in bits 29 - 28
87  * The interrupt number is stored in bits 27 - 20
88  * The GPIO port (0, 1, 2, or 3) is stored in bits 19 - 16
89  * The GPIO pad offset is stored in bits 15 - 4
90  * The pin mode is stored in bits 3 - 0
91  *
92  * 31 - 30 29 - 28 27 - 20 19 - 16 15 - 4 3 - 0
93  * --------------------------------------------------------------------------
94  * | TimerId | Timer half | IntNum | GPIO Port | GPIO Pad Offset | Pin Mode |
95  * --------------------------------------------------------------------------
96  *
97  * The CC32XX has fixed GPIO assignments and pin modes for a given pin.
98  * A Capture pin mode for a given pin has a fixed timer/timer-half.
99  */
100 #define CaptureCC32XX_T0A (0x10000000 | (INT_TIMERA0A << 20))
101 #define CaptureCC32XX_T0B (0x20000000 | (INT_TIMERA0B << 20))
102 #define CaptureCC32XX_T1A (0x50000000 | (INT_TIMERA1A << 20))
103 #define CaptureCC32XX_T1B (0x60000000 | (INT_TIMERA1B << 20))
104 #define CaptureCC32XX_T2A (0x90000000 | (INT_TIMERA2A << 20))
105 #define CaptureCC32XX_T2B (0xA0000000 | (INT_TIMERA2B << 20))
106 #define CaptureCC32XX_T3A (0xD0000000 | (INT_TIMERA3A << 20))
107 #define CaptureCC32XX_T3B (0xE0000000 | (INT_TIMERA3B << 20))
108 
109 #define CaptureCC32XX_GPIO0 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_0 << 4))
110 #define CaptureCC32XX_GPIO1 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_1 << 4))
111 #define CaptureCC32XX_GPIO2 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_2 << 4))
112 #define CaptureCC32XX_GPIO5 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_5 << 4))
113 #define CaptureCC32XX_GPIO6 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_6 << 4))
114 #define CaptureCC32XX_GPIO8 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_8 << 4))
115 #define CaptureCC32XX_GPIO9 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_9 << 4))
116 #define CaptureCC32XX_GPIO10 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_10 << 4))
117 #define CaptureCC32XX_GPIO11 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_11 << 4))
118 #define CaptureCC32XX_GPIO12 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_12 << 4))
119 #define CaptureCC32XX_GPIO13 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_13 << 4))
120 #define CaptureCC32XX_GPIO14 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_14 << 4))
121 #define CaptureCC32XX_GPIO15 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_15 << 4))
122 #define CaptureCC32XX_GPIO16 (0x00020000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_16 << 4))
123 #define CaptureCC32XX_GPIO22 (0x00020000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_22 << 4))
124 #define CaptureCC32XX_GPIO24 (0x00030000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_24 << 4))
125 #define CaptureCC32XX_GPIO30 (0x00030000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_30 << 4))
126 
137 #define CaptureCC32XX_PIN_01 CaptureCC32XX_T0B | CaptureCC32XX_GPIO10 | 0xC
143 #define CaptureCC32XX_PIN_02 CaptureCC32XX_T1A | CaptureCC32XX_GPIO11 | 0xC
149 #define CaptureCC32XX_PIN_03 CaptureCC32XX_T1B | CaptureCC32XX_GPIO12 | 0xC
155 #define CaptureCC32XX_PIN_04 CaptureCC32XX_T2A | CaptureCC32XX_GPIO13 | 0xC
161 #define CaptureCC32XX_PIN_05 CaptureCC32XX_T2B | CaptureCC32XX_GPIO14 | 0xC
167 #define CaptureCC32XX_PIN_06 CaptureCC32XX_T3A | CaptureCC32XX_GPIO15 | 0xD
173 #define CaptureCC32XX_PIN_07 CaptureCC32XX_T3B | CaptureCC32XX_GPIO16 | 0xD
179 #define CaptureCC32XX_PIN_15 CaptureCC32XX_T2A | CaptureCC32XX_GPIO22 | 0x5
185 #define CaptureCC32XX_PIN_17 CaptureCC32XX_T3A | CaptureCC32XX_GPIO24 | 0x4
191 #define CaptureCC32XX_PIN_50 CaptureCC32XX_T0A | CaptureCC32XX_GPIO0 | 0x7
197 #define CaptureCC32XX_PIN_53 CaptureCC32XX_T2B | CaptureCC32XX_GPIO30 | 0x4
203 #define CaptureCC32XX_PIN_55 CaptureCC32XX_T0B | CaptureCC32XX_GPIO1 | 0x7
209 #define CaptureCC32XX_PIN_57 CaptureCC32XX_T1A | CaptureCC32XX_GPIO2 | 0x7
215 #define CaptureCC32XX_PIN_60 CaptureCC32XX_T2B | CaptureCC32XX_GPIO5 | 0x7
221 #define CaptureCC32XX_PIN_61 CaptureCC32XX_T3A | CaptureCC32XX_GPIO6 | 0x7
227 #define CaptureCC32XX_PIN_63 CaptureCC32XX_T3A | CaptureCC32XX_GPIO8 | 0xC
233 #define CaptureCC32XX_PIN_64 CaptureCC32XX_T0A | CaptureCC32XX_GPIO9 | 0xC
237 extern const Capture_FxnTable CaptureCC32XX_fxnTable;
238 
260 typedef struct {
266  uint32_t capturePin;
267 
269  uint32_t intPriority;
271 
277 typedef struct {
278  HwiP_Handle hwiHandle;
282  uint32_t mode;
283  uint32_t timer;
284  uint32_t previousCount;
285  bool isRunning;
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 
292 #endif /* ti_drivers_capture_CaptureCC32XX__include */
Power_NotifyObj notifyObj
Definition: CaptureCC32XX.h:279
Power Manager.
HwiP_Handle hwiHandle
Definition: CaptureCC32XX.h:278
uint32_t capturePin
Definition: CaptureCC32XX.h:266
Capture_PeriodUnits
Capture period unit enum.
Definition: Capture.h:221
uint32_t previousCount
Definition: CaptureCC32XX.h:284
CaptureCC32XX_Object.
Definition: CaptureCC32XX.h:277
Power notify object structure.
Definition: Power.h:443
uint32_t intPriority
Definition: CaptureCC32XX.h:269
uint32_t mode
Definition: CaptureCC32XX.h:282
void(* Capture_CallBackFxn)(Capture_Handle handle, uint32_t interval)
Capture callback function.
Definition: Capture.h:243
Capture_CallBackFxn callBack
Definition: CaptureCC32XX.h:280
bool isRunning
Definition: CaptureCC32XX.h:285
uint32_t timer
Definition: CaptureCC32XX.h:283
Capture Driver.
CaptureCC32XX Hardware Attributes.
Definition: CaptureCC32XX.h:260
Capture_PeriodUnits periodUnits
Definition: CaptureCC32XX.h:281
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale