diff --git a/include/mraa_internal.h b/include/mraa_internal.h index 8905f65..b5f7a3f 100644 --- a/include/mraa_internal.h +++ b/include/mraa_internal.h @@ -54,12 +54,19 @@ mraa_result_t mraa_setup_mux_mapped(mraa_pin_t meta); mraa_result_t mraa_setup_uart(int index); /** - * Runtime detect running x86 platform + * runtime detect running x86 platform * * @return mraa_platform_t of the init'ed platform */ mraa_platform_t mraa_x86_platform(); +/** + * runtime detect running arm platforms + * + * @return mraa_platform_t of the init'ed platform + */ +mraa_platform_t mraa_arm_platform(); + #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index adf4c71..9cceb96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,11 @@ if (X86PLAT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1") endif() +if (ARMPLAT) + add_subdirectory(arm) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1") +endif() + set (mraa_LIB_SRCS ${mraa_LIB_SRCS_NOAUTO} # autogenerated version file diff --git a/src/arm/CMakeLists.txt b/src/arm/CMakeLists.txt new file mode 100644 index 0000000..7f06106 --- /dev/null +++ b/src/arm/CMakeLists.txt @@ -0,0 +1,5 @@ +message (INFO " - Adding ARM platforms") +set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO} + ${PROJECT_SOURCE_DIR}/src/arm/arm.c + PARENT_SCOPE +) diff --git a/src/arm/arm.c b/src/arm/arm.c new file mode 100644 index 0000000..f0eda22 --- /dev/null +++ b/src/arm/arm.c @@ -0,0 +1,36 @@ +/* + * Author: Thomas Ingleby + * 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 + +#include "mraa_internal.h" + +mraa_platform_t +mraa_arm_platform() +{ + mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM; + return platform_type; +} + + diff --git a/src/mraa.c b/src/mraa.c index 321e165..6b3a5da 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -81,6 +81,11 @@ mraa_init() #ifdef X86PLAT // Use runtime x86 platform detection platform_type = mraa_x86_platform(); +#elif ARMPLAT + // Use runtime ARM platform detection + platform_type = mraa_arm_platform(); +#else + #error mraa_ARCH NOTHING #endif if (plat == NULL) {