AM243x Motor Control SDK  09.01.00
sdfm_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
3  *
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
15  * distribution.
16  *
17  * * Neither the name of Texas Instruments Incorporated nor the names of
18  * its contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _SDFM_API_H_
35 #define _SDFM_API_H_
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <stdint.h>
42 #include "../firmware/icssg_sdfm.h"
44 #include <drivers/pruicss.h>
45 
63 /* Number of ICSSG PRUs */
64 #define NUM_PRU ( 2 )
65 
66 /* PRU IDs */
67 #define PRU_ID_0 ( 0 ) /* PRU 0 ID */
68 #define PRU_ID_1 ( 1 ) /* PRU 1 ID */
69 
70 #define PRUx_DMEM_BASE_ADD (0x00)
71 #define RTUx_DMEM_BASE_ADD (0x200)
72 #define TXPRUx_DMEM_BASE_ADD (0x400)
73 /* Number of SD channels */
74 #define NUM_SD_CH ( ICSSG_NUM_SD_CH )
75 /* ICSSG INTC event */
76 #define SDFM_EVT ( TRIGGER_HOST_SDFM_EVT )
77 
78 /* SDFM handle */
79 typedef SDFM *sdfm_handle;
80 
91 sdfm_handle SDFM_init(uint8_t pru_id, uint8_t coreId);
92 
103 void SDFM_configIepCount(sdfm_handle h_sdfm, uint32_t epwm_out_freq);
104 
115 void SDFM_configEcap(sdfm_handle h_sdfm, uint8_t ecap_divider);
116 
128 void SDFM_setEnableChannel(sdfm_handle h_sdfm, uint8_t channel_number);
129 
141 void SDFM_setCompFilterOverSamplingRatio(sdfm_handle h_sdfm, uint8_t ch_id, uint16_t osr);
142 
153 
165 void SDFM_setCompFilterThresholds(sdfm_handle h_sdfm, uint8_t ch_id, SDFM_ThresholdParms thresholdParms);
166 
177 void SDFM_setSampleTriggerTime(sdfm_handle h_sdfm, float samp_trig_time);
178 
190 void SDFM_enableDoubleSampling(sdfm_handle h_sdfm, float samp_trig_time);
191 
203 
204 
217 void SDFM_configDataFilter(sdfm_handle h_sdfm, uint8_t ch_id, uint8_t filter);
218 
230 void SDFM_selectClockSource(sdfm_handle h_sdfm, uint8_t ch_id, SDFM_ClkSourceParms clkPrams);
231 
243 void SDFM_enableComparator(sdfm_handle h_sdfm, uint8_t ch);
244 
256 void SDFM_disableComparator(sdfm_handle h_sdfm, uint8_t ch);
257 
270 void SDFM_configComparatorGpioPins(sdfm_handle h_sdfm, uint8_t ch,uint32_t gpio_base_addr, uint32_t pin_number);
271 
282 uint32_t SDFM_getFilterData(sdfm_handle h_sdfm,uint8_t ch);
292 void SDFM_setFilterOverSamplingRatio(sdfm_handle h_sdfm, uint16_t nc_osr);
303 
314 void SDFM_configFastDetect(sdfm_handle h_sdfm, uint8_t ch, uint8_t *fdParms);
315 
325 int32_t SDFM_getFastDetectErrorStatus(sdfm_handle h_sdfm, uint8_t chNum);
326 
335 int32_t SDFM_clearPwmTripStatus(sdfm_handle h_sdfm, uint8_t chNum);
336 
346 
355 void SDFM_enableLoadShareMode(sdfm_handle h_sdfm, uint8_t sliceId);
356 
366 void SDFM_measureClockPhaseDelay(sdfm_handle h_sdfm, uint16_t clEdg);
367 
387 uint8_t SDFM_getLowThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum);
388 
397 uint8_t SDFM_getHighThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum);
398 
407 int32_t SDFM_clearOverCurrentError(sdfm_handle h_sdfm, uint8_t chNum);
408 
417 void SDFM_enableZeroCrossDetection(sdfm_handle h_sdfm, uint8_t chNum, uint32_t zcThr);
418 
427 uint8_t SDFM_getZeroCrossThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum);
428 
437 void SDFM_disableZeroCrossDetection(sdfm_handle h_sdfm, uint8_t chNum);
440 #ifdef __cplusplus
441 }
442 #endif
443 
444 #endif
SDFM_configFastDetect
void SDFM_configFastDetect(sdfm_handle h_sdfm, uint8_t ch, uint8_t *fdParms)
This API Configure Fast detect block fields.
sdfm_drv.h
SDFM_enableDoubleSampling
void SDFM_enableDoubleSampling(sdfm_handle h_sdfm, float samp_trig_time)
configuration and enable second normal current sample starting time one Epwm cycle
SDFM_disableZeroCrossDetection
void SDFM_disableZeroCrossDetection(sdfm_handle h_sdfm, uint8_t chNum)
This API disbales zero cross detection for specified SDFM channel number.
SDFM_configComparatorGpioPins
void SDFM_configComparatorGpioPins(sdfm_handle h_sdfm, uint8_t ch, uint32_t gpio_base_addr, uint32_t pin_number)
configure GPIO pin number and address for associate Channel Number
SDFM_enableLoadShareMode
void SDFM_enableLoadShareMode(sdfm_handle h_sdfm, uint8_t sliceId)
This API enables load share mode.
SDFM_setCompFilterThresholds
void SDFM_setCompFilterThresholds(sdfm_handle h_sdfm, uint8_t ch_id, SDFM_ThresholdParms thresholdParms)
configuration of SDFM threshold values
SDFM_getLowThresholdStatus
uint8_t SDFM_getLowThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum)
This API returns Low threshold Status for specified SDFM channel number.
SDFM_enableContinuousNormalCurrent
void SDFM_enableContinuousNormalCurrent(sdfm_handle h_sdfm)
This API enables continuous normal current sampling.
SDFM_getFastDetectErrorStatus
int32_t SDFM_getFastDetectErrorStatus(sdfm_handle h_sdfm, uint8_t chNum)
This API returns the fast detect error status for specified SDFM channel number.
SDFM_enableComparator
void SDFM_enableComparator(sdfm_handle h_sdfm, uint8_t ch)
This API enables the Comparator for the selected channel.
sdfm_handle
SDFM * sdfm_handle
Definition: sdfm_api.h:79
SDFM_setFilterOverSamplingRatio
void SDFM_setFilterOverSamplingRatio(sdfm_handle h_sdfm, uint16_t nc_osr)
Configure iep count for normal current sampling.
SDFM_configIepCount
void SDFM_configIepCount(sdfm_handle h_sdfm, uint32_t epwm_out_freq)
Configure iep increment & iep count in one epwm cycle.
SDFM_getZeroCrossThresholdStatus
uint8_t SDFM_getZeroCrossThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum)
This API returns Zero cross Status for specified SDFM channel number.
SDFM_init
sdfm_handle SDFM_init(uint8_t pru_id, uint8_t coreId)
Initialize SDFM instance.
SDFM_getFilterData
uint32_t SDFM_getFilterData(sdfm_handle h_sdfm, uint8_t ch)
get sample data from DMEM
SDFM_getFirmwareVersion
uint32_t SDFM_getFirmwareVersion(sdfm_handle h_sdfm)
Return Firmware version.
SDFM_enable
void SDFM_enable(sdfm_handle h_sdfm)
SDFM global enable.
SDFM_measureClockPhaseDelay
void SDFM_measureClockPhaseDelay(sdfm_handle h_sdfm, uint16_t clEdg)
Measure Clock phase compensation.
SDFM_setCompFilterOverSamplingRatio
void SDFM_setCompFilterOverSamplingRatio(sdfm_handle h_sdfm, uint8_t ch_id, uint16_t osr)
Configure comparator filter (over current) sampling ratio.
SDFM_configEcap
void SDFM_configEcap(sdfm_handle h_sdfm, uint8_t ecap_divider)
Configure ecap parameters for generate 20MHz SD clock.
SDFM_ThresholdParms
Structure defining SDFM thresholds parametrs.
Definition: sdfm_drv.h:259
SDFM_configDataFilter
void SDFM_configDataFilter(sdfm_handle h_sdfm, uint8_t ch_id, uint8_t filter)
configuration of SDFM channel Acc source (sync filter type). Current SDFM firmware implementation s...
SDFM_enableZeroCrossDetection
void SDFM_enableZeroCrossDetection(sdfm_handle h_sdfm, uint8_t chNum, uint32_t zcThr)
This API enables zero cross detection for specified SDFM channel number.
SDFM_clearPwmTripStatus
int32_t SDFM_clearPwmTripStatus(sdfm_handle h_sdfm, uint8_t chNum)
Clear PWM trip status of the corresponding PWM trip zone block for specified SDFM channel number.
SDFM_clearOverCurrentError
int32_t SDFM_clearOverCurrentError(sdfm_handle h_sdfm, uint8_t chNum)
This API clears Overcurrent error bit of corresponding PWM register for specified SDFM channel number...
SDFM_selectClockSource
void SDFM_selectClockSource(sdfm_handle h_sdfm, uint8_t ch_id, SDFM_ClkSourceParms clkPrams)
configuration of SDFM channel clock source & clock inversion
SDFM_getClockPhaseDelay
float SDFM_getClockPhaseDelay(sdfm_handle h_sdfm)
This API returns Clock phase compensation.
SDFM_ClkSourceParms
Structure defining clk source for sdfm ch.
Definition: sdfm_drv.h:245
SDFM_setEnableChannel
void SDFM_setEnableChannel(sdfm_handle h_sdfm, uint8_t channel_number)
Enable the channel specified by the channel number parameter.
SDFM_disableDoubleSampling
void SDFM_disableDoubleSampling(sdfm_handle h_sdfm)
Disable double normal current update/sampling.
SDFM
Structure defining SDFM interface.
Definition: sdfm_drv.h:354
SDFM_setSampleTriggerTime
void SDFM_setSampleTriggerTime(sdfm_handle h_sdfm, float samp_trig_time)
configuration of single sample trigger time one Epwm cycle
SDFM_getHighThresholdStatus
uint8_t SDFM_getHighThresholdStatus(sdfm_handle h_sdfm, uint8_t chNum)
This API returns high threshold Status for specified SDFM channel number.
SDFM_disableComparator
void SDFM_disableComparator(sdfm_handle h_sdfm, uint8_t ch)
This API disables the Comparator for the selected channel.