1.我使用uartecho 驱动发送数据给传感器,传感器正常响应回发了数据,但是我uart_read 函数时程序阻塞在uart_read函数,我想知道uart_read函数的阻塞条件是什么原因造成的?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
/*! * @brief Function that reads data from a UART with interrupt enabled. * * %UART_read() reads data from a UART controller. The destination is specified * by \a buffer and the number of bytes to read is given by \a size. * * In #UART_MODE_BLOCKING, %UART_read() blocks task execution until all * the data in buffer has been read. * * In #UART_MODE_CALLBACK, %UART_read() does not block task execution. * Instead, a callback function specified by UART_Params::readCallback * is called when the transfer is finished. * The callback function can occur in the caller's context or in HWI or SWI * context, depending on the device-specific implementation. * An unfinished asynchronous read operation must always be canceled using * UART_readCancel() before calling UART_close(). * * %UART_read() is mutually exclusive to UART_readPolling(). For an opened * UART peripheral, either %UART_read() or UART_readPolling() can be used, * but not both. * * @sa UART_readPolling() * * @param handle A #UART_Handle returned by UART_open() * * @param buffer A pointer to an empty buffer to which * received data should be written * * @param size The number of bytes to be written into buffer * * @return Returns the number of bytes that have been read from the UART, * #UART_STATUS_ERROR on an error. */ extern int_fast32_t UART_read(UART_Handle handle, void *buffer, size_t size);