00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef M4API_H
00020 #define M4API_H
00021
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif // __cplusplus
00025
00026 const int M4API_VERSION_MAJOR = 0;
00027 const int M4API_VERSION_MINOR = 1;
00028 const float M4API_VERSION = 0.1;
00029
00030 enum m4Type {
00031 M4_VLT_12_11,
00032 M4_VLT_12_07,
00033 M4_VLT_5_03,
00034 M4_VLT_33_01,
00035 M4_DEG,
00036 M4_SEC,
00037 M4_MSC_1_1,
00038 M4_MSC_1_2,
00039 M4_MSC_10_1,
00040 M4_MSC_10_2,
00041 M4_TIM,
00042 M4_TRY,
00043 M4_BYT
00044 };
00045
00046 enum m4FieldID {
00047 M4_IGN_HIGH,
00048 M4_IGN_LOW,
00049 M4_IGN_DBC,
00050 M4_PSU_DELAY,
00051 M4_VIN_MIN_START,
00052 M4_VIN_MIN_ON,
00053 M4_VIN_MIN_5V,
00054 M4_VIN_MAX,
00055 M4_12V_MAX,
00056 M4_12V_MIN,
00057 M4_5V_MAX,
00058 M4_5V_MIN,
00059 M4_33V_MAX,
00060 M4_33V_MIN,
00061 M4_12V_TIME,
00062 M4_33V_TIME,
00063 M4_PWRSW,
00064 M4_PSU_ON_TIME,
00065 M4_ON_DELAY,
00066 M4_PSU_OFF_TIME,
00067 M4_OFF_DELAY,
00068 M4_EMG_TIME_5VSB,
00069 M4_EMG_TIMER,
00070 M4_PS_ON_0,
00071 M4_PS_ON_1,
00072 M4_THUMP,
00073 M4_TEMP_MAX,
00074 M4_TEMP_MIN,
00075 M4_EMG_OFF_MODE,
00076 M4_5V_SBY_DLY,
00077 M4_OFF_DELAY_0,
00078 M4_OFF_HARD_0,
00079 M4_OFF_DELAY_1,
00080 M4_OFF_HARD_1,
00081 M4_OFF_DELAY_2,
00082 M4_OFF_HARD_2,
00083 M4_OFF_DELAY_3,
00084 M4_OFF_HARD_3,
00085 M4_OFF_DELAY_4,
00086 M4_OFF_HARD_4,
00087 M4_OFF_DELAY_5,
00088 M4_OFF_HARD_5,
00089 M4_OFF_DELAY_6,
00090 M4_OFF_HARD_6,
00091 M4_OFF_DELAY_7,
00092 M4_OFF_HARD_7,
00093 M4_RESET,
00094 M4_NUM_CONFIG_FIELDS
00095 };
00096
00097 enum m4Repr {
00098 M4_INTEG,
00099 M4_FLOAT,
00100 M4_TIMER
00101 };
00102
00103 struct m4DiagField {
00104 enum m4Type type;
00105 unsigned int index;
00106 char *name;
00107 char *desc;
00108 };
00109
00110 struct m4ConfigField {
00111 enum m4Type type;
00112 unsigned int index;
00113 char *name;
00114 char *desc;
00115 };
00116
00117 struct m4Diagnostics {
00118 float vin;
00119 float vign;
00120 float v33;
00121 float v5;
00122 float v12;
00123 float temp;
00124 };
00125
00126 struct m4Version {
00127 int major;
00128 int minor;
00129 };
00130
00131 extern struct m4DiagField m4DiagFields[];
00132 extern struct m4ConfigField m4ConfigFields[];
00133 extern char* m4TypeDescs[];
00134
00135
00136 struct usb_dev_handle *m4Init();
00137
00138
00139 int m4GetFloat(struct usb_dev_handle *dev, enum m4FieldID fid, float *out);
00140 int m4SetFloat(struct usb_dev_handle *dev, enum m4FieldID fid, float val);
00141 int m4GetInteger(struct usb_dev_handle *dev, enum m4FieldID fid, int *out);
00142 int m4SetInteger(struct usb_dev_handle *dev, enum m4FieldID fid, int val);
00143
00144
00145 int m4FetchDiag (struct usb_dev_handle *dev, char *buf);
00146
00147
00148 int m4GetDiag (struct usb_dev_handle *dev, struct m4Diagnostics *diag);
00149
00150
00151 float m4GetVal(enum m4Type type, char *posn);
00152
00153
00154 void m4PrintVal(enum m4Type type, float val);
00155
00156
00157 int m4GetConfig(struct usb_dev_handle *dev, struct m4ConfigField *field, char *buf);
00158
00159
00160 int m4ParseValue(enum m4Type type, char const *strval, char *buf);
00161
00162
00163 int m4SetConfig(struct usb_dev_handle *dev, struct m4ConfigField *field, char const *strval);
00164
00165
00166 void m4PrintDiag(char *buf);
00167
00168
00169 int m4ConfigField(char const *name);
00170
00171 #ifdef __cplusplus
00172 }
00173 #endif // __cplusplus
00174
00175 #endif