Example #1
0
/****************************************************************************
* DESCRIPTION: Send some data and wait until it is sent
* RETURN:      none
* ALGORITHM:   none
* NOTES:       none
*****************************************************************************/
void RS485_Send_Data(
    uint8_t * buffer,   /* data to send */
    uint16_t nbytes)
{       

	memcpy(uart_send, buffer, nbytes); 
	if(modbus.com_config[0] == BAC_MSTP)
	{
		USART_SendDataString(nbytes);
//		/* while (nbytes) 
//		{
//			SBUF0 = *buffer;	
//	        MSTP_Transmit_Finished = 0;
//			count = 0;
//	        while (!MSTP_Transmit_Finished && count < 2500) {
//			count++;
//	            /* do nothing - wait until Tx buffer is empty */
//	        }
//			gbReceiveError = false;
//			if(count >= 2500)
//			{		
//				gbReceiveError = true;
//			}
//				
//	        buffer++;
//	        nbytes--;
//	    }*/
	}
	/*if(Modbus.com_config[2] == MAIN_MSTP)
	{
		uart_send_string(buffer,nbytes,2);
	}*/
    /* per MSTP spec */
    Timer_Silence_Reset();
}
Example #2
0
/****************************************************************************
* DESCRIPTION: Send some data and wait until it is sent
* RETURN:      none
* ALGORITHM:   none
* NOTES:       none
*****************************************************************************/
void RS485_Send_Data(
    uint8_t * buffer,   /* data to send */
    uint16_t nbytes)
{       /* number of bytes of data */
    /* send all the bytes */
    ComSendData(buffer, nbytes);
    while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
        /* do nothing - wait until Tx buffer is empty */
    }
    /* per MSTP spec */
    Timer_Silence_Reset();
}