Ejemplo n.º 1
0
void _485PortInit(unsigned char Port, int baud, unsigned char stopBits, unsigned char Parity)
{	
    //UARTWrite(1, "_485PortInit...");		
	Port_ = Port;
	Baud_ = baud;
	
	// Initialize the serial port
	RS485Remap(Port_, TX_485, RX_485, DE_485, RE_485);
	RS485Init(Port_, Baud_);
    UARTInit(Port_, Baud_);  		
	RS485SetParam(Port_, RS485_STOP_BITS, stopBits);
	RS485SetParam(Port_, RS485_DATA_PARITY, Parity);
	RS485On(Port_);	
	vTaskDelay(100);
	
    //UARTWrite(1, "..._SerialPortInit");		
}
Ejemplo n.º 2
0
int main (void) {
    uint8_t i;

    /* SystemClockUpdate() updates the SystemFrequency variable */
    SystemClockUpdate();

    /* Clear receive buffer, handled inside ISR. */
    for ( i = 0; i < BUFSIZE; i++ )
    {
        UARTBuffer[i] = 0x00;
    }

    /* NVIC is installed inside UARTInit file. */
    RS485Init(115200);

    /* To test RS485 mode, connect two boards, one is set to TX and
    the other is RX. The test is conducted on the inter-board communication. */
#if RS485_RX
    /* If RX, do nothing, check the content of UARTBuffer */
    /* To get the test result, program the boards with both TX and RX program,
    power up the board with the RX program first, start the debugger on the
    board with the RX program, power up the board with the TX program, stop
    the debugger, and check the content of the UARTBuffer on the RX program,
    it should be the same as seen on UARTTxBuffer, 0x01-0x02-0x03.... */
    while ( 1 );

#else
    /* If TX. send a string out start with RS485 slave address */
    UARTTxBuffer[0] = RS485_SLAVE_ADR;
    for ( i = 1; i < BUFSIZE; i++ )
    {
        UARTTxBuffer[i] = i;
    }
    RS485Send((uint8_t *)UARTTxBuffer, BUFSIZE);
    while ( 1 );
#endif			/* #endif RS485_RX */

}