Simplified timeout handling in MAC driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10935 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2017-11-04 15:06:17 +00:00
parent 981e11216a
commit b2b05acab3
1 changed files with 1 additions and 12 deletions

View File

@ -151,7 +151,6 @@ msg_t macWaitTransmitDescriptor(MACDriver *macp,
MACTransmitDescriptor *tdp,
sysinterval_t timeout) {
msg_t msg;
systime_t now;
osalDbgCheck((macp != NULL) && (tdp != NULL));
osalDbgAssert(macp->state == MAC_ACTIVE, "not active");
@ -159,15 +158,11 @@ msg_t macWaitTransmitDescriptor(MACDriver *macp,
while (((msg = mac_lld_get_transmit_descriptor(macp, tdp)) != MSG_OK) &&
(timeout > (sysinterval_t)0)) {
osalSysLock();
now = osalOsGetSystemTimeX();
msg = osalThreadEnqueueTimeoutS(&macp->tdqueue, timeout);
if (msg == MSG_TIMEOUT) {
osalSysUnlock();
break;
}
if (timeout != TIME_INFINITE) {
timeout -= (osalOsGetSystemTimeX() - now);
}
osalSysUnlock();
}
return msg;
@ -211,23 +206,17 @@ msg_t macWaitReceiveDescriptor(MACDriver *macp,
MACReceiveDescriptor *rdp,
sysinterval_t timeout) {
msg_t msg;
systime_t now;
osalDbgCheck((macp != NULL) && (rdp != NULL));
osalDbgAssert(macp->state == MAC_ACTIVE, "not active");
while (((msg = mac_lld_get_receive_descriptor(macp, rdp)) != MSG_OK) &&
(timeout > (sysinterval_t)0)) {
while (((msg = mac_lld_get_receive_descriptor(macp, rdp)) != MSG_OK)) {
osalSysLock();
now = osalOsGetSystemTimeX();
msg = osalThreadEnqueueTimeoutS(&macp->rdqueue, timeout);
if (msg == MSG_TIMEOUT) {
osalSysUnlock();
break;
}
if (timeout != TIME_INFINITE) {
timeout -= (osalOsGetSystemTimeX() - now);
}
osalSysUnlock();
}
return msg;