From ece3f74e6daa2186ec8f5cf2f0c927ddd332ef3b Mon Sep 17 00:00:00 2001 From: Alexandru Radovici Date: Thu, 28 Jan 2016 17:07:44 +0000 Subject: [PATCH] deviceintel setup --- CMakeLists.txt | 24 +++++------------- src/libraries/LiquidCrystal.cpp | 4 +-- src/libraries/Servo.cpp | 10 ++++---- src/libraries/Servo.h | 4 +-- src/wiring/arduinogalileo.c | 28 ++++++++++++-------- src/wiring/wiring.h | 2 +- wylio/CMakeLists.txt | 45 +++++++++++++++++++++++++++++++++ wylio/Makefile | 5 ---- wylio/wylio.c | 2 +- 9 files changed, 80 insertions(+), 44 deletions(-) create mode 100644 wylio/CMakeLists.txt delete mode 100644 wylio/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 8336286..5382ad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,32 +33,18 @@ configure_file ( # Options option (RASPBERRYPI "Build for the RaspberryPi." OFF) -option (GALILEO "Build for the Intel Galileo." OFF) -option (EDISON "Build for the Intel Galileo." OFF) +option (DEVICEINTEL "Build for the Intel Galileo." OFF) option (BEAGLEBONE "Build for the Beaglebone." OFF) -option (MINNOWBOARDMAX "Build for the Minnowboard Max." OFF) option (REDPITAYA "Build for the RedPitaya." OFF) option (UDOONEO "Build for the UDOO NEO." OFF) option (SERVER "Build for the Server." OFF) # Option management -if (GALILEO) - add_definitions (-DARDUINOGALILEO) +if (DEVICEINTEL) + add_definitions (-DDEVICEINTEL) pkg_check_modules (MRAA REQUIRED mraa>=0.4.0) message (INFO "found libmraa version: ${MRAA_VERSION}") - set(FLAGS "-DARDUINOGALILEO") - -elseif (EDISON) - add_definitions (-DEDISON) - pkg_check_modules (MRAA REQUIRED mraa>=0.4.0) - message (INFO "found libmraa version: ${MRAA_VERSION}") - set(FLAGS "-DEDISON") - -elseif (MINNOWBOARDMAX) - add_definitions (-DMINNOWBOARDMAX) - pkg_check_modules (MRAA REQUIRED mraa>=0.4.0) - message (INFO "found libmraa version: ${MRAA_VERSION}") - set(FLAGS "-DMINNOWBOARDMAX") + set(FLAGS "-DDEVICEINTEL") elseif (RASPBERRYPI) add_definitions (-DRASPBERRYPI) @@ -144,6 +130,8 @@ set (wyliodrin_LIB_SRCS add_subdirectory (src) add_subdirectory (languages) +add_subdirectory (wylio) + if (SERVER) else () install (FILES scripts/install_social DESTINATION bin/ PERMISSIONS WORLD_READ WORLD_EXECUTE) diff --git a/src/libraries/LiquidCrystal.cpp b/src/libraries/LiquidCrystal.cpp index 86d28bc..81d7024 100644 --- a/src/libraries/LiquidCrystal.cpp +++ b/src/libraries/LiquidCrystal.cpp @@ -327,11 +327,11 @@ void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { /*********** mid level commands, for sending data/cmds */ -inline void LiquidCrystal::command(uint8_t value) { +void LiquidCrystal::command(uint8_t value) { send(value, LOW); } -inline size_t LiquidCrystal::write(uint8_t value) { +size_t LiquidCrystal::write(uint8_t value) { send(value, HIGH); return 1; } diff --git a/src/libraries/Servo.cpp b/src/libraries/Servo.cpp index d915221..9cb393a 100644 --- a/src/libraries/Servo.cpp +++ b/src/libraries/Servo.cpp @@ -23,7 +23,7 @@ Servo::Servo() this->index = INVALID_SERVO; // too many servos } - #ifdef ARDUINOGALILEO + #ifdef DEVICEINTEL m_currentAngle = 180; #endif @@ -70,7 +70,7 @@ uint8_t Servo::attach(int pin, int min, int max) this->is188hz = true; this->isAttached = true; - #ifdef ARDUINOGALILEO + #ifdef DEVICEINTEL m_pwmServoContext = mraa_pwm_init (this->pin); write (0); #endif @@ -116,7 +116,7 @@ void Servo::write(int val) else if (val > 180) val = 180; - #ifdef ARDUINOGALILEO + #ifdef DEVICEINTEL int period = (max - min) / 180; int cycles = (int)(100.0 * ((float)abs (m_currentAngle - val) / 180)); @@ -133,7 +133,7 @@ void Servo::write(int val) // std::cout << "angle = " << angle << " ,pulse = " << calcPulseTraveling(angle) << ", cycles " << cycles << std::endl; m_currentAngle = val; - #endif + #endif } else { @@ -145,7 +145,7 @@ void Servo::write(int val) int Servo::read() { - #ifdef ARDUINOGALILEO + #ifdef DEVICEINTEL return this->m_currentAngle; #else return 0; diff --git a/src/libraries/Servo.h b/src/libraries/Servo.h index 8828ee6..779772f 100644 --- a/src/libraries/Servo.h +++ b/src/libraries/Servo.h @@ -19,7 +19,7 @@ #include -#ifdef ARDUINOGALILEO +#ifdef DEVICEINTEL #include #define MAX_PERIOD 7968 @@ -58,7 +58,7 @@ class Servo bool is188hz; int lastByteInDuty; // to avoid jitter caused by analogWrite() int calcPulseTraveling (int value); - #ifdef ARDUINOGALILEO + #ifdef DEVICEINTEL int m_currentAngle; mraa_pwm_context m_pwmServoContext; #endif diff --git a/src/wiring/arduinogalileo.c b/src/wiring/arduinogalileo.c index faf72a9..861f732 100644 --- a/src/wiring/arduinogalileo.c +++ b/src/wiring/arduinogalileo.c @@ -1,9 +1,10 @@ -#if defined(ARDUINOGALILEO) || defined (EDISON) || defined (MINNOWBOARDMAX) +#if defined(DEVICEINTEL) // defined(ARDUINOGALILEO) || defined (EDISON) || defined (MINNOWBOARDMAX) #include "wiring.h" #include #include +#include #include static mraa_gpio_context gpio_pins[MAX_GPIO_PINS]; @@ -102,6 +103,7 @@ int wiringSetup () adc_power = pow (2, adc_raw_bits)-1; pthread_mutex_init(&lockspi, NULL); pthread_mutex_init(&locki2c, NULL); + return 0; } void pinReset (int pin) @@ -506,15 +508,21 @@ int i2c_openadapter(uint8_t i2c_bus) { if (i2c_bus == 255) { - #ifdef ARDUINOGALILEO - i2c_bus = 0; - #endif - #ifdef EDISON - i2c_bus = 6; - #endif - #ifdef MINNOWBOARDMAX - i2c_bus = 0; - #endif + const char *platform = mraa_get_platform_name (); + if (strncmp (platform, "Intel Galileo ", 14)==0) + { + i2c_bus = 0; + } + else if (strncmp (platform, "Intel Edison", 12)==0) + { + i2c_bus = 6; + } + else if (strncmp (platform, "MinnowBoard MAX",15)==0) + { + i2c_bus = 0; + } + else + i2c_bus = 0; } i2c_buses[i2cId] = mraa_i2c_init (i2c_bus); } diff --git a/src/wiring/wiring.h b/src/wiring/wiring.h index abb53b2..a58698c 100644 --- a/src/wiring/wiring.h +++ b/src/wiring/wiring.h @@ -78,7 +78,7 @@ #define MAX_I2C_PINS 10 #endif /* UDOONEO */ -#if defined(ARDUINOGALILEO) || defined(EDISON) +#if defined(DEVICEINTEL)//defined(ARDUINOGALILEO) || defined(EDISON) #include #include #include diff --git a/wylio/CMakeLists.txt b/wylio/CMakeLists.txt new file mode 100644 index 0000000..951d875 --- /dev/null +++ b/wylio/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required (VERSION 2.8.8) + +project (wylio) + +set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") +set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall") + +# Appends the cmake/modules path to MAKE_MODULE_PATH variable. +set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) + + + +# Dependencies +find_package (PkgConfig REQUIRED) +find_package (Hiredis REQUIRED) +include_directories (${HIREDIS_INCLUDE_DIR}) +find_package (Jansson REQUIRED) +include_directories (${JANSSON_INCLUDE_DIR}) +pkg_check_modules (EVENT REQUIRED libevent) + + +add_definitions ("-Wall -DDEBUG") + + +include_directories (${PROJECT_BINARY_DIR}) + + + +# Sources +set (wylio_SRCS + # Core + ${PROJECT_SOURCE_DIR}/wylio.c +) + +add_executable (wylio + ${wylio_SRCS} +) + +target_link_libraries (wylio wyliodrin -levent) + + + +install (TARGETS wylio DESTINATION bin) + + diff --git a/wylio/Makefile b/wylio/Makefile deleted file mode 100644 index 1dc4555..0000000 --- a/wylio/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -build: wylio.c - gcc wylio.c -o wylio -lwyliodrin -levent - -install: build - cp wylio /usr/bin diff --git a/wylio/wylio.c b/wylio/wylio.c index 20a071c..302bf8b 100644 --- a/wylio/wylio.c +++ b/wylio/wylio.c @@ -1,6 +1,6 @@ #include #include -#include +#include "../src/Wyliodrin.h" int main(int argc, char **argv) { if (argc == 2) {