i2c: set_frequency now takes a mraa_i2c_mode_t
authorBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 10 Dec 2014 00:32:17 +0000 (00:32 +0000)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Mon, 5 Jan 2015 14:38:48 +0000 (14:38 +0000)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
api/mraa/i2c.h
api/mraa/i2c.hpp
api/mraa/types.h
src/i2c/i2c.c

index b2e57d7..9ba9779 100644 (file)
@@ -72,10 +72,10 @@ mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
  * Sets the frequency of the i2c context. Most platforms do not support this.
  *
  * @param dev The i2c context
- * @param hz The bus frequency in hertz
+ * @param mode The bus mode
  * @return Result of operation
  */
-mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz);
+mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode);
 
 /**
  * Simple bulk read from an i2c context, this will always begin with the i2c
index 63106f5..7f3b99a 100644 (file)
@@ -74,11 +74,11 @@ class I2c {
          * the set frequency. Anyone can change this at any time and this will
          * affect every slave on the bus
          *
-         * @param hz Frequency to set the bus to in hz
+         * @param mode Frequency to set the bus to
          * @return Result of operation
          */
-        mraa_result_t frequency(int hz) {
-            return mraa_i2c_frequency(m_i2c, hz);
+        mraa_result_t frequency(mraa_i2c_mode_t mode) {
+            return mraa_i2c_frequency(m_i2c, mode);
         }
 
         /**
index 90cb4f4..93d4968 100644 (file)
@@ -174,6 +174,15 @@ typedef enum {
     MRAA_PIN_UART        = 7  /**< UART */
 } mraa_pinmodes_t;
 
+/**
+ * Enum reprensenting different i2c speeds/modes
+ */
+typedef enum {
+    MRAA_I2C_STD =  0, /**< up to 100Khz */
+    MRAA_I2C_FAST = 1, /**< up to 400Khz */
+    MRAA_I2C_HIGH = 2  /**< up to 3.4Mhz */
+} mraa_i2c_mode_t;
+
 #ifdef __cplusplus
 }
 #endif
index caa8130..3207db2 100644 (file)
@@ -135,7 +135,7 @@ mraa_i2c_init_raw(unsigned int bus)
 }
 
 mraa_result_t
-mraa_i2c_frequency(mraa_i2c_context dev, int hz)
+mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
 {
     dev->hz = hz;