stepRocker servo Open Source TMCL  1.00
 All Data Structures Files Functions Variables Typedefs Enumerations Macros
TMC429.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Project: stepRocker Mini-TMCL (for stepRocker V2.2)
3 
4  Module: TMC429.h
5  Defintions for TMC429 register addresses and TMC429 support functions.
6 
7  Copyright (C) 2016 TRINAMIC Motion Control GmbH & Co KG
8  Waterloohain 5
9  D - 22769 Hamburg, Germany
10  http://www.trinamic.com/
11 
12  This program is free software; you can redistribute it and/or modify it
13  freely.
14 
15  This program is distributed "as is" in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  or FITNESS FOR A PARTICULAR PURPOSE.
18 *******************************************************************************/
19 
31 #define MOTOR0 0
32 #define MOTOR1 0x20
33 #define MOTOR2 0x40
34 
35 #define IDX_XTARGET 0x00
36 #define IDX_XACTUAL 0x02
37 #define IDX_VMIN 0x04
38 #define IDX_VMAX 0x06
39 #define IDX_VTARGET 0x08
40 #define IDX_VACTUAL 0x0A
41 #define IDX_AMAX 0x0C
42 #define IDX_AACTUAL 0x0E
43 #define IDX_AGTAT_ALEAT 0x10
44 #define IDX_PMUL_PDIV 0x12
45 #define IDX_REFCONF_RM 0x14
46 #define IDX_IMASK_IFLAGS 0x16
47 #define IDX_PULSEDIV_RAMPDIV 0x18
48 #define IDX_DX_REFTOLERANCE 0x1A
49 #define IDX_XLATCHED 0x1C
50 #define IDX_USTEP_COUNT_429 0x1E
51 
52 #define IDX_LOW_WORD 0x60
53 #define IDX_HIGH_WORD 0x62
54 #define IDX_COVER_POS_LEN 0x64
55 #define IDX_COVER_DATA 0x66
56 
57 #define IDX_IF_CONFIG_429 0x68
58 #define IDX_POS_COMP_429 0x6A
59 #define IDX_POS_COMP_INT_429 0x6C
60 #define IDX_TYPE_VERSION_429 0x72
61 
62 #define IDX_REF_SWITCHES 0x7c
63 #define IDX_SMGP 0x7e
64 
65 #define TMC429_READ 0x01
66 
67 #define RM_RAMP 0
68 #define RM_SOFT 1
69 #define RM_VELOCITY 2
70 #define RM_HOLD 3
71 
72 #define NO_REF 0x03
73 #define SOFT_REF 0x04
74 
75 #define NO_LIMIT 0
76 #define HARD_LIMIT 1
77 #define SOFT_LIMIT 2
78 
79 #define REFSW_LEFT 0x02
80 #define REFSW_RIGHT 0x01
81 
82 #define M0_POS_REACHED 0x01
83 #define M1_POS_REACHED 0x04
84 #define M2_POS_REACHED 0x10
85 #define TMC429_STATUS_CDGW 0x40
86 #define TMC429_STATUS_INT 0x80
87 
88 #define IFLAG_POS_REACHED 0x01
89 #define IFLAG_REF_WRONG 0x02
90 #define IFLAG_REF_MISS 0x04
91 #define IFLAG_STOP 0x08
92 #define IFLAG_STOP_LEFT_LOW 0x10
93 #define IFLAG_STOP_RIGHT_LOW 0x20
94 #define IFLAG_STOP_LEFT_HIGH 0x40
95 #define IFLAG_STOP_RIGHT_HIGH 0x80
96 
97 #define IFCONF_INV_REF 0x0001
98 #define IFCONF_SDO_INT 0x0002
99 #define IFCONF_STEP_HALF 0x0004
100 #define IFCONF_INV_STEP 0x0008
101 #define IFCONF_INV_DIR 0x0010
102 #define IFCONF_EN_SD 0x0020
103 #define IFCONF_POS_COMP_0 0x0000
104 #define IFCONF_POS_COMP_1 0x0040
105 #define IFCONF_POS_COMP_2 0x0080
106 #define IFCONF_POS_COMP_OFF 0x00C0
107 #define IFCONF_EN_REFR 0x0100
108 
109 
110 void ReadWrite429(UCHAR *Read, UCHAR *Write);
111 void Write429Zero(UCHAR Address);
112 void Write429Bytes(UCHAR Address, UCHAR *Bytes);
113 void Write429Datagram(UCHAR Address, UCHAR HighByte, UCHAR MidByte, UCHAR LowByte);
114 void Write429Short(UCHAR Address, int Value);
115 void Write429Int(UCHAR Address, int Value);
116 UCHAR Read429Status(void);
117 UCHAR Read429Bytes(UCHAR Address, UCHAR *Bytes);
118 UCHAR Read429SingleByte(UCHAR Address, UCHAR Index);
119 int Read429Short(UCHAR Address);
120 int Read429Int(UCHAR Address);
121 void Set429RampMode(UCHAR Axis, UCHAR RampMode);
122 void Set429SwitchMode(UCHAR Axis, UCHAR SwitchMode);
123 UCHAR SetAMax(UCHAR Motor, UINT AMax);
124 void HardStop(UINT Motor);
125 
126 void Init429(void);
void Write429Int(UCHAR Address, int Value)
Write 24 bit value to a TMC429 register.
Definition: TMC429.c:178
void Write429Datagram(UCHAR Address, UCHAR HighByte, UCHAR MidByte, UCHAR LowByte)
TMC429 write access.
Definition: TMC429.c:116
UCHAR Read429SingleByte(UCHAR Address, UCHAR Index)
Read TMC429 register.
Definition: TMC429.c:243
void Set429SwitchMode(UCHAR Axis, UCHAR SwitchMode)
Set the end switch mode.
Definition: TMC429.c:337
void Init429(void)
TMC429 initialization.
Definition: TMC429.c:431
unsigned int UINT
32 bits unsigned
Definition: stepRocker.h:33
void ReadWrite429(UCHAR *Read, UCHAR *Write)
32 bit SPI communication with TMC429
Definition: TMC429.c:54
void Write429Zero(UCHAR Address)
Write zero to a TMC429 register.
Definition: TMC429.c:136
void Write429Bytes(UCHAR Address, UCHAR *Bytes)
TMC429 write access.
Definition: TMC429.c:94
UCHAR Read429Bytes(UCHAR Address, UCHAR *Bytes)
Read TMC429 register.
Definition: TMC429.c:217
int Read429Int(UCHAR Address)
Read TMC429 register (24 bit)
Definition: TMC429.c:289
void Set429RampMode(UCHAR Axis, UCHAR RampMode)
Set the ramping mode of an axis.
Definition: TMC429.c:313
UCHAR SetAMax(UCHAR Motor, UINT AMax)
Set the maximum acceleration.
Definition: TMC429.c:363
unsigned char UCHAR
8 bits unsigned
Definition: stepRocker.h:31
void HardStop(UINT Motor)
Stop a motor immediately.
Definition: TMC429.c:417
int Read429Short(UCHAR Address)
Read TMC429 register (12 bit)
Definition: TMC429.c:264
UCHAR Read429Status(void)
Read TMC429 status byte.
Definition: TMC429.c:200
void Write429Short(UCHAR Address, int Value)
Write 16 bit value to a TMC429 register.
Definition: TMC429.c:157