コード例 #1
0
ファイル: hal_uart.c プロジェクト: AlexShiLucky/ChibiOS
/**
 * @brief   Stops any ongoing transmission.
 * @note    Stopping a transmission also suppresses the transmission 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 transmitted by the
 *                      stopped transmit operation.
 * @retval 0            There was no transmit operation in progress.
 *
 * @iclass
 */
size_t uartStopSendI(UARTDriver *uartp) {

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

  if (uartp->txstate == UART_TX_ACTIVE) {
    size_t n = uart_lld_stop_send(uartp);
    uartp->txstate = UART_TX_IDLE;
    return n;
  }
  return 0;
}
コード例 #2
0
ファイル: uart.c プロジェクト: DroneBuster/lpc_gsm
/**
 * @brief   Stops any ongoing transmission.
 * @note    Stopping a transmission also suppresses the transmission callbacks.
 *
 * @param[in] uartp     pointer to the @p UARTDriver object
 *
 * @return              The number of data frames not transmitted by the
 *                      stopped transmit operation.
 * @retval 0            There was no transmit operation in progress.
 *
 * @api
 */
size_t uartStopSend(UARTDriver *uartp) {
    size_t n;

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

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

    if (uartp->txstate == UART_TX_ACTIVE) {
        n = uart_lld_stop_send(uartp);
        uartp->txstate = UART_TX_IDLE;
    }
    else
        n = 0;
    chSysUnlock();
    return n;
}