Defines | Functions | Variables
m4api.c File Reference
#include <stdio.h>
#include <usb.h>
#include "m4atx_battery_monitor/m4api.h"
Include dependency graph for m4api.c:

Go to the source code of this file.

Defines

#define PRODUCT   0xd001
#define READ_ENDPOINT   0x81
#define TIMEOUT   3000
#define VENDOR   0x04d8
#define WRITE_ENDPOINT   0x01

Functions

int m4CheckVersion (char *buf)
int m4ConfigField (char const *name)
int m4FetchDiag (usb_dev_handle *dev, char *buf)
int m4GetConfig (usb_dev_handle *dev, struct m4ConfigField *field, char *buf)
int m4GetDiag (usb_dev_handle *dev, struct m4Diagnostics *diag)
int m4GetFloat (usb_dev_handle *dev, enum m4FieldID fid, float *out)
int m4GetInteger (usb_dev_handle *dev, enum m4FieldID fid, int *out)
float m4GetVal (enum m4Type type, char *posn)
usb_dev_handle * m4Init ()
static usb_dev_handle * m4InitUSB ()
int m4ParseValue (enum m4Type type, char const *strval, char *buf)
void m4PrintDiag (char *buf)
void m4PrintVal (enum m4Type type, float val)
int m4Read (usb_dev_handle *dev, unsigned char *buf, unsigned int len, int timeout)
int m4SetBinary (usb_dev_handle *dev, struct m4ConfigField *field, char const *val)
int m4SetConfig (usb_dev_handle *dev, struct m4ConfigField *field, char const *strval)
int m4SetFloat (usb_dev_handle *dev, enum m4FieldID fid, float val)
int m4SetInteger (usb_dev_handle *dev, enum m4FieldID fid, int val)
int m4Write (usb_dev_handle *dev, unsigned char *buf, unsigned int len, int timeout)

Variables

struct m4ConfigField m4ConfigFields [47]
struct m4Version m4CurrentVersion
struct m4DiagField m4DiagFields [6]
size_t m4NumDiagFields = sizeof(m4DiagFields) / sizeof(m4DiagFields[0])
static float * m4TypeConversions = NULL
static float m4TypeConversionsV1 [13]
static float m4TypeConversionsV2 [13]
char * m4TypeDescs [14]
static int m4TypeForms [13]
static size_t m4TypeLengths [13]

Define Documentation

#define PRODUCT   0xd001

Definition at line 128 of file m4api.c.

#define READ_ENDPOINT   0x81

Definition at line 129 of file m4api.c.

#define TIMEOUT   3000

Definition at line 131 of file m4api.c.

#define VENDOR   0x04d8

Definition at line 127 of file m4api.c.

#define WRITE_ENDPOINT   0x01

Definition at line 130 of file m4api.c.


Function Documentation

int m4CheckVersion ( char *  buf)

Definition at line 239 of file m4api.c.

int m4ConfigField ( char const *  name)

Definition at line 500 of file m4api.c.

int m4FetchDiag ( usb_dev_handle *  dev,
char *  buf 
)

Definition at line 224 of file m4api.c.

int m4GetConfig ( usb_dev_handle *  dev,
struct m4ConfigField field,
char *  buf 
)

Definition at line 335 of file m4api.c.

int m4GetDiag ( usb_dev_handle *  dev,
struct m4Diagnostics diag 
)

Definition at line 250 of file m4api.c.

int m4GetFloat ( usb_dev_handle *  dev,
enum m4FieldID  fid,
float *  out 
)

Definition at line 389 of file m4api.c.

int m4GetInteger ( usb_dev_handle *  dev,
enum m4FieldID  fid,
int *  out 
)

Definition at line 423 of file m4api.c.

float m4GetVal ( enum m4Type  type,
char *  posn 
)

Definition at line 267 of file m4api.c.

usb_dev_handle* m4Init ( ) [read]

Definition at line 200 of file m4api.c.

static usb_dev_handle* m4InitUSB ( ) [static]

Definition at line 134 of file m4api.c.

int m4ParseValue ( enum m4Type  type,
char const *  strval,
char *  buf 
)

Definition at line 353 of file m4api.c.

void m4PrintDiag ( char *  buf)

Definition at line 487 of file m4api.c.

void m4PrintVal ( enum m4Type  type,
float  val 
)

Definition at line 303 of file m4api.c.

int m4Read ( usb_dev_handle *  dev,
unsigned char *  buf,
unsigned int  len,
int  timeout 
)

Definition at line 191 of file m4api.c.

int m4SetBinary ( usb_dev_handle *  dev,
struct m4ConfigField field,
char const *  val 
)

Definition at line 465 of file m4api.c.

int m4SetConfig ( usb_dev_handle *  dev,
struct m4ConfigField field,
char const *  strval 
)

Definition at line 456 of file m4api.c.

int m4SetFloat ( usb_dev_handle *  dev,
enum m4FieldID  fid,
float  val 
)

Definition at line 403 of file m4api.c.

int m4SetInteger ( usb_dev_handle *  dev,
enum m4FieldID  fid,
int  val 
)

Definition at line 437 of file m4api.c.

int m4Write ( usb_dev_handle *  dev,
unsigned char *  buf,
unsigned int  len,
int  timeout 
)

Definition at line 195 of file m4api.c.


Variable Documentation

Definition at line 76 of file m4api.c.

Initial value:
 {
    .major = 0,
    .minor = 0,
}

Definition at line 46 of file m4api.c.

Initial value:
 {
  {M4_VLT_12_11, 2, "VIN", "Input voltage"},
  {M4_VLT_12_11, 3, "IGN", "Ignition voltage"},
  {M4_VLT_33_01, 4, "33V", "Voltage on 3.3V rail"},
  {M4_VLT_5_03, 5, "5V", "Voltage on 5V rail"},
  {M4_VLT_12_07, 6, "12V", "Voltage on 12V rail"},
  {M4_DEG, 12, "TEMP", "Temperature"},
}

Definition at line 65 of file m4api.c.

size_t m4NumDiagFields = sizeof(m4DiagFields) / sizeof(m4DiagFields[0])

Definition at line 74 of file m4api.c.

float* m4TypeConversions = NULL [static]

Definition at line 44 of file m4api.c.

float m4TypeConversionsV1[13] [static]
Initial value:
 {
 0.1123, 0.076625, 0.0375, 0.0188136,
 1.0, 1.0, 1.0, 1.0,
 10.0, 10.0, 1.0, 1.0,
 1.0
}

Definition at line 29 of file m4api.c.

float m4TypeConversionsV2[13] [static]
Initial value:
 {
 0.1572, 0.1165, 0.0389, 0.0195,
 1.0, 1.0, 1.0, 1.0,
 10.0, 10.0, 1.0, 1.0,
 1.0
}

Definition at line 37 of file m4api.c.

char* m4TypeDescs[14]
Initial value:
 {
  "V", "V", "V", "V",
  "deg. C", "sec", "ms", "ms",
  "ms", "ms", "", "tries",
  ""
}

Definition at line 58 of file m4api.c.

int m4TypeForms[13] [static]
Initial value:

Definition at line 51 of file m4api.c.

size_t m4TypeLengths[13] [static]
Initial value:
 {
 1, 1, 1, 1, 1, 1, 1, 2,
 1, 2, 2, 1, 1
}

Definition at line 24 of file m4api.c.



m4atx_battery_monitor
Author(s): Ken Tossell , Chris Dunkers , Russell Toris
autogenerated on Sun Mar 6 2016 12:02:34