?? motor.h
字號:
/* File: MOTOR.H */
/****************************************************************************
*
* STK16XSW.MOTOR
* ==============
*
* Low level routines for stepping motor control
*
* TQ-Systems GmbH
* ---------------
* Customer: TQ-Components
* Project : STK16XSW
* Tools : uVision 2.05
*
* Rev: Date: Name: Modification:
* ----+---------+----------------+------------------------------------------
* 100 16.01.01 A. Lichte taken over from STK16X.506
*****************************************************************************/
#include "header.h"
/*==========================================================================*
* extern available definitions (#DEFINE):
*===========================================================================*/
/*--------------------------------------------------------------------------*
* hardware definitions for stepping motor control:
*---------------------------------------------------------------------------*/
#define PHASE_DIR_OUT 1 /* data direction register: output */
// definitions for TQM165,166,167,167LC
#define PHASE_0_DIR_167 DP2^8 /* data direction register: phase 0 */
#define PHASE_0_167 P2^8 /* data register: phase 0 */
#define PHASE_1_DIR_167 DP2^10 /* data direction register: phase 1 */
#define PHASE_1_167 P2^10 /* data register: phase 1 */
#define PHASE_2_DIR_167 DP2^9 /* data direction register: phase 2 */
#define PHASE_2_167 P2^9 /* data register: phase 2 */
#define PHASE_3_DIR_167 DP2^11 /* data direction register: phase 3 */
#define PHASE_3_167 P2^11 /* data register: phase 3 */
#define PHASE_ON 1 /* level for phase 0..3 ON */
/*--------------------------------------------------------------------------*
* hardware definitions for motor driver enabling:
*---------------------------------------------------------------------------*/
#define DRV_ENABLE_EN 1 /* level for enabling motor driver */
/*--------------------------------------------------------------------------*
* steeping motor windings bit mask:
*---------------------------------------------------------------------------*/
#define PHASE_0_MASK 0x01
#define PHASE_1_MASK 0x02
#define PHASE_2_MASK 0x04
#define PHASE_3_MASK 0x08
/*--------------------------------------------------------------------------*
* stepping motor windings OFF state:
*---------------------------------------------------------------------------*/
#define PHASES_ALL_OFF 0x00
/*--------------------------------------------------------------------------*
* stepping motor operating modes:
*---------------------------------------------------------------------------*/
#define MOTOR_FSTEP1 0 /* full step mode, 1 active winding */
#define MOTOR_FSTEP2 1 /* full step mode, 2 active windings */
#define MOTOR_HSTEP 2 /* half step mode */
#define MOTOR_MODE_UNDEF 0xFF /* undefined operating mode */
/*--------------------------------------------------------------------------*
* stepping motor direction:
*---------------------------------------------------------------------------*/
#define MOTOR_CW 0 /* clock wise rotation */
#define MOTOR_CCW 1 /* counter clock wise rotation */
/*--------------------------------------------------------------------------*
* general definitions:
*---------------------------------------------------------------------------*/
/*==========================================================================*
* extern available type definitions (TYPEDEF):
*===========================================================================*/
/*==========================================================================*
* extern available constants (CONST):
*===========================================================================*/
/*==========================================================================*
* globale extern available variables (EXTERN):
*===========================================================================*/
/*==========================================================================*
* extern available functions:
*===========================================================================*/
/*--------------------------------------------------------------------------*
* BYTE motor_setdir(BYTE dir)
*---------------------------------------------------------------------------*
* FT: set stepping motor direction
* EP: dir = motor direction MOTOR_CW: clock wise rotation
* MOTOR_CCW: counter clock wise rotation
* RV: TRUE = function succesfully; FALSE = function failed
* GP:
*---------------------------------------------------------------------------*/
BYTE motor_setdir(BYTE dir);
/*--------------------------------------------------------------------------*
* BYTE motor_setdir()
*---------------------------------------------------------------------------*
* FT: detect stepping motor direction
* EP -
* RV: MOTOR_CW = motor direction; MOTOR_CW = clock wise rotation
* GP:
*---------------------------------------------------------------------------*/
BYTE motor_getdir();
/*--------------------------------------------------------------------------*
* BYTE motor_init(BYTE mode)
*---------------------------------------------------------------------------*
* FT: init motor
* EP: mode = operating mode 0: full step with 1 winding
* 1: full step with 2 windings
* 2: half step
* RV: 0 = function succesfully; 1 = unvalid mode; 2 = motor defect
* GP:
*---------------------------------------------------------------------------*/
BYTE motor_init(BYTE mode);
/*--------------------------------------------------------------------------*
* void motor_enable()
*---------------------------------------------------------------------------*
* FT: switch on motor driver
* EP: -
* RV: -
* GP: -
*---------------------------------------------------------------------------*/
void motor_enable();
/*--------------------------------------------------------------------------*
* void motor_disable()
*---------------------------------------------------------------------------*
* FT: switch off motor driver ( = standby mode)
* EP: -
* RV: -
* GP:
*---------------------------------------------------------------------------*/
void motor_disable();
/*--------------------------------------------------------------------------*
* BOOL motor_step()
*---------------------------------------------------------------------------*
* FT: motor driver port output
* EP: -
* RV: TRUE = function succesfully; FALSE = unvalid driving mode
* GP:
*---------------------------------------------------------------------------*/
BOOL motor_step();
/*--------------------------------------------------------------------------*
* void motor_set(BYTE state)
*---------------------------------------------------------------------------*
* FT: control motor phases
* EP: state = 4 bit nibble for motor phase stati
* RV: -
* GP:
*---------------------------------------------------------------------------*/
void motor_set(BYTE state);
/*--------------------------------------------------------------------------*
* BOOL motor_getfault()
*---------------------------------------------------------------------------*
* FT: get motor error status
* EP: -
* RV: TRUE = driver failure detected; FALSE = no driver failure detected
* GP:
*---------------------------------------------------------------------------*/
BOOL motor_getfault();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -