From 82c5f9f0f4f3af0a0709b9022f48e0e760f60c15 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 4 Sep 2011 12:37:39 -0500 Subject: [PATCH] PIOS_RCVR: Document return values better and use enum for them --- flight/PiOS/Common/pios_rcvr.c | 9 +++++++++ flight/PiOS/inc/pios_rcvr.h | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/flight/PiOS/Common/pios_rcvr.c b/flight/PiOS/Common/pios_rcvr.c index b76e04a44..bd8cce3cd 100644 --- a/flight/PiOS/Common/pios_rcvr.c +++ b/flight/PiOS/Common/pios_rcvr.c @@ -76,6 +76,15 @@ out_fail: return(-1); } +/** + * @brief Reads an input channel from the appropriate driver + * @param[in] rcvr_id driver to read from + * @param[in] channel channel to read + * @returns Unitless input value + * @retval PIOS_RCVR_TIMEOUT indicates a failsafe or timeout from that channel + * @retval PIOS_RCVR_INVALID invalid channel for this driver (usually out of range supported) + * @retval PIOS_RCVR_NODRIVER driver was not initialized + */ int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel) { if (rcvr_id == 0) diff --git a/flight/PiOS/inc/pios_rcvr.h b/flight/PiOS/inc/pios_rcvr.h index a61798d8c..ab493cd35 100644 --- a/flight/PiOS/inc/pios_rcvr.h +++ b/flight/PiOS/inc/pios_rcvr.h @@ -39,9 +39,15 @@ struct pios_rcvr_driver { /* Public Functions */ extern int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel); -#define PIOS_RCVR_TIMEOUT 0 -#define PIOS_RCVR_NODRIVER -2 -#define PIOS_RCVR_INVALID -1 +/*! Define error codes for PIOS_RCVR_Get */ +enum PIOS_RCVR_errors { + /*! Indicates that a failsafe condition or missing receiver detected for that channel */ + PIOS_RCVR_TIMEOUT = 0, + /*! Channel is invalid for this driver (usually out of range supported) */ + PIOS_RCVR_INVALID = -1, + /*! Indicates that the driver for this channel has not been initialized */ + PIOS_RCVR_NODRIVER = -2 +}; #endif /* PIOS_RCVR_H */