/** * @file switchhall.c * @author * @brief * @version * @date 2021-11-22 * * @copyright Copyright (c) 2021 * */ /************************************************************************ Beginning of File, do not put anything above here except notes Compiler Directives: *************************************************************************/ #ifndef SWITCHHALL_H #define SWITCHHALL_H /************************************************************************ Compiler Directives (N/A) *************************************************************************/ //#ifdef _SWITCHHALL_C_ // #define _SWITCHHALL_EXT //#else // #define _SWITCHHALL_EXT extern //#endif /**************************************** * * Definitions & Macros * ****************************************/ #define HALL3_SPD_CAL_COEF ((((SQWORD)TIM3CNTCLK_KHZ * 1000 / FBASE)<< 15) / 6 ) // pi/3*(7200kHz) PU(pi/3)=2^15/6 #define HALL1_SPD_CAL_COEF (((SQWORD)TIM3CNTCLK_KHZ * 1000 / FBASE)<< 15) #define HALL3_SPD_CAP_LEVEL1 (TIM3CNTCLK_KHZ*1000/((2)*6)) // electrical frequency 2Hz 6 hal edge pules per electrical cycle #define HALL3_SPD_CAP_LEVEL2 (TIM3CNTCLK_KHZ*1000/((1500)*6)) //motor electrical frequency 1500Hz 6 hal edge pules per electrical cycle #define HALL3_SPD_CAP_STARTUP_LEVEL (TIM3CNTCLK_KHZ*1000/((5)*6)) //motor electrical frequency 5Hz 6 hal edge pules per electrical cycle #define HALL_SPD_SWITCH_LEVEL (TIM3CNTCLK_KHZ*1000/((20)*6)) //motor electrical frequency 5Hz 6 hal edge pules per electrical cycle #define HALL_THETEA_OFFSET 7357 // (X)/360*2^15 #define HALL_THETEA_OFFSET_FANXIANG 0 // (X)/360*2^15 #define SWITCHHALL_CAP_DEFAULT \ { \ 0, 0, 0 \ } #define SWITCHHALL_OUT_DEFAULT \ { \ 0, 0, 0, 0, 0, 0, 0, 0 \ } /*************************************** * * Type Definations * ***************************************/ typedef struct { ULONG ulCapValue; SLONG slCapValueDelta; ULONG ulCapValuePre; SLONG slDeltaPre; UWORD uwCaptureOverFlowCnt; ULONG ulHighCapValue; SLONG slHighCapValueDelta; ULONG ulHighCapValuePre; UWORD uwHighCapOverFlowCnt; UWORD ulSTATE; } SWITCHHALL_CAP; typedef struct { UWORD uwSectorNum; UWORD uwSectorNumPre; SWORD swSpdCWorCCW; SLONG slLowThetaPu; UWORD uwLowThetaPu; SLONG slInitThetaPu; SWORD swLowSpdPu; SWORD swLowSpdLpfPu; SWORD swLowThetaOffsetPu; SLONG slHighThetaPu; UWORD uwHighThetaPu; SWORD swHighSpdPu; SWORD swHighSpdLpfPu; } SWITCHHALL_OUT; /**************************************** * * Exported Variables * ****************************************/ extern SWITCHHALL_OUT switchhall_stOut; /*************************************** * * Function Definations * ***************************************/ void switchhall_voInit(void); void switchhall_voTim3Int(void); void switchhall_voCapIsr(UWORD source); void switchhall_voPosCalTbc(void); /************************************************************************/ #endif /************************************************************************ End of this File (EOF): Do not put anything after this part! *************************************************************************/