LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_input.c File Reference
#include <string.h>
#include <math.h>
#include "lms2012.h"
#include "c_input.h"
#include "c_output.h"
#include "c_ui.h"
#include "c_com.h"
#include "c_daisy.h"
#include "../../c_memory/source/c_memory.h"
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define snprintf   _snprintf
 
#define FALSE   0
 
#define TRUE   1
 
#define SENSOR_RESOLUTION   1023L
 
#define AD_MAX   2703L
 
#define AD_FS   3300L
 
#define COLORSENSORBGMIN   (214/(AD_FS/AD_MAX))
 
#define COLORSENSORMIN   (1L/(AD_FS/AD_MAX)) /* 1 inserted else div 0 (1L/(120/AD_MAX)) */
 
#define COLORSENSORMAX   ((AD_MAX * AD_FS)/3300)
 
#define COLORSENSORPCTDYN   (UBYTE)(((COLORSENSORMAX - COLORSENSORMIN) * 100L)/AD_MAX)
 
#define COLORSENSORBGPCTDYN   (UBYTE)(((COLORSENSORMAX - COLORSENSORBGMIN) * 100L)/AD_MAX)
 

Functions

void setInputInstance (INPUT_GLOBALS *_Instance)
 
INPUT_GLOBALSgetInputInstance ()
 
RESULT cInputComSetDeviceType (DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
 
void Memcpy (void *pDest, const void *pSrc, size_t No)
 
void ClrLayer (void)
 
void StopLayer (void)
 
RESULT cInputExpandDevice (DATA8 Device, DATA8 *pLayer, DATA8 *pPort, DATA8 *pOutput)
 
RESULT cInputCompressDevice (DATA8 *pDevice, UBYTE Layer, UBYTE Port)
 
RESULT cInputInsertNewIicString (DATA8 Type, DATA8 Mode, DATA8 *pManufacturer, DATA8 *pSensorType, DATA8 SetupLng, ULONG SetupString, DATA8 PollLng, ULONG PollString, DATA8 ReadLng)
 
RESULT cInputGetIicString (DATA8 Type, DATA8 Mode, IICSTR *IicStr)
 
RESULT cInputGetNewTypeDataPointer (SBYTE *pName, DATA8 Type, DATA8 Mode, DATA8 Connection, TYPES **ppPlace)
 
RESULT cInputInsertTypeData (char *pFilename)
 
void cInputTypeDataInit (void)
 
RESULT cInputSetupDevice (DATA8 Device, DATA8 Repeat, DATA16 Time, DATA8 WrLng, DATA8 *pWrData, DATA8 RdLng, DATA8 *pRdData)
 
RESULT cInputGetData (DATA8 Layer, DATA8 Port, DATA16 Time, DATA16 *pInit, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
RESULT cInputFindDumbInputDevice (DATA8 Device, DATA8 Type, DATA8 Mode, UWORD *pTypeIndex)
 
RESULT cInputFindDumbOutputDevice (DATA8 Device, DATA8 Type, DATA8 Mode, UWORD *pTypeIndex)
 
RESULT cInputFindDevice (DATA8 Type, DATA8 Mode, UWORD *pTypeIndex)
 
void cInputResetDevice (DATA8 Device, UWORD TypeIndex)
 
void cInputSetDeviceType (DATA8 Device, DATA8 Type, DATA8 Mode, int Line)
 
void cInputCalDataInit (void)
 
void cInputCalDataExit (void)
 
void cInputCalcFullScale (UWORD *pRawVal, UWORD ZeroPointOffset, UBYTE PctFullScale, UBYTE InvStatus)
 
void cInputCalibrateColor (COLORSTRUCT *pC, UWORD *pNewVals)
 
DATAF cInputCalculateColor (COLORSTRUCT *pC)
 
RESULT cInputGetColor (DATA8 Device, DATA8 *pData)
 
RESULT cInputSetChainedDeviceType (DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
 
RESULT cInputComSetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
RESULT cInputComGetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
RESULT cInputComGetDeviceData (DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
RESULT cInputComGetDeviceType (DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
RESULT cInputGetDeviceData (DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
DATAF cInputReadDeviceRaw (DATA8 Device, DATA8 Index, DATA16 Time, DATA16 *pInit)
 
void cInputWriteDeviceRaw (DATA8 Device, DATA8 Connection, DATA8 Type, DATAF DataF)
 
DATA8 cInputReadDevicePct (DATA8 Device, DATA8 Index, DATA16 Time, DATA16 *pInit)
 
DATAF cInputReadDeviceSi (DATA8 Device, DATA8 Index, DATA16 Time, DATA16 *pInit)
 
RESULT cInputCheckUartInfo (UBYTE Port)
 
RESULT cInputCheckIicInfo (UBYTE Port)
 
void cInputDcmUpdate (UWORD Time)
 Update Device Types. More...
 
RESULT cInputStartTypeDataUpload (void)
 
void cInputUpdate (UWORD Time)
 
RESULT cInputInit (void)
 
RESULT cInputOpen (void)
 
RESULT cInputClose (void)
 
RESULT cInputExit (void)
 
DATA8 cInputGetDevice (void)
 
void cInputSetType (DATA8 Device, DATA8 Type, DATA8 Mode, int Line)
 
void cInputDeviceList (void)
 opINPUT_DEVICE_LIST byte code More...
 
void cInputDevice (void)
 opINPUT_DEVICE byte code More...
 
void cInputRead (void)
 opINPUT_READ byte code More...
 
void cInputReadSi (void)
 opINPUT_READSI byte code More...
 
void cInputTest (void)
 opINPUT_TEST byte code More...
 
void cInputReady (void)
 opINPUT_READY byte code More...
 
void cInputWrite (void)
 opINPUT_WRITE byte code More...
 
void cInputReadExt (void)
 opINPUT_READEXT byte code More...
 
void cInputSample (void)
 opINPUT_SAMPLE byte code More...
 

Variables

INPUT_GLOBALSgInputInstance
 
TYPES TypeDefault []
 
IMGDATA CLR_LAYER_CLR_CHANGES [] = { opINPUT_DEVICE,CLR_CHANGES,0,0,opINPUT_DEVICE,CLR_CHANGES,0,1,opINPUT_DEVICE,CLR_CHANGES,0,2,opINPUT_DEVICE,CLR_CHANGES,0,3,opOBJECT_END }
 
IMGDATA CLR_LAYER_CLR_BUMBED [] = { opUI_BUTTON,FLUSH,opOBJECT_END }
 
IMGDATA CLR_LAYER_OUTPUT_RESET [] = { opOUTPUT_RESET,0,15,opOBJECT_END }
 
IMGDATA CLR_LAYER_OUTPUT_CLR_COUNT [] = { opOUTPUT_CLR_COUNT,0,15,opOBJECT_END }
 
IMGDATA CLR_LAYER_INPUT_WRITE [] = { opINPUT_WRITE,0,0,1,DEVCMD_RESET,opINPUT_WRITE,0,1,1,DEVCMD_RESET,opINPUT_WRITE,0,2,1,DEVCMD_RESET,opINPUT_WRITE,0,3,1,DEVCMD_RESET,opOBJECT_END }
 
IMGDATA STOP_LAYER [] = { opOUTPUT_PRG_STOP, opOBJECT_END }
 

Macro Definition Documentation

#define AD_FS   3300L

Definition at line 1313 of file c_input.c.

#define AD_MAX   2703L

Definition at line 1312 of file c_input.c.

#define COLORSENSORBGMIN   (214/(AD_FS/AD_MAX))

Definition at line 1315 of file c_input.c.

#define COLORSENSORBGPCTDYN   (UBYTE)(((COLORSENSORMAX - COLORSENSORBGMIN) * 100L)/AD_MAX)

Definition at line 1319 of file c_input.c.

#define COLORSENSORMAX   ((AD_MAX * AD_FS)/3300)

Definition at line 1317 of file c_input.c.

#define COLORSENSORMIN   (1L/(AD_FS/AD_MAX)) /* 1 inserted else div 0 (1L/(120/AD_MAX)) */

Definition at line 1316 of file c_input.c.

#define COLORSENSORPCTDYN   (UBYTE)(((COLORSENSORMAX - COLORSENSORMIN) * 100L)/AD_MAX)

Definition at line 1318 of file c_input.c.

#define FALSE   0

Definition at line 1305 of file c_input.c.

#define SENSOR_RESOLUTION   1023L

Definition at line 1308 of file c_input.c.

#define snprintf   _snprintf

Definition at line 141 of file c_input.c.

#define TRUE   1

Definition at line 1306 of file c_input.c.

Function Documentation

void cInputCalcFullScale ( UWORD pRawVal,
UWORD  ZeroPointOffset,
UBYTE  PctFullScale,
UBYTE  InvStatus 
)

Definition at line 1321 of file c_input.c.

DATAF cInputCalculateColor ( COLORSTRUCT *  pC)

Definition at line 1388 of file c_input.c.

void cInputCalDataExit ( void  )

Definition at line 1288 of file c_input.c.

void cInputCalDataInit ( void  )

Definition at line 1254 of file c_input.c.

void cInputCalibrateColor ( COLORSTRUCT *  pC,
UWORD pNewVals 
)

Definition at line 1344 of file c_input.c.

RESULT cInputCheckIicInfo ( UBYTE  Port)

Definition at line 2925 of file c_input.c.

RESULT cInputCheckUartInfo ( UBYTE  Port)

Definition at line 2845 of file c_input.c.

RESULT cInputClose ( void  )

Definition at line 3574 of file c_input.c.

RESULT cInputComGetDeviceData ( DATA8  Layer,
DATA8  Port,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 1887 of file c_input.c.

RESULT cInputComGetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 1830 of file c_input.c.

RESULT cInputComGetDeviceType ( DATA8  Layer,
DATA8  Port,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 1920 of file c_input.c.

RESULT cInputCompressDevice ( DATA8 pDevice,
UBYTE  Layer,
UBYTE  Port 
)

Definition at line 448 of file c_input.c.

RESULT cInputComSetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 1784 of file c_input.c.

RESULT cInputComSetDeviceType ( DATA8  Layer,
DATA8  Port,
DATA8  Type,
DATA8  Mode 
)

Definition at line 1855 of file c_input.c.

void cInputDcmUpdate ( UWORD  Time)

Update Device Types.

Called when the VM read the device list

Definition at line 3000 of file c_input.c.

void cInputDevice ( void  )

opINPUT_DEVICE byte code

Definition at line 3887 of file c_input.c.

void cInputDeviceList ( void  )

opINPUT_DEVICE_LIST byte code

Definition at line 3678 of file c_input.c.

RESULT cInputExit ( void  )

Definition at line 3584 of file c_input.c.

RESULT cInputExpandDevice ( DATA8  Device,
DATA8 pLayer,
DATA8 pPort,
DATA8 pOutput 
)

Definition at line 417 of file c_input.c.

RESULT cInputFindDevice ( DATA8  Type,
DATA8  Mode,
UWORD pTypeIndex 
)

Definition at line 988 of file c_input.c.

RESULT cInputFindDumbInputDevice ( DATA8  Device,
DATA8  Type,
DATA8  Mode,
UWORD pTypeIndex 
)

Definition at line 895 of file c_input.c.

RESULT cInputFindDumbOutputDevice ( DATA8  Device,
DATA8  Type,
DATA8  Mode,
UWORD pTypeIndex 
)

Definition at line 948 of file c_input.c.

RESULT cInputGetColor ( DATA8  Device,
DATA8 pData 
)

Definition at line 1537 of file c_input.c.

RESULT cInputGetData ( DATA8  Layer,
DATA8  Port,
DATA16  Time,
DATA16 pInit,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 1963 of file c_input.c.

DATA8 cInputGetDevice ( void  )

Definition at line 3628 of file c_input.c.

RESULT cInputGetDeviceData ( DATA8  Layer,
DATA8  Port,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 1935 of file c_input.c.

RESULT cInputGetIicString ( DATA8  Type,
DATA8  Mode,
IICSTR IicStr 
)

Definition at line 539 of file c_input.c.

RESULT cInputGetNewTypeDataPointer ( SBYTE pName,
DATA8  Type,
DATA8  Mode,
DATA8  Connection,
TYPES **  ppPlace 
)

Definition at line 581 of file c_input.c.

RESULT cInputInit ( void  )

Definition at line 3415 of file c_input.c.

RESULT cInputInsertNewIicString ( DATA8  Type,
DATA8  Mode,
DATA8 pManufacturer,
DATA8 pSensorType,
DATA8  SetupLng,
ULONG  SetupString,
DATA8  PollLng,
ULONG  PollString,
DATA8  ReadLng 
)

Definition at line 476 of file c_input.c.

RESULT cInputInsertTypeData ( char *  pFilename)

Definition at line 636 of file c_input.c.

RESULT cInputOpen ( void  )

Definition at line 3564 of file c_input.c.

void cInputRead ( void  )

opINPUT_READ byte code

Definition at line 4688 of file c_input.c.

DATA8 cInputReadDevicePct ( DATA8  Device,
DATA8  Index,
DATA16  Time,
DATA16 pInit 
)

Definition at line 2742 of file c_input.c.

DATAF cInputReadDeviceRaw ( DATA8  Device,
DATA8  Index,
DATA16  Time,
DATA16 pInit 
)

<

Todo:
EMETER hack

Definition at line 2407 of file c_input.c.

DATAF cInputReadDeviceSi ( DATA8  Device,
DATA8  Index,
DATA16  Time,
DATA16 pInit 
)

Definition at line 2790 of file c_input.c.

void cInputReadExt ( void  )

opINPUT_READEXT byte code

Definition at line 4950 of file c_input.c.

void cInputReadSi ( void  )

opINPUT_READSI byte code

Definition at line 4722 of file c_input.c.

void cInputReady ( void  )

opINPUT_READY byte code

Definition at line 4793 of file c_input.c.

void cInputResetDevice ( DATA8  Device,
UWORD  TypeIndex 
)

Definition at line 1017 of file c_input.c.

void cInputSample ( void  )

opINPUT_SAMPLE byte code

Definition at line 5065 of file c_input.c.

RESULT cInputSetChainedDeviceType ( DATA8  Layer,
DATA8  Port,
DATA8  Type,
DATA8  Mode 
)

Definition at line 1752 of file c_input.c.

void cInputSetDeviceType ( DATA8  Device,
DATA8  Type,
DATA8  Mode,
int  Line 
)

Definition at line 1041 of file c_input.c.

void cInputSetType ( DATA8  Device,
DATA8  Type,
DATA8  Mode,
int  Line 
)

Definition at line 3640 of file c_input.c.

RESULT cInputSetupDevice ( DATA8  Device,
DATA8  Repeat,
DATA16  Time,
DATA8  WrLng,
DATA8 pWrData,
DATA8  RdLng,
DATA8 pRdData 
)

Definition at line 821 of file c_input.c.

RESULT cInputStartTypeDataUpload ( void  )

Definition at line 3243 of file c_input.c.

void cInputTest ( void  )

opINPUT_TEST byte code

Definition at line 4758 of file c_input.c.

void cInputTypeDataInit ( void  )

Definition at line 762 of file c_input.c.

void cInputUpdate ( UWORD  Time)

Definition at line 3356 of file c_input.c.

void cInputWrite ( void  )

opINPUT_WRITE byte code

Definition at line 4827 of file c_input.c.

void cInputWriteDeviceRaw ( DATA8  Device,
DATA8  Connection,
DATA8  Type,
DATAF  DataF 
)

Definition at line 2636 of file c_input.c.

void ClrLayer ( void  )

Definition at line 390 of file c_input.c.

INPUT_GLOBALS* getInputInstance ( )

Definition at line 152 of file c_input.c.

void Memcpy ( void *  pDest,
const void *  pSrc,
size_t  No 
)

Definition at line 338 of file c_input.c.

void setInputInstance ( INPUT_GLOBALS _Instance)

Definition at line 147 of file c_input.c.

void StopLayer ( void  )

Definition at line 402 of file c_input.c.

Variable Documentation

IMGDATA CLR_LAYER_CLR_BUMBED[] = { opUI_BUTTON,FLUSH,opOBJECT_END }

Definition at line 384 of file c_input.c.

IMGDATA CLR_LAYER_CLR_CHANGES[] = { opINPUT_DEVICE,CLR_CHANGES,0,0,opINPUT_DEVICE,CLR_CHANGES,0,1,opINPUT_DEVICE,CLR_CHANGES,0,2,opINPUT_DEVICE,CLR_CHANGES,0,3,opOBJECT_END }

Definition at line 383 of file c_input.c.

IMGDATA CLR_LAYER_INPUT_WRITE[] = { opINPUT_WRITE,0,0,1,DEVCMD_RESET,opINPUT_WRITE,0,1,1,DEVCMD_RESET,opINPUT_WRITE,0,2,1,DEVCMD_RESET,opINPUT_WRITE,0,3,1,DEVCMD_RESET,opOBJECT_END }

Definition at line 387 of file c_input.c.

IMGDATA CLR_LAYER_OUTPUT_CLR_COUNT[] = { opOUTPUT_CLR_COUNT,0,15,opOBJECT_END }

Definition at line 386 of file c_input.c.

IMGDATA CLR_LAYER_OUTPUT_RESET[] = { opOUTPUT_RESET,0,15,opOBJECT_END }

Definition at line 385 of file c_input.c.

INPUT_GLOBALS* gInputInstance

Definition at line 145 of file c_input.c.

IMGDATA STOP_LAYER[] = { opOUTPUT_PRG_STOP, opOBJECT_END }

Definition at line 400 of file c_input.c.

TYPES TypeDefault[]
Initial value:
=
{
{ "PORT ERROR" , TYPE_ERROR , CONN_ERROR , 0 , 0 , 0 , 4 , 0 , 1 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 'f', "" },
{ "NONE" , TYPE_NONE , CONN_NONE , 0 , 0 , 0 , 4 , 0 , 1 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 'f', "" },
{ "UNKNOWN" , TYPE_UNKNOWN , CONN_UNKNOWN , 0 , 1 , 1 , 4 , 0 , 1 , 0.0, 1023.0, 0.0, 100.0, 0.0, 1023.0, 0, 0, 'f', "" },
{ "\0" }
}
Port empty or not available.
Definition: lms2012.h:585
Port not empty but type has not been determined.
Definition: lms2012.h:584
Port not empty and type is invalid.
Definition: lms2012.h:586

Definition at line 163 of file c_input.c.