AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/at91sam7s/rs485.c
void RS485_Send_Data(
    uint8_t * buffer,   /* data to send */
    uint16_t nbytes)
{       /* number of bytes of data */
    /* LED on send */
    volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
    /* LED ON */
    pPIO->PIO_CODR = LED1;
    /* send all the bytes */
    while (nbytes) {
        while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
            /* do nothing - wait until Tx buffer is empty */
        }
        RS485_Interface->US_THR = *buffer;
        buffer++;
        nbytes--;
    }
    while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
        /* do nothing - wait until Tx buffer is empty */
    }
    /* per MSTP spec */
    Timer_Silence_Reset();
}
/****************************************************************************
* DESCRIPTION: Send some data and wait until it is sent
* RETURN:      none
* ALGORITHM:   none
* NOTES:       none
*****************************************************************************/
Send some data and wait until it is sent
RETURN:      none
ALGORITHM:   none
NOTES:       none
Send some data and wait until it is sent RETURN : none ALGORITHM : none NOTES : none
void RS485_Send_Data(
    uint8_t * buffer,   
    uint16_t nbytes)
{       
    volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
    pPIO->PIO_CODR = LED1;
    while (nbytes) {
        while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
        }
        RS485_Interface->US_THR = *buffer;
        buffer++;
        nbytes--;
    }
    while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
    }
    Timer_Silence_Reset();
}
void RS485_Send_Data ( uint8_t * buffer , uint16_t nbytes ) { volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA ; pPIO -> PIO_CODR = LED1 ; while ( nbytes ) { while ( ! ( RS485_Interface -> US_CSR & AT91C_US_TXRDY ) ) { } RS485_Interface -> US_THR = * buffer ; buffer ++ ; nbytes -- ; } while ( ! ( RS485_Interface -> US_CSR & AT91C_US_TXRDY ) ) { } Timer_Silence_Reset ( ) ; }
DESCRIPTION: Send some data and wait until it is sent
RETURN:      none
ALGORITHM:   none
NOTES:       none
DESCRIPTION : Send some data and wait until it is sent RETURN : none ALGORITHM : none NOTES : none
/* data to send */ /* number of bytes of data */ /* LED on send */ /* LED ON */ /* send all the bytes */ /* do nothing - wait until Tx buffer is empty */ /* do nothing - wait until Tx buffer is empty */ /* per MSTP spec */