/* $Id: firm.h,v 1.19 2004/03/31 08:18:31 jmuelmen Exp $ */ #ifndef _FIRM_INC #define _FIRM_INC #include "types.h" /* * USB descriptor types */ #define USB_DT_DEVICE 0x01 #define USB_DT_CONFIG 0x02 #define USB_DT_STRING 0x03 #define USB_DT_INTERFACE 0x04 #define USB_DT_ENDPOINT 0x05 #define USB_DT_HID 0x21 #define USB_DT_REPORT 0x22 #define USB_DT_PHYSICAL 0x23 #define USB_DT_HUB 0x29 /* mapping for the setup packet */ struct setup_dat { Byte bmRequestType; Byte bRequest; Byte wValueL; Byte wValueH; Byte wIndexL; Byte wIndexH; Byte wLengthL; Byte wLengthH; }; typedef struct setup_dat setup_dat; void usb_isr (void) interrupt 8 using 1 critical; byte rev_lookup (signed int, byte); /* define some useful addresses */ #define ADC1ADDR 0x31 #define ADC2ADDR 0x33 #define RDACADDR(n) (0x2c + (n)) #define ADCANLVH(n) (ADC(40 + 2 * ((n) - 1))) #define ADCANLVL(n) (ADC(41 + 2 * ((n) - 1))) #define ADCDIGVH(n) (ADC(24 + 2 * ((n) - 1))) #define ADCDIGVL(n) (ADC(25 + 2 * ((n) - 1))) #define ADCGNDVH(n) (ADC(8 + 2 * ((n) - 1))) #define ADCGNDVL(n) (ADC(9 + 2 * ((n) - 1))) #define ADCANLIH(n) (ADC(32 + 2 * ((n) - 1))) #define ADCANLIL(n) (ADC(33 + 2 * ((n) - 1))) #define ADCDIGIH(n) (ADC(16 + 2 * ((n) - 1))) #define ADCDIGIL(n) (ADC(17 + 2 * ((n) - 1))) #define ADCTEMPH(n) (ADC(2 * ((n) - 1))) #define ADCTEMPL(n) (ADC(1 + 2 * ((n) - 1))) /* error signal */ #define ERROR(e,m) /* OUTC &= ~0x08 */ FLASH #define SELECT(x) OUTB = (OUTB & 0x3f) | x << 6 #define SLEEP { register int c = IDLE_COUNT_RELOAD; \ while (c--); } #define FLASH OUTC &= ~0x08; SLEEP; OUTC |= 0x08 #define I2CFAIL(x) (!((x).cs & 0x02)) /* reload count for IDLE situations */ #define IDLE_COUNT_RELOAD ((1 << 15) - 1) #define NRESET 0x01; #define ENSING 0x08; #define ABS(x) ((x) > 0 ? (x) : -(x)) #define VTOL_DIG (signed int)0x0080 #define VTOL_ANL (signed int)0x0040 #define LOOKUP(adc,chn) _vtable[((chn) << 8) + (adc)] #endif /* _FIRM_INC */