mraa.c: Add mraa_get_platform_version call
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -142,6 +142,16 @@ mraa_result_t mraa_set_log_level(int level);
|
|||||||
*/
|
*/
|
||||||
char* mraa_get_platform_name();
|
char* mraa_get_platform_name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the platform's versioning info, the information given depends per
|
||||||
|
* platform and can be NULL. platform_offset has to be given. Do not modify
|
||||||
|
* this pointer
|
||||||
|
*
|
||||||
|
* @param specified platform offset; 0 for main platform, 1 for sub platform
|
||||||
|
* @return platform's versioning string
|
||||||
|
*/
|
||||||
|
const char* mraa_get_platform_version(int platform_offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function attempts to set the mraa process to a given priority and the
|
* This function attempts to set the mraa process to a given priority and the
|
||||||
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
||||||
|
|||||||
@@ -154,6 +154,19 @@ getPlatformName()
|
|||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return platform versioning info. Returns NULL if no info present.
|
||||||
|
*
|
||||||
|
* @param optional subplatform identifier
|
||||||
|
* @return platform versioning info
|
||||||
|
*/
|
||||||
|
inline std::string
|
||||||
|
getPlatformVersion(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
|
||||||
|
{
|
||||||
|
std::string ret_val(mraa_get_platform_version(platform_offset));
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return count of physical pins on the running platform
|
* Return count of physical pins on the running platform
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ typedef struct _board_t {
|
|||||||
int pwm_min_period; /**< Minimum period in us */
|
int pwm_min_period; /**< Minimum period in us */
|
||||||
mraa_platform_t platform_type; /**< Platform type */
|
mraa_platform_t platform_type; /**< Platform type */
|
||||||
const char* platform_name; /**< Platform Name pointer */
|
const char* platform_name; /**< Platform Name pointer */
|
||||||
|
const char* platform_version; /**< Platform versioning info */
|
||||||
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
||||||
mraa_adv_func_t* adv_func; /**< Pointer to advanced function disptach table */
|
mraa_adv_func_t* adv_func; /**< Pointer to advanced function disptach table */
|
||||||
struct _board_t* sub_platform; /**< Pointer to sub platform */
|
struct _board_t* sub_platform; /**< Pointer to sub platform */
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ extern "C" {
|
|||||||
#define MRAA_INTEL_MINNOW_MAX_PINCOUNT (26 + 1)
|
#define MRAA_INTEL_MINNOW_MAX_PINCOUNT (26 + 1)
|
||||||
|
|
||||||
mraa_board_t*
|
mraa_board_t*
|
||||||
mraa_intel_minnowboard_byt_compatible();
|
mraa_intel_minnowboard_byt_compatible(mraa_boolean_t);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/mraa.c
16
src/mraa.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Copyright (c) 2014-2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@@ -51,6 +51,7 @@ mraa_board_t* plat = NULL;
|
|||||||
mraa_iio_info_t* plat_iio = NULL;
|
mraa_iio_info_t* plat_iio = NULL;
|
||||||
|
|
||||||
static char platform_name[MAX_PLATFORM_NAME_LENGTH];
|
static char platform_name[MAX_PLATFORM_NAME_LENGTH];
|
||||||
|
static char* platform_long_name;
|
||||||
|
|
||||||
static int num_i2c_devices = 0;
|
static int num_i2c_devices = 0;
|
||||||
static int num_iio_devices = 0;
|
static int num_iio_devices = 0;
|
||||||
@@ -473,6 +474,19 @@ mraa_get_platform_name()
|
|||||||
return platform_name;
|
return platform_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
mraa_get_platform_version(int platform_offset)
|
||||||
|
{
|
||||||
|
if (plat == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (platform_offset == MRAA_MAIN_PLATFORM_OFFSET) {
|
||||||
|
return plat->platform_version;
|
||||||
|
} else {
|
||||||
|
return plat->sub_platform->platform_version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mraa_get_i2c_bus_count()
|
mraa_get_i2c_bus_count()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Brendan Le Foll <brendan.le.foll@intel.com>
|
||||||
|
* Copyright (c) 2014-2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@@ -1173,6 +1174,7 @@ mraa_intel_edison_fab_c()
|
|||||||
b->phy_pin_count = 20;
|
b->phy_pin_count = 20;
|
||||||
b->gpio_count = 14;
|
b->gpio_count = 14;
|
||||||
b->aio_count = 6;
|
b->aio_count = 6;
|
||||||
|
b->platform_version = "arduino";
|
||||||
|
|
||||||
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
||||||
if (b->adv_func == NULL) {
|
if (b->adv_func == NULL) {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ mraa_get_pin_index(mraa_board_t* board, char* name, int* pin_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mraa_board_t*
|
mraa_board_t*
|
||||||
mraa_intel_minnowboard_byt_compatible()
|
mraa_intel_minnowboard_byt_compatible(mraa_boolean_t turbot)
|
||||||
{
|
{
|
||||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||||
|
|
||||||
@@ -96,6 +96,11 @@ mraa_intel_minnowboard_byt_compatible()
|
|||||||
}
|
}
|
||||||
|
|
||||||
b->platform_name = PLATFORM_NAME;
|
b->platform_name = PLATFORM_NAME;
|
||||||
|
if (turbot) {
|
||||||
|
b->platform_version = "Turbot";
|
||||||
|
} else {
|
||||||
|
b->platform_version = "Ax";
|
||||||
|
}
|
||||||
b->phy_pin_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
b->phy_pin_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
||||||
b->gpio_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
b->gpio_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Brendan Le Foll <brendan.le.foll@intel.com>
|
||||||
|
* Copyright (c) 2014-2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@@ -64,19 +65,19 @@ mraa_x86_platform()
|
|||||||
plat = mraa_intel_nuc5();
|
plat = mraa_intel_nuc5();
|
||||||
} else if (strncmp(line, "NOTEBOOK", 8) == 0) {
|
} else if (strncmp(line, "NOTEBOOK", 8) == 0) {
|
||||||
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
||||||
plat = mraa_intel_minnowboard_byt_compatible();
|
plat = mraa_intel_minnowboard_byt_compatible(0);
|
||||||
} else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
|
} else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
|
||||||
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
||||||
plat = mraa_intel_minnowboard_byt_compatible();
|
plat = mraa_intel_minnowboard_byt_compatible(0);
|
||||||
} else if (strncasecmp(line, "Galileo", 7) == 0) {
|
} else if (strncasecmp(line, "Galileo", 7) == 0) {
|
||||||
platform_type = MRAA_INTEL_GALILEO_GEN1;
|
platform_type = MRAA_INTEL_GALILEO_GEN1;
|
||||||
plat = mraa_intel_galileo_rev_d();
|
plat = mraa_intel_galileo_rev_d();
|
||||||
} else if (strncasecmp(line, "MinnowBoard Compatible", 22) == 0) {
|
} else if (strncasecmp(line, "MinnowBoard Compatible", 22) == 0) {
|
||||||
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
||||||
plat = mraa_intel_minnowboard_byt_compatible();
|
plat = mraa_intel_minnowboard_byt_compatible(1);
|
||||||
} else if (strncasecmp(line, "MinnowBoard Turbot", 18) == 0) {
|
} else if (strncasecmp(line, "MinnowBoard Turbot", 18) == 0) {
|
||||||
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
|
||||||
plat = mraa_intel_minnowboard_byt_compatible();
|
plat = mraa_intel_minnowboard_byt_compatible(1);
|
||||||
} else {
|
} else {
|
||||||
syslog(LOG_ERR, "Platform not supported, not initialising");
|
syslog(LOG_ERR, "Platform not supported, not initialising");
|
||||||
platform_type = MRAA_UNKNOWN_PLATFORM;
|
platform_type = MRAA_UNKNOWN_PLATFORM;
|
||||||
|
|||||||
Reference in New Issue
Block a user