Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mbed-hal/serial_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@

#define SERIAL_RESERVED_CHAR_MATCH (255)

/**
* @defgroup SerialRXErrors Serial RX Errors Macros
*
* @{
*/
#define SERIAL_ERROR_RX_OVERRUN (1 << 0)
#define SERIAL_ERROR_RX_FRAMING (1 << 1)
#define SERIAL_ERROR_RX_PARITY (1 << 2)
#define SERIAL_ERROR_RX_OVERFLOW (1 << 3)
/**@}*/

typedef enum {
ParityNone = 0,
ParityOdd = 1,
Expand Down Expand Up @@ -175,6 +186,21 @@ void serial_putc(serial_t *obj, int c);
*/
int serial_readable(serial_t *obj);

/** Returns any errors that were encountered by the serial peripheral:
* RX overrun, parity error, framing error, or FIFO overflow. All the
* error flags are cleared after the function call.
*
* The return value is a bit field where one bit represents one error
* type (in the above mentioned order, the least significant bit first).
*
* @param obj The serial object
* @return Non-zero value if any of the errors have occurred, 0 otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return values shall be described as @RetVal - each of the possible return values. You can rebase the current branch here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the documentation. Added a few @RetVal tags as an example; didn't want to enumerate the whole list of values. A developer should get the idea...

* @retval 0000b No errors have occurred on the serial
* @retval 0101b RX overrrun, framing errors
* @retval 1111b All error types have occurred
*/
int serial_error(serial_t *obj);

/** Check if the serial peripheral is writable
*
* @param obj The serial object
Expand Down