Private
Public Access
2
0

cmake: add -DFTDID2xx and use FindFtd2xx.cmake

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-06-26 13:44:38 +01:00
parent e170e21031
commit e353508e30
7 changed files with 119 additions and 5 deletions

View File

@@ -50,8 +50,16 @@ endif()
if (USBPLAT)
add_subdirectory(usb)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
set (mraa_LIBS ${mraa_LIBS} ft4222)
endif()
find_package (Ftd2xx)
if (FTDID2xx)
if (${LIBFTD2XX_FOUND})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1")
set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES})
else ()
message (WARNING " - Enabled FTDID2xx support but library not found")
endif ()
endif ()
endif ()
set (mraa_LIB_SRCS

View File

@@ -115,11 +115,12 @@ mraa_init()
// This is a platform extender so create null base platform if one doesn't already exist
if (plat == NULL) {
plat = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
plat->platform_name = "Null platform";
plat->platform_name = "Unknown platform";
if (plat != NULL) {
int usb_platform_type = mraa_usb_platform_extender(plat);
if (platform_type == MRAA_UNKNOWN_PLATFORM)
if (platform_type == MRAA_UNKNOWN_PLATFORM) {
platform_type = usb_platform_type;
}
}
}
if (plat == NULL) {

View File

@@ -1,7 +1,12 @@
message (INFO " - Adding USB platforms")
set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO}
${PROJECT_SOURCE_DIR}/src/usb/usb.c
${PROJECT_SOURCE_DIR}/src/usb/ftdi_ft4222.c
PARENT_SCOPE
)
if (FTDID2XX)
set (mraa_LIB_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/usb/ftdi_ft4222.c
PARENT_SCOPE
)
endif ()

View File

@@ -26,13 +26,16 @@
#include <string.h>
#include "mraa_internal.h"
#ifdef FTDID2XX
#include "usb/ftdi_ft4222.h"
#endif
mraa_platform_t
mraa_usb_platform_extender(mraa_board_t* board)
{
mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
#ifdef FTDID2XX
if (mraa_ftdi_ft4222_init() == MRAA_SUCCESS) {
unsigned int versionChip, versionLib;
if (mraa_ftdi_ft4222_get_version(&versionChip, &versionLib) == MRAA_SUCCESS) {
@@ -47,5 +50,6 @@ mraa_usb_platform_extender(mraa_board_t* board)
default:
syslog(LOG_ERR, "Unknown USB Platform Extender, currently not supported by MRAA");
}
#endif
return platform_type;
}