From aeb293a163961bf10239416d9c6d9dd0c02cdf3f Mon Sep 17 00:00:00 2001 From: Noel Eck Date: Mon, 24 Apr 2017 16:04:33 -0700 Subject: [PATCH] Peripheralman: Update peripheralman API docs * Update documentation for C methods * Update documentation for CXX methods * Update build instructions for building on AT Peripheral Manager Client Signed-off-by: Noel Eck --- CMakeLists.txt | 2 +- api/mraa/common.h | 28 ++++++++++++---------------- api/mraa/common.hpp | 32 ++++++++++++++++---------------- docs/building.md | 24 +++++++++++------------- 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3503d9..00df464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,7 @@ elseif (DETECTED_ARCH STREQUAL "MOCK") elseif (DETECTED_ARCH STREQUAL "PERIPHERALMAN") set (PERIPHERALMAN ON) else () - message (FATAL_ERROR "Only x86, arm, peripheral manager and mock platforms currently supported") + message (FATAL_ERROR "Only x86, arm, PERIPHERALMAN and mock platforms currently supported") endif() if (BUILDSWIGPYTHON OR BUILDTESTS) diff --git a/api/mraa/common.h b/api/mraa/common.h index db86f45..c4f8d0a 100644 --- a/api/mraa/common.h +++ b/api/mraa/common.h @@ -234,39 +234,35 @@ unsigned int mraa_get_platform_pin_count(uint8_t platform_offset); char* mraa_get_pin_name(int pin); /** -* Get pin number, board must be initialised. +* Get GPIO index by pin name, board must be initialised. * -* @param pin_name: GPIO Pin Name. Eg: IO0 -* @return int of MRAA index for gpio +* @param pin_name: GPIO pin name. Eg: IO0 +* @return int of MRAA index for GPIO or -1 if not found. */ - int mraa_gpio_lookup(const char* pin_name); /** -* Get pin number, board must be initialised. +* Get I2C bus index by bus name, board must be initialised. * -* @param i2c_name: I2c Bus Name. Eg: I2C6 -* @return int of MRAA index of i2c bus +* @param i2c_name: I2C bus name. Eg: I2C6 +* @return int of MRAA index for I2C bus or -1 if not found. */ - int mraa_i2c_lookup(const char* i2c_name); /** -* Get pin number, board must be initialised. +* Get SPI bus index by bus name, board must be initialised. * -* @param spi_name: Name of spi bus. Eg: SPI2 -* @return int for MRAA index of spi bus +* @param spi_name: Name of SPI bus. Eg: SPI2 +* @return int of MRAA index for SPI bus or -1 if not found. */ - int mraa_spi_lookup(const char* spi_name); /** -* Get pin number, board must be initialised. +* Get PWM index by PWM name, board must be initialised. * -* @param pwm_name: Name of pwm. Eg:PWM0 -* @return int of MRAA index for pwm bus +* @param pwm_name: Name of PWM. Eg:PWM0 +* @return int of MRAA index for PWM or -1 if not found. */ - int mraa_pwm_lookup(const char* pwm_name); /** diff --git a/api/mraa/common.hpp b/api/mraa/common.hpp index bec1fef..b146f7b 100644 --- a/api/mraa/common.hpp +++ b/api/mraa/common.hpp @@ -217,11 +217,11 @@ getPinName(int pin) } /** -* Get pin number, board must be initialised. +* Get GPIO index by pin name, board must be initialised. * -* @param pin_name: GPIO Pin Name. Eg: IO0 -* @throws std::invalid_argument if name is not valid -* @return int of MRAA index for gpio +* @param pin_name: GPIO pin name. Eg: IO0 +* @throws std::invalid_argument if name is not found +* @return int of MRAA index for GPIO */ inline int getGpioLookup(std::string pin_name) @@ -238,11 +238,11 @@ getGpioLookup(std::string pin_name) } /** -* Get pin number, board must be initialised. +* Get I2C bus index by bus name, board must be initialised. * -* @param i2c_name: I2c Bus Name. Eg: I2C6 -* @throws std::invalid_argument if name is not valid -* @return int of MRAA index of i2c bus +* @param i2c_name: I2C bus name. Eg: I2C6 +* @throws std::invalid_argument if name is not found +* @return int of MRAA index for I2C bus */ inline int getI2cLookup(std::string i2c_name) @@ -259,11 +259,11 @@ getI2cLookup(std::string i2c_name) } /** -* Get pin number, board must be initialised. +* Get SPI bus index by bus name, board must be initialised. * -* @param spi_name: Name of spi bus. Eg: SPI2 -* @throws std::invalid_argument if name is not valid -* @return int for MRAA index of spi bus +* @param spi_name: Name of SPI bus. Eg: SPI2 +* @throws std::invalid_argument if name is not found +* @return int of MRAA index for SPI bus */ inline int getSpiLookup(std::string spi_name) @@ -280,11 +280,11 @@ getSpiLookup(std::string spi_name) } /** -* Get pin number, board must be initialised. +* Get PWM index by PWM name, board must be initialised. * -* @param pwm_name: Name of pwm. Eg:PWM0 -* @throws std::invalid_argument if name is not valid -* @return int of MRAA index for pwm bus +* @param pwm_name: Name of PWM. Eg:PWM0 +* @throws std::invalid_argument if name is not found +* @return int of MRAA index for PWM */ inline int getPwmLookup(std::string pwm_name) diff --git a/docs/building.md b/docs/building.md index d89ee9e..f48887e 100644 --- a/docs/building.md +++ b/docs/building.md @@ -185,20 +185,18 @@ build machine. cmake -DRPM=ON -DCMAKE_INSTALL_PREFIX=/usr .. ~~~~~~~~~~~~~ -## Building for Peripheralmanager Android Things +## Building for the Android Things Peripheralmanager Client -Change src/CMakeLists.txt:140 to the location of libandroidthings.so on your -machine or have it in your Android NDK. Switch the toolchain file var to point -to where your Android NDK is (here android-ndk is in /opt). +Requirements: + Android Things Native Library (https://github.com/androidthings/native-libandroidthings) + Android NDK >= 14b -NDK r13b +The Android Things Native Library contains a CMake find_package module +(FindAndroidThings.cmake). Make sure the directory containing this module is +added to the CMAKE_MODULE_PATH. + Example cmake -DCMAKE_MODULE_PATH=/path/to/native-libandroidthings + +NDK r14b ~~~~~~~~~~~~~{.sh} -cmake -DBUILDSWIG=OFF -DBUILDARCH=PERIPHERALMAN -DANDROID_TOOLCHAIN_NAME=x86-i686 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk-r13b/build/cmake/android.toolchain.cmake .. +cmake -DBUILDSWIG=OFF -DBUILDARCH=PERIPHERALMAN -DANDROID_TOOLCHAIN_NAME=x86-i686 -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk-r14b/build/cmake/android.toolchain.cmake -DCMAKE_MODULE_PATH=/path/to/native-libandroidthings .. ~~~~~~~~~~~~~ - -NDK r14-beta1 -~~~~~~~~~~~~~{.sh} -cmake -DBUILDSWIG=OFF -DBUILDARCH=PERIPHERALMAN -DANDROID_TOOLCHAIN_NAME=x86-i686 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk-r14-beta1/build/cmake/android.toolchain.cmake .. -~~~~~~~~~~~~~ - -For some reason this is broken on cmake 3.7+ Use cmake 3.6+ for the time being