LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_daisy.c File Reference
#include "c_input.h"
#include "c_daisy.h"
#include "c_output.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>

Go to the source code of this file.

Functions

void SetUnlocked (int Status)
 
int GetUnlocked (void)
 
void SetSlaveUnlocked (int Status)
 
int GetSlaveUnlocked (void)
 
int cDaisyGetLastWriteState (void)
 
int cDaisyGetLastWriteResult (void)
 
void cDaisyFlagFail (DATA8 Layer, DATA8 Sensor)
 
void cDaisyFlagBusy (DATA8 Layer, DATA8 Sensor)
 
void cDaisyFlagDisconnected (DATA8 StartLayer)
 
void cDaisySetOwnLayer (UBYTE Layer)
 
UBYTE cDaisyGetOwnLayer (void)
 
void cDaisyResetBusyTiming (void)
 
RESULT cDaisyTxDownStream (void)
 
void cDaisySetMasterCookie (uint Index, UBYTE CookieValue)
 
void cDaisyClearMasterCookie (uint Index)
 
void cDaisyIncrementMasterCookie (uint Index)
 
uint cDaisyGetPosFromLayerAndPort (UBYTE Layer, UBYTE Port)
 
void cDaisySetupMagicCookies (uint StoreFrom, UBYTE Layer, UBYTE PortField)
 
RESULT cDaisyCheckBusyIndex (UBYTE Layer, UBYTE Port)
 
UBYTE cDaisyCheckBusyBit (UBYTE Layer, UBYTE PortBits)
 
void cDaisyUpdateLocalBusyFlags (UBYTE Layer)
 
void cDaisySetBusyFlags (UBYTE Layer, UBYTE Port, UBYTE MagicCookie)
 
RESULT cDaisyMotorDownStream (DATA8 *pData, DATA8 Length, DATA8 Layer, DATA8 PortField)
 
void cDaisyStuffRefill (void)
 
UWORD cDaisyData (UBYTE **pData)
 
uint GetDaisyPushCounter (void)
 
void SetDaisyPushCounter (int Count)
 
void ResetDaisyPushCounter (void)
 
void DecrementDaisyPushCounter (void)
 
RESULT cDaisyReady (void)
 
void DaisyAsyncReadCallBack (struct libusb_transfer *ReadUsbTransfer)
 
void cDaisyStartReadUnlockAnswer (void)
 
RESULT cDaisyDownStreamCmd (DATA8 *pData, DATA8 Length, DATA8 Layer)
 
void cDaisyCmd (RXBUF *pRxBuf, TXBUF *pTxBuf)
 
int cDaisyGetMaxPacketSize (libusb_device_handle *DeviceHandle)
 
DATA8 cDaisyGetUsbUpStreamSpeed (void)
 
int GetLayerPointer (void)
 
int GetSensorPointer (void)
 
RESULT cDaisyChained (void)
 
void cDaisySetTimeout (int TimeOut)
 
int cDaisyGetInterruptPacketSize (void)
 
RESULT cDaisyCreateSpeedInfo (void)
 
RESULT cDaisyWriteTypeDownstream (DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
 
RESULT cDaisySetDeviceType (DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
 
void DaisyResetTheBuffers (int FromLayer)
 
void DaisyZeroTheBuffers (void)
 
void DaisyZeroAllExceptMySelf (void)
 
RESULT cDaisyInit (void)
 
int cDaisyWriteUnlockToSlave ()
 
int GetLayerStorePointer (void)
 
int GetSensorStorePointer (void)
 
MSGCNT cDaisyReplyNumber (void)
 
RESULT cDaisyGetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
RESULT cDaisySetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
void cDaisyPushUpStream (void)
 
void cDaisyPrepareNext (void)
 
RESULT cDaisyGetDownstreamData (DATA8 Layer, DATA8 Sensor, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
void DaisyAsyncWriteCallBack (struct libusb_transfer *WriteUsbTransfer)
 
int cDaisyWriteDone (void)
 
void cDaisyPollFromDownStream (void)
 
int cDaisyWrite ()
 
RESULT cDaisyUnlockOk (void)
 
RESULT cDaisyCheckForAttachedSlave (void)
 
void cDaisyControl (void)
 
RESULT cDaisyOpen (void)
 
RESULT cDaisyClose (void)
 
RESULT cDaisyExit (void)
 

Variables

int MaxInterruptPacketSize
 
int TimeOutMs = 10
 
struct libusb_device_handleDeviceHandle
 
struct libusb_transferReadTransfer
 
struct libusb_transferWriteTransfer
 
int WriteState
 
int ReadState
 
int LastWriteResult
 
int BytesWritten
 
int ReadLength
 
DATA8 ReadLayerPointer
 
DATA8 ReadSensorPointer
 
int MaxLowerLayer
 
int DaisyMsgCounter
 
int DaisyControlState
 
UBYTE DaisyInfo
 
int DownConnectionState = DAISY_DOWN_DISCONNECTED
 
int PushState = DAISY_PUSH_NOT_CONNECTED
 
int PlugAndPlay = TIME_TO_CHECK_FOR_DAISY_DOWNSTREAM
 
UBYTE DataIn [DAISY_DEFAULT_MAX_EP_SIZE]
 
UBYTE DataOut [DAISY_DEFAULT_MAX_EP_SIZE]
 
UBYTE DaisyUpstreamDataBuffer [DAISY_DEFAULT_MAX_EP_SIZE]
 
DATA8 DaisyBuffers [DAISY_MAX_LAYER_DEPT][DAISY_MAX_SENSORS_PER_LAYER][DAISY_MAX_DATASIZE]
 
UBYTE DaisyInfoBuffer [DAISY_DEFAULT_MAX_EP_SIZE]
 
RESULT IsDaisyChained = FAIL
 
MSGCNT ReplyNumber = 0
 
DATA8 DaisyTempTypeLayer
 
DATA8 DaisyTempTypeSensor
 
DATA8 DaisyTempDownLayer
 
USB_SPEED * pUsbSpeed
 
USB_SPEED UpStreamConnection
 
int Unlocked = FALSE
 
int SlaveUnlocked = FALSE
 
ULONG BusyTimer = 0
 
uint PushPriorityCounter = 0
 
RESULT DaisyReadyState = OK
 
uint DaisyPushCounter = 55
 
uint OldDaisyCounter = 0
 
int DaisyStuffRefill = TRUE
 
int DaisyUpstreamDataReady = TRUE
 
UBYTE cDaisyOwnLayer = 0
 
UBYTE cDaisyMasterCookieArray [16]
 
UBYTE DaisyBusyFlags [BUSYFLAGS]
 
struct timeval TV = { 0 , 0}
 

Function Documentation

RESULT cDaisyChained ( void  )

Definition at line 1004 of file c_daisy.c.

UBYTE cDaisyCheckBusyBit ( UBYTE  Layer,
UBYTE  PortBits 
)

Definition at line 360 of file c_daisy.c.

RESULT cDaisyCheckBusyIndex ( UBYTE  Layer,
UBYTE  Port 
)

Definition at line 350 of file c_daisy.c.

RESULT cDaisyCheckForAttachedSlave ( void  )

Definition at line 2307 of file c_daisy.c.

void cDaisyClearMasterCookie ( uint  Index)

Definition at line 302 of file c_daisy.c.

RESULT cDaisyClose ( void  )

Definition at line 2582 of file c_daisy.c.

void cDaisyCmd ( RXBUF pRxBuf,
TXBUF pTxBuf 
)

Definition at line 722 of file c_daisy.c.

void cDaisyControl ( void  )

Definition at line 2340 of file c_daisy.c.

RESULT cDaisyCreateSpeedInfo ( void  )

Definition at line 1019 of file c_daisy.c.

UWORD cDaisyData ( UBYTE **  pData)

Definition at line 500 of file c_daisy.c.

RESULT cDaisyDownStreamCmd ( DATA8 pData,
DATA8  Length,
DATA8  Layer 
)

Definition at line 665 of file c_daisy.c.

RESULT cDaisyExit ( void  )

Definition at line 2587 of file c_daisy.c.

void cDaisyFlagBusy ( DATA8  Layer,
DATA8  Sensor 
)

Definition at line 184 of file c_daisy.c.

void cDaisyFlagDisconnected ( DATA8  StartLayer)

Definition at line 189 of file c_daisy.c.

void cDaisyFlagFail ( DATA8  Layer,
DATA8  Sensor 
)

Definition at line 179 of file c_daisy.c.

RESULT cDaisyGetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 1370 of file c_daisy.c.

RESULT cDaisyGetDownstreamData ( DATA8  Layer,
DATA8  Sensor,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 1670 of file c_daisy.c.

int cDaisyGetInterruptPacketSize ( void  )

Definition at line 1014 of file c_daisy.c.

int cDaisyGetLastWriteResult ( void  )

Definition at line 174 of file c_daisy.c.

int cDaisyGetLastWriteState ( void  )

Definition at line 169 of file c_daisy.c.

int cDaisyGetMaxPacketSize ( libusb_device_handle DeviceHandle)

Definition at line 948 of file c_daisy.c.

UBYTE cDaisyGetOwnLayer ( void  )

Definition at line 215 of file c_daisy.c.

uint cDaisyGetPosFromLayerAndPort ( UBYTE  Layer,
UBYTE  Port 
)

Definition at line 315 of file c_daisy.c.

DATA8 cDaisyGetUsbUpStreamSpeed ( void  )

Definition at line 960 of file c_daisy.c.

void cDaisyIncrementMasterCookie ( uint  Index)

Definition at line 307 of file c_daisy.c.

RESULT cDaisyInit ( void  )

Definition at line 1212 of file c_daisy.c.

RESULT cDaisyMotorDownStream ( DATA8 pData,
DATA8  Length,
DATA8  Layer,
DATA8  PortField 
)

Definition at line 399 of file c_daisy.c.

RESULT cDaisyOpen ( void  )

Definition at line 2572 of file c_daisy.c.

void cDaisyPollFromDownStream ( void  )

Definition at line 1852 of file c_daisy.c.

void cDaisyPrepareNext ( void  )

Definition at line 1643 of file c_daisy.c.

void cDaisyPushUpStream ( void  )

Definition at line 1442 of file c_daisy.c.

RESULT cDaisyReady ( void  )

Definition at line 531 of file c_daisy.c.

MSGCNT cDaisyReplyNumber ( void  )

Definition at line 1361 of file c_daisy.c.

void cDaisyResetBusyTiming ( void  )

Definition at line 220 of file c_daisy.c.

void cDaisySetBusyFlags ( UBYTE  Layer,
UBYTE  Port,
UBYTE  MagicCookie 
)

Definition at line 391 of file c_daisy.c.

RESULT cDaisySetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 1396 of file c_daisy.c.

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

Definition at line 1156 of file c_daisy.c.

void cDaisySetMasterCookie ( uint  Index,
UBYTE  CookieValue 
)

Definition at line 297 of file c_daisy.c.

void cDaisySetOwnLayer ( UBYTE  Layer)

Definition at line 204 of file c_daisy.c.

void cDaisySetTimeout ( int  TimeOut)

Definition at line 1009 of file c_daisy.c.

void cDaisySetupMagicCookies ( uint  StoreFrom,
UBYTE  Layer,
UBYTE  PortField 
)

Definition at line 320 of file c_daisy.c.

void cDaisyStartReadUnlockAnswer ( void  )

Definition at line 610 of file c_daisy.c.

void cDaisyStuffRefill ( void  )

Definition at line 495 of file c_daisy.c.

RESULT cDaisyTxDownStream ( void  )

Definition at line 227 of file c_daisy.c.

RESULT cDaisyUnlockOk ( void  )

Definition at line 2249 of file c_daisy.c.

void cDaisyUpdateLocalBusyFlags ( UBYTE  Layer)

Definition at line 385 of file c_daisy.c.

int cDaisyWrite ( void  )

Definition at line 2159 of file c_daisy.c.

int cDaisyWriteDone ( void  )

Definition at line 1806 of file c_daisy.c.

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

Definition at line 1069 of file c_daisy.c.

int cDaisyWriteUnlockToSlave ( )

Definition at line 1333 of file c_daisy.c.

void DaisyAsyncReadCallBack ( struct libusb_transfer ReadUsbTransfer)

Definition at line 547 of file c_daisy.c.

void DaisyAsyncWriteCallBack ( struct libusb_transfer WriteUsbTransfer)

Definition at line 1735 of file c_daisy.c.

void DaisyResetTheBuffers ( int  FromLayer)

Definition at line 1185 of file c_daisy.c.

void DaisyZeroAllExceptMySelf ( void  )

Definition at line 1207 of file c_daisy.c.

void DaisyZeroTheBuffers ( void  )

Definition at line 1202 of file c_daisy.c.

void DecrementDaisyPushCounter ( void  )

Definition at line 525 of file c_daisy.c.

uint GetDaisyPushCounter ( void  )

Definition at line 510 of file c_daisy.c.

int GetLayerPointer ( void  )

Definition at line 994 of file c_daisy.c.

int GetLayerStorePointer ( void  )

Definition at line 1351 of file c_daisy.c.

int GetSensorPointer ( void  )

Definition at line 999 of file c_daisy.c.

int GetSensorStorePointer ( void  )

Definition at line 1356 of file c_daisy.c.

int GetSlaveUnlocked ( void  )

Definition at line 164 of file c_daisy.c.

int GetUnlocked ( void  )

Definition at line 154 of file c_daisy.c.

void ResetDaisyPushCounter ( void  )

Definition at line 520 of file c_daisy.c.

void SetDaisyPushCounter ( int  Count)

Definition at line 515 of file c_daisy.c.

void SetSlaveUnlocked ( int  Status)

Definition at line 159 of file c_daisy.c.

void SetUnlocked ( int  Status)

Definition at line 149 of file c_daisy.c.

Variable Documentation

ULONG BusyTimer = 0

Definition at line 108 of file c_daisy.c.

int BytesWritten

Definition at line 67 of file c_daisy.c.

UBYTE cDaisyMasterCookieArray[16]

Definition at line 119 of file c_daisy.c.

UBYTE cDaisyOwnLayer = 0

Definition at line 117 of file c_daisy.c.

UBYTE DaisyBusyFlags[BUSYFLAGS]

Definition at line 120 of file c_daisy.c.

int DaisyControlState

Definition at line 77 of file c_daisy.c.

UBYTE DaisyInfo

Definition at line 78 of file c_daisy.c.

UBYTE DaisyInfoBuffer[DAISY_DEFAULT_MAX_EP_SIZE]

Definition at line 94 of file c_daisy.c.

int DaisyMsgCounter

Definition at line 76 of file c_daisy.c.

uint DaisyPushCounter = 55

Definition at line 111 of file c_daisy.c.

RESULT DaisyReadyState = OK

Definition at line 110 of file c_daisy.c.

int DaisyStuffRefill = TRUE

Definition at line 114 of file c_daisy.c.

DATA8 DaisyTempDownLayer

Definition at line 100 of file c_daisy.c.

DATA8 DaisyTempTypeLayer

Definition at line 98 of file c_daisy.c.

DATA8 DaisyTempTypeSensor

Definition at line 99 of file c_daisy.c.

UBYTE DaisyUpstreamDataBuffer[DAISY_DEFAULT_MAX_EP_SIZE]

Definition at line 86 of file c_daisy.c.

int DaisyUpstreamDataReady = TRUE

Definition at line 115 of file c_daisy.c.

Definition at line 84 of file c_daisy.c.

Definition at line 85 of file c_daisy.c.

struct libusb_device_handle* DeviceHandle

Definition at line 58 of file c_daisy.c.

int DownConnectionState = DAISY_DOWN_DISCONNECTED

Definition at line 80 of file c_daisy.c.

RESULT IsDaisyChained = FAIL

Definition at line 95 of file c_daisy.c.

int LastWriteResult

Definition at line 66 of file c_daisy.c.

int MaxInterruptPacketSize

Definition at line 56 of file c_daisy.c.

int MaxLowerLayer

Definition at line 74 of file c_daisy.c.

uint OldDaisyCounter = 0

Definition at line 112 of file c_daisy.c.

Definition at line 82 of file c_daisy.c.

USB_SPEED* pUsbSpeed

Definition at line 102 of file c_daisy.c.

uint PushPriorityCounter = 0

Definition at line 109 of file c_daisy.c.

int PushState = DAISY_PUSH_NOT_CONNECTED

Definition at line 81 of file c_daisy.c.

DATA8 ReadLayerPointer

Definition at line 72 of file c_daisy.c.

int ReadLength

Definition at line 68 of file c_daisy.c.

DATA8 ReadSensorPointer

Definition at line 73 of file c_daisy.c.

int ReadState

Definition at line 65 of file c_daisy.c.

struct libusb_transfer* ReadTransfer

Definition at line 62 of file c_daisy.c.

MSGCNT ReplyNumber = 0

Definition at line 96 of file c_daisy.c.

int SlaveUnlocked = FALSE

Definition at line 106 of file c_daisy.c.

int TimeOutMs = 10

Definition at line 57 of file c_daisy.c.

struct timeval TV = { 0 , 0}

Definition at line 147 of file c_daisy.c.

int Unlocked = FALSE

Definition at line 105 of file c_daisy.c.

USB_SPEED UpStreamConnection

Definition at line 103 of file c_daisy.c.

int WriteState

Definition at line 64 of file c_daisy.c.

struct libusb_transfer* WriteTransfer

Definition at line 63 of file c_daisy.c.