SerialNEST (OP-LIB-006)

From openPicus Wiki
Jump to: navigation, search

Contents

Description

To help user in the Serial Parameters configuration, two helper libraries was developed.

The RS232Helper library permits to configure the remappable pin of the FLYPORT with the add-on of RTS/CTS hardware flow control enable/disable. Plus, it can set the baudrate, the data bits and parity, and the stop bits.

The RS485Helper library permits to configure the remappable pin of the FLYPORT with separated DE (write enable) and RE (receive enable) control, the baudrate, the data bits and parity, and the stop bits.

Content

  • RS232Helper.c
  • RS232Helper.h
  • RS485Helper.c
  • RS485Helper.h

Download

OP-LIB-006 Serial RS232 RS485

Connections

Importing into OpenPicus IDE

How To import external Lib Tutorial

Commands - RS232Helper


RS232Remap

Function to remap the UART as RS232 port

VOID RS232Remap(int port, int TXPin, int RXPin, int RTSPin, int CTSPin)
Argument Description
int port UART port number
int TXPin pin to use as TX
int RXPin pin to use as RX
int RTSPin pin to use as RTS (0 if not used)
int CTSPin pin to use as CTS (0 if not used)


RS232Init

Function to initialize the speed of RS232

VOID RS232Init( int port, long int baud)
Argument Description
int port UART port number
long int baud value of desired baudrate


RS232SetParam

Function to setup RS232 parameters

VOID RS232SetParam( int port, int param, int value)
Argument Description
int port UART port number
int param parameter to set
  • RS232_STOP_BITS
  • RS232_DATA_PARITY
int value values to set
  • stop bits:
    • RS232_ONE_STOP
    • RS232_TWO_STOP
  • data bits and parity:
    • RS232_8BITS_PARITY_NONE
    • RS232_8BITS_PARITY_EVEN
    • RS232_8BITS_PARITY_ODD
    • RS232_9BITS_PARITY_NONE


RS232On

Function to turn on the UART of RS232

VOID RS232On( int port)
Argument Description
int port UART port number


RS232Off

Function to turn off the UART of RS232

VOID RS232Off( int port)
Argument Description
int port UART port number


RS232Flush

Function to flush the RS232 receive buffer

VOID RS232Flush(int port)
Argument Description
int port UART port number


RS232BufferSize

Function returns the size of the receive buffer of the selected RS232
returns how many chars are available to read

INT RS232BufferSize( int port)
Argument Description
int port UART port number


RS232Write

Function to write chars to RS232

VOID RS232Write( int port, char* buffer)
Argument Description
int port UART port number
char* buffer char array buffer of data to write


RS232Read

Function to read from RS232 receive buffer
returns how many chars were successfully read

INT RS232Read( int port, char* towrite, int value)
Argument Description
int port UART port number
char* towrite char array buffer to store data
int value how many chars to read from the buffer


RS232WriteCh

Function to write a single char to RS232

VOID RS232WriteCh( int port, char chr)
Argument Description
int port UART port number
char chr char to write


Commands - RS485Helper


RS485Remap

Function to remap the UART as RS485 port

VOID RS485Remap( int port, int TXPin, int RXPin, int writeEnPin, int readEnPin)
Argument Description
int port UART port number
int TXPin pin to use as TX
int RXPin pin to use as RX
int writeEnPin pin to use as Write Enable
int readEnPin pin to use as Read Enable


RS485Init

Function to initialize the speed of RS485

VOID RS485Init( int port, long int baud)
Argument Description
int port UART port number
long int baud value of desired baudrate


RS485SetParam

Function to setup RS485 parameters

VOID RS485SetParam( int port, int param, int value)
Argument Description
int port UART port number
int param parameter to set
  • RS485_STOP_BITS
  • RS485_DATA_PARITY
int value values to set
  • stop bits:
    • RS485_ONE_STOP
    • RS485_TWO_STOP
  • data bits and parity:
    • RS485_8BITS_PARITY_NONE
    • RS485_8BITS_PARITY_EVEN
    • RS485_8BITS_PARITY_ODD
    • RS485_9BITS_PARITY_NONE


RS485On

Function to turn on the UART of RS485

VOID RS485On( int port)
Argument Description
int port UART port number


RS485Off

Function to turn off the UART of RS485

VOID RS485Off( int port)
Argument Description
int port UART port number


RS485Flush

Function to flush the RS485 receive buffer

VOID RS485Flush(int port)
Argument Description
int port UART port number


RS485BufferSize

Function returns the size of the receive buffer of the selected RS485
returns how many chars are available to read

INT RS232BufferSize( int port)
Argument Description
int port UART port number


RS485Write

Function to write chars to RS485

VOID RS485Write( int port, char* buffer)
Argument Description
int port UART port number
char* buffer char array buffer (with terminator character) of data to write


RS485Read

Function to read from RS485 receive buffer
returns how many chars were successfully read

INT RS485Read( int port, char* towrite, int value)
Argument Description
int port UART port number
char* towrite char array buffer to store data
int value how many chars to read from the buffer


RS485WriteCh

Function to write a single char to RS485

VOID RS485WriteCh( int port, char chr)
Argument Description
int port UART port number
char chr char to write


RS485WriteChs

Function to write a char array to RS485

VOID RS485WriteChs(int port, char *buffer, int len)
Argument Description
int port UART port number
char *buffer data to be sent
int len the buffer length

Related Resources

Credits

Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox