📄 f280xhall3.h
字号:
/* ==================================================================================
File name: F280XHALL3.H
Originator: Digital Control Systems Group
Texas Instruments
Description:
Header file containing data type and object definitions and
initializers. Also contains prototypes for the functions in F280XHALL3.C.
Target: TMS320F280x family
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20: Using DSP280x v. 1.10 or higher
-----------------------------------------------------------------------------------*/
#ifndef __F280X_HALL3_H__
#define __F280X_HALL3_H__
#include "f280xbmsk.h"
/*-----------------------------------------------------------------------------
Initialization states for ECAP Control Registers 1 and 2 for ECAP1/2/3
------------------------------------------------------------------------------*/
#define HALL3_ECCTL1_ECAP1_INIT_STATE ( CAP1POL_RISING_EDGE + \
CAP2POL_FALLING_EDGE + \
CAP3POL_FALLING_EDGE + \
CAP4POL_RISING_EDGE + \
CAPLDEN_ENABLE + \
EVTFLTPS_X_1 + \
EMULATION_FREE )
#define HALL3_ECCTL1_ECAP2_INIT_STATE ( CAP1POL_RISING_EDGE + \
CAP2POL_FALLING_EDGE + \
CAP3POL_RISING_EDGE + \
CAP4POL_FALLING_EDGE + \
CAPLDEN_ENABLE + \
EVTFLTPS_X_1 + \
EMULATION_FREE )
#define HALL3_ECCTL1_ECAP3_INIT_STATE ( CAP1POL_RISING_EDGE + \
CAP2POL_FALLING_EDGE + \
CAP3POL_FALLING_EDGE + \
CAP4POL_FALLING_EDGE + \
CAPLDEN_ENABLE + \
EVTFLTPS_X_1 + \
EMULATION_FREE )
#define HALL3_ECCTL2_INIT_STATE ( CONTINUOUS_MODE + \
TSCNTSTP_FREE + \
SYNCI_DISABLE + \
SYNCO_DISABLE + \
CAPTURE_MODE )
/*-----------------------------------------------------------------------------
Define the structure of the Capture Driver Object
------------------------------------------------------------------------------*/
typedef struct { Uint16 CmtnTrigHall; // Output: Commutation trigger for Mod6cnt input (0 or 0x7FFF)
Uint16 CapCounter; // Variable: Running count of detected edges on ECAP1,2,3
Uint16 DebounceCount; // Variable: Counter/debounce delay current value
Uint16 DebounceAmount; // Parameter: Counter delay amount to validate/debounce GPIO readings
Uint16 HallGpio; // Variable: Most recent logic level on ECAP/GPIO
Uint16 HallGpioBuffer; // Variable: Buffer of last logic level on ECAP/GPIO while being debounced
Uint16 HallGpioAccepted; // Variable: Debounced logic level on ECAP/GPIO
Uint16 EdgeDebounced; // Variable: Trigger from Debounce function to Hall_Drv, if = 0x7FFF edge is debounced
Uint16 HallMap[6]; // Variable: ECAP/GPIO logic levels for HallMapPointer = 0-5
Uint16 CapFlag; // Variable: ECAP flags, indicating which ECAP detected the edge
Uint16 StallCount; // Variable: If motor stalls, this counter overflow triggers
// commutation to start rotation. Rotation is defined as
// an edge detection of a hall signal.
Uint16 HallMapPointer; // Input/Output (see note below): During hall map creation, this variable points to the
// current commutation state. After map creation, it
// points to the next commutation state.
int16 Revolutions; // Parameter: Running counter, with a revolution defined as 1-cycle
// of the 6 hall states
void (*init)(); // Pointer to the init function
void (*read)(); // Pointer to the read function
} HALL3;
/* Note:
- When HallMapPointer is as an input, it is defined by MOD6_CNT.
- When HallMapPointer is as an output, during hall map creation,
this variable points to the current commutation state.
After map creation, it points to the next commutation state.
*/
/*-----------------------------------------------------------------------------
Define a handle for the HALL3 object
------------------------------------------------------------------------------*/
typedef HALL3 *HALL3_handle;
/*------------------------------------------------------------------------------
Default Initializer for the F280X HALL3 Object
------------------------------------------------------------------------------*/
#define F280XHALL3 { 0, \
0, \
0, \
10, \
0, \
0, \
0, \
0, \
{0,0,0,0,0,0}, \
0, \
0xFFFF, \
0, \
-10, \
(void (*)(Uint32))F280X_HALL3_Init, \
(void (*)(Uint32))F280X_HALL3_Read \
}
/*------------------------------------------------------------------------------
Target Independent Default Initializer HALL3 Object
------------------------------------------------------------------------------*/
#define HALL3_DEFAULTS F280XHALL3
/*------------------------------------------------------------------------------
Prototypes for the functions in F280XHALL3.C
------------------------------------------------------------------------------*/
void F280X_HALL3_Init(HALL3_handle);
void F280X_HALL3_Read(HALL3_handle);
void F280X_HALL3_Determine_State(HALL3_handle);
void F280X_HALL3_Debounce(HALL3_handle);
void F280X_HALL3_Next_State_Ptr(HALL3_handle);
void F280X_HALL3_Create_Map(HALL3_handle);
#endif // __F280X_HALL3_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -