Private
Public Access
2
0

i2c: add busnum to context

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-12-10 00:33:34 +00:00
parent 836d953cb7
commit ab3af9cc2d
2 changed files with 2 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ struct _gpio {
*/
struct _i2c {
/*@{*/
int busnum; /**< the bus number of the /dev/i2c-* device */
int fh; /**< the file handle to the /dev/i2c-* device */
int addr; /**< the address of the i2c slave */
/*@}*/

View File

@@ -119,6 +119,7 @@ mraa_i2c_init_raw(unsigned int bus)
}
char filepath[32];
dev->busnum = bus;
snprintf(filepath, 32, "/dev/i2c-%u", bus);
if ((dev->fh = open(filepath, O_RDWR)) < 1) {
syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);