LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_input.h
Go to the documentation of this file.
1 /*
2  * LEGO® MINDSTORMS EV3
3  *
4  * Copyright (C) 2010-2013 The LEGO Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #ifndef C_INPUT_H_
23 #define C_INPUT_H_
24 
25 #include "lms2012.h"
26 
27 #define INPUT_PORTS INPUTS
28 #define INPUT_DEVICES (INPUT_PORTS * CHAIN_DEPT)
29 
30 #define OUTPUT_PORTS OUTPUTS
31 #define OUTPUT_DEVICES (OUTPUT_PORTS * CHAIN_DEPT)
32 
33 #define DEVICES (INPUT_DEVICES + OUTPUT_DEVICES)
34 
35 #define INPUT_VALUES (INPUT_PORTS * 3)
36 #define INPUT_VALUE_SIZE 5
37 #define INPUT_BUFFER_SIZE (INPUT_VALUES * INPUT_VALUE_SIZE)
38 #define INPUT_SIZE (INPUT_VALUES * 2)
39 
40 RESULT cInputInit(void);
41 
42 RESULT cInputOpen(void);
43 
44 RESULT cInputClose(void);
45 
46 RESULT cInputExit(void);
47 
48 void cInputChar(DATA8 Char);
49 
50 void cInputUpdate(UWORD Time);
51 
52 RESULT cInputCompressDevice(DATA8 *pDevice,UBYTE Layer,UBYTE Port);
53 
54 RESULT cInputGetDeviceData(DATA8 Layer,DATA8 Port,DATA8 Length,DATA8 *pType,DATA8 *pMode,DATA8 *pData);
55 
56 RESULT cInputSetChainedDeviceType(DATA8 Layer,DATA8 Port,DATA8 Type,DATA8 Mode);
57 
58 void cInputDeviceList(void);
59 
60 RESULT cInputStartTypeDataUpload(void);
61 
62 #define INPUT_DEVICE_LIST OC(opINPUT_DEVICE_LIST,&cInputDeviceList,7,0 )
63 
64 
65 void cInputDevice(void);
66 
67 void cInputRead(void);
68 
69 void cInputReadSi(void);
70 
71 void cInputReadExt(void);
72 
73 void cInputTest(void);
74 
75 void cInputReady(void);
76 
77 void cInputWrite(void);
78 
79 void cInputSample(void);
80 
81 
82 typedef struct
83 {
89  RESULT DevStatus;
91  DATAF Raw[MAX_DEVICE_DATASETS];
92 #ifndef DISABLE_BUMBED
96 #endif
97 #ifdef Linux_X86
98  UWORD Timer;
99  UBYTE Dir;
100 #endif
101 }
102 DEVICE;
103 
104 
105 typedef struct
106 {
110 }
111 CALIB;
112 
113 
114 typedef struct
115 {
116  //*****************************************************************************
117  // Input Global variables
118  //*****************************************************************************
119 
120 #ifndef DISABLE_DAISYCHAIN
121  UBYTE Data[MAX_DEVICE_DATALENGTH];
122 #endif
123  ANALOG Analog;
124  ANALOG *pAnalog;
125 
126  UART Uart;
127  UART *pUart;
128 
129  IIC Iic;
130  IIC *pIic;
131 
132  int UartFile;
133  int AdcFile;
134  int DcmFile;
135  int IicFile;
136 
141 
143 
144  DATA8 TmpMode[INPUT_PORTS];
145 
146  DATA8 ConfigurationChanged[MAX_PROGRAMS];
147 
148  DATA8 DeviceType[DEVICES];
149  DATA8 DeviceMode[DEVICES];
150  DEVICE DeviceData[DEVICES];
151 
155 
156  DATA8 TypeModes[MAX_DEVICE_TYPE + 1];
157 
163 
166 
167 
168  CALIB Calib[MAX_DEVICE_TYPE][MAX_DEVICE_MODES];
169 }
171 
172 #if (HARDWARE == SIMULATION)
173  extern INPUT_GLOBALS * gInputInstance;
174  #define InputInstance (*gInputInstance)
175 
176  void setInputInstance(INPUT_GLOBALS * _Instance);
178 #else
180 #endif
181 
182 #endif /* C_INPUT_H_ */
void cInputReadSi(void)
opINPUT_READSI byte code
Definition: c_input.c:4722
char Char
Definition: tistdtypes.h:54
RESULT cInputGetDeviceData(DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
Definition: c_input.c:1935
UART * pUart
Definition: c_input.h:127
void cInputWrite(void)
opINPUT_WRITE byte code
Definition: c_input.c:4827
DATA32 InputNull
Definition: c_input.h:142
DATA8 InUse
Definition: c_input.h:107
void cInputChar(DATA8 Char)
IICDAT IicDat
Definition: c_input.h:140
DATA16 TypeDataIndex
Definition: c_input.h:165
SWORD DATA16
VM Type for 2 byte signed value.
Definition: lmstypes.h:62
RESULT cInputStartTypeDataUpload(void)
Definition: c_input.c:3243
DATA32 Changes
Definition: c_input.h:94
SLONG DATA32
VM Type for 4 byte signed value.
Definition: lmstypes.h:63
void cInputDeviceList(void)
opINPUT_DEVICE_LIST byte code
Definition: c_input.c:3678
DATA8 DCMUpdate
Definition: c_input.h:154
void cInputReadExt(void)
opINPUT_READEXT byte code
Definition: c_input.c:4950
void cInputReady(void)
opINPUT_READY byte code
Definition: c_input.c:4793
UWORD OBJID
Object id type.
Definition: lmstypes.h:73
RESULT DevStatus
Definition: c_input.h:89
UWORD TypeIndex
Index to information in "TypeData" table.
Definition: c_input.h:86
Definition: c_input.h:82
UWORD MaxDeviceTypes
Number of device type/mode entries in tabel.
Definition: c_input.h:158
UWORD NoneIndex
Definition: c_input.h:152
IICSTR * IicString
Definition: c_input.h:161
UWORD InvalidTime
mS from type change to valid data
Definition: c_input.h:84
DATA8 Busy
Definition: c_input.h:90
IICSTR IicStr
Definition: c_input.h:162
#define Timer
Definition: lms2012.h:774
TYPES * TypeData
Type specific data.
Definition: c_input.h:159
UWORD IicDeviceTypes
Number of IIC device type/mode entries in tabel.
Definition: c_input.h:160
IICCTL IicCtl
Definition: c_input.h:139
void cInputRead(void)
opINPUT_READ byte code
Definition: c_input.c:4688
void cInputTest(void)
opINPUT_TEST byte code
Definition: c_input.c:4758
UARTCTL UartCtl
Definition: c_input.h:138
RESULT cInputCompressDevice(DATA8 *pDevice, UBYTE Layer, UBYTE Port)
Definition: c_input.c:448
void cInputDevice(void)
opINPUT_DEVICE byte code
Definition: c_input.c:3887
UWORD UnknownIndex
Definition: c_input.h:153
ANALOG Analog
Definition: c_input.h:123
void cInputUpdate(UWORD Time)
Definition: c_input.c:3356
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
Definition: lmstypes.h:29
FLOAT DATAF
VM Type for 4 byte floating point value.
Definition: lmstypes.h:64
DATA16 TypeDataTimer
Definition: c_input.h:164
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
Definition: lmstypes.h:30
DATA32 Bumps
Definition: c_input.h:95
RESULT cInputExit(void)
Definition: c_input.c:3584
OBJID Owner
Definition: c_input.h:88
INPUT_GLOBALS * getInputInstance()
Definition: c_input.c:152
DATAF Min
Definition: c_input.h:108
RESULT cInputClose(void)
Definition: c_input.c:3574
DEVCON DevCon
Definition: c_input.h:137
Definition: c_input.h:105
ANALOG * pAnalog
Definition: c_input.h:124
DATAF OldRaw
Definition: c_input.h:93
#define DEVICES
Definition: c_input.h:33
DATA8 Connection
Connection type (from DCM)
Definition: c_input.h:87
INPUT_GLOBALS * gInputInstance
Definition: c_input.c:145
SBYTE DATA8
VM Type for 1 byte signed value.
Definition: lmstypes.h:61
void cInputSample(void)
opINPUT_SAMPLE byte code
Definition: c_input.c:5065
int UartFile
Definition: c_input.h:132
#define InputInstance
Definition: c_input.h:174
RESULT cInputInit(void)
Definition: c_input.c:3415
DATAF Max
Definition: c_input.h:109
void setInputInstance(INPUT_GLOBALS *_Instance)
Definition: c_input.c:147
RESULT cInputSetChainedDeviceType(DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
Definition: c_input.c:1752
RESULT cInputOpen(void)
Definition: c_input.c:3564
IIC * pIic
Definition: c_input.h:130
#define INPUT_PORTS
Definition: c_input.h:27
UWORD TimeoutTimer
mS allowed to be busy timer
Definition: c_input.h:85