pinmap: Added aio support.
* Intel Galileo Rev D: Added analog information * maa_check_aio, similar to maa_check_gpio, will setup multiplexers. * aio: Removed now duplicated functionality. Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
18
api/aio.h
18
api/aio.h
@@ -23,6 +23,11 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
/** @file
|
||||
*
|
||||
* This file defines the aio (analog in) interface for libmaa
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -30,21 +35,8 @@
|
||||
#include "maa.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define TOTAL_ANALOG_INPUTS_ON_BOARD (6)
|
||||
|
||||
static const unsigned int A0 = 0;
|
||||
static const unsigned int A1 = 1;
|
||||
static const unsigned int A2 = 2;
|
||||
static const unsigned int A3 = 3;
|
||||
static const unsigned int A4 = 4;
|
||||
static const unsigned int A5 = 5;
|
||||
|
||||
#define ADC_RAW_RESOLUTION_BITS (12)
|
||||
#define ADC_SUPPORTED_RESOLUTION_BITS (10)
|
||||
#define ADC_COMMON_GATE_A4_A5 (29)
|
||||
|
||||
static const unsigned int
|
||||
adc_gate_pins[TOTAL_ANALOG_INPUTS_ON_BOARD] = {37, 36, 23, 22, 21, 20};
|
||||
|
||||
typedef struct {
|
||||
unsigned int channel;
|
||||
|
||||
87
api/maa.h
87
api/maa.h
@@ -54,41 +54,86 @@ typedef enum {
|
||||
MAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} maa_result_t;
|
||||
|
||||
/**
|
||||
* MAA boolean type
|
||||
* 1 For TRUE
|
||||
*/
|
||||
typedef unsigned int maa_boolean_t;
|
||||
|
||||
/**
|
||||
* A bitfield representing the capabilities of a pin.
|
||||
*/
|
||||
typedef struct {
|
||||
maa_boolean_t valid:1;
|
||||
maa_boolean_t gpio:1;
|
||||
maa_boolean_t pwm:1;
|
||||
maa_boolean_t fast_gpio:1;
|
||||
maa_boolean_t spi:1;
|
||||
maa_boolean_t i2c:1;
|
||||
}
|
||||
maa_pincapabilities_t;
|
||||
/*@{*/
|
||||
maa_boolean_t valid:1; /**< Is the pin valid at all */
|
||||
maa_boolean_t gpio:1; /**< Is the pin gpio capable */
|
||||
maa_boolean_t pwm:1; /**< Is the pin pwm capable */
|
||||
maa_boolean_t fast_gpio:1; /**< Is the pin fast gpio capable */
|
||||
maa_boolean_t spi:1; /**< Is the pin spi capable */
|
||||
maa_boolean_t i2c:1; /**< Is the pin i2c capable */
|
||||
maa_boolean_t aio:1; /**< Is the pin analog input capable */
|
||||
/*@}*/
|
||||
} maa_pincapabilities_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a multiplexer and the required value
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int pin;
|
||||
unsigned int value;
|
||||
/*@{*/
|
||||
unsigned int pin; /**< Raw GPIO pin id */
|
||||
unsigned int value; /**< Raw GPIO value */
|
||||
/*@}*/
|
||||
} maa_mux_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a physical Pin.
|
||||
*/
|
||||
typedef struct {
|
||||
char name[8];// do we need this
|
||||
unsigned int pin;
|
||||
int parent_id;
|
||||
maa_pincapabilities_t capabilites;
|
||||
maa_mux_t mux[4];
|
||||
unsigned int mux_total;
|
||||
/*@{*/
|
||||
char name[8]; /**< Pin's real world name */
|
||||
unsigned int pin; /**< Pin ID */
|
||||
int parent_id; /**< IO Parent ID*/
|
||||
maa_pincapabilities_t capabilites; /**< Pin Capabiliites */
|
||||
maa_mux_t mux[4]; /**< Multiplexer array */
|
||||
unsigned int mux_total; /**< Total Multiplexors required */
|
||||
/*@}*/
|
||||
} maa_pininfo_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a platform/board.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int gpio_count;
|
||||
unsigned int aio_count;
|
||||
unsigned int pwm_count;
|
||||
maa_pininfo_t* pins;
|
||||
/*@{*/
|
||||
unsigned int gpio_count; /**< GPIO Count */
|
||||
unsigned int aio_count; /**< Analog In Count */
|
||||
unsigned int pwm_count; /**< PWM Count */
|
||||
maa_pininfo_t* pins; /**< Pointer to pin array */
|
||||
/*@}*/
|
||||
} maa_board_t;
|
||||
|
||||
/** Initialise MAA
|
||||
*
|
||||
* Detects running platform and attempts to use included pinmap
|
||||
* @return maa_result_t maa result
|
||||
*/
|
||||
maa_result_t maa_init();
|
||||
|
||||
/** Check GPIO
|
||||
*
|
||||
* Will check input is valid for gpio and will also setup required multiplexers.
|
||||
* @param pin the pin as read from the board surface. i.e IO3 would be 3/
|
||||
* @return the pin as found in the pinmap
|
||||
*/
|
||||
unsigned int maa_check_gpio(int pin);
|
||||
//unsigned int maa_check_aio(int pin);
|
||||
|
||||
/** Check AIO
|
||||
*
|
||||
* Will check input is valid for aio and will also setup required multiplexers.
|
||||
* @param pin the pin as read from the board surface. i.e A3 would be 3/
|
||||
* @return the pin as found in the pinmap
|
||||
*/
|
||||
unsigned int maa_check_aio(int pin);
|
||||
|
||||
//unsigned int maa_check_pwm(int pin);
|
||||
|
||||
/** Get the version string of maa autogenerated from git tag
|
||||
|
||||
Reference in New Issue
Block a user