nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Abstracted support for error returns. More...
#include <nrfcxx/periph.hpp>
Public Types | |
using | size_type = unsigned int |
The type used for transfer sizes (unsigned) | |
using | ssize_type = int |
The type used for transfer sizes (non-negative) or errors (negative). More... | |
using | error_type = unsigned int |
The type used to encode TWI peripheral errors. More... | |
Static Public Member Functions | |
constexpr static error_type | error_decoded (ssize_type rc) |
Extract an encoded error value from an API return value. More... | |
constexpr static ssize_type | error_encoded (error_type ec) |
Pack an error value into a negative return value. More... | |
Static Public Attributes | |
constexpr static unsigned int | ERR_OVERRUN = 0x001 |
NRF_TWI_Type::ERRORSRC bit indicating incomplete reception at start. | |
constexpr static unsigned int | ERR_ANACK = 0x002 |
NRF_TWI_Type::ERRORSRC bit indicating NACK received during address transmission. | |
constexpr static unsigned int | ERR_DNACK = 0x004 |
NRF_TWI_Type::ERRORSRC bit indicating NACK received during data transmission. | |
constexpr static unsigned int | ERR_TIMEOUT = 0x100 |
Bit set in an error code when the TWI bus transaction timed out. | |
constexpr static unsigned int | ERR_CLEAR = 0x200 |
Bit set in an error code when the TWI bus could not be cleared. | |
constexpr static unsigned int | ERR_INVALID = 0x400 |
Bit set in an error code to indicate that the bus was not properly configured or a parameter was invalid. | |
constexpr static unsigned int | ERR_CHECKSUM = 0x800 |
Bit set in an error code to indicate a checksum error. More... | |
constexpr static unsigned int | ERR_UNKNOWN = 0x1000 |
Bit set in an error code to indicate an undescribable error. | |
Abstracted support for error returns.
This is designed around the needs of #TWI but applies to SPI as well for a couple operations that can fail with ERR_INVALID.
using nrfcxx::periph::details::comm_error_support::error_type = unsigned int |
The type used to encode TWI peripheral errors.
TWI errors are indicated returned as negative ssize_type values from read() and write(). Details of the error are obtained by converting this value to an error_type value using error_decoded().
The resulting code comprises bits from the TWI ERRORSRC
register along with ERR_TIMEOUT, ERR_CLEAR, ERR_INVALID, and ERR_UNKNOWN.
The type used for transfer sizes (non-negative) or errors (negative).
|
inlinestaticconstexpr |
Extract an encoded error value from an API return value.
rc | a result code, which is negative if it represents an error. |
rc
does not represent an error, otherwise the corresponding error_type value.
|
inlinestaticconstexpr |
Pack an error value into a negative return value.
ec
is zero, otherwise the encoded error value.
|
staticconstexpr |
Bit set in an error code to indicate a checksum error.
Generally this error will appear only in results from methods supporting higher-level operations on devices that can detect data errors.