From a47f5705d3f6abf4abaffa949f7bb50132507d94 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 15 Oct 2017 06:51:20 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rt5_dev_point1@10822 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal_buffers.h | 16 ++--- os/hal/include/hal_can.h | 4 +- os/hal/include/hal_channels.h | 9 +-- os/hal/include/hal_i2c.h | 4 +- os/hal/include/hal_mac.h | 4 +- os/hal/include/hal_pal.h | 5 +- os/hal/include/hal_queues.h | 8 +-- os/hal/include/hal_uart.h | 6 +- os/hal/osal/nil/osal.h | 5 +- os/hal/osal/rt/osal.h | 138 ++++++++++++++++++++++++++++++++---------- os/hal/src/hal_buffers.c | 24 ++++---- os/hal/src/hal_can.c | 4 +- os/hal/src/hal_i2c.c | 4 +- os/hal/src/hal_mac.c | 8 +-- os/hal/src/hal_pal.c | 7 ++- os/hal/src/hal_queues.c | 12 ++-- os/hal/src/hal_serial.c | 10 +-- os/hal/src/hal_serial_usb.c | 10 +-- os/hal/src/hal_uart.c | 6 +- 19 files changed, 185 insertions(+), 99 deletions(-) (limited to 'os/hal') diff --git a/os/hal/include/hal_buffers.h b/os/hal/include/hal_buffers.h index 7d776f4a7..ac541d286 100644 --- a/os/hal/include/hal_buffers.h +++ b/os/hal/include/hal_buffers.h @@ -284,14 +284,14 @@ extern "C" { uint8_t *ibqGetEmptyBufferI(input_buffers_queue_t *ibqp); void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size); msg_t ibqGetFullBufferTimeout(input_buffers_queue_t *ibqp, - systime_t timeout); + sysinterval_t timeout); msg_t ibqGetFullBufferTimeoutS(input_buffers_queue_t *ibqp, - systime_t timeout); + sysinterval_t timeout); void ibqReleaseEmptyBuffer(input_buffers_queue_t *ibqp); void ibqReleaseEmptyBufferS(input_buffers_queue_t *ibqp); - msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout); + msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, sysinterval_t timeout); size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp, - size_t n, systime_t timeout); + size_t n, sysinterval_t timeout); void obqObjectInit(output_buffers_queue_t *obqp, bool suspended, uint8_t *bp, size_t size, size_t n, bqnotify_t onfy, void *link); void obqResetI(output_buffers_queue_t *obqp); @@ -299,15 +299,15 @@ extern "C" { size_t *sizep); void obqReleaseEmptyBufferI(output_buffers_queue_t *obqp); msg_t obqGetEmptyBufferTimeout(output_buffers_queue_t *obqp, - systime_t timeout); + sysinterval_t timeout); msg_t obqGetEmptyBufferTimeoutS(output_buffers_queue_t *obqp, - systime_t timeout); + sysinterval_t timeout); void obqPostFullBuffer(output_buffers_queue_t *obqp, size_t size); void obqPostFullBufferS(output_buffers_queue_t *obqp, size_t size); msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b, - systime_t timeout); + sysinterval_t timeout); size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp, - size_t n, systime_t timeout); + size_t n, sysinterval_t timeout); bool obqTryFlushI(output_buffers_queue_t *obqp); void obqFlush(output_buffers_queue_t *obqp); #ifdef __cplusplus diff --git a/os/hal/include/hal_can.h b/os/hal/include/hal_can.h index e91d8bd8b..78bd12a20 100644 --- a/os/hal/include/hal_can.h +++ b/os/hal/include/hal_can.h @@ -152,11 +152,11 @@ extern "C" { msg_t canTransmitTimeout(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp, - systime_t timeout); + sysinterval_t timeout); msg_t canReceiveTimeout(CANDriver *canp, canmbx_t mailbox, CANRxFrame *crfp, - systime_t timeout); + sysinterval_t timeout); #if CAN_USE_SLEEP_MODE void canSleep(CANDriver *canp); void canWakeup(CANDriver *canp); diff --git a/os/hal/include/hal_channels.h b/os/hal/include/hal_channels.h index 748dbe04a..f0d8f4d77 100644 --- a/os/hal/include/hal_channels.h +++ b/os/hal/include/hal_channels.h @@ -51,14 +51,15 @@ #define _base_channel_methods \ _base_sequential_stream_methods \ /* Channel put method with timeout specification.*/ \ - msg_t (*putt)(void *instance, uint8_t b, systime_t time); \ + msg_t (*putt)(void *instance, uint8_t b, sysinterval_t time); \ /* Channel get method with timeout specification.*/ \ - msg_t (*gett)(void *instance, systime_t time); \ + msg_t (*gett)(void *instance, sysinterval_t time); \ /* Channel write method with timeout specification.*/ \ size_t (*writet)(void *instance, const uint8_t *bp, \ - size_t n, systime_t time); \ + size_t n, sysinterval_t time); \ /* Channel read method with timeout specification.*/ \ - size_t (*readt)(void *instance, uint8_t *bp, size_t n, systime_t time); \ + size_t (*readt)(void *instance, uint8_t *bp, size_t n, \ + sysinterval_t time); \ /* Channel put method with timeout specification.*/ \ msg_t (*ctl)(void *instance, unsigned int operation, void *arg); diff --git a/os/hal/include/hal_i2c.h b/os/hal/include/hal_i2c.h index c9c8409cb..379c56308 100644 --- a/os/hal/include/hal_i2c.h +++ b/os/hal/include/hal_i2c.h @@ -145,11 +145,11 @@ extern "C" { i2caddr_t addr, const uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes, - systime_t timeout); + sysinterval_t timeout); msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp, i2caddr_t addr, uint8_t *rxbuf, size_t rxbytes, - systime_t timeout); + sysinterval_t timeout); #if I2C_USE_MUTUAL_EXCLUSION == TRUE void i2cAcquireBus(I2CDriver *i2cp); void i2cReleaseBus(I2CDriver *i2cp); diff --git a/os/hal/include/hal_mac.h b/os/hal/include/hal_mac.h index 5c7bc82de..0ca5e5fcd 100644 --- a/os/hal/include/hal_mac.h +++ b/os/hal/include/hal_mac.h @@ -184,11 +184,11 @@ extern "C" { void macSetAddress(MACDriver *macp, const uint8_t *p); msg_t macWaitTransmitDescriptor(MACDriver *macp, MACTransmitDescriptor *tdp, - systime_t timeout); + sysinterval_t timeout); void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp); msg_t macWaitReceiveDescriptor(MACDriver *macp, MACReceiveDescriptor *rdp, - systime_t timeout); + sysinterval_t timeout); void macReleaseReceiveDescriptor(MACReceiveDescriptor *rdp); bool macPollLinkStatus(MACDriver *macp); #ifdef __cplusplus diff --git a/os/hal/include/hal_pal.h b/os/hal/include/hal_pal.h index e2d85f0fe..fdf4e2586 100644 --- a/os/hal/include/hal_pal.h +++ b/os/hal/include/hal_pal.h @@ -1006,8 +1006,9 @@ extern "C" { void palSetLineCallbackI(ioline_t line, palcallback_t cb, void *arg); #endif /* PAL_USE_CALLBACKS */ #if PAL_USE_WAIT || defined(__DOXYGEN__) - msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad, systime_t timeout); - msg_t palWaitLineTimeoutS(ioline_t line, systime_t timeout); + msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad, + sysinterval_t timeout); + msg_t palWaitLineTimeoutS(ioline_t line, sysinterval_t timeout); #endif /* PAL_USE_WAIT */ #ifdef __cplusplus } diff --git a/os/hal/include/hal_queues.h b/os/hal/include/hal_queues.h index 1f2777e76..ffafc8805 100644 --- a/os/hal/include/hal_queues.h +++ b/os/hal/include/hal_queues.h @@ -278,17 +278,17 @@ extern "C" { qnotify_t infy, void *link); void iqResetI(input_queue_t *iqp); msg_t iqPutI(input_queue_t *iqp, uint8_t b); - msg_t iqGetTimeout(input_queue_t *iqp, systime_t timeout); + msg_t iqGetTimeout(input_queue_t *iqp, sysinterval_t timeout); size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, - size_t n, systime_t timeout); + size_t n, sysinterval_t timeout); void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link); void oqResetI(output_queue_t *oqp); - msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t timeout); + msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, sysinterval_t timeout); msg_t oqGetI(output_queue_t *oqp); size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, - size_t n, systime_t timeout); + size_t n, sysinterval_t timeout); #ifdef __cplusplus } #endif diff --git a/os/hal/include/hal_uart.h b/os/hal/include/hal_uart.h index 5523b82f1..01d61df7a 100644 --- a/os/hal/include/hal_uart.h +++ b/os/hal/include/hal_uart.h @@ -359,11 +359,11 @@ extern "C" { size_t uartStopReceiveI(UARTDriver *uartp); #if UART_USE_WAIT == TRUE msg_t uartSendTimeout(UARTDriver *uartp, size_t *np, - const void *txbuf, systime_t timeout); + const void *txbuf, sysinterval_t timeout); msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, - const void *txbuf, systime_t timeout); + const void *txbuf, sysinterval_t timeout); msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np, - void *rxbuf, systime_t timeout); + void *rxbuf, sysinterval_t timeout); #endif #if UART_USE_MUTUAL_EXCLUSION == TRUE void uartAcquireBus(UARTDriver *uartp); diff --git a/os/hal/osal/nil/osal.h b/os/hal/osal/nil/osal.h index 5f3ff1bc5..9a8d16d12 100644 --- a/os/hal/osal/nil/osal.h +++ b/os/hal/osal/nil/osal.h @@ -875,8 +875,9 @@ static inline void osalEventBroadcastFlags(event_source_t *esp, osalDbgCheck(esp != NULL); chSysLock(); - osalEventBroadcastFlagsI(esp, flags); - chSchRescheduleS(); + esp->flags |= flags; + if (esp->cb != NULL) { + esp->cb(esp); chSysUnlock(); } diff --git a/os/hal/osal/rt/osal.h b/os/hal/osal/rt/osal.h index 07072e88f..c81edef4f 100644 --- a/os/hal/osal/rt/osal.h +++ b/os/hal/osal/rt/osal.h @@ -67,8 +67,8 @@ * @name Special time constants * @{ */ -#define TIME_IMMEDIATE ((systime_t)0) -#define TIME_INFINITE ((systime_t)-1) +#define TIME_IMMEDIATE ((sysinterval_t)0) +#define TIME_INFINITE ((sysinterval_t)-1) /** @} */ #endif @@ -148,6 +148,13 @@ typedef int32_t msg_t; typedef uint32_t systime_t; #endif +#if 0 +/** + * @brief Type of system time counter. + */ +typedef uint32_t sysinterval_t; +#endif + #if 0 /** * @brief Type of realtime counter. @@ -179,14 +186,15 @@ typedef uint32_t eventflags_t; * API and are implementation-dependent. */ typedef struct { - volatile eventflags_t flags; /**< @brief Flags stored into the - object. */ + volatile eventflags_t flags; /**< @brief Stored event flags. */ + eventcallback_t cb; /**< @brief Event source callback. */ + void *param; /**< @brief User defined field. */ } event_source_t; #endif /** * @brief Type of a mutex. - * @note If the OS does not support mutexes or there is no OS then them + * @note If the OS does not support mutexes or there is no OS then the * mechanism can be simulated. */ #if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) @@ -304,36 +312,36 @@ typedef struct { * @details Converts from seconds to system ticks number. * @note The result is rounded upward to the next tick boundary. * - * @param[in] sec number of seconds + * @param[in] secs number of seconds * @return The number of ticks. * * @api */ -#define OSAL_S2ST(sec) S2ST(sec) +#define OSAL_S2I(secs) TIME_S2I(secs) /** * @brief Milliseconds to system ticks. * @details Converts from milliseconds to system ticks number. * @note The result is rounded upward to the next tick boundary. * - * @param[in] msec number of milliseconds + * @param[in] msecs number of milliseconds * @return The number of ticks. * * @api */ -#define OSAL_MS2ST(msec) TIME_MS2I(msec) +#define OSAL_MS2I(msecs) TIME_MS2I(msecs) /** * @brief Microseconds to system ticks. * @details Converts from microseconds to system ticks number. * @note The result is rounded upward to the next tick boundary. * - * @param[in] usec number of microseconds + * @param[in] usecs number of microseconds * @return The number of ticks. * * @api */ -#define OSAL_US2ST(usec) TIME_US2I(usec) +#define OSAL_US2I(usecs) TIME_US2I(usecs) /** @} */ /** @@ -392,11 +400,11 @@ typedef struct { * system tick clock. * @note The maximum specifiable value is implementation dependent. * - * @param[in] sec time in seconds, must be different from zero + * @param[in] secs time in seconds, must be different from zero * * @api */ -#define osalThreadSleepSeconds(sec) osalThreadSleep(OSAL_S2ST(sec)) +#define osalThreadSleepSeconds(secs) osalThreadSleep(OSAL_S2I(secs)) /** * @brief Delays the invoking thread for the specified number of @@ -405,11 +413,11 @@ typedef struct { * system tick clock. * @note The maximum specifiable value is implementation dependent. * - * @param[in] msec time in milliseconds, must be different from zero + * @param[in] msecs time in milliseconds, must be different from zero * * @api */ -#define osalThreadSleepMilliseconds(msec) osalThreadSleep(OSAL_MS2ST(msec)) +#define osalThreadSleepMilliseconds(msecs) osalThreadSleep(OSAL_MS2I(msecs)) /** * @brief Delays the invoking thread for the specified number of @@ -418,11 +426,11 @@ typedef struct { * system tick clock. * @note The maximum specifiable value is implementation dependent. * - * @param[in] usec time in microseconds, must be different from zero + * @param[in] usecs time in microseconds, must be different from zero * * @api */ -#define osalThreadSleepMicroseconds(usec) osalThreadSleep(OSAL_US2ST(usec)) +#define osalThreadSleepMicroseconds(usecs) osalThreadSleep(OSAL_US2I(usecs)) /** @} */ /*===========================================================================*/ @@ -618,6 +626,35 @@ static inline systime_t osalOsGetSystemTimeX(void) { return chVTGetSystemTimeX(); } +/** + * @brief Adds an interval to a system time returning a system time. + * + * @param[in] systime base system time + * @param[in] interval interval to be added + * @return The new system time. + * + * @xclass + */ +static inline systime_t osalTimeAddX(systime_t systime, + sysinterval_t interval) { + + return chTimeAddX(systime, interval); +} + +/** + * @brief Subtracts two system times returning an interval. + * + * @param[in] start first system time + * @param[in] end second system time + * @return The interval representing the time difference. + * + * @xclass + */ +static inline sysinterval_t osalTimeDiffX(systime_t start, systime_t end) { + + return chTimeDiffX(start, end); +} + /** * @brief Checks if the specified time is within the specified time window. * @note When start==end then the function returns always true because the @@ -632,9 +669,9 @@ static inline systime_t osalOsGetSystemTimeX(void) { * * @xclass */ -static inline bool osalOsIsTimeWithinX(systime_t time, - systime_t start, - systime_t end) { +static inline bool osalTimeIsInRangeX(systime_t time, + systime_t start, + systime_t end) { return chTimeIsInRangeX(time, start, end); } @@ -642,7 +679,7 @@ static inline bool osalOsIsTimeWithinX(systime_t time, /** * @brief Suspends the invoking thread for the specified time. * - * @param[in] time the delay in system ticks, the special values are + * @param[in] delay the delay in system ticks, the special values are * handled as follow: * - @a TIME_INFINITE is allowed but interpreted as a * normal time specification. @@ -651,15 +688,15 @@ static inline bool osalOsIsTimeWithinX(systime_t time, * * @sclass */ -static inline void osalThreadSleepS(systime_t time) { +static inline void osalThreadSleepS(sysinterval_t delay) { - chThdSleepS(time); + chThdSleepS(delay); } /** * @brief Suspends the invoking thread for the specified time. * - * @param[in] time the delay in system ticks, the special values are + * @param[in] delay the delay in system ticks, the special values are * handled as follow: * - @a TIME_INFINITE is allowed but interpreted as a * normal time specification. @@ -668,9 +705,9 @@ static inline void osalThreadSleepS(systime_t time) { * * @api */ -static inline void osalThreadSleep(systime_t time) { +static inline void osalThreadSleep(sysinterval_t delay) { - chThdSleep(time); + chThdSleep(delay); } /** @@ -708,7 +745,7 @@ static inline msg_t osalThreadSuspendS(thread_reference_t *trp) { * @sclass */ static inline msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, - systime_t timeout) { + sysinterval_t timeout) { return chThdSuspendTimeoutS(trp, timeout); } @@ -761,7 +798,7 @@ static inline void osalThreadQueueObjectInit(threads_queue_t *tqp) { * dequeued or the specified timeouts expires. * * @param[in] tqp pointer to the threads queue object - * @param[in] time the timeout in system ticks, the special values are + * @param[in] timeout the timeout in system ticks, the special values are * handled as follow: * - @a TIME_INFINITE the thread enters an infinite sleep * state. @@ -779,9 +816,9 @@ static inline void osalThreadQueueObjectInit(threads_queue_t *tqp) { * @sclass */ static inline msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, - systime_t time) { + sysinterval_t timeout) { - return chThdEnqueueTimeoutS(tqp, time); + return chThdEnqueueTimeoutS(tqp, timeout); } /** @@ -823,9 +860,13 @@ static inline void osalEventObjectInit(event_source_t *esp) { chEvtObjectInit(esp); } #else -static inline void osalEventObjectInit(event_source_t *esp) { +static inline void osalEventObjectInit(osal_event_source_t *esp) { + + osalDbgCheck(esp != NULL); esp->flags = 0; + esp->cb = NULL; + esp->param = NULL; } #endif @@ -847,7 +888,12 @@ static inline void osalEventBroadcastFlagsI(event_source_t *esp, static inline void osalEventBroadcastFlagsI(event_source_t *esp, eventflags_t flags) { + osalDbgCheck(esp != NULL); + esp->flags |= flags; + if (esp->cb != NULL) { + esp->cb(esp); + } } #endif @@ -868,12 +914,42 @@ static inline void osalEventBroadcastFlags(event_source_t *esp, #else static inline void osalEventBroadcastFlags(event_source_t *esp, eventflags_t flags) { + + osalDbgCheck(esp != NULL); + osalSysLock(); esp->flags |= flags; + if (esp->cb != NULL) { + esp->cb(esp); osalSysUnlock(); } #endif +#if !CH_CFG_USE_EVENTS || defined(__DOXYGEN__) +/** + * @brief Event callback setup. + * @note The callback is invoked from ISR context and can + * only invoke I-Class functions. The callback is meant + * to wakeup the task that will handle the event by + * calling @p osalEventGetAndClearFlagsI(). + * + * @param[in] esp pointer to the event flags object + * @param[in] cb pointer to the callback function + * @param[in] param parameter to be passed to the callback function + * + * @api + */ +static inline void osalEventSetCallback(event_source_t *esp, + eventcallback_t cb, + void *param) { + + osalDbgCheck(esp != NULL); + + esp->cb = cb; + esp->param = param; +} +#endif + /** * @brief Initializes s @p mutex_t object. * diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c index 871fd0a42..0f1e35440 100644 --- a/os/hal/src/hal_buffers.c +++ b/os/hal/src/hal_buffers.c @@ -188,7 +188,7 @@ void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size) { * @api */ msg_t ibqGetFullBufferTimeout(input_buffers_queue_t *ibqp, - systime_t timeout) { + sysinterval_t timeout) { msg_t msg; osalSysLock(); @@ -220,7 +220,7 @@ msg_t ibqGetFullBufferTimeout(input_buffers_queue_t *ibqp, * @sclass */ msg_t ibqGetFullBufferTimeoutS(input_buffers_queue_t *ibqp, - systime_t timeout) { + sysinterval_t timeout) { osalDbgCheckClassS(); @@ -306,7 +306,7 @@ void ibqReleaseEmptyBuffer(input_buffers_queue_t *ibqp) { * * @api */ -msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) { +msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, sysinterval_t timeout) { msg_t msg; osalSysLock(); @@ -356,9 +356,9 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) { * @api */ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp, - size_t n, systime_t timeout) { + size_t n, sysinterval_t timeout) { size_t r = 0; - systime_t deadline; + sysinterval_t deadline; osalDbgCheck(n > 0U); @@ -380,7 +380,7 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp, msg = ibqGetFullBufferTimeoutS(ibqp, timeout); } else { - systime_t next_timeout = deadline - osalOsGetSystemTimeX(); + sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX(); /* Handling the case where the system time went past the deadline, in this case next becomes a very high number because the system @@ -562,7 +562,7 @@ void obqReleaseEmptyBufferI(output_buffers_queue_t *obqp) { * @api */ msg_t obqGetEmptyBufferTimeout(output_buffers_queue_t *obqp, - systime_t timeout) { + sysinterval_t timeout) { msg_t msg; osalSysLock(); @@ -594,7 +594,7 @@ msg_t obqGetEmptyBufferTimeout(output_buffers_queue_t *obqp, * @sclass */ msg_t obqGetEmptyBufferTimeoutS(output_buffers_queue_t *obqp, - systime_t timeout) { + sysinterval_t timeout) { osalDbgCheckClassS(); @@ -688,7 +688,7 @@ void obqPostFullBufferS(output_buffers_queue_t *obqp, size_t size) { * @api */ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b, - systime_t timeout) { + sysinterval_t timeout) { msg_t msg; osalSysLock(); @@ -738,9 +738,9 @@ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b, * @api */ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp, - size_t n, systime_t timeout) { + size_t n, sysinterval_t timeout) { size_t w = 0; - systime_t deadline; + sysinterval_t deadline; osalDbgCheck(n > 0U); @@ -762,7 +762,7 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp, msg = obqGetEmptyBufferTimeoutS(obqp, timeout); } else { - systime_t next_timeout = deadline - osalOsGetSystemTimeX(); + sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX(); /* Handling the case where the system time went past the deadline, in this case next becomes a very high number because the system diff --git a/os/hal/src/hal_can.c b/os/hal/src/hal_can.c index 014d59c70..122e5eb76 100644 --- a/os/hal/src/hal_can.c +++ b/os/hal/src/hal_can.c @@ -233,7 +233,7 @@ bool canTryReceiveI(CANDriver *canp, msg_t canTransmitTimeout(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp, - systime_t timeout) { + sysinterval_t timeout) { osalDbgCheck((canp != NULL) && (ctfp != NULL) && (mailbox <= (canmbx_t)CAN_TX_MAILBOXES)); @@ -281,7 +281,7 @@ msg_t canTransmitTimeout(CANDriver *canp, msg_t canReceiveTimeout(CANDriver *canp, canmbx_t mailbox, CANRxFrame *crfp, - systime_t timeout) { + sysinterval_t timeout) { osalDbgCheck((canp != NULL) && (crfp != NULL) && (mailbox <= (canmbx_t)CAN_RX_MAILBOXES)); diff --git a/os/hal/src/hal_i2c.c b/os/hal/src/hal_i2c.c index 54a362f0c..02d405daa 100644 --- a/os/hal/src/hal_i2c.c +++ b/os/hal/src/hal_i2c.c @@ -173,7 +173,7 @@ msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp, size_t txbytes, uint8_t *rxbuf, size_t rxbytes, - systime_t timeout) { + sysinterval_t timeout) { msg_t rdymsg; osalDbgCheck((i2cp != NULL) && (addr != 0U) && @@ -222,7 +222,7 @@ msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp, i2caddr_t addr, uint8_t *rxbuf, size_t rxbytes, - systime_t timeout){ + sysinterval_t timeout) { msg_t rdymsg; diff --git a/os/hal/src/hal_mac.c b/os/hal/src/hal_mac.c index 7d0f4cf43..2ae0b677d 100644 --- a/os/hal/src/hal_mac.c +++ b/os/hal/src/hal_mac.c @@ -149,7 +149,7 @@ void macStop(MACDriver *macp) { */ msg_t macWaitTransmitDescriptor(MACDriver *macp, MACTransmitDescriptor *tdp, - systime_t timeout) { + sysinterval_t timeout) { msg_t msg; systime_t now; @@ -157,7 +157,7 @@ msg_t macWaitTransmitDescriptor(MACDriver *macp, osalDbgAssert(macp->state == MAC_ACTIVE, "not active"); while (((msg = mac_lld_get_transmit_descriptor(macp, tdp)) != MSG_OK) && - (timeout > (systime_t)0)) { + (timeout > (sysinterval_t)0)) { osalSysLock(); now = osalOsGetSystemTimeX(); msg = osalThreadEnqueueTimeoutS(&macp->tdqueue, timeout); @@ -209,7 +209,7 @@ void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp) { */ msg_t macWaitReceiveDescriptor(MACDriver *macp, MACReceiveDescriptor *rdp, - systime_t timeout) { + sysinterval_t timeout) { msg_t msg; systime_t now; @@ -217,7 +217,7 @@ msg_t macWaitReceiveDescriptor(MACDriver *macp, osalDbgAssert(macp->state == MAC_ACTIVE, "not active"); while (((msg = mac_lld_get_receive_descriptor(macp, rdp)) != MSG_OK) && - (timeout > (systime_t)0)) { + (timeout > (sysinterval_t)0)) { osalSysLock(); now = osalOsGetSystemTimeX(); msg = osalThreadEnqueueTimeoutS(&macp->rdqueue, timeout); diff --git a/os/hal/src/hal_pal.c b/os/hal/src/hal_pal.c index b46c9e7ea..3a83005ec 100644 --- a/os/hal/src/hal_pal.c +++ b/os/hal/src/hal_pal.c @@ -167,7 +167,9 @@ void palSetLineCallbackI(ioline_t line, palcallback_t cb, void *arg) { * * @sclass */ -msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad, systime_t timeout) { +msg_t palWaitPadTimeoutS(ioportid_t port, + iopadid_t pad, + sysinterval_t timeout) { palevent_t *pep = pal_lld_get_pad_event(port, pad); return osalThreadEnqueueTimeoutS(&pep->threads, timeout); @@ -186,7 +188,8 @@ msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad, systime_t timeout) { * * @sclass */ -msg_t palWaitLineTimeoutS(ioline_t line, systime_t timeout) { +msg_t palWaitLineTimeoutS(ioline_t line, + sysinterval_t timeout) { palevent_t *pep = pal_lld_get_line_event(line); return osalThreadEnqueueTimeoutS(&pep->threads, timeout); diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index d0ef6f489..d3ead6998 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -138,7 +138,7 @@ msg_t iqPutI(input_queue_t *iqp, uint8_t b) { * * @api */ -msg_t iqGetTimeout(input_queue_t *iqp, systime_t timeout) { +msg_t iqGetTimeout(input_queue_t *iqp, sysinterval_t timeout) { uint8_t b; osalSysLock(); @@ -194,7 +194,7 @@ msg_t iqGetTimeout(input_queue_t *iqp, systime_t timeout) { * @api */ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, - size_t n, systime_t timeout) { + size_t n, sysinterval_t timeout) { systime_t deadline; qnotify_t nfy = iqp->q_notify; size_t r = 0; @@ -219,7 +219,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, timeout); } else { - systime_t next_timeout = deadline - osalOsGetSystemTimeX(); + sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX(); /* Handling the case where the system time went past the deadline, in this case next becomes a very high number because the system @@ -334,7 +334,7 @@ void oqResetI(output_queue_t *oqp) { * * @api */ -msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t timeout) { +msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, sysinterval_t timeout) { osalSysLock(); @@ -419,7 +419,7 @@ msg_t oqGetI(output_queue_t *oqp) { * @api */ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, - size_t n, systime_t timeout) { + size_t n, sysinterval_t timeout) { systime_t deadline; qnotify_t nfy = oqp->q_notify; size_t w = 0; @@ -443,7 +443,7 @@ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, timeout); } else { - systime_t next_timeout = deadline - osalOsGetSystemTimeX(); + sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX(); /* Handling the case where the system time went past the deadline, in this case next becomes a very high number because the system diff --git a/os/hal/src/hal_serial.c b/os/hal/src/hal_serial.c index 5c24c8216..6658a44e0 100644 --- a/os/hal/src/hal_serial.c +++ b/os/hal/src/hal_serial.c @@ -69,22 +69,24 @@ static msg_t _get(void *ip) { return iqGetTimeout(&((SerialDriver *)ip)->iqueue, TIME_INFINITE); } -static msg_t _putt(void *ip, uint8_t b, systime_t timeout) { +static msg_t _putt(void *ip, uint8_t b, sysinterval_t timeout) { return oqPutTimeout(&((SerialDriver *)ip)->oqueue, b, timeout); } -static msg_t _gett(void *ip, systime_t timeout) { +static msg_t _gett(void *ip, sysinterval_t timeout) { return iqGetTimeout(&((SerialDriver *)ip)->iqueue, timeout); } -static size_t _writet(void *ip, const uint8_t *bp, size_t n, systime_t timeout) { +static size_t _writet(void *ip, const uint8_t *bp, size_t n, + sysinterval_t timeout) { return oqWriteTimeout(&((SerialDriver *)ip)->oqueue, bp, n, timeout); } -static size_t _readt(void *ip, uint8_t *bp, size_t n, systime_t timeout) { +static size_t _readt(void *ip, uint8_t *bp, size_t n, + sysinterval_t timeout) { return iqReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, timeout); } diff --git a/os/hal/src/hal_serial_usb.c b/os/hal/src/hal_serial_usb.c index 1af9b50a3..f2dcd6c32 100644 --- a/os/hal/src/hal_serial_usb.c +++ b/os/hal/src/hal_serial_usb.c @@ -104,22 +104,24 @@ static msg_t _get(void *ip) { return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, TIME_INFINITE); } -static msg_t _putt(void *ip, uint8_t b, systime_t timeout) { +static msg_t _putt(void *ip, uint8_t b, sysinterval_t timeout) { return obqPutTimeout(&((SerialUSBDriver *)ip)->obqueue, b, timeout); } -static msg_t _gett(void *ip, systime_t timeout) { +static msg_t _gett(void *ip, sysinterval_t timeout) { return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, timeout); } -static size_t _writet(void *ip, const uint8_t *bp, size_t n, systime_t timeout) { +static size_t _writet(void *ip, const uint8_t *bp, size_t n, + sysinterval_t timeout) { return obqWriteTimeout(&((SerialUSBDriver *)ip)->obqueue, bp, n, timeout); } -static size_t _readt(void *ip, uint8_t *bp, size_t n, systime_t timeout) { +static size_t _readt(void *ip, uint8_t *bp, size_t n, + sysinterval_t timeout) { return ibqReadTimeout(&((SerialUSBDriver *)ip)->ibqueue, bp, n, timeout); } diff --git a/os/hal/src/hal_uart.c b/os/hal/src/hal_uart.c index 89276f28f..ac3e4df3e 100644 --- a/os/hal/src/hal_uart.c +++ b/os/hal/src/hal_uart.c @@ -367,7 +367,7 @@ size_t uartStopReceiveI(UARTDriver *uartp) { * @api */ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np, - const void *txbuf, systime_t timeout) { + const void *txbuf, sysinterval_t timeout) { msg_t msg; osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL)); @@ -412,7 +412,7 @@ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np, * @api */ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, - const void *txbuf, systime_t timeout) { + const void *txbuf, sysinterval_t timeout) { msg_t msg; osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL)); @@ -459,7 +459,7 @@ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, * @api */ msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np, - void *rxbuf, systime_t timeout) { + void *rxbuf, sysinterval_t timeout) { msg_t msg; osalDbgCheck((uartp != NULL) && (*np > 0U) && (rxbuf != NULL)); -- cgit v1.2.3