MotorWare f2806x Driver API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

comp.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2015, 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 * --/COPYRIGHT--*/
32 #ifndef _COMP_H_
33 #define _COMP_H_
34
41
42
43 // **************************************************************************
44 // the includes
45
46 // drivers
47 #include "sw/drivers/cpu/src/32b/f28x/f2806x/cpu.h"
48
53
54
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60
61 // **************************************************************************
62 // the defines
63
64
67 #define COMP1_BASE_ADDR (0x00006400)
68
71 #define COMP2_BASE_ADDR (0x00006420)
72
75 #define COMP3_BASE_ADDR (0x00006440)
76
77
80 #define COMP_COMPCTL_COMPDACE_BITS (1 << 0)
81
84 #define COMP_COMPCTL_COMPSOURCE_BITS (1 << 1)
85
88 #define COMP_COMPCTL_CMPINV_BITS (1 << 2)
89
92 #define COMP_COMPCTL_QUALSEL_BITS (31 << 3)
93
96 #define COMP_COMPCTL_SYNCSEL_BITS (1 << 8)
97
98
101 #define COMP_COMPSTS_COMPSTS_BITS (1 << 0)
102
103
106 #define COMP_DACCTL_DACSOURCE_BITS (1 << 0)
107
110 #define COMP_DACCTL_RAMPSOURCE_BITS (15 << 1)
111
114 #define COMP_DACCTL_FREESOFT_BITS (3 << 14)
115
116
117 // **************************************************************************
118 // the typedefs
119
122 typedef enum
123 {
124 COMP_QualSel_Sync = (0 << 3),
125 COMP_QualSel_Qual_2 = (1 << 3),
126 COMP_QualSel_Qual_3 = (2 << 3),
127 COMP_QualSel_Qual_4 = (3 << 3),
128 COMP_QualSel_Qual_5 = (3 << 3),
129 COMP_QualSel_Qual_6 = (4 << 3),
130 COMP_QualSel_Qual_7 = (5 << 3),
131 COMP_QualSel_Qual_8 = (6 << 3),
132 COMP_QualSel_Qual_9 = (7 << 3),
133 COMP_QualSel_Qual_10 = (8 << 3),
134 COMP_QualSel_Qual_11 = (9 << 3),
135 COMP_QualSel_Qual_12 = (10 << 3),
136 COMP_QualSel_Qual_13 = (11 << 3),
137 COMP_QualSel_Qual_14 = (12 << 3),
138 COMP_QualSel_Qual_15 = (13 << 3),
139 COMP_QualSel_Qual_16 = (14 << 3),
140 COMP_QualSel_Qual_17 = (15 << 3),
141 COMP_QualSel_Qual_18 = (16 << 3),
142 COMP_QualSel_Qual_19 = (17 << 3),
143 COMP_QualSel_Qual_20 = (18 << 3),
144 COMP_QualSel_Qual_21 = (19 << 3),
145 COMP_QualSel_Qual_22 = (20 << 3),
146 COMP_QualSel_Qual_23 = (21 << 3),
147 COMP_QualSel_Qual_24 = (22 << 3),
148 COMP_QualSel_Qual_25 = (23 << 3),
149 COMP_QualSel_Qual_26 = (24 << 3),
150 COMP_QualSel_Qual_27 = (25 << 3),
151 COMP_QualSel_Qual_28 = (26 << 3),
152 COMP_QualSel_Qual_29 = (27 << 3),
153 COMP_QualSel_Qual_30 = (28 << 3),
154 COMP_QualSel_Qual_31 = (29 << 3),
155 COMP_QualSel_Qual_32 = (30 << 3),
156 COMP_QualSel_Qual_33 = (31 << 3)
157 } COMP_QualSel_e;
158
159
162 typedef enum
163 {
164 COMP_RampSyncSrc_PWMSYNC1 = (0 << 1),
165 COMP_RampSyncSrc_PWMSYNC2 = (1 << 1),
166 COMP_RampSyncSrc_PWMSYNC3 = (2 << 1),
167 COMP_RampSyncSrc_PWMSYNC4 = (3 << 1)
168 } COMP_RampSyncSrc_e;
169
170
173 typedef struct _COMP_Obj_
174 {
175 volatile uint16_t COMPCTL;
176 volatile uint16_t rsvd_1;
177 volatile uint16_t COMPSTS;
178 volatile uint16_t rsvd_2;
179 volatile uint16_t DACCTL;
180 volatile uint16_t rsvd_3;
181 volatile uint16_t DACVAL;
182 volatile uint16_t rsvd_4;
183 volatile uint16_t RAMPMAXREF_ACTIVE;
184 volatile uint16_t rsvd_5;
185 volatile uint16_t RAMPMAXREF_SHADOW;
186 volatile uint16_t rsvd_6;
187 volatile uint16_t RAMPDECVAL_ACTIVE;
188 volatile uint16_t rsvd_7;
189 volatile uint16_t RAMPDECVAL_SHADOW;
190 volatile uint16_t rsvd_8;
191 volatile uint16_t RAMPSTS;
192 } COMP_Obj;
193
194
197 typedef struct _COMP_Obj_ *COMP_Handle;
198
199
200 // **************************************************************************
201 // the globals
202
203
204 // **************************************************************************
205 // the function prototypes
206
209 extern void COMP_disable(COMP_Handle compHandle);
210
211
214 extern void COMP_disableDac(COMP_Handle compHandle);
215
216
219 extern void COMP_enable(COMP_Handle compHandle);
220
221
224 extern void COMP_enableDac(COMP_Handle compHandle);
225
226
231 extern COMP_Handle COMP_init(void *pMemory, const size_t numBytes);
232
233
237 static inline void COMP_setDacValue(COMP_Handle compHandle, uint16_t dacValue)
238 {
239 COMP_Obj *comp = (COMP_Obj *)compHandle;
240
241 comp->DACVAL = dacValue;
242
243 return;
244 }
245
246
247 #ifdef __cplusplus
248 }
249 #endif // extern "C"
250
252 #endif // end of _COMP_H_ definition
253
_COMP_Obj_::RAMPSTS
volatile uint16_t RAMPSTS
Ramp Generator Status.
Definition: comp.h:191
COMP_QualSel_Qual_8
Qualify comparator output with 8 cycles.
Definition: comp.h:131
_COMP_Obj_::rsvd_5
volatile uint16_t rsvd_5
Reserved.
Definition: comp.h:184
COMP_QualSel_Qual_6
Qualify comparator output with 6 cycles.
Definition: comp.h:129
COMP_QualSel_Qual_11
Qualify comparator output with 11 cycles.
Definition: comp.h:134
COMP_QualSel_Qual_14
Qualify comparator output with 14 cycles.
Definition: comp.h:137
COMP_QualSel_Qual_27
Qualify comparator output with 27 cycles.
Definition: comp.h:150
COMP_disable
void COMP_disable(COMP_Handle compHandle)
Disables the comparator (COMP)
Definition: comp.c:60
COMP_disableDac
void COMP_disableDac(COMP_Handle compHandle)
Disables the DAC.
Definition: comp.c:75
COMP_setDacValue
static void COMP_setDacValue(COMP_Handle compHandle, uint16_t dacValue)
Sets the DAC's value.
Definition: comp.h:237
COMP_enableDac
void COMP_enableDac(COMP_Handle compHandle)
Enables the DAC.
Definition: comp.c:105
_COMP_Obj_::rsvd_3
volatile uint16_t rsvd_3
Reserved.
Definition: comp.h:180
COMP_QualSel_Qual_5
Qualify comparator output with 5 cycles.
Definition: comp.h:128
COMP_QualSel_Qual_32
Qualify comparator output with 32 cycles.
Definition: comp.h:155
COMP_QualSel_Qual_22
Qualify comparator output with 22 cycles.
Definition: comp.h:145
COMP_QualSel_Qual_31
Qualify comparator output with 31 cycles.
Definition: comp.h:154
COMP_QualSel_Qual_28
Qualify comparator output with 28 cycles.
Definition: comp.h:151
COMP_QualSel_Qual_2
Qualify comparator output with 2 cycles.
Definition: comp.h:125
_COMP_Obj_::DACVAL
volatile uint16_t DACVAL
DAC Value Register.
Definition: comp.h:181
_COMP_Obj_::RAMPMAXREF_SHADOW
volatile uint16_t RAMPMAXREF_SHADOW
Ramp Generator Maximum Reference (Shadow)
Definition: comp.h:185
COMP_QualSel_Sync
Synchronize comparator output.
Definition: comp.h:124
_COMP_Obj_::rsvd_8
volatile uint16_t rsvd_8
Reserved.
Definition: comp.h:190
COMP_QualSel_Qual_33
Qualify comparator output with 33 cycles.
Definition: comp.h:156
COMP_QualSel_Qual_15
Qualify comparator output with 15 cycles.
Definition: comp.h:138
_COMP_Obj_::rsvd_7
volatile uint16_t rsvd_7
Reserved.
Definition: comp.h:188
_COMP_Obj_::COMPSTS
volatile uint16_t COMPSTS
COMP Status Register.
Definition: comp.h:177
COMP_RampSyncSrc_PWMSYNC2
PWMSync2 used as Ramp Sync.
Definition: comp.h:165
_COMP_Obj_::rsvd_2
volatile uint16_t rsvd_2
Reserved.
Definition: comp.h:178
COMP_enable
void COMP_enable(COMP_Handle compHandle)
Enables the comparator (COMP)
Definition: comp.c:90
COMP_QualSel_Qual_12
Qualify comparator output with 12 cycles.
Definition: comp.h:135
COMP_QualSel_Qual_9
Qualify comparator output with 9 cycles.
Definition: comp.h:132
_COMP_Obj_::rsvd_1
volatile uint16_t rsvd_1
Reserved.
Definition: comp.h:176
COMP_QualSel_Qual_20
Qualify comparator output with 20 cycles.
Definition: comp.h:143
COMP_RampSyncSrc_PWMSYNC3
PWMSync3 used as Ramp Sync.
Definition: comp.h:166
COMP_QualSel_Qual_7
Qualify comparator output with 7 cycles.
Definition: comp.h:130
_COMP_Obj_::RAMPMAXREF_ACTIVE
volatile uint16_t RAMPMAXREF_ACTIVE
Ramp Generator Maxmimum Reference (Active)
Definition: comp.h:183
COMP_QualSel_Qual_29
Qualify comparator output with 29 cycles.
Definition: comp.h:152
COMP_QualSel_Qual_16
Qualify comparator output with 16 cycles.
Definition: comp.h:139
_COMP_Obj_::rsvd_4
volatile uint16_t rsvd_4
Reserved.
Definition: comp.h:182
cpu.h
Contains public interface to various functions related to the central processing unit (CPU) object...
_COMP_Obj_
Defines the comparator (COMP) object.
Definition: comp.h:173
COMP_QualSel_Qual_26
Qualify comparator output with 26 cycles.
Definition: comp.h:149
COMP_QualSel_Qual_21
Qualify comparator output with 21 cycles.
Definition: comp.h:144
COMP_QualSel_Qual_4
Qualify comparator output with 4 cycles.
Definition: comp.h:127
_COMP_Obj_::COMPCTL
volatile uint16_t COMPCTL
COMP Control Register.
Definition: comp.h:175
COMP_Obj
struct _COMP_Obj_ COMP_Obj
Defines the comparator (COMP) object.
COMP_QualSel_Qual_3
Qualify comparator output with 3 cycles.
Definition: comp.h:126
COMP_Handle
struct _COMP_Obj_ * COMP_Handle
Defines the comparator (COMP) handle.
Definition: comp.h:197
COMP_RampSyncSrc_e
COMP_RampSyncSrc_e
Enumeration to define the comparator (COMP) ramp generator sync source.
Definition: comp.h:162
COMP_QualSel_Qual_17
Qualify comparator output with 17 cycles.
Definition: comp.h:140
COMP_QualSel_Qual_30
Qualify comparator output with 30 cycles.
Definition: comp.h:153
COMP_QualSel_Qual_18
Qualify comparator output with 18 cycles.
Definition: comp.h:141
_COMP_Obj_::RAMPDECVAL_ACTIVE
volatile uint16_t RAMPDECVAL_ACTIVE
Ramp Generator Decrement Value (Active)
Definition: comp.h:187
COMP_QualSel_Qual_24
Qualify comparator output with 24 cycles.
Definition: comp.h:147
COMP_QualSel_Qual_10
Qualify comparator output with 10 cycles.
Definition: comp.h:133
_COMP_Obj_::DACCTL
volatile uint16_t DACCTL
DAC Control Register.
Definition: comp.h:179
_COMP_Obj_::RAMPDECVAL_SHADOW
volatile uint16_t RAMPDECVAL_SHADOW
Ramp Generator Decrement Value (Shadow)
Definition: comp.h:189
COMP_QualSel_e
COMP_QualSel_e
Enumeration to define the comparator (COMP) output qualification.
Definition: comp.h:122
COMP_RampSyncSrc_PWMSYNC4
PWMSync4 used as Ramp Sync.
Definition: comp.h:167
COMP_QualSel_Qual_25
Qualify comparator output with 25 cycles.
Definition: comp.h:148
COMP_init
COMP_Handle COMP_init(void *pMemory, const size_t numBytes)
Initializes the comparator (COMP) object handle.
Definition: comp.c:120
_COMP_Obj_::rsvd_6
volatile uint16_t rsvd_6
Reserved.
Definition: comp.h:186
COMP_QualSel_Qual_23
Qualify comparator output with 23 cycles.
Definition: comp.h:146
COMP_QualSel_Qual_19
Qualify comparator output with 19 cycles.
Definition: comp.h:142
COMP_RampSyncSrc_PWMSYNC1
PWMSync1 used as Ramp Sync.
Definition: comp.h:164
COMP_QualSel_Qual_13
Qualify comparator output with 13 cycles.
Definition: comp.h:136