maa: add maa_get_platform_type function and move swig common to type.h
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared values for libmaa
|
||||
@@ -33,37 +35,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
MAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
MAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
|
||||
MAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} maa_platform_t;
|
||||
|
||||
/**
|
||||
* MAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
MAA_SUCCESS = 0, /**< Expected response */
|
||||
MAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
|
||||
MAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} maa_result_t;
|
||||
|
||||
/**
|
||||
* MAA boolean type
|
||||
* 1 For TRUE
|
||||
@@ -213,33 +184,6 @@ maa_result_t maa_init() __attribute__((constructor));
|
||||
maa_result_t maa_init();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function attempts to set the maa process to a given priority and the
|
||||
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
||||
* This function * will set to MAX if * priority is > MAX. Function will return
|
||||
* -1 on failure.
|
||||
|
||||
* @param priority Value from typically 0 to 99
|
||||
* @return The priority value set
|
||||
*/
|
||||
int maa_set_priority(const unsigned int priority);
|
||||
|
||||
/** Get the version string of maa autogenerated from git tag
|
||||
*
|
||||
* The version returned may not be what is expected however it is a reliable
|
||||
* number associated with the git tag closest to that version at build time
|
||||
*
|
||||
* @return version string from version.h
|
||||
*/
|
||||
const char* maa_get_version();
|
||||
|
||||
/**
|
||||
* Print a textual representation of the maa_result_t
|
||||
*
|
||||
* @param result the result to print
|
||||
*/
|
||||
void maa_result_print(maa_result_t result);
|
||||
|
||||
/**
|
||||
* Checks if a pin is able to use the passed in mode.
|
||||
*
|
||||
|
||||
103
api/maa/types.h
Normal file
103
api/maa/types.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared types for libmaa
|
||||
* this file is different to common.h in that swig takes this as an input
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
MAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
MAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
|
||||
MAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} maa_platform_t;
|
||||
|
||||
/**
|
||||
* MAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
MAA_SUCCESS = 0, /**< Expected response */
|
||||
MAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
|
||||
MAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} maa_result_t;
|
||||
|
||||
/**
|
||||
* This function attempts to set the maa process to a given priority and the
|
||||
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
||||
* This function * will set to MAX if * priority is > MAX. Function will return
|
||||
* -1 on failure.
|
||||
|
||||
* @param priority Value from typically 0 to 99
|
||||
* @return The priority value set
|
||||
*/
|
||||
int maa_set_priority(const unsigned int priority);
|
||||
|
||||
/** Get the version string of maa autogenerated from git tag
|
||||
*
|
||||
* The version returned may not be what is expected however it is a reliable
|
||||
* number associated with the git tag closest to that version at build time
|
||||
*
|
||||
* @return version string from version.h
|
||||
*/
|
||||
const char* maa_get_version();
|
||||
|
||||
/**
|
||||
* Print a textual representation of the maa_result_t
|
||||
*
|
||||
* @param result the result to print
|
||||
*/
|
||||
void maa_result_print(maa_result_t result);
|
||||
|
||||
/**
|
||||
* Get platform type, board must be initialised.
|
||||
*
|
||||
* @return maa_platform_t Platform type enum
|
||||
*/
|
||||
maa_platform_t maa_get_platform_type();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@ add_executable (isr_pin6 isr_pin6.c)
|
||||
add_executable (gpio_read6 gpio_read6.c)
|
||||
add_executable (spi_mcp4261 spi_mcp4261.c)
|
||||
add_executable (mmap-io2 mmap-io2.c)
|
||||
add_executable (blink_onboard blink_onboard.c)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
|
||||
@@ -19,6 +20,7 @@ target_link_libraries (isr_pin6 maa)
|
||||
target_link_libraries (gpio_read6 maa)
|
||||
target_link_libraries (spi_mcp4261 maa)
|
||||
target_link_libraries (mmap-io2 maa)
|
||||
target_link_libraries (blink_onboard maa)
|
||||
|
||||
add_subdirectory (c++)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
//static maa_pininfo_t* pindata;
|
||||
static maa_board_t* plat = NULL;
|
||||
static maa_platform_t platform_type = 99;
|
||||
static maa_platform_t platform_type = MAA_UNKNOWN_PLATFORM;
|
||||
|
||||
const char *
|
||||
maa_get_version()
|
||||
@@ -64,8 +64,6 @@ maa_init()
|
||||
Py_InitializeEx(0);
|
||||
PyEval_InitThreads();
|
||||
#endif
|
||||
platform_type = MAA_UNKNOWN_PLATFORM;
|
||||
|
||||
// detect a galileo gen2 board
|
||||
char *line = NULL;
|
||||
// let getline allocate memory for *line
|
||||
@@ -420,3 +418,8 @@ maa_swap_complex_gpio(int pin, int out)
|
||||
default: return MAA_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
maa_platform_t maa_get_platform_type()
|
||||
{
|
||||
return platform_type;
|
||||
}
|
||||
|
||||
28
src/maa.i
28
src/maa.i
@@ -21,40 +21,20 @@
|
||||
maa_init();
|
||||
%}
|
||||
|
||||
%rename(getVersion) maa_get_version();
|
||||
const char * maa_get_version();
|
||||
%rename(getVersion) maa_get_version;
|
||||
|
||||
%rename(setPriority) maa_set_priority;
|
||||
int maa_set_priority(const unsigned int);
|
||||
|
||||
%rename(printError) maa_result_print(maa_result_t error);
|
||||
void maa_result_print(maa_result_t error);
|
||||
|
||||
/**
|
||||
* MAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
MAA_SUCCESS = 0, /**< Expected response */
|
||||
MAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
|
||||
MAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} maa_result_t;
|
||||
%rename(getPlatform) maa_get_platform_type;
|
||||
|
||||
%typemap(in) unsigned char* = char*;
|
||||
%typemap(in) uint8_t* = char*;
|
||||
%typemap(in) uint8_t = char;
|
||||
|
||||
%include "types.h"
|
||||
|
||||
#### GPIO ####
|
||||
|
||||
%include "gpio.hpp"
|
||||
|
||||
Reference in New Issue
Block a user