stepRocker Open Source TMCL
1.00
|
RS485 functions. More...
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) |
Write to the RS485 interface. More... | |
UCHAR | ReadRS485 (char *Byte) |
Read from the RS485 interface. More... | |
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) | |
RS485 functions.
This file provides all functions needed for using the RS485 interface.
CheckUARTTimeout | ( | void | ) |
Check and reset RS485 timeout flag.
This function checks the timeout flag and then resets it.
InitRS485 | ( | UCHAR | baudrateIndex | ) |
Initalize RS485 interface.
Baudrate | baud rate code (0..11) |
This function initializes the RS485 interface. The baud rate codes are the same as with TMCL.
ReadRS485 | ( | char * | Byte | ) |
Read from the RS485 interface.
Byte | Pointer to variable for result |
This function tries to read a byte from the RS485 receive buffer.
SetUARTTransmitDelay | ( | UINT | Delay | ) |
Set RS485 transmit delay.
Delay | Delay 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.
WriteRS485 | ( | char | Byte | ) |
Write to the RS485 interface.
Byte | Byte to be written |
This function puts a byte into the RS485 transmit buffer and starts sending if not already done.