AM243x Motor Control SDK  09.01.00
pruicss_pwm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 /* ========================================================================== */
82 /* Include Files */
83 /* ========================================================================== */
84 
85 #ifndef PRUICSS_PWM_H_
86 #define PRUICSS_PWM_H_
87 
88 #include <stddef.h>
89 #include <stdint.h>
90 #include <drivers/pruicss.h>
91 #include <kernel/dpl/SystemP.h>
92 #include <drivers/hw_include/cslr.h>
93 #include <drivers/hw_include/hw_types.h>
94 
95 /* ========================================================================== */
96 /* Macros & Typedefs */
97 /* ========================================================================== */
98 
99 
107 #define PRUICSS_NUM_PWM_SETS (0x4U)
108 
109 #define PRUICSS_PWM_SET0 (0x0U)
110 
111 #define PRUICSS_PWM_SET1 (0x1U)
112 
113 #define PRUICSS_PWM_SET2 (0x2U)
114 
115 #define PRUICSS_PWM_SET3 (0x3U)
116 
126 #define PRUICSS_NUM_PWM_STATES (0x3U)
127 
128 #define PRUICSS_PWM_INTIAL_STATE (0x0U)
129 
130 #define PRUICSS_PWM_ACTIVE_STATE (0x1U)
131 
132 #define PRUICSS_PWM_TRIP_STATE (0x2U)
133 
142 #define PRUICSS_NUM_PWM_OUTPUT_ACTIONS (0x3U)
143 
144 #define PRUICSS_PWM_OUTPUT_TOGGLE (0x0U)
145 
146 #define PRUICSS_PWM_OUTPUT_LOW (0x1U)
147 
148 #define PRUICSS_PWM_OUTPUT_HIGH (0x2U)
149 
158 #define PRUICSS_NUM_IEP_INSTANCES (0x2U)
159 
160 #define PRUICSS_IEP_INST0 (0x0U)
161 
162 #define PRUICSS_IEP_INST1 (0x1U)
163 
169 #define PRUICSS_IEP_COUNT_REG_MAX (0xFFFFFFFFU)
170 
178 #define PRUICSS_NUM_IEP_CMP_EVENTS (0x10U)
179 
180 #define CMP_EVENT0 (0x0U)
181 
182 #define CMP_EVENT1 (0x1U)
183 
184 #define CMP_EVENT2 (0x2U)
185 
186 #define CMP_EVENT3 (0x3U)
187 
188 #define CMP_EVENT4 (0x4U)
189 
190 #define CMP_EVENT5 (0x5U)
191 
192 #define CMP_EVENT6 (0x6U)
193 
194 #define CMP_EVENT7 (0x7U)
195 
196 #define CMP_EVENT8 (0x8U)
197 
198 #define CMP_EVENT9 (0x9U)
199 
200 #define CMP_EVENT10 (0xAU)
201 
202 #define CMP_EVENT11 (0xBU)
203 
204 #define CMP_EVENT12 (0xCU)
205 
206 #define CMP_EVENT13 (0xDU)
207 
208 #define CMP_EVENT14 (0xEU)
209 
210 #define CMP_EVENT15 (0xFU)
211 
216 #define PRUICSS_IEP_CMP_EVENTS_ENABLE_MAX_VALUE (0x0000FFFFU)
217 
221 #define PRUICSS_PWM_DEBOUNCE_MAX_VALUE (0xFFU)
222 
226 #define PRUICSS_PWM_TRIP_MASK_MAX_VALUE (0x000001FFU)
227 
228 
229 
230 /* ========================================================================== */
231 /* Function Declarations */
232 /* ========================================================================== */
233 
243 int32_t PRUICSS_PWM_setIepCounterLower_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint32_t value);
244 
254 int32_t PRUICSS_PWM_setIepCounterUpper_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint32_t value);
255 
265 int32_t PRUICSS_PWM_configureIepCmp0ResetEnable(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable);
266 
276 int32_t PRUICSS_PWM_configureIepCompareEnable(PRUICSS_Handle handle, uint8_t iepInstance, uint16_t value);
277 
288 int32_t PRUICSS_PWM_setIepCompareEventLower_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t cmpEvent, uint32_t value);
289 
300 int32_t PRUICSS_PWM_setIepCompareEventUpper_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t cmpEvent, uint32_t value);
301 
311 int32_t PRUICSS_PWM_setPwmDebounceValue(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t value);
312 
333 int32_t PRUICSS_PWM_setPwmTripMask(PRUICSS_Handle handle, uint8_t pwmSet, uint16_t maskvalue);
334 
344 int32_t PRUICSS_PWM_configurePwmCmp0TripResetEnable(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t enable);
345 
354 int32_t PRUICSS_PWM_generatePwmTripReset(PRUICSS_Handle handle, uint8_t pwmSet);
355 
364 int32_t PRUICSS_PWM_generatePwmOverCurrentErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet);
365 
374 int32_t PRUICSS_PWM_generatePwmPositionFeedbackErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet);
375 
384 int32_t PRUICSS_PWM_clearPwmTripResetStatus(PRUICSS_Handle handle, uint8_t pwmSet);
385 
394 int32_t PRUICSS_PWM_clearPwmOverCurrentErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet);
395 
404 int32_t PRUICSS_PWM_clearPwmPositionFeedbackErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet);
405 
414 int32_t PRUICSS_PWM_getPwmTripTriggerCauseVector(PRUICSS_Handle handle, uint8_t pwmSet);
415 
424 int32_t PRUICSS_PWM_getPwmTripStatus(PRUICSS_Handle handle, uint8_t pwmSet);
425 
435 int32_t PRUICSS_PWM_clearPwmTripStatus(PRUICSS_Handle handle, uint8_t pwmSet);
436 
447 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA0(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
448 
459 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA1(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
460 
471 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA2(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
472 
483 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB0(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
484 
495 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB1(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
496 
507 int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB2(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action);
508 
520 int32_t PRUICSS_PWM_configurePwmEfficiencyModeEnable(PRUICSS_Handle handle, uint8_t enable);
521 
532 int32_t PRUICSS_PWM_enableIEP1Slave(PRUICSS_Handle handle, uint8_t enable);
533 
543 int32_t PRUICSS_PWM_enableIEPResetOnEPWM0SyncOut(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable);
544 
554 int32_t PRUICSS_PWM_enableIEPResetOnEPWM3SyncOut(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable);
555 
558 #ifdef __cplusplus
559 }
560 #endif
561 
562 #endif/* #ifndef PRUICSS_PWM_H_ */
PRUICSS_PWM_configureIepCmp0ResetEnable
int32_t PRUICSS_PWM_configureIepCmp0ResetEnable(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable)
This API sets enables/disables of IEP counter reset on compare 0 event in IEP module.
PRUICSS_PWM_getPwmTripTriggerCauseVector
int32_t PRUICSS_PWM_getPwmTripTriggerCauseVector(PRUICSS_Handle handle, uint8_t pwmSet)
This API returns Trip trigger cause vector for specified pwm set.
PRUICSS_PWM_generatePwmOverCurrentErrorTrip
int32_t PRUICSS_PWM_generatePwmOverCurrentErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet)
This API generates Software Over current error trip by writing 1 to bit field for specified pwm set.
PRUICSS_PWM_clearPwmPositionFeedbackErrorTrip
int32_t PRUICSS_PWM_clearPwmPositionFeedbackErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet)
This API clears Software Position Feedback Error Trip by writing 0 to bit field for specified pwm set...
PRUICSS_PWM_enableIEP1Slave
int32_t PRUICSS_PWM_enableIEP1Slave(PRUICSS_Handle handle, uint8_t enable)
This function enables IEP1 counter follow IEP0 counter when Enabled IEP1 counter acts as slave IEP1 c...
PRUICSS_PWM_getPwmTripStatus
int32_t PRUICSS_PWM_getPwmTripStatus(PRUICSS_Handle handle, uint8_t pwmSet)
This API returns Trip status for specified pwm set.
PRUICSS_PWM_actionOnOutputCfgPwmSignalB2
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB2(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of B2 signal for specified PWM set.
PRUICSS_PWM_setIepCounterLower_32bitValue
int32_t PRUICSS_PWM_setIepCounterLower_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint32_t value)
This API writes Lower_32bit Value of IEP counter in IEP module.
PRUICSS_PWM_setPwmTripMask
int32_t PRUICSS_PWM_setPwmTripMask(PRUICSS_Handle handle, uint8_t pwmSet, uint16_t maskvalue)
This API updates TripMask Value for specified pwm set.
PRUICSS_PWM_generatePwmTripReset
int32_t PRUICSS_PWM_generatePwmTripReset(PRUICSS_Handle handle, uint8_t pwmSet)
This API generates Software Trip Reset by writing 1 to bit field for specified pwm set.
PRUICSS_PWM_configurePwmEfficiencyModeEnable
int32_t PRUICSS_PWM_configurePwmEfficiencyModeEnable(PRUICSS_Handle handle, uint8_t enable)
This API enables Efficiency mode In Efficiency mode Pwm state machine will go from Idle to Active and...
PRUICSS_PWM_setPwmDebounceValue
int32_t PRUICSS_PWM_setPwmDebounceValue(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t value)
This API updates Debounce Value for specified pwm set.
PRUICSS_PWM_actionOnOutputCfgPwmSignalA2
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA2(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of A2 signal for specified PWM set.
PRUICSS_PWM_generatePwmPositionFeedbackErrorTrip
int32_t PRUICSS_PWM_generatePwmPositionFeedbackErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet)
This API generates Software Position Feedback Error Trip by writing 1 to bit field for specified pwm ...
PRUICSS_PWM_actionOnOutputCfgPwmSignalB1
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB1(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of B1 signal for specified PWM set.
PRUICSS_PWM_clearPwmTripResetStatus
int32_t PRUICSS_PWM_clearPwmTripResetStatus(PRUICSS_Handle handle, uint8_t pwmSet)
This API clears Software Trip Reset by writing 0 to bit field for specified pwm set.
PRUICSS_PWM_configurePwmCmp0TripResetEnable
int32_t PRUICSS_PWM_configurePwmCmp0TripResetEnable(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t enable)
This API enables/disables TripReset on Compare_0 Event for specified pwm set.
PRUICSS_PWM_setIepCounterUpper_32bitValue
int32_t PRUICSS_PWM_setIepCounterUpper_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint32_t value)
This API writes Upper_32bit Value of IEP counter in IEP module.
PRUICSS_PWM_enableIEPResetOnEPWM0SyncOut
int32_t PRUICSS_PWM_enableIEPResetOnEPWM0SyncOut(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable)
This API sets enables/disables of IEP counter reset on EPWM0 SYNC OUT event in IEP module.
PRUICSS_PWM_actionOnOutputCfgPwmSignalA1
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA1(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of A1 signal for specified PWM set.
PRUICSS_PWM_clearPwmOverCurrentErrorTrip
int32_t PRUICSS_PWM_clearPwmOverCurrentErrorTrip(PRUICSS_Handle handle, uint8_t pwmSet)
This API clears Software Over current error trip by writing 0 to bit field for specified pwm set.
PRUICSS_PWM_actionOnOutputCfgPwmSignalA0
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalA0(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of A0 signal for specified PWM set.
PRUICSS_PWM_clearPwmTripStatus
int32_t PRUICSS_PWM_clearPwmTripStatus(PRUICSS_Handle handle, uint8_t pwmSet)
This API clears Trip status and makes state transition to Intial state as follows (Active->Intial) or...
PRUICSS_PWM_setIepCompareEventLower_32bitValue
int32_t PRUICSS_PWM_setIepCompareEventLower_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t cmpEvent, uint32_t value)
This API writes Lower_32bit Value of compare event in IEP module.
PRUICSS_PWM_enableIEPResetOnEPWM3SyncOut
int32_t PRUICSS_PWM_enableIEPResetOnEPWM3SyncOut(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t enable)
This API sets enables/disables of IEP counter reset on EPWM3 SYNCOUT in IEP module.
PRUICSS_PWM_setIepCompareEventUpper_32bitValue
int32_t PRUICSS_PWM_setIepCompareEventUpper_32bitValue(PRUICSS_Handle handle, uint8_t iepInstance, uint8_t cmpEvent, uint32_t value)
This API writes Upper_32bit Value of compare event in IEP module.
PRUICSS_PWM_actionOnOutputCfgPwmSignalB0
int32_t PRUICSS_PWM_actionOnOutputCfgPwmSignalB0(PRUICSS_Handle handle, uint8_t pwmSet, uint8_t state, uint8_t action)
This API updates output action for specified state of B0 signal for specified PWM set.
PRUICSS_PWM_configureIepCompareEnable
int32_t PRUICSS_PWM_configureIepCompareEnable(PRUICSS_Handle handle, uint8_t iepInstance, uint16_t value)
This API sets enables/disables compare events in IEP module.