60 #define DAISY_COMMAND_REPLY 0x0A // Daisy command, reply required
61 #define DAISY_COMMAND_NO_REPLY 0x8A // Daisy command, reply not required
67 #define DAISY_CHAIN_DOWNSTREAM 0xA0 // Write down into the branch of DaisyChained Bricks
68 #define DAISY_CHAIN_UPSTREAM 0xA1 // Data packet from port expanding (DaisyChained) downstream Bricks
69 #define DAISY_CHAIN_INFO 0xA2 // Sensor information packet (max. 54 bytes)
70 #define DAISY_UNLOCK_SLAVE 0xA3 // Ask the slave to start pushing data upstream
71 #define DAISY_SET_TYPE 0xA4 // Set mode/type downstream (no reply needed - status via array)
72 #define DAISY_CHAIN_DOWNSTREAM_WITH_BUSY 0XA5 // Payload also includes Magic Cookies (4 pcs)
98 #define DAISY_REPLY 0x08 // Daisy command reply
99 #define DAISY_REPLY_ERROR 0x09 // Daisy command reply error
115 #define DAISY_VENDOR_ID 0x0694 // LEGO Group
116 #define DAISY_PRODUCT_ID 0x0005 // EV3, the 5'th USB device
117 #define INTERFACE_NUMBER 0 // One and only
119 #define DIR_IN 0x80 // USB EP direction
120 #define DIR_OUT 0x00 // -
121 #define DAISY_INT_EP_ADR 0x01 // HW specific
123 #define DAISY_INTERRUPT_EP_IN DIR_IN + DAISY_INT_EP_ADR // Interrupt endpoint used for UPSTREAM
124 #define DAISY_INTERRUPT_EP_OUT DIR_OUT + DAISY_INT_EP_ADR // Interrupt endpoint used for DOWNSTREAM
126 #define DAISY_MAX_EP_IN_SIZE 64 // FULL speed record size
127 #define DAISY_MAX_EP_OUT_SIZE 64 // FULL speed record size
128 #define DAISY_DEFAULT_MAX_EP_SIZE DAISY_MAX_EP_OUT_SIZE
129 #define DAISY_UPSTREAM_DATA_LENGTH DAISY_DEFAULT_MAX_EP_SIZE
130 #define DAISY_DEFAULT_TIMEOUT 1000 // Timeout set to 1 sec by default
131 #define NO_USER_DATA 0 // No user data embedded in transfer
132 #define DAISY_MAX_INPUT_PER_LAYER 4 // Hardware size
133 #define DAISY_MAX_OUTPUT_PER_LAYER 4 // -
134 #define DAISY_MAX_SENSORS_PER_LAYER (DAISY_MAX_INPUT_PER_LAYER + DAISY_MAX_OUTPUT_PER_LAYER) // Total per layer
135 #define DAISY_MAX_LAYER_DEPT 4 // Max layer depth
137 #define DEVICE_MAX_DATA 32 // Max data size
138 #define BUSYFLAGS 16 // Motor busyflags (grand total)
139 #define DEVICE_MAX_INCL_BUSYFLAGS (DEVICE_MAX_DATA + BUSYFLAGS)
141 #define SLAVE_PROD_ID "0005"
142 #define SLAVE_VENDOR_ID "0694"
153 #define SIZEOF_DAISY_POLL 6
164 #define SIZEOF_UNLOCK_REPLY 7
177 #define SIZEOF_DAISY_READ 8
188 #define SIZEOF_DAISY_WRITE 6
206 #define SIZEOF_DAISY_DEVICE_DATA_PROLOG 11
207 #define SIZEOF_REPLY_DAISY_READ (DAISY_DEFAULT_MAX_EP_SIZE - sizeof(CMDSIZE))
208 #define DAISY_DEVICE_PAYLOAD_SIZE (DEVICE_MAX_DATA + 4) // Status, Type, Mode, DeviceData, CheckSum
209 #define DAISY_DEVICE_CHKSUM_SIZE 1
210 #define DAISY_MAX_INPUT_SENSOR_INDEX 3
211 #define DAISY_SENSOR_OUTPUT_OFFSET 12
212 #define DAISY_SENSOR_DATA_SIZE (SIZEOF_DAISY_DEVICE_DATA_PROLOG + DEVICE_MAX_DATA + DAISY_DEVICE_CHKSUM_SIZE - sizeof(CMDSIZE))
213 #define BUSYFLAGS_START_POS (SIZEOF_DAISY_DEVICE_DATA_PROLOG + DEVICE_MAX_DATA + DAISY_DEVICE_CHKSUM_SIZE)
223 #define SIZEOF_DAISY_INFO 6
224 #define SIZEOF_DAISY_INFO_READ (DAISY_DEFAULT_MAX_EP_SIZE - SIZEOF_DAISY_INFO)
227 #define SENSOR_POS (LAYER_POS + 1)
230 #define DAISY_MAX_DATASIZE DAISY_DEFAULT_MAX_EP_SIZE
231 #define DAISY_DATA_PACKET (DAISY_DEFAULT_MAX_EP_SIZE - sizeof(CMDSIZE))
233 #define PAYLOAD_OFFSET 4
393 #define LAYER_POS_DOWN (STAT +1)
394 #define SENSOR_POS_DOWN (LAYER_POS_DOWN +1)
395 #define TYPE_POS_DOWN (SENSOR_POS_DOWN + 1)
396 #define MODE_POS_DOWN (TYPE_POS_DOWN + 1)
398 #define LAYER_POS_TO_SLAVE (STAT)
399 #define SENSOR_POS_TO_SLAVE (LAYER_POS_TO_SLAVE +1)
400 #define TYPE_POS_TO_SLAVE (SENSOR_POS_TO_SLAVE + 1)
401 #define MODE_POS_TO_SLAVE (TYPE_POS_TO_SLAVE + 1)
410 #define CHECKSUM_POS (DAISY_DEVICE_PAYLOAD_SIZE - 1)
412 #define BUSYTIME 25000 // [uS]
413 #define DAISY_PRIORITY_COUNT 2 // 1:3
414 #define DAISY_PUSH_NOT_UNLOCKED 0x55
426 #define TIME_TO_CHECK_FOR_DAISY_DOWNSTREAM 2000 //16000
427 #define DAISY_SLAVE_SEARCH_STRING "ID 0694:0005 Lego Group"
void SetUnlocked(int Status)
int cDaisyGetInterruptPacketSize(void)
RESULT cDaisyChained(void)
RESULT cDaisyCheckBusyIndex(UBYTE Layer, UBYTE Port)
void cDaisyPollFromDownstream(void)
UBYTE cDaisyCheckBusyBit(UBYTE Layer, UBYTE PortBits)
enum @17 DAISY_PUSH_CONNECTION_STATES
void SetSlaveUnlocked(int Status)
UBYTE cDaisyGetOwnLayer(void)
void cDaisyPrepareNext(void)
uint GetDaisyPushCounter(void)
void cDaisySetOwnLayer(UBYTE Layer)
void Info(void)
opINFO byte code
enum @14 DAISY_WRITE_STATES
RESULT cDaisyMotorDownStream(DATA8 *pData, DATA8 Length, DATA8 Layer, DATA8 PortField)
int GetSlaveUnlocked(void)
RESULT cDaisyDownStreamCmd(DATA8 *pData, DATA8 Length, DATA8 Layer)
enum @18 DAISY_WR_ERROR_CODES
void cDaisyReadFromDownStream(void)
void ResetDaisyPushCounter(void)
RESULT cDaisySetDeviceType(DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
RESULT cDaisyGetDeviceInfo(DATA8 Length, UBYTE *pInfo)
enum @16 DAISY_DOWN_CONNECTION_STATES
int cDaisyGetLastWriteState(void)
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
RESULT cDaisySetDeviceInfo(DATA8 Length, UBYTE *pInfo)
void cDaisyPushUpStream(void)
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
void cDaisyStuffTxed(void)
DATA8 cDaisyGetUsbUpStreamSpeed(void)
RESULT cDaisyGetDownstreamData(DATA8 Layer, DATA8 Sensor, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
enum @15 DAISY_READ_STATES
void cDaisySetBusyFlags(UBYTE Layer, UBYTE Port, UBYTE MagicCookie)
SBYTE DATA8
VM Type for 1 byte signed value.
enum @19 PAYLOAD_POSITIONS
enum @23 DAISY_READ_ERROR_CODES
int cDaisyGetLastWriteResult(void)
void DecrementDaisyPushCounter(void)
void cDaisyCmd(RXBUF *pRxBuf, TXBUF *pTxBuf)
void cDaisySetTimeout(int TimeOut)
UWORD cDaisyData(UBYTE **pData)
int cDaisyWriteDone(void)