#ifndef __STM32F10X_SVPWM_3SHUNT_H #define __STM32F10X_SVPWM_3SHUNT_H #include "stm32f1xx_hal.h" #include "MC_type.h" #include "var.h" #define TW_AFTER ((uint16_t)(((DEADTIME_NS+MAX_TNTR_NS)*72ul)/1000ul)) #define TW_BEFORE (((uint16_t)(((((uint16_t)(SAMPLING_TIME_NS)))*72ul)/1000ul))+1) #define TW_DT_TN_TS ((uint16_t)(((DEADTIME_NS+MAX_TNTR_NS+SAMPLING_TIME_NS)*72ul)/1000ul)) #define TW_DT_TR_TS ((uint16_t)(((DEADTIME_NS+TRISE_NS+SAMPLING_TIME_NS)*72ul)/1000ul)) #define TW_DT_TN_TS_HALF ((uint16_t)(TW_DT_TN_TS/2)) #define SAMPLING_TIME_NS 700 //700ns #if (SAMPLING_TIME_NS == 700) #define SAMPLING_TIME_CK ADC_SampleTime_1Cycles5 #elif (SAMPLING_TIME_NS == 1200) #define SAMPLING_TIME_CK ADC_SampleTime_7Cycles5 #elif (SAMPLING_TIME_NS == 2400) #define SAMPLING_TIME_CK ADC_SampleTime_13Cycles5 #warning "Sampling time is not a possible value" #endif #define TNOISE_NS 1550 //2.55usec #define TRISE_NS 1550 //2.55usec #define SAMPLING_TIME (uint16_t)(((uint16_t)(SAMPLING_TIME_NS) * 72uL)/1000uL) #define TNOISE (uint16_t)((((uint16_t)(TNOISE_NS)) * 72uL)/1000uL) #define TRISE (uint16_t)((((uint16_t)(TRISE_NS)) * 72uL)/1000uL) #define TDEAD (uint16_t)((DEADTIME_NS * 72uL)/1000uL) #if (TNOISE_NS > TRISE_NS) #define MAX_TNTR_NS TNOISE_NS #else #define MAX_TNTR_NS TRISE_NS #endif #define T (PWM_PERIOD * 4) #define T_SQRT3 (uint16_t)(T * SQRT_3) #define SECTOR_1 ((uint8_t)1) #define SECTOR_2 ((uint8_t)2) #define SECTOR_3 ((uint8_t)3) #define SECTOR_4 ((uint8_t)4) #define SECTOR_5 ((uint8_t)5) #define SECTOR_6 ((uint8_t)6) extern void SVPWM_3ShuntCurrentReadingCalibration(MC_ErrorCode_Struct_t* p_MC_ErrorCode); extern void CurrentReadingCalibration(MC_ErrorCode_Struct_t* p_MC_ErrorCode); extern void SVPWM_3ShuntCalcDutyCycles (Volt_Components Stat_Volt_Input); extern Curr_Components SVPWM_3ShuntGetPhaseCurrentValues(void); extern int16_t GetCurrentValues(void); #endif