/* $Id: surf_drv.h,v 1.5 2004/04/01 05:35:39 jmuelmen Exp $ */ #ifndef __SURF_DRV_INC__ #define __SURF_DRV_INC__ /* * module commands --- these get sent to module endpoints (1-4) */ /* The buffer that gets passed to the driver should have the following layout: byte 0: surf board number byte 1: endpoint number byte 2: command (choose from the #defines below) byte 3-65: 63 bytes (or fewer) of arguments to the command The driver figures out the USB address and endpoint it should talk to and transmits the following as the data stage of a bulk USB message: byte 0: command byte 1-63: 63 bytes (or fewer) of arguments to the command The endpoint will ACK valid requests and STALL after invalid requests. Invalid requests include ones with out-of-range arguments. Here is the syntax for the commands. Sending arguments longer than specified here or outside the range specified here will make the endpoint stall. command arguments action ----------------------------------------------------------------------------- SURF_MOD_SEL_RD none Select this module for readback. Unselect whichever was selected before. SURF_MOD_SET_ANAL 2 bytes of Set the analog DAC so that the analog ADC target supply voltage at the module corresponds value, 1 byte to the ADC value specified in the of DAC hint argument SURF_MOD_SET_DIG 2 bytes of ADC, idem for digital supply voltage 1 byte of DAC hint SURF_MOD_STATUS none Read out the module status If you ask an endpoint for its status, you must immediately make a USB bulk in request to the endpoint. If you send further bulk out requests the endpoint will stall. The data returned in the bulk in request is the following: byte 0.0: module enabled for read? byte 0.1: module enabled for write? byte 0.2: module interlocked (thermal)? byte 0.3: analog suppply enabled? byte 0.4: digital supply enabled? byte 0.5: module interlocked (powerfail)? byte 1-2: analog supply voltage ADC byte 3-4: digital supply voltage ADC byte 5-6: ground ADC byte 7-8: analog supply current ADC byte 9-10: digital supply current ADC byte 11-13: temperature ADC */ #define SURF_MOD_SEL_RD 0x41 /* select module for readout */ #define SURF_MOD_SEL_WR 0x40 /* select module for writing */ #define SURF_MOD_SET_ANAL 0x42 /* set analog supply voltage */ #define SURF_MOD_SET_DIG 0x43 /* set digital supply voltage */ #define SURF_MOD_ENA 0x44 /* enable analog supply */ #define SURF_MOD_END 0x45 /* enable digital supply */ #define SURF_MOD_STATUS 0x46 /* read out module status */ #define SURF_MOD_DISCON 0x47 /* enable digital supply */ #define SURF_MOD_RECON 0x48 /* enable digital supply */ #define SURF_MOD_TALK 0x49 /* talk to the endpoint (send data verbatim) */ #define SURF_MOD_LISTEN 0x4a /* listen to the data (receive data verbatim) */ #define SURF_MOD_COMP_ANL 0x4b /* compensate analog */ #define SURF_MOD_COMP_DIG 0x4c /* compensate digital */ #define SURF_MOD_TOL_ANL 0x4d /* analog tolerance */ #define SURF_MOD_TOL_DIG 0x4e /* digital tolerance */ /* The global commands below affect all modules attached to the SURF board. The layout of the buffer that gets passed to the driver is: byte 0: board no. byte 1: command (choose from the list below) byte 2: argument The driver transmits a USB control message to the surf board specified in byte 0. It uses the following values: bmRequestType: 01000000 (vendor request, host to device) bRequest: byte 1 of buffer wValue: byte 2 of buffer wIndex: 0 wLength: 0 (no data stage) Anything else will stall EP0. There is no data stage. Oh wait, yes there is: get the error bit field. */ /* global commands --- these get sent to EP 0 */ #define SURF_GLOB 0xb1 /* request >= SURF_GLOB are global */ #define SURF_GLOB_WRITE 0xb1 /* write to all modules */ #if (0) /* these requests are nonsense */ #define SURF_GLOB_EN_ANAL 0xb2 /* enable analog supplies */ #define SURF_GLOB_EN_DIG 0xb3 /* enable digital supplies */ #endif /* these requests were nonsense. */ #define SURF_GLOB_RESET 0xb4 /* reset thermal interlocks */ #define SURF_GLOB_KLUGE_A 0xb5 /* talk to port A */ #define SURF_GLOB_KLUGE_B 0xb6 /* talk to port B */ #define SURF_GLOB_GET_ERR 0xb8 /* get errors */ #define SURF_GLOB_RESET_PFAIL 0xb9 /* reset power fail condition */ #define SURF_FIRM_REV 0x05 /* string index containing firmware revision */ #define SURF_LOOKUP_ADDR 0x2720 #ifdef SURF_DRIVER int surf_write(); int surf_read(); #endif #endif