mraa: initial implementation of "hooks"
* Should allow for more platform quirks to be handled by mraa without * massive conditional areas per platform. Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
@@ -24,9 +24,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mraa.h"
|
||||
#include "mraa_adv_func.h"
|
||||
|
||||
#define MRAA_INTEL_GALILEO_REV_D_PINCOUNT 25
|
||||
|
||||
mraa_board_t*
|
||||
mraa_intel_galileo_rev_d();
|
||||
mraa_intel_galileo_rev_d(mraa_adv_func* adv);
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mraa_adv_func.h"
|
||||
|
||||
#define MRAA_INTEL_GALILEO_GEN_2_PINCOUNT 25
|
||||
|
||||
mraa_board_t*
|
||||
mraa_intel_galileo_gen2();
|
||||
mraa_intel_galileo_gen2(mraa_adv_func* adv);
|
||||
|
||||
66
include/mraa_adv_func.h
Normal file
66
include/mraa_adv_func.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 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
|
||||
|
||||
#include "common.h"
|
||||
#include "mraa.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef struct {
|
||||
mraa_boolean_t gpio_init_pre:1;
|
||||
mraa_boolean_t gpio_init_post:1;
|
||||
mraa_boolean_t gpio_mode_replace:1;
|
||||
mraa_boolean_t gpio_mode_pre:1;
|
||||
mraa_boolean_t gpio_mode_post:1;
|
||||
mraa_boolean_t gpio_dir_replace:1;
|
||||
mraa_boolean_t gpio_dir_pre:1;
|
||||
mraa_boolean_t gpio_dir_post:1;
|
||||
mraa_boolean_t gpio_write_pre:1;
|
||||
mraa_boolean_t gpio_write_post:1;
|
||||
mraa_boolean_t gpio_mmaped_write_replace:1;
|
||||
mraa_boolean_t gpio_mmaped_write_pre:1;
|
||||
mraa_boolean_t gpio_mmaped_write_post:1;
|
||||
} mraa_adv_def_t;
|
||||
|
||||
typedef struct {
|
||||
mraa_adv_def_t defined;
|
||||
int (*gpio_init_pre) (int pin);
|
||||
void (*gpio_init_post) (mraa_gpio_context dev);
|
||||
|
||||
mraa_result_t (*gpio_mode_replace) (mraa_gpio_context dev, gpio_mode_t mode);
|
||||
mraa_result_t (*gpio_mode_pre) (mraa_gpio_context dev, gpio_mode_t mode);
|
||||
mraa_result_t (*gpio_mode_post) (mraa_gpio_context dev, gpio_mode_t mode);
|
||||
|
||||
mraa_result_t (*gpio_dir_replace) (mraa_gpio_context dev, gpio_dir_t dir);
|
||||
mraa_result_t (*gpio_dir_pre) (mraa_gpio_context dev, gpio_dir_t dir);
|
||||
mraa_result_t (*gpio_dir_post) (mraa_gpio_context dev, gpio_dir_t dir);
|
||||
|
||||
mraa_result_t (*gpio_write_pre) (mraa_gpio_context dev, int value);
|
||||
mraa_result_t (*gpio_write_post) (mraa_gpio_context dev, int value);
|
||||
|
||||
mraa_result_t (*gpio_mmaped_write_replace) (mraa_gpio_context dev, int value);
|
||||
mraa_result_t (*gpio_mmaped_write_pre) (mraa_gpio_context dev, int value);
|
||||
mraa_result_t (*gpio_mmaped_write_post) (mraa_gpio_context dev, int value);
|
||||
} mraa_adv_func;
|
||||
@@ -25,6 +25,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "mraa_adv_func.h"
|
||||
#include "mraa_internal_types.h"
|
||||
|
||||
/** Setup gpio
|
||||
*
|
||||
@@ -76,3 +78,9 @@ mraa_mmap_pin_t* mraa_setup_mmap_gpio(int pin);
|
||||
* @return out direction to setup. 1 for output 0 for input
|
||||
*/
|
||||
mraa_result_t mraa_swap_complex_gpio(int pin, int out);
|
||||
|
||||
/** Get the advance structure.
|
||||
*
|
||||
* @return struct containing internal advance information for hooks
|
||||
*/
|
||||
mraa_adv_func* mraa_get_advance();
|
||||
|
||||
48
include/mraa_internal_types.h
Normal file
48
include/mraa_internal_types.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 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
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* A structure representing a gpio pin.
|
||||
*/
|
||||
struct _gpio {
|
||||
/*@{*/
|
||||
int pin; /**< the pin number, as known to the os. */
|
||||
int phy_pin; /**< pin passed to clean init. -1 none and raw*/
|
||||
int value_fp; /**< the file pointer to the value of the gpio */
|
||||
void (* isr)(void *); /**< the interupt service request */
|
||||
void *isr_args; /**< args return when interupt service request triggered */
|
||||
pthread_t thread_id; /**< the isr handler thread id */
|
||||
int isr_value_fp; /**< the isr file pointer on the value */
|
||||
mraa_boolean_t owner; /**< If this context originally exported the pin */
|
||||
mraa_boolean_t mmap;
|
||||
void *reg;
|
||||
unsigned int reg_sz;
|
||||
unsigned int reg_bit_pos;
|
||||
/*@}*/
|
||||
};
|
||||
Reference in New Issue
Block a user