Private
Public Access
2
0

i2c: set_frequency now takes a mraa_i2c_mode_t

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-12-10 00:32:17 +00:00
parent 87e242a07b
commit fc5d37d391
4 changed files with 15 additions and 6 deletions

View 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

View 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);
}
/**

View 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

View 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;