Corrected Atmel ARM7 AT91SAM7S port by fixing some problems in the dlmstp.c functions. Validated.
This commit is contained in:
@@ -51,15 +51,15 @@ void dlmstp_copy_bacnet_address(BACNET_ADDRESS * dest, BACNET_ADDRESS * src)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (src && dest) {
|
||||
src->mac_len = dest->mac_len;
|
||||
if (dest && src) {
|
||||
dest->mac_len = src->mac_len;
|
||||
for (i = 0; i < MAX_MAC_LEN; i++) {
|
||||
src->mac[i] = dest->mac[i];
|
||||
dest->mac[i] = src->mac[i];
|
||||
}
|
||||
src->net = dest->net;
|
||||
src->len = dest->len;
|
||||
dest->net = src->net;
|
||||
dest->len = src->len;
|
||||
for (i = 0; i < MAX_MAC_LEN; i++) {
|
||||
src->adr[i] = dest->adr[i];
|
||||
dest->adr[i] = src->adr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,8 @@ bool dlmstp_init(char *ifname)
|
||||
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
||||
MSTP_Port.OutputBuffer = &TxBuffer[0];
|
||||
MSTP_Port.OutputBufferSize = sizeof(TxBuffer);
|
||||
MSTP_Init.SilenceTimer = Timer_Silence;
|
||||
MSTP_Init.SilenceTimerReset = Timer_Silence_Reset;
|
||||
MSTP_Port.SilenceTimer = Timer_Silence;
|
||||
MSTP_Port.SilenceTimerReset = Timer_Silence_Reset;
|
||||
MSTP_Init(&MSTP_Port);
|
||||
|
||||
return true;
|
||||
@@ -248,6 +248,7 @@ uint16_t MSTP_Get_Send(
|
||||
destination, src,
|
||||
&Transmit_Packet.pdu[0],
|
||||
Transmit_Packet.pdu_len);
|
||||
Transmit_Packet.ready = false;
|
||||
}
|
||||
|
||||
return pdu_len;
|
||||
|
||||
@@ -163,7 +163,7 @@ void RS485_Send_Frame(
|
||||
if (!turnaround_time) {
|
||||
turnaround_time = 1;
|
||||
}
|
||||
while (mstp_port->SilenceTimer < turnaround_time) {
|
||||
while (mstp_port->SilenceTimer() < turnaround_time) {
|
||||
/* do nothing - wait for timer to increment */
|
||||
};
|
||||
}
|
||||
@@ -180,7 +180,7 @@ void RS485_Send_Frame(
|
||||
nbytes--;
|
||||
/* per MSTP spec */
|
||||
if (mstp_port) {
|
||||
mstp_port->SilenceTimer = 0;
|
||||
mstp_port->SilenceTimerReset();
|
||||
}
|
||||
}
|
||||
while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) {
|
||||
@@ -195,6 +195,7 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
|
||||
|
||||
/* FIXME: Framing or overrun error? */
|
||||
if (mstp_port->ReceiveError == true) {
|
||||
/* wait for state machine to clear this */
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ void Timer_Silence_Reset(void)
|
||||
// Moved timer startup code from main
|
||||
// modified the peripheral clock init
|
||||
// *****************************************************************************
|
||||
void TimerInit(void) {
|
||||
pTimer_MSTP_Silence = dlmstp_millisecond_timer_address();
|
||||
void TimerInit(void)
|
||||
{
|
||||
// enable the Timer0 peripheral clock
|
||||
volatile AT91PS_PMC pPMC = AT91C_BASE_PMC;
|
||||
pPMC->PMC_PCER = pPMC->PMC_PCSR | (1<<AT91C_ID_TC0);
|
||||
|
||||
Reference in New Issue
Block a user