Skip to content

Commit

Permalink
deviceintel setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Radovici committed Jan 28, 2016
1 parent e2a65f5 commit ece3f74
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 44 deletions.
24 changes: 6 additions & 18 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/LiquidCrystal.cpp
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/libraries/Servo.cpp
Expand Up @@ -23,7 +23,7 @@ Servo::Servo()
this->index = INVALID_SERVO; // too many servos
}

#ifdef ARDUINOGALILEO
#ifdef DEVICEINTEL
m_currentAngle = 180;
#endif

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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
{
Expand All @@ -145,7 +145,7 @@ void Servo::write(int val)

int Servo::read()
{
#ifdef ARDUINOGALILEO
#ifdef DEVICEINTEL
return this->m_currentAngle;
#else
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Servo.h
Expand Up @@ -19,7 +19,7 @@

#include <stdint.h>

#ifdef ARDUINOGALILEO
#ifdef DEVICEINTEL
#include <mraa/pwm.h>

#define MAX_PERIOD 7968
Expand Down Expand Up @@ -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
Expand Down
28 changes: 18 additions & 10 deletions 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 <pthread.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

static mraa_gpio_context gpio_pins[MAX_GPIO_PINS];
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wiring/wiring.h
Expand Up @@ -78,7 +78,7 @@
#define MAX_I2C_PINS 10
#endif /* UDOONEO */

#if defined(ARDUINOGALILEO) || defined(EDISON)
#if defined(DEVICEINTEL)//defined(ARDUINOGALILEO) || defined(EDISON)
#include <mraa/gpio.h>
#include <mraa/aio.h>
#include <mraa/pwm.h>
Expand Down
45 changes: 45 additions & 0 deletions 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)


5 changes: 0 additions & 5 deletions wylio/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion wylio/wylio.c
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <Wyliodrin.h>
#include "../src/Wyliodrin.h"

int main(int argc, char **argv) {
if (argc == 2) {
Expand Down

0 comments on commit ece3f74

Please sign in to comment.