-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commands.h
100 lines (81 loc) · 3.56 KB
/
Commands.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*******************************************************************************
Project: stepRocker Mini TMCL
Module: Commands.h
Definitions needed for the TMCL interpreter
Copyright (C) 2011 TRINAMIC Motion Control GmbH & Co KG
Waterloohain 5
D - 22769 Hamburg, Germany
http://www.trinamic.com/
This program is free software; you can redistribute it and/or modify it
freely.
This program is distributed "as is" in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
*******************************************************************************/
/**
\file Commands.h
\author Trinamic Motion Control GmbH & Co KG
\version 1.00
\brief TMCL command definitions
This file contains all necessary definitions for the
TMCL command interpreter.
*/
//States of the command interpreter
#define TCS_IDLE 0 //!< TMCL interpreter is in idle mode (no command to process)
#define TCS_UART 1 //!< processing a command from RS485
#define TCS_UART_ERROR 2 //!< last command from RS485 had bad check sum
//Supported TMCL commands
#define TMCL_ROR 1 //!< ROR command opcode
#define TMCL_ROL 2 //!< ROL command opcode
#define TMCL_MST 3 //!< MST command opcode
#define TMCL_MVP 4 //!< MVP command opcode
#define TMCL_SAP 5 //!< SAP command opcode
#define TMCL_GAP 6 //!< GAP command opcode
#define TMCL_GetVersion 136 //!< GetVersion command opcode
#define TMCL_Boot 0xf2 //!< Boot command opcode
#define TMCL_SoftwareReset 0xff //!< software reset command opcode
//Type codes of the MVP command
#define MVP_ABS 0 //!< absolute movement (with MVP command)
#define MVP_REL 1 //!< relative movement (with MVP command)
#define MVP_COORD 2 //!< coordinate movement (with MVO command)
//TMCL status codes
#define REPLY_OK 100 //!< command successfully executed
#define REPLY_CHKERR 1 //!< checksum error
#define REPLY_INVALID_CMD 2 //!< command not supported
#define REPLY_WRONG_TYPE 3 //!< wrong type code
#define REPLY_INVALID_VALUE 4 //!< wrong value
#define REPLY_EEPROM_LOCKED 5 //!< EEPROM is locked
#define REPLY_CMD_NOT_AVAILABLE 6 //!< command not available due to current state
#define REPLY_CMD_LOAD_ERROR 7 //!< error when storing command to EEPROM
#define REPLY_WRITE_PROTECTED 8 //!< EEPROM is write protected
#define REPLY_MAX_EXCEEDED 9 //!< maximum number of commands in EEPROM exceeded
//Reply format
#define RF_STANDARD 0 //!< use standard TMCL reply
#define RF_SPECIAL 1 //!< use special reply
//Data structures needed by the TMCL interpreter
//! TMCL command
typedef struct
{
UCHAR Opcode; //!< command opcode
UCHAR Type; //!< type parameter
UCHAR Motor; //!< motor/bank parameter
union
{
long Int32; //!< value parameter as 32 bit integer
UCHAR Byte[4]; //!< value parameter as 4 bytes
} Value; //!< value parameter
} TTMCLCommand;
//! TMCL reply
typedef struct
{
UCHAR Status; //!< status code
UCHAR Opcode; //!< opcode of executed command
union
{
long Int32; //!< reply value as 32 bit integer
UCHAR Byte[4]; //!< reply value as 4 bytes
} Value; //!< value parameter
} TTMCLReply;
//Prototypes of exported functions
void InitTMCL(void);
void ProcessCommand(void);