forked from GraniteDevices/SimpleMotionV2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimplemotion_private.h
120 lines (102 loc) · 4.81 KB
/
simplemotion_private.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//Internal functions & definitions, not for library user
//Copyright (c) Granite Devices Oy
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed 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. See the
GNU General Public License for more details.
*/
#ifndef SIMPLEMOTION_PRIVATE_H
#define SIMPLEMOTION_PRIVATE_H
#include "simplemotion.h"
#include "busdevice.h"
#include <stdio.h>
#define SM_VERSION 0x020001
//max number of simultaneously opened buses. change this and recompiple SMlib if
//necessary (to increase channels or reduce to save memory)
#define SM_MAX_BUSES 10
//bus device types
#define BUSDEV_NONE 0
#define BUSDEV_RS 1 /* rs232 like com port support */
#define BUSDEV_FTDI 2 /*not implemented yet: direct FTDI lib support*/
#define SM_BUSDEVICENAME_LEN 64
//default timeout in ms
//Argon drive's worst case response time should be ~20ms with max length packets
#define SM_READ_TIMEOUT 500
extern const smuint8 table_crc16_hi[];
extern const smuint8 table_crc16_lo[];
extern FILE *smDebugOut; //such as stderr or file handle. if NULL, debug info disbled
extern smuint16 readTimeoutMs;
void smDebug( smbus handle, smVerbosityLevel verbositylevel, char *format, ...);
SM_STATUS smRawCmd( const char *axisname, smuint8 cmd, smuint16 val, smuint32 *retdata );
typedef struct {
/* ID=0 param size 30 bits (cmd total 4 bytes)
* ID=1 param size 22 bits (cmd total 3 bytes)
* ID=2 set parameter store address, param: 14 bits=register address (cmd total 2 bytes)
* ID=3 reserved
*/
long param :30; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommand32;
typedef struct {
/* ID=0 param size 30 bits (cmd total 4 bytes)
* ID=1 param size 22 bits (cmd total 3 bytes)
* ID=2 set parameter store address, param: 14 bits=register address (cmd total 2 bytes)
* ID=3 reserved
*/
long param :14; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommand16;
typedef struct {
/* ID=0 param size 30 bits (cmd total 4 bytes)
* ID=1 param size 22 bits (cmd total 3 bytes)
* ID=2 set parameter store address, param: 14 bits=register address (cmd total 2 bytes)
* ID=3 reserved
*/
long param :22; //MSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommand24;
//SM payload command return data structure
typedef struct {
/* ID=0 ret data 30 bits (tot 4 bytes)
* ID=1 ret data 22 bits (tot 3 bytes)
* ID=2 ret data 16 bits (tot 2 bytes), i.e. ACK/NACK.
* ID=3 reserved
*/
long retData: 30; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommandRet32;
//SM payload command return data structure
typedef struct {
/* ID=0 ret data 30 bits (tot 4 bytes)
* ID=1 ret data 22 bits (tot 3 bytes)
* ID=2 ret data 16 bits (tot 2 bytes), i.e. ACK/NACK.
* ID=3 reserved
*/
long retData: 22; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommandRet24;
//SM payload command return data structure
typedef struct {
/* ID=0 ret data 30 bits (tot 4 bytes)
* ID=1 ret data 22 bits (tot 3 bytes)
* ID=2 ret data 16 bits (tot 2 bytes), i.e. ACK/NACK.
* ID=3 reserved
*/
long retData: 14; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommandRet16;
//SM payload command return data structure
typedef struct {
/* ID=0 ret data 30 bits (tot 4 bytes)
* ID=1 ret data 22 bits (tot 3 bytes)
* ID=2 ret data 16 bits (tot 2 bytes), i.e. ACK/NACK.
* ID=3 reserved
*/
long retData: 6; //LSB 30 bits
long ID:2; //MSB 2 bits. when serailzied to bytestream byte4 must be transmitted first to contain ID
} __attribute__ ((packed)) SMPayloadCommandRet8;
#endif // SIMPLEMOTION_PRIVATE_H