usb: Skeleton platform code for FTDI FT4222 USB to i2c bridge
Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
22a930e39e
commit
8f48df0533
@@ -47,8 +47,23 @@ typedef struct {
|
||||
mraa_result_t (*gpio_mmap_setup) (mraa_gpio_context dev, mraa_boolean_t en);
|
||||
|
||||
mraa_result_t (*i2c_init_pre) (unsigned int bus);
|
||||
mraa_result_t (*i2c_init_bus_replace) (mraa_i2c_context dev);
|
||||
mraa_i2c_context (*i2c_init_raw_replace) (unsigned int bus);
|
||||
mraa_result_t (*i2c_init_post) (mraa_i2c_context dev);
|
||||
mraa_result_t (*i2c_set_frequency_replace) (mraa_i2c_context dev, mraa_i2c_mode_t mode);
|
||||
mraa_result_t (*i2c_address_replace) (mraa_i2c_context dev, uint8_t addr);
|
||||
int (*i2c_read_replace) (mraa_i2c_context dev, uint8_t* data, int length);
|
||||
uint8_t (*i2c_read_byte_replace) (mraa_i2c_context dev);
|
||||
uint8_t (*i2c_read_byte_data_replace) (mraa_i2c_context dev, const uint8_t command);
|
||||
uint16_t (*i2c_read_word_data_replace) (mraa_i2c_context dev, const uint8_t command);
|
||||
int (*i2c_read_bytes_data_replace) (mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
|
||||
mraa_result_t (*i2c_write_replace) (mraa_i2c_context dev, const uint8_t* data, int length);
|
||||
mraa_result_t (*i2c_write_byte_replace) (mraa_i2c_context dev, uint8_t data);
|
||||
mraa_result_t (*i2c_write_byte_data_replace) (mraa_i2c_context dev, const uint8_t data, const uint8_t command);
|
||||
mraa_result_t (*i2c_write_word_data_replace) (mraa_i2c_context dev, const uint16_t data, const uint8_t command);
|
||||
mraa_result_t (*i2c_stop_replace) (mraa_i2c_context dev);
|
||||
|
||||
|
||||
|
||||
mraa_result_t (*aio_get_valid_fp) (mraa_aio_context dev);
|
||||
mraa_result_t (*aio_init_pre) (unsigned int aio);
|
||||
|
||||
51
include/mraa_func.h
Normal file
51
include/mraa_func.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 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_i2c_context (*i2c_init_raw) (unsigned int bus);
|
||||
mraa_result_t (*i2c_frequency) (mraa_i2c_context dev, mraa_i2c_mode_t mode);
|
||||
mraa_result_t (*i2c_address) (mraa_i2c_context dev, uint8_t addr);
|
||||
int (*i2c_read) (mraa_i2c_context dev, uint8_t* data, int length);
|
||||
uint8_t (*i2c_read_byte) (mraa_i2c_context dev);
|
||||
uint8_t (*i2c_read_byte_data) (mraa_i2c_context dev, const uint8_t command);
|
||||
uint16_t (*i2c_read_word_data) (mraa_i2c_context dev, const uint8_t command);
|
||||
int (*i2c_read_bytes_data) (mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
|
||||
mraa_result_t (*i2c_write) (mraa_i2c_context dev, const uint8_t* data, int length);
|
||||
mraa_result_t (*i2c_write_byte) (mraa_i2c_context dev, const uint8_t data);
|
||||
mraa_result_t (*i2c_write_byte_data) (mraa_i2c_context dev, const uint8_t data, const uint8_t command);
|
||||
mraa_result_t (*i2c_write_word_data) (mraa_i2c_context dev, const uint16_t data, const uint8_t command);
|
||||
mraa_result_t (*i2c_stop) (mraa_i2c_context dev);
|
||||
} mraa_i2c_func_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
mraa_i2c_func_t* i2c;
|
||||
} mraa_func_t;
|
||||
|
||||
@@ -59,6 +59,13 @@ mraa_platform_t mraa_x86_platform();
|
||||
*/
|
||||
mraa_platform_t mraa_arm_platform();
|
||||
|
||||
/**
|
||||
* runtime detect running usb platform extender
|
||||
*
|
||||
* @return mraa_platform_t of the detected platform extender
|
||||
*/
|
||||
mraa_platform_t mraa_usb_platform_extender(mraa_board_t* board);
|
||||
|
||||
/**
|
||||
* helper function to check if file exists
|
||||
*
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "mraa.h"
|
||||
#include "mraa_func.h"
|
||||
#include "mraa_adv_func.h"
|
||||
|
||||
// general status failures for internal functions
|
||||
#define MRAA_PLATFORM_NO_INIT -3
|
||||
@@ -59,7 +61,9 @@ struct _i2c {
|
||||
int busnum; /**< the bus number of the /dev/i2c-* device */
|
||||
int fh; /**< the file handle to the /dev/i2c-* device */
|
||||
int addr; /**< the address of the i2c slave */
|
||||
unsigned long funcs;
|
||||
unsigned long funcs; /**< /dev/i2c-* device capabilities as per https://www.kernel.org/doc/Documentation/i2c/functionality */
|
||||
void *handle; /**< generic handle for non-standard drivers that don't use file descriptors */
|
||||
mraa_adv_func_t* func_table;
|
||||
/*@}*/
|
||||
};
|
||||
|
||||
@@ -189,6 +193,7 @@ typedef struct {
|
||||
unsigned int bus_id; /**< ID as exposed in the system */
|
||||
unsigned int scl; /**< i2c SCL */
|
||||
unsigned int sda; /**< i2c SDA */
|
||||
// mraa_drv_api_t drv_type; /**< Driver type */
|
||||
/*@}*/
|
||||
} mraa_i2c_bus_t;
|
||||
|
||||
@@ -222,7 +227,8 @@ typedef struct {
|
||||
/**
|
||||
* A Structure representing a platform/board.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
typedef struct _board_t {
|
||||
/*@{*/
|
||||
unsigned int phy_pin_count; /**< The Total IO pins on board */
|
||||
unsigned int gpio_count; /**< GPIO Count */
|
||||
@@ -243,5 +249,9 @@ typedef struct {
|
||||
int pwm_min_period; /**< Minimum period in us */
|
||||
const char* platform_name; /**< Platform Name pointer */
|
||||
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
||||
mraa_adv_func_t* adv_func; /**< Pointer to advanced function disptach table */
|
||||
struct _board_t* sub_platform; /**< Pointer to sub platform */
|
||||
/*@}*/
|
||||
} mraa_board_t;
|
||||
|
||||
|
||||
|
||||
40
include/usb/ftdi_ft4222.h
Normal file
40
include/usb/ftdi_ft4222.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mraa_internal.h"
|
||||
|
||||
mraa_result_t mraa_ftdi_ft4222_init();
|
||||
mraa_result_t mraa_ftdi_ft4222_get_version(unsigned int* versionChip, unsigned int* versionLib);
|
||||
mraa_board_t* mraa_ftdi_ft4222(mraa_board_t* board);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user