changed delays to yields.
This commit is contained in:
@@ -73,13 +73,11 @@ static void RS485_Standard_Port_Settings(long port, long *pIRQ,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TestCOMPort(
|
static int TestCOMPort(int Base)
|
||||||
int Base)/* base address of UART */
|
{ /* base address of UART */
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i<256; i++)
|
for (i = 0; i < 256; i++) {
|
||||||
{
|
|
||||||
RTOut(Base + 7, (BYTE) i); // write scratch register
|
RTOut(Base + 7, (BYTE) i); // write scratch register
|
||||||
RTOut(Base + 1, RTIn(Base + 1)); // read/write IER
|
RTOut(Base + 1, RTIn(Base + 1)); // read/write IER
|
||||||
if (RTIn(Base + 7) != i) // check scratch register
|
if (RTIn(Base + 7) != i) // check scratch register
|
||||||
@@ -144,11 +142,9 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
fprintf(stderr, "RS485 Tx:");
|
fprintf(stderr, "RS485 Tx:");
|
||||||
for (i = 0; i < nbytes; i++)
|
for (i = 0; i < nbytes; i++) {
|
||||||
{
|
|
||||||
fprintf(stderr, " %02X", buffer[i]);
|
fprintf(stderr, " %02X", buffer[i]);
|
||||||
if ((!(i%20)) && (i != 0))
|
if ((!(i % 20)) && (i != 0)) {
|
||||||
{
|
|
||||||
fprintf(stderr, "\r\n ");
|
fprintf(stderr, "\r\n ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,18 +161,18 @@ void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
|||||||
unsigned timeout = 1; /* milliseconds to wait for a character */
|
unsigned timeout = 1; /* milliseconds to wait for a character */
|
||||||
static Duration ticks = 0; /* duration to wait for data */
|
static Duration ticks = 0; /* duration to wait for data */
|
||||||
|
|
||||||
|
if (mstp_port->ReceiveError) {
|
||||||
|
/* wait for state machine to clear this */
|
||||||
|
RTKScheduler();
|
||||||
|
}
|
||||||
|
/* wait for state machine to read from the DataRegister */
|
||||||
|
else if (!mstp_port->DataAvailable) {
|
||||||
if (!ticks)
|
if (!ticks)
|
||||||
{
|
{
|
||||||
ticks = MilliSecsToTicks(timeout);
|
ticks = MilliSecsToTicks(timeout);
|
||||||
if (!ticks)
|
if (!ticks)
|
||||||
ticks = 1;
|
ticks = 1;
|
||||||
}
|
}
|
||||||
if (mstp_port->ReceiveError) {
|
|
||||||
/* wait for state machine to clear this */
|
|
||||||
RTKDelay(ticks);
|
|
||||||
}
|
|
||||||
/* wait for state machine to read from the DataRegister */
|
|
||||||
else if (!mstp_port->DataAvailable) {
|
|
||||||
/* check for data */
|
/* check for data */
|
||||||
if (RTKGetTimed(ReceiveBuffer[RS485_Port], &com_data, ticks)) {
|
if (RTKGetTimed(ReceiveBuffer[RS485_Port], &com_data, ticks)) {
|
||||||
/* if error, */
|
/* if error, */
|
||||||
@@ -191,6 +187,5 @@ void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RTKDelay(ticks);
|
RTKScheduler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user