3.10 Serial Port Configuration
Driver supports configuration of serial port mode for RS232, RS422 and RS485.
The SAMD51 function for configuring serial port mode is DSCSAM_SerialPortConfig.
Step-By-Step Instructions
The serial port will be configured according to the argument mode provided to function DSCSAM_SerialPortConfig(). The serial port will be configured as RS232 if 0 is provided as argument , will be configured as RS422 if 1 is provided as argument and will be configured as RS485 if 2 is given as argument.
...
ERRPARAMS errparams; // structure for returning error code and error string
BYTE mode,port;
...
// To configure serial port as RS232
mode = 0; // 0- RS232, 1-RS422, 2-RS485
port = 0; // 0 - Serial Port pair 1 and 2 , 1 - Serial port pair 3 and 4
if(DSCSAM_SerialPortConfig(mode,port) != DE_NONE)
{
DSCGetLastError ( &errparams );
printf ( "DSCSAM_SerialPortConfig error: %s %s\n", DSCGetErrorString ( errparams.ErrCode ), errparams.errstring );
return 0;
}
...
Last updated
Was this helpful?