stepRocker Open Source TMCL
1.00
|
TMC4361 Ramp generator functions. More...
#include <stdlib.h>
#include "derivative.h"
#include "bits.h"
#include "stepRocker.h"
#include "Globals.h"
#include "SPI.h"
#include "TMC4361.h"
Functions | |
void | WriteTMC43xxBytes (UCHAR Axis, UCHAR Address, UCHAR x1, UCHAR x2, UCHAR x3, UCHAR x4) |
Write bytes to a TMC4361 register. More... | |
void | WriteTMC43xxInt (UCHAR Axis, UCHAR Address, int Value) |
Write a 32 bit integer value to a TMC4361 register. More... | |
int | ReadTMC43xxInt (UCHAR Axis, UCHAR Address) |
Read from a TMC4361 register. More... | |
void | TMC43xxSetBits (UCHAR Axis, UCHAR Address, UINT BitMask) |
Set bits in a TMC4361 register. More... | |
void | TMC43xxClearBits (UCHAR Axis, UCHAR Address, UINT BitMask) |
Clear bits in a TMC4361 register. More... | |
void | TMC43xxWriteBits (UCHAR Axis, UCHAR Address, UINT Value, UCHAR Start, UCHAR Size) |
Write bits in a TMC4361 register. More... | |
UINT | PeekTMC43xxEvents (UCHAR Axis) |
Read events without clearing them. More... | |
UINT | ReadAndClearTMC43xxEvents (UCHAR Axis, UINT EventMask) |
Read events and clear specific events. More... | |
void | HardStop (UINT Axis) |
Stop the motor immediately. More... | |
void | InitTMC43xx (void) |
Initialize the TMC4361. More... | |
void | ResetTMC43xx (void) |
Reset the TMC4361. More... | |
UCHAR | GetHomeInput (UCHAR Motor) |
Read TMC4361 home input. More... | |
int | ConvertVelocityUserToInternal (int UserVelocity) |
Convert from pps to internal unit. More... | |
int | ConvertAccelerationUserToInternal (int UserAcceleration) |
Convert from pps/s to internal unit. More... | |
int | ConvertVelocityInternalToUser (int InternalVelocity) |
Convert from internal unit to pps. More... | |
int | ConvertAccelerationInternalToUser (int InternalAcceleration) |
Convert from internal unit to pps/s. More... | |
int | ConvertInternalToInternal (int Internal) |
Dummy function used when unit conversion is switched off. More... | |
Variables | |
USHORT | TMC43xxTable [1] ={SPI_DEV_TMC43xx_0} |
TMC4361 Ramp generator functions.
This file provides all functions needed for easy access to the TMC4361 stepper motor driver IC.
ConvertAccelerationInternalToUser | ( | int | InternalAcceleration | ) |
Convert from internal unit to pps/s.
InternalAcceleration | Accleration/Deceleration as internal value |
This function converts an acceleration/deceleration value given in internal units of the TMC4361 back into pps/s.
ConvertAccelerationUserToInternal | ( | int | UserAcceleration | ) |
Convert from pps/s to internal unit.
UserVelocity | Acceleration/Deceleration as pps/s value |
This function converts an acceleration value or a deceleration value given in pps/s for use with most TMC4361 acceleration/deceleration registers.
ConvertInternalToInternal | ( | int | Internal | ) |
Dummy function used when unit conversion is switched off.
Internal | Input value |
This is a dummy function which is used when unit conversion is switched off.
ConvertVelocityInternalToUser | ( | int | InternalVelocity | ) |
Convert from internal unit to pps.
InternalVelocity | Velocity as internal value |
This function converts a velocity value given in internal units of the TMC4361 back into pps.
ConvertVelocityUserToInternal | ( | int | UserVelocity | ) |
Convert from pps to internal unit.
UserVelocity | Velocity as pps value |
This function converts a velocity value given in pps for use with most TMC4361 velocity registers.
GetHomeInput | ( | UCHAR | Motor | ) |
Read TMC4361 home input.
Motor | Index of TMC4361 to be used (with stepRocker always 0) |
This function reads the TMC4361 home input. This works using a little trick: Bit 17 and bit 16 in the REFERENCE_CONF register must be set and the XHOME register must be set to INT_MAX.
HardStop | ( | UINT | Axis | ) |
Stop the motor immediately.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
This function stops the motor immediately, without using any deceleration ramp.
InitTMC43xx | ( | void | ) |
Initialize the TMC4361.
This function initializes the TMC4361.
PeekTMC43xxEvents | ( | UCHAR | Axis | ) |
Read events without clearing them.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
This function reads the TMC4361 event register, without clearing the event bits (by setting the event clear mask to 0xffffffff before reading the event register).
Read events and clear specific events.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
EventMask | Clear all event bits that are set here |
This function reads the TMC4361 event register and clears all event bits specified by EventMask (all bits that are set there).
Read from a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
This is a low level function for reading data from a TMC4361 register.
ResetTMC43xx | ( | void | ) |
Reset the TMC4361.
This function resets the TMC4361 (by pulling its reset pin low for some clock periods).
Clear bits in a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
BitMask | Bits to be cleared |
This function clears specified bits in a specified register. Bits that are set in the bit mask will be cleared in the register, too. All other bits in the register remain untouched.
Set bits in a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
BitMask | Bits to be set |
This function sets specified bits in a specified register. Bits that are set in the bit mask will also be set in the register. All other bits in the register remain untouched.
Write bits in a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
Value | Value to be written |
Start | First bit to be written |
Size | Number of bits to be written |
This function writes to specified bits in a specified register. The value given will be copied to the specified register, limited to the bits specified by Start and Size. All other bits remain unchanged.
Write bytes to a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
x1 | First byte to write (MSB) |
x2 | Second byte to write |
x3 | Third byte to write |
x4 | Fourth byte to write (LSB) |
This is a low level function for writing data to a TMC4361 register (32 bit value split up into four bytes).
Write a 32 bit integer value to a TMC4361 register.
Axis | Index of TMC4361 to be used (with stepRocker always 0) |
Address | TMC4361 register address |
Value | Value to be written |
This is a low level function for writing data to a TMC4361 register (32 bit value).