Repository navigation
Expand file tree
/
Copy pathdxl_protocol.h
More file actions
71 lines (63 loc) · 2.17 KB
/
Copy pathdxl_protocol.h
File metadata and controls
71 lines (63 loc) · 2.17 KB
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
#ifndef DXL_PROTOCOL_H
#define DXL_PROTOCOL_H
#include "dxl.h"
#define DXL_PING 0x01
#define DXL_READ_DATA 0x02
#define DXL_WRITE_DATA 0x03
#define DXL_REG_WRITE 0x04
#define DXL_ACTION 0x05
#define DXL_RESET 0x06
#define DXL_SYNC_WRITE 0x83
#define DXL_SYNC_READ 0x84
#define DXL_NO_ERROR 0x00
void dxl_process(
volatile struct dxl_device *device,
volatile struct dxl_packet *packet,
bool (*dxl_check_id)(volatile struct dxl_device *self, ui8 id),
void (*dxl_write_data)(volatile struct dxl_device *self, ui8 id, ui8 addr, ui8 *values, ui8 length),
void (*dxl_read_data)(volatile struct dxl_device *self, ui8 id, ui8 addr, ui8 *values, ui8 length, ui8 *error)
);
struct dxl_registers
{
volatile struct dxl_eeprom {
unsigned short modelNumber;
unsigned char firmwareVersion;
unsigned char id;
unsigned char baudrate;
unsigned char returnDelay;
unsigned short cwLimit;
unsigned short ccwLimit;
unsigned char _dummy;
unsigned char temperatureLimit;
unsigned char lowestVoltage;
unsigned char highestVoltage;
unsigned short maxTorque;
unsigned char returnStatus;
unsigned char alarmLed;
unsigned char alarmShutdown;
} eeprom __attribute((packed));
volatile unsigned char _dummy2[4];
volatile struct dxl_ram {
unsigned char torqueEnable;
unsigned char led;
unsigned char cwComplianceMargin;
unsigned char ccwComplianceMargin;
unsigned char cwComplianceSlope;
unsigned char ccwComplianceSlope;
unsigned short goalPosition;
unsigned short movingSpeed;
unsigned short torqueLimit;
unsigned short presentPosition;
unsigned short presentSpeed;
unsigned short presentLoad;
unsigned char presentVoltage;
unsigned char presentTemperature;
unsigned char registeredInstruction;
unsigned char _dummy3;
unsigned char moving;
unsigned char lock;
unsigned short punch;
} ram __attribute__((packed));
volatile char eeprom_dirty;
} __attribute__((packed));
#endif // DXL_PROTOCOL_H