Private
Public Access
2
0
Files
mraa/examples/hellomraa.c
Yong Li 02399b61f9 mraa.c: Add new API to support I2C bus number query
Add two new API to get the usable I2C bus count and related I2C adapter number

Signed-off-by: Yong Li <yong.b.li@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-08-25 11:36:14 +01:00

51 lines
1.7 KiB
C

/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <syslog.h>
#include <string.h>
//! [Interesting]
#include "mraa.h"
int
main(int argc, char** argv)
{
char* board_name = mraa_get_platform_name();
int i2c_bus, i, i2c_adapter;
fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
i2c_bus = mraa_get_i2c_bus_count();
for (i = 0; i < i2c_bus; i++) {
i2c_adapter = mraa_get_i2c_bus_id(i);
fprintf(stdout, "I2C[%d] adapter=%d\n", i, i2c_adapter);
}
mraa_deinit();
return MRAA_SUCCESS;
}
//! [Interesting]