CaptureCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018, 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  *******************************************************************************
56  */
57 #ifndef ti_drivers_capture_CaptureCC32XX__include
58 #define ti_drivers_capture_CaptureCC32XX__include
59 
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
65 #include <stdbool.h>
66 #include <stdint.h>
67 
68 #include <ti/drivers/Capture.h>
69 #include <ti/drivers/Power.h>
70 #include <ti/drivers/dpl/HwiP.h>
71 #include <ti/devices/cc32xx/inc/hw_ints.h>
72 #include <ti/devices/cc32xx/inc/hw_ocp_shared.h>
73 
75 /*
76  * Capture port/pin defines for pin configuration.
77  *
78  * The timer id (0, 1, 2, or 3) is stored in bits 31 - 30
79  * The timer half (1 = A, 2 = B) is stored in bits 29 - 28
80  * The interrupt number is stored in bits 27 - 20
81  * The GPIO port (0, 1, 2, or 3) is stored in bits 19 - 16
82  * The GPIO pad offset is stored in bits 15 - 4
83  * The pin mode is stored in bits 3 - 0
84  *
85  * 31 - 30 29 - 28 27 - 20 19 - 16 15 - 4 3 - 0
86  * --------------------------------------------------------------------------
87  * | TimerId | Timer half | IntNum | GPIO Port | GPIO Pad Offset | Pin Mode |
88  * --------------------------------------------------------------------------
89  *
90  * The CC32XX has fixed GPIO assignments and pin modes for a given pin.
91  * A Capture pin mode for a given pin has a fixed timer/timer-half.
92  */
93 #define CaptureCC32XX_T0A (0x10000000 | (INT_TIMERA0A << 20))
94 #define CaptureCC32XX_T0B (0x20000000 | (INT_TIMERA0B << 20))
95 #define CaptureCC32XX_T1A (0x50000000 | (INT_TIMERA1A << 20))
96 #define CaptureCC32XX_T1B (0x60000000 | (INT_TIMERA1B << 20))
97 #define CaptureCC32XX_T2A (0x90000000 | (INT_TIMERA2A << 20))
98 #define CaptureCC32XX_T2B (0xA0000000 | (INT_TIMERA2B << 20))
99 #define CaptureCC32XX_T3A (0xD0000000 | (INT_TIMERA3A << 20))
100 #define CaptureCC32XX_T3B (0xE0000000 | (INT_TIMERA3B << 20))
101 
102 #define CaptureCC32XX_GPIO0 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_0 << 4))
103 #define CaptureCC32XX_GPIO1 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_1 << 4))
104 #define CaptureCC32XX_GPIO2 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_2 << 4))
105 #define CaptureCC32XX_GPIO5 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_5 << 4))
106 #define CaptureCC32XX_GPIO6 (0x00000000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_6 << 4))
107 #define CaptureCC32XX_GPIO8 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_8 << 4))
108 #define CaptureCC32XX_GPIO9 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_9 << 4))
109 #define CaptureCC32XX_GPIO10 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_10 << 4))
110 #define CaptureCC32XX_GPIO11 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_11 << 4))
111 #define CaptureCC32XX_GPIO12 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_12 << 4))
112 #define CaptureCC32XX_GPIO13 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_13 << 4))
113 #define CaptureCC32XX_GPIO14 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_14 << 4))
114 #define CaptureCC32XX_GPIO15 (0x00010000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_15 << 4))
115 #define CaptureCC32XX_GPIO16 (0x00020000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_16 << 4))
116 #define CaptureCC32XX_GPIO22 (0x00020000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_22 << 4))
117 #define CaptureCC32XX_GPIO24 (0x00030000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_24 << 4))
118 #define CaptureCC32XX_GPIO30 (0x00030000 | (OCP_SHARED_O_GPIO_PAD_CONFIG_30 << 4))
119 
130 #define CaptureCC32XX_PIN_01 CaptureCC32XX_T0B | CaptureCC32XX_GPIO10 | 0xC
136 #define CaptureCC32XX_PIN_02 CaptureCC32XX_T1A | CaptureCC32XX_GPIO11 | 0xC
142 #define CaptureCC32XX_PIN_03 CaptureCC32XX_T1B | CaptureCC32XX_GPIO12 | 0xC
148 #define CaptureCC32XX_PIN_04 CaptureCC32XX_T2A | CaptureCC32XX_GPIO13 | 0xC
154 #define CaptureCC32XX_PIN_05 CaptureCC32XX_T2B | CaptureCC32XX_GPIO14 | 0xC
160 #define CaptureCC32XX_PIN_06 CaptureCC32XX_T3A | CaptureCC32XX_GPIO15 | 0xD
166 #define CaptureCC32XX_PIN_07 CaptureCC32XX_T3B | CaptureCC32XX_GPIO16 | 0xD
172 #define CaptureCC32XX_PIN_15 CaptureCC32XX_T2A | CaptureCC32XX_GPIO22 | 0x5
178 #define CaptureCC32XX_PIN_17 CaptureCC32XX_T3A | CaptureCC32XX_GPIO24 | 0x4
184 #define CaptureCC32XX_PIN_50 CaptureCC32XX_T0A | CaptureCC32XX_GPIO0 | 0x7
190 #define CaptureCC32XX_PIN_53 CaptureCC32XX_T2B | CaptureCC32XX_GPIO30 | 0x4
196 #define CaptureCC32XX_PIN_55 CaptureCC32XX_T0B | CaptureCC32XX_GPIO1 | 0x7
202 #define CaptureCC32XX_PIN_57 CaptureCC32XX_T1A | CaptureCC32XX_GPIO2 | 0x7
208 #define CaptureCC32XX_PIN_60 CaptureCC32XX_T2B | CaptureCC32XX_GPIO5 | 0x7
214 #define CaptureCC32XX_PIN_61 CaptureCC32XX_T3A | CaptureCC32XX_GPIO6 | 0x7
220 #define CaptureCC32XX_PIN_63 CaptureCC32XX_T3A | CaptureCC32XX_GPIO8 | 0xC
226 #define CaptureCC32XX_PIN_64 CaptureCC32XX_T0A | CaptureCC32XX_GPIO9 | 0xC
230 extern const Capture_FxnTable CaptureCC32XX_fxnTable;
231 
253 typedef struct CaptureCC32XX_HWAttrs_ {
259  uint32_t capturePin;
260 
262  uint32_t intPriority;
264 
270 typedef struct CaptureCC32XX_Object_ {
271  HwiP_Handle hwiHandle;
275  uint32_t mode;
276  uint32_t timer;
277  uint32_t previousCount;
278  bool isRunning;
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 
285 #endif /* ti_drivers_capture_CaptureCC32XX__include */
bool isRunning
Definition: CaptureCC32XX.h:278
uint32_t previousCount
Definition: CaptureCC32XX.h:277
Power Manager.
CaptureCC32XX_Object.
Definition: CaptureCC32XX.h:270
struct CaptureCC32XX_Object_ CaptureCC32XX_Object
CaptureCC32XX_Object.
HwiP_Handle hwiHandle
Definition: CaptureCC32XX.h:271
Capture_PeriodUnits periodUnits
Definition: CaptureCC32XX.h:274
Capture_PeriodUnits
Capture period unit enum.
Definition: Capture.h:212
struct CaptureCC32XX_HWAttrs_ CaptureCC32XX_HWAttrs
CaptureCC32XX Hardware Attributes.
Power_NotifyObj notifyObj
Definition: CaptureCC32XX.h:272
uint32_t intPriority
Definition: CaptureCC32XX.h:262
Power notify object structure.
Definition: Power.h:443
uint32_t timer
Definition: CaptureCC32XX.h:276
void(* Capture_CallBackFxn)(Capture_Handle handle, uint32_t interval)
Capture callback function.
Definition: Capture.h:233
uint32_t mode
Definition: CaptureCC32XX.h:275
CaptureCC32XX Hardware Attributes.
Definition: CaptureCC32XX.h:253
Capture_CallBackFxn callBack
Definition: CaptureCC32XX.h:273
Capture Driver.
uint32_t capturePin
Definition: CaptureCC32XX.h:259
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale