Beispiel #1
0
/**
 * @brief   Stops any ongoing receive operation.
 * @note    Stopping a receive operation also suppresses the receive callbacks.
 * @note    This function has to be invoked from a lock zone.
 *
 * @param[in] uartp     pointer to the @p UARTDriver object
 *
 * @return              The number of data frames not received by the
 *                      stopped receive operation.
 * @retval 0            There was no receive operation in progress.
 *
 * @iclass
 */
size_t uartStopReceiveI(UARTDriver *uartp) {

  osalDbgCheckClassI();
  osalDbgCheck(uartp != NULL);
  osalDbgAssert(uartp->state == UART_READY, "not active");

  if (uartp->rxstate == UART_RX_ACTIVE) {
    size_t n = uart_lld_stop_receive(uartp);
    uartp->rxstate = UART_RX_IDLE;
    return n;
  }
  return 0;
}
Beispiel #2
0
/**
 * @brief   Stops any ongoing receive operation.
 * @note    Stopping a receive operation also suppresses the receive callbacks.
 *
 * @param[in] uartp     pointer to the @p UARTDriver object
 *
 * @return              The number of data frames not received by the
 *                      stopped receive operation.
 * @retval 0            There was no receive operation in progress.
 *
 * @api
 */
size_t uartStopReceive(UARTDriver *uartp) {
    size_t n;

    chDbgCheck(uartp != NULL, "uartStopReceive");

    chSysLock();
    chDbgAssert(uartp->state == UART_READY,
                "uartStopReceive(), #1", "not active");

    if (uartp->rxstate == UART_RX_ACTIVE) {
        n = uart_lld_stop_receive(uartp);
        uartp->rxstate = UART_RX_IDLE;
    }
    else
        n = 0;
    chSysUnlock();
    return n;
}