/** * @brief Starts a transmission on the UART peripheral. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. * @note This function has to be invoked from a lock zone. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] n number of data frames to send * @param[in] txbuf the pointer to the transmit buffer * * @iclass */ void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) { osalDbgCheckClassI(); osalDbgCheck((uartp != NULL) && (n > 0U) && (txbuf != NULL)); osalDbgAssert(uartp->state == UART_READY, "is active"); osalDbgAssert(uartp->txstate != UART_TX_ACTIVE, "tx active"); uart_lld_start_send(uartp, n, txbuf); uartp->txstate = UART_TX_ACTIVE; }
/** * @brief Starts a transmission on the UART peripheral. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. * @note This function has to be invoked from a lock zone. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] n number of data frames to send * @param[in] txbuf the pointer to the transmit buffer * * @iclass */ void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) { chDbgCheckClassI(); chDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL), "uartStartSendI"); chDbgAssert((uartp->state == UART_READY) && (uartp->txstate != UART_TX_ACTIVE), "uartStartSendI(), #1", "not active"); uart_lld_start_send(uartp, n, txbuf); uartp->txstate = UART_TX_ACTIVE; }
/** * @brief Starts a transmission on the UART peripheral. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] n number of data frames to send * @param[in] txbuf the pointer to the transmit buffer * * @api */ void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf) { chDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL), "uartStartSend"); chSysLock(); chDbgAssert(uartp->state == UART_READY, "uartStartSend(), #1", "is active"); chDbgAssert(uartp->txstate != UART_TX_ACTIVE, "uartStartSend(), #2", "tx active"); uart_lld_start_send(uartp, n, txbuf); uartp->txstate = UART_TX_ACTIVE; chSysUnlock(); }
/** * @brief Performs a transmission on the UART peripheral. * @note The function returns when the specified number of frames have been * physically transmitted or on timeout. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in,out] np number of data frames to transmit, on exit the number * of frames actually transmitted * @param[in] txbuf the pointer to the transmit buffer * @param[in] timeout operation timeout * @return The operation status. * @retval MSG_OK if the operation completed successfully. * @retval MSG_TIMEOUT if the operation timed out. * * @api */ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, const void *txbuf, systime_t timeout) { msg_t msg; osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL)); osalSysLock(); osalDbgAssert(uartp->state == UART_READY, "is active"); osalDbgAssert(uartp->txstate != UART_TX_ACTIVE, "tx active"); /* Transmission start.*/ uartp->early = false; uart_lld_start_send(uartp, *np, txbuf); uartp->txstate = UART_TX_ACTIVE; /* Waiting for result.*/ msg = osalThreadSuspendTimeoutS(&uartp->threadtx, timeout); if (msg != MSG_OK) { *np = uartStopSendI(uartp); } osalSysUnlock(); return msg; }