mraa: add mraa_get_platform_name
getPlatformName for c++/swig API Closes #35 Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#define MRAA_PLATFORM_NAME_MAX_SIZE 64
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* This file defines the basic shared values for libmraa
|
* This file defines the basic shared values for libmraa
|
||||||
@@ -186,6 +188,8 @@ typedef struct {
|
|||||||
int pwm_default_period; /**< The default PWM period is US */
|
int pwm_default_period; /**< The default PWM period is US */
|
||||||
int pwm_max_period; /**< Maximum period in us */
|
int pwm_max_period; /**< Maximum period in us */
|
||||||
int pwm_min_period; /**< Minimum period in us */
|
int pwm_min_period; /**< Minimum period in us */
|
||||||
|
unsigned int platform_name_length; /**< Platform Name length */
|
||||||
|
char* platform_name; /**< Platform Name pointer */
|
||||||
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
} mraa_board_t;
|
} mraa_board_t;
|
||||||
@@ -247,6 +251,13 @@ unsigned int mraa_adc_supported_bits();
|
|||||||
*/
|
*/
|
||||||
mraa_result_t mraa_set_log_level(int level);
|
mraa_result_t mraa_set_log_level(int level);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the Platform's Name, If no platform detected return "Unknown"
|
||||||
|
*
|
||||||
|
* @return platform name
|
||||||
|
*/
|
||||||
|
char* mraa_get_platform_name();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -116,6 +116,17 @@ inline unsigned int adcSupportedBits()
|
|||||||
return mraa_adc_supported_bits();
|
return mraa_adc_supported_bits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Platform Name. "Unknown" if no platform inited.
|
||||||
|
*
|
||||||
|
* @return platform name
|
||||||
|
*/
|
||||||
|
inline std::string getPlatformName()
|
||||||
|
{
|
||||||
|
std::string ret_val(mraa_get_platform_name());
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
||||||
* syslog log levels, see syslog(3) for more information on the levels.
|
* syslog log levels, see syslog(3) for more information on the levels.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "intel_de3815.h"
|
#include "intel_de3815.h"
|
||||||
|
|
||||||
|
#define PLATFORM_NAME "Intel DE3815"
|
||||||
#define MAX_SIZE 64
|
#define MAX_SIZE 64
|
||||||
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
||||||
|
|
||||||
@@ -38,6 +39,10 @@ mraa_intel_de3815()
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
b->platform_name_length = strlen(PLATFORM_NAME) + 1;
|
||||||
|
b->platform_name = (char*) malloc(sizeof(char) * b->platform_name_length);
|
||||||
|
strncpy(b->platform_name, PLATFORM_NAME, b->platform_name_length);
|
||||||
|
|
||||||
b->phy_pin_count = 18;
|
b->phy_pin_count = 18;
|
||||||
//b->gpio_count = 14;
|
//b->gpio_count = 14;
|
||||||
b->aio_count = 0;
|
b->aio_count = 0;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "intel_edison_fab_c.h"
|
#include "intel_edison_fab_c.h"
|
||||||
|
|
||||||
|
#define PLATFORM_NAME "Intel Edison"
|
||||||
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
||||||
#define SYSFS_PINMODE_PATH "/sys/kernel/debug/gpio_debug/gpio"
|
#define SYSFS_PINMODE_PATH "/sys/kernel/debug/gpio_debug/gpio"
|
||||||
#define MAX_SIZE 64
|
#define MAX_SIZE 64
|
||||||
@@ -972,6 +973,10 @@ mraa_intel_edison_fab_c()
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
b->platform_name_length = strlen(PLATFORM_NAME) + 1;
|
||||||
|
b->platform_name = (char*) malloc(sizeof(char) * b->platform_name_length);
|
||||||
|
strncpy(b->platform_name, PLATFORM_NAME, b->platform_name_length);
|
||||||
|
|
||||||
// This seciton will also check if the arduino board is there
|
// This seciton will also check if the arduino board is there
|
||||||
tristate = mraa_gpio_init_raw(214);
|
tristate = mraa_gpio_init_raw(214);
|
||||||
if (tristate == NULL) {
|
if (tristate == NULL) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "intel_galileo_rev_d.h"
|
#include "intel_galileo_rev_d.h"
|
||||||
|
|
||||||
#define UIO_PATH "/dev/uio0"
|
#define UIO_PATH "/dev/uio0"
|
||||||
|
#define PLATFORM_NAME "Intel Galileo Gen 1"
|
||||||
|
|
||||||
static uint8_t *mmap_reg = NULL;
|
static uint8_t *mmap_reg = NULL;
|
||||||
static int mmap_fd = 0;
|
static int mmap_fd = 0;
|
||||||
@@ -123,6 +124,10 @@ mraa_intel_galileo_rev_d()
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
b->platform_name_length = strlen(PLATFORM_NAME) + 1;
|
||||||
|
b->platform_name = (char*) malloc(sizeof(char) * b->platform_name_length);
|
||||||
|
strncpy(b->platform_name, PLATFORM_NAME, b->platform_name_length);
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#define MAX_SIZE 64
|
#define MAX_SIZE 64
|
||||||
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
||||||
|
#define PLATFORM_NAME "Intel Galileo Gen 2"
|
||||||
|
|
||||||
#define UIO_PATH "/dev/uio0"
|
#define UIO_PATH "/dev/uio0"
|
||||||
|
|
||||||
@@ -275,6 +276,10 @@ mraa_intel_galileo_gen2()
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
b->platform_name_length = strlen(PLATFORM_NAME) + 1;
|
||||||
|
b->platform_name = (char*) malloc(sizeof(char) * b->platform_name_length);
|
||||||
|
strncpy(b->platform_name, PLATFORM_NAME, b->platform_name_length);
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "intel_minnow_max.h"
|
#include "intel_minnow_max.h"
|
||||||
|
|
||||||
|
#define PLATFORM_NAME "MinnowBoard MAX"
|
||||||
#define I2C_BUS_COUNT 10
|
#define I2C_BUS_COUNT 10
|
||||||
#define I2C_BUS_DEFAULT 7
|
#define I2C_BUS_DEFAULT 7
|
||||||
|
|
||||||
@@ -76,6 +77,10 @@ mraa_intel_minnow_max()
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
b->platform_name_length = strlen(PLATFORM_NAME) + 1;
|
||||||
|
b->platform_name = (char*) malloc(sizeof(char) * b->platform_name_length);
|
||||||
|
strncpy(b->platform_name, PLATFORM_NAME, b->platform_name_length);
|
||||||
|
|
||||||
b->phy_pin_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
b->phy_pin_count = MRAA_INTEL_MINNOW_MAX_PINCOUNT;
|
||||||
//b->gpio_count = 14;
|
//b->gpio_count = 14;
|
||||||
b->aio_count = 0;
|
b->aio_count = 0;
|
||||||
|
|||||||
@@ -332,3 +332,11 @@ mraa_setup_uart(int index)
|
|||||||
|
|
||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
mraa_get_platform_name()
|
||||||
|
{
|
||||||
|
if (plat == NULL)
|
||||||
|
return "Unknown";
|
||||||
|
return plat->platform_name;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user