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

RS485 functions. More...

#include "derivative.h"
#include "bits.h"
#include "stepRocker.h"
#include "nvic.h"
Include dependency graph for RS485.c:

Macros

#define UART0   UART0_BASE_PTR
 
#define UART_BUFFER_SIZE   32
 Size of the RS485 transmit and receive buffers.
 
#define UART_TIMEOUT_VALUE   5
 Timeout value (ms)
 
#define SET_RS485_SEND_MODE()   GPIOA_PSOR=BIT17
 Switch RS485 transceiver to send mode.
 
#define SET_RS485_RECEIVE_MODE()   GPIOA_PCOR=BIT17
 Switch RS485 transceiver to receive mode.
 
#define IS_RS485_SENDING()   (GPIOA_PDOR & BIT17)
 TRUE when transceiver is in send mode.
 

Functions

void __attribute__ ((interrupt))
 
void InitRS485 (UCHAR baudrateIndex)
 Initalize RS485 interface. More...
 
void WriteRS485 (char Byte)
 
UCHAR ReadRS485 (char *Byte)
 
void SetUARTTransmitDelay (UINT Delay)
 Set RS485 transmit delay. More...
 
UINT CheckUARTTimeout (void)
 Check and reset RS485 timeout flag. More...
 

Variables

static const UINT baudrateTable [] = {9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200, 230400, 250000, 500000, 1000000}
 
static volatile char UARTRxBuffer [UART_BUFFER_SIZE]
 Receive buffer.
 
static volatile char UARTTxBuffer [UART_BUFFER_SIZE]
 Transmit buffer.
 
static volatile int UARTRxWritePtr
 Receive buffer read index.
 
static volatile int UARTRxReadPtr
 Receive buffer write index.
 
static volatile int UARTTxWritePtr
 Transmit buffer write index.
 
static volatile int UARTTxReadPtr
 Transmit buffer read index.
 
static volatile UINT UARTTransmitDelay
 Delay between receiving and sending.
 
volatile UCHAR UARTTimeoutFlag
 Timeout flag (gets set in the system timer interrupt)
 
volatile UINT UARTTimeoutTimer
 Timeout timer (gets deceremented in the system timer interrupt)
 
volatile UINT UARTTransmitDelayTimer
 Timer for delay between receiving and sending (gets decremented in the system timer interrupt)
 

Detailed Description

RS485 functions.

Author
Trinamic Motion Control GmbH & Co KG
Version
2.20

This file provides all functions needed for using the RS485 interface.

Function Documentation

CheckUARTTimeout ( void  )

Check and reset RS485 timeout flag.

Returns
TRUE if there has been a timeout (>5ms after last received byte)
FALSE if there has not been a timeout since the last call of this function

This function checks the timeout flag and then resets it.

Here is the caller graph for this function:

InitRS485 ( UCHAR  baudrateIndex)

Initalize RS485 interface.

Parameters
Baudratebaud rate code (0..11)

This function initializes the RS485 interface. The baud rate codes are the same as with TMCL.

Here is the caller graph for this function:

SetUARTTransmitDelay ( UINT  Delay)

Set RS485 transmit delay.

Parameters
DelayDelay in ms

This function sets the delay between receiving the last byte and sending the first byte. This can be necessary with some RS485 interfaces.

Here is the caller graph for this function: