stepRocker Open Source TMCL  1.00
 All Data Structures Files Functions Variables Typedefs Enumerations Macros
Functions | Variables
TMC4361.c File Reference

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"
Include dependency graph for TMC4361.c:

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}
 

Detailed Description

TMC4361 Ramp generator functions.

Author
Trinamic Motion Control GmbH & Co KG
Version
1.00

This file provides all functions needed for easy access to the TMC4361 stepper motor driver IC.

Function Documentation

ConvertAccelerationInternalToUser ( int  InternalAcceleration)

Convert from internal unit to pps/s.

Parameters
InternalAccelerationAccleration/Deceleration as internal value
Returns
PPS/S acceleration/deceleration value

This function converts an acceleration/deceleration value given in internal units of the TMC4361 back into pps/s.

Here is the caller graph for this function:

ConvertAccelerationUserToInternal ( int  UserAcceleration)

Convert from pps/s to internal unit.

Parameters
UserVelocityAcceleration/Deceleration as pps/s value
Returns
Internal acceleration/deceleration value

This function converts an acceleration value or a deceleration value given in pps/s for use with most TMC4361 acceleration/deceleration registers.

Here is the caller graph for this function:

ConvertInternalToInternal ( int  Internal)

Dummy function used when unit conversion is switched off.

Parameters
InternalInput value
Returns
Unchanged value

This is a dummy function which is used when unit conversion is switched off.

Here is the caller graph for this function:

ConvertVelocityInternalToUser ( int  InternalVelocity)

Convert from internal unit to pps.

Parameters
InternalVelocityVelocity as internal value
Returns
PPS velocity value

This function converts a velocity value given in internal units of the TMC4361 back into pps.

Here is the caller graph for this function:

ConvertVelocityUserToInternal ( int  UserVelocity)

Convert from pps to internal unit.

Parameters
UserVelocityVelocity as pps value
Returns
Internal velocity value

This function converts a velocity value given in pps for use with most TMC4361 velocity registers.

Here is the caller graph for this function:

GetHomeInput ( UCHAR  Motor)

Read TMC4361 home input.

Parameters
MotorIndex of TMC4361 to be used (with stepRocker always 0)
Returns
State of the home input (TRUE or FALSE)

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.

Here is the call graph for this function:

Here is the caller graph for this function:

HardStop ( UINT  Axis)

Stop the motor immediately.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)

This function stops the motor immediately, without using any deceleration ramp.

Here is the call graph for this function:

Here is the caller graph for this function:

InitTMC43xx ( void  )

Initialize the TMC4361.

This function initializes the TMC4361.

Here is the call graph for this function:

Here is the caller graph for this function:

PeekTMC43xxEvents ( UCHAR  Axis)

Read events without clearing them.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
Returns
Value of the event register

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).

Here is the call graph for this function:

Here is the caller graph for this function:

ReadAndClearTMC43xxEvents ( UCHAR  Axis,
UINT  EventMask 
)

Read events and clear specific events.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
EventMaskClear all event bits that are set here
Returns
Value of the event register

This function reads the TMC4361 event register and clears all event bits specified by EventMask (all bits that are set there).

Here is the call graph for this function:

Here is the caller graph for this function:

ReadTMC43xxInt ( UCHAR  Axis,
UCHAR  Address 
)

Read from a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
Returns
Value read from the register

This is a low level function for reading data from a TMC4361 register.

Here is the caller graph for this function:

ResetTMC43xx ( void  )

Reset the TMC4361.

This function resets the TMC4361 (by pulling its reset pin low for some clock periods).

TMC43xxClearBits ( UCHAR  Axis,
UCHAR  Address,
UINT  BitMask 
)

Clear bits in a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
BitMaskBits 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.

Here is the call graph for this function:

Here is the caller graph for this function:

TMC43xxSetBits ( UCHAR  Axis,
UCHAR  Address,
UINT  BitMask 
)

Set bits in a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
BitMaskBits 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.

Here is the call graph for this function:

Here is the caller graph for this function:

TMC43xxWriteBits ( UCHAR  Axis,
UCHAR  Address,
UINT  Value,
UCHAR  Start,
UCHAR  Size 
)

Write bits in a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
ValueValue to be written
StartFirst bit to be written
SizeNumber 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.

Here is the call graph for this function:

Here is the caller graph for this function:

WriteTMC43xxBytes ( UCHAR  Axis,
UCHAR  Address,
UCHAR  x1,
UCHAR  x2,
UCHAR  x3,
UCHAR  x4 
)

Write bytes to a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
x1First byte to write (MSB)
x2Second byte to write
x3Third byte to write
x4Fourth 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).

Here is the caller graph for this function:

WriteTMC43xxInt ( UCHAR  Axis,
UCHAR  Address,
int  Value 
)

Write a 32 bit integer value to a TMC4361 register.

Parameters
AxisIndex of TMC4361 to be used (with stepRocker always 0)
AddressTMC4361 register address
ValueValue to be written

This is a low level function for writing data to a TMC4361 register (32 bit value).

Here is the caller graph for this function: