Corrected Atmel ARM7 AT91SAM7S port by fixing some problems in the dlmstp.c functions. Validated.

This commit is contained in:
skarg
2007-08-20 15:57:13 +00:00
parent eabe6dee96
commit 4980eb8b2e
3 changed files with 14 additions and 12 deletions
+9 -8
View File
@@ -51,15 +51,15 @@ void dlmstp_copy_bacnet_address(BACNET_ADDRESS * dest, BACNET_ADDRESS * src)
{ {
int i = 0; int i = 0;
if (src && dest) { if (dest && src) {
src->mac_len = dest->mac_len; dest->mac_len = src->mac_len;
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
src->mac[i] = dest->mac[i]; dest->mac[i] = src->mac[i];
} }
src->net = dest->net; dest->net = src->net;
src->len = dest->len; dest->len = src->len;
for (i = 0; i < MAX_MAC_LEN; i++) { 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.InputBufferSize = sizeof(RxBuffer);
MSTP_Port.OutputBuffer = &TxBuffer[0]; MSTP_Port.OutputBuffer = &TxBuffer[0];
MSTP_Port.OutputBufferSize = sizeof(TxBuffer); MSTP_Port.OutputBufferSize = sizeof(TxBuffer);
MSTP_Init.SilenceTimer = Timer_Silence; MSTP_Port.SilenceTimer = Timer_Silence;
MSTP_Init.SilenceTimerReset = Timer_Silence_Reset; MSTP_Port.SilenceTimerReset = Timer_Silence_Reset;
MSTP_Init(&MSTP_Port); MSTP_Init(&MSTP_Port);
return true; return true;
@@ -248,6 +248,7 @@ uint16_t MSTP_Get_Send(
destination, src, destination, src,
&Transmit_Packet.pdu[0], &Transmit_Packet.pdu[0],
Transmit_Packet.pdu_len); Transmit_Packet.pdu_len);
Transmit_Packet.ready = false;
} }
return pdu_len; return pdu_len;
+3 -2
View File
@@ -163,7 +163,7 @@ void RS485_Send_Frame(
if (!turnaround_time) { if (!turnaround_time) {
turnaround_time = 1; turnaround_time = 1;
} }
while (mstp_port->SilenceTimer < turnaround_time) { while (mstp_port->SilenceTimer() < turnaround_time) {
/* do nothing - wait for timer to increment */ /* do nothing - wait for timer to increment */
}; };
} }
@@ -180,7 +180,7 @@ void RS485_Send_Frame(
nbytes--; nbytes--;
/* per MSTP spec */ /* per MSTP spec */
if (mstp_port) { if (mstp_port) {
mstp_port->SilenceTimer = 0; mstp_port->SilenceTimerReset();
} }
} }
while (!(RS485_Interface->US_CSR & AT91C_US_TXRDY)) { 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; volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
/* FIXME: Framing or overrun error? */
if (mstp_port->ReceiveError == true) { if (mstp_port->ReceiveError == true) {
/* wait for state machine to clear this */ /* wait for state machine to clear this */
} }
+2 -2
View File
@@ -330,8 +330,8 @@ void Timer_Silence_Reset(void)
// Moved timer startup code from main // Moved timer startup code from main
// modified the peripheral clock init // modified the peripheral clock init
// ***************************************************************************** // *****************************************************************************
void TimerInit(void) { void TimerInit(void)
pTimer_MSTP_Silence = dlmstp_millisecond_timer_address(); {
// enable the Timer0 peripheral clock // enable the Timer0 peripheral clock
volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; volatile AT91PS_PMC pPMC = AT91C_BASE_PMC;
pPMC->PMC_PCER = pPMC->PMC_PCSR | (1<<AT91C_ID_TC0); pPMC->PMC_PCER = pPMC->PMC_PCSR | (1<<AT91C_ID_TC0);