diff usb.h @ 35:fed32b382de2

Tidy up, hide details behind macros to make it more obvious what we talk to do do things. Convert constants to my preferred format.
author darius
date Tue, 23 Oct 2007 10:54:01 +0930
parents 4e417d84365e
children
line wrap: on
line diff
--- a/usb.h	Tue Oct 23 10:52:50 2007 +0930
+++ b/usb.h	Tue Oct 23 10:54:01 2007 +0930
@@ -97,19 +97,20 @@
     uint16_t wLANGID0;
 } __attribute__ ((packed))  LANGID_DESCRIPTOR;
 
-#define D12_SET_ADDRESS_ENABLE		0xD0
-#define D12_SET_ENDPOINT_ENABLE  	0xD8
-#define D12_SET_MODE			0xF3
-#define D12_SET_DMA			0xFB
-#define D12_READ_INTERRUPT_REGISTER 	0xF4
-#define D12_READ_BUFFER			0xF0
-#define D12_WRITE_BUFFER		0xF0
-#define D12_ACK_SETUP			0xF1
-#define D12_CLEAR_BUFFER		0xF2
-#define D12_VALIDATE_BUFFER		0xFA
+#define D12_SET_ADDRESS_ENABLE		0xd0
+#define D12_SET_ENDPOINT_ENABLE  	0xd8
+#define D12_SET_MODE			0xf3
+#define D12_SET_DMA			0xfb
+#define D12_READ_INTERRUPT_REGISTER 	0xf4
+#define D12_READ_BUFFER			0xf0
+#define D12_WRITE_BUFFER		0xf0
+#define D12_ACK_SETUP			0xf2
+#define D12_CLEAR_BUFFER		0xf2
+#define D12_VALIDATE_BUFFER		0xfa
 #define D12_READ_LAST_TRANSACTION	0x40
 #define D12_SET_ENDPOINT_STATUS		0x40
 #define D12_READ_ENDPOINT_STATUS	0x80
+#define D12_READ_CHIP_ID		0xfd
 
 #define D12_ENDPOINT_EP0_OUT 		0x00
 #define D12_ENDPOINT_EP0_IN 		0x01
@@ -189,8 +190,31 @@
 void		d12_send_data_ep2(void);
 void		d12_receive_data_ep2(void);
 
-static void	reset(void);
+void 		reset(void);
 
 void		usb_init(void);
 void		usb_intr(void);
 void		usb_gendata(void);
+
+/*
+ * The PDIUSBD12 is wired up like so
+ *
+ *  PDI		     AVR	
+ * ======================
+ * D7:0     <=>     PA7:0	   
+ * RD_N     <=      PB0
+ * INT_N     =>     PB1
+ * WR_N     <=      PB2
+ * A0       <=      PB3 (0 = data, 1 = cmd)
+ * SUSPEND  <=>     PB4
+ */
+
+#define PDIPORT	PORTA
+#define PDIDDR	PORTA
+#define PDICTL	PORTB
+#define PDIRD	PB0
+#define PDIINT	PB1
+#define PDIWR	PB2
+#define PDIA0	PB3
+#define PDISUSP	PB4
+