aio: change return from uint16 to unsigned int
authorThomas Ingleby <thomas.c.ingleby@intel.com>
Mon, 22 Sep 2014 14:29:02 +0000 (15:29 +0100)
committerThomas Ingleby <thomas.c.ingleby@intel.com>
Mon, 22 Sep 2014 14:29:02 +0000 (15:29 +0100)
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
api/mraa/aio.h
api/mraa/aio.hpp
src/aio/aio.c

index 43ae226..ee30fb0 100644 (file)
@@ -59,12 +59,13 @@ typedef struct _aio* mraa_aio_context;
 mraa_aio_context mraa_aio_init(unsigned int pin);
 
 /**
- * Read the input voltage
+ * Read the input voltage. By default mraa will shift
+ * the raw value up or down to a 10 bit value.
  *
  * @param dev The AIO context
- * @returns The current input voltage, normalised to a 16-bit value
+ * @returns The current input voltage.
  */
-uint16_t mraa_aio_read(mraa_aio_context dev);
+unsigned int mraa_aio_read(mraa_aio_context dev);
 
 /**
  * Close the analog input context, this will free the memory for the context
index e136309..76c89c7 100644 (file)
@@ -53,14 +53,13 @@ class Aio {
             mraa_aio_close(m_aio);
         }
         /**
-         * Read a value from the AIO pin. Note this value can never be outside
-         * of the bounds of an unsigned short
+         * Read a value from the AIO pin. By default mraa will shift
+         * the raw value up or down to a 10 bit value.
          *
-         * @returns The current input voltage, normalised to a 16-bit value
+         * @returns The current input voltage. By default, a 10bit value
          */
         int read() {
-            // Use basic types to make swig code generation simpler
-            return (int) mraa_aio_read(m_aio);
+            return mraa_aio_read(m_aio);
         }
         /**
          * Set the bit value which mraa will shift the raw reading
index f4d658a..816fb01 100644 (file)
@@ -112,17 +112,14 @@ mraa_aio_context mraa_aio_init(unsigned int aio_channel)
     return dev;
 }
 
-/** Read the input voltage, represented as an unsigned short in the range [0x0,
- * 0xFFFF]
+/** Read the input voltage.
  *
  * @param pointer to mraa_aio_context structure  initialised by
  * mraa_aio_init()
  *
- * @returns
- *   unsigned 16 bit int representing the current input voltage, normalised to
- *   a 16-bit value
+ * @returns The current input voltage. By default, a 10bit value
  */
-uint16_t mraa_aio_read(mraa_aio_context dev)
+unsigned int mraa_aio_read(mraa_aio_context dev)
 {
     char buffer[16];
     unsigned int shifter_value = 0;
@@ -139,7 +136,7 @@ uint16_t mraa_aio_read(mraa_aio_context dev)
 
     errno = 0;
     char *end;
-    uint16_t analog_value = (uint16_t) strtoul(buffer, &end, 10);
+    unsigned int analog_value = (unsigned int) strtoul(buffer, &end, 10);
     if (end == &buffer[0]) {
         fprintf(stderr, "%s is not a decimal number\n", buffer);
     }