* the USB module */
extern volatile bool ep1_out;
extern volatile bool ep1_in;
+extern volatile bool ep6_out;
extern volatile __xdata __at 0xE6B8 struct setup_data setup_data;
cmd_id_index = 0;
payload_index_in = 0;
- /* Wait until host sends EP1 Bulk-OUT packet */
- while (!ep1_out)
+ /* Wait until host sends Bulk-OUT packet */
+ while ((!ep1_out) && (!ep6_out))
;
- ep1_out = false;
-
- /* Execute the commands */
- last_command = false;
- while (!last_command)
- last_command = execute_command();
-
- /* Send back EP6 Bulk-IN packet if required */
- if (payload_index_in > 0) {
- EP1INBC = payload_index_in;
+ if (ep6_out) {
+ /* Execute I2C command */
+ i2c_recieve();
+ ep6_out = false;
+ }
+ if (ep1_out) {
+ ep1_out = false;
+ /* Execute the commands */
+ last_command = false;
+ while (!last_command)
+ last_command = execute_command();
+
+ /* Send back EP1 Bulk-IN packet if required */
+ if (payload_index_in > 0) {
+ EP1INBC = payload_index_in;
+ syncdelay(3);
+
+ while (!ep1_in)
+ ;
+ ep1_in = false;
+ }
+
+ /* Re-arm EP1-OUT after command execution */
+ EP1OUTBC = 0;
+ syncdelay(3);
+ EP1OUTBC = 0;
syncdelay(3);
-
- while (!ep1_in)
- ;
- ep1_in = false;
}
-
- /* Re-arm EP1-OUT after command execution */
- EP1OUTBC = 0;
- syncdelay(3);
- EP1OUTBC = 0;
- syncdelay(3);
}
}
*/
volatile bool ep1_out;
volatile bool ep1_in;
+volatile bool ep6_out;
volatile __xdata __at 0xE6B8 struct setup_data setup_data;
void ep1in_isr(void)__interrupt EP1IN_ISR
{
ep1_in = true;
-
EXIF &= ~0x10; /* Clear USBINT: Main global interrupt */
EPIRQ = 0x04; /* Clear individual EP1IN IRQ */
}
void ep1out_isr(void)__interrupt EP1OUT_ISR
{
ep1_out = true;
-
EXIF &= ~0x10; /* Clear USBINT: Main global interrupt */
EPIRQ = 0x08; /* Clear individual EP1OUT IRQ */
}
void ep2_isr(void)__interrupt EP2_ISR
{
- ep1_out = false; /* Does nothing but required by the compiler */
}
void ep4_isr(void)__interrupt EP4_ISR
{
}
void ep6_isr(void)__interrupt EP6_ISR
{
- i2c_recieve();
+ ep6_out = true;
EXIF &= ~0x10; /* Clear USBINT: Main global interrupt */
EPIRQ = 0x40; /* Clear individual EP6OUT IRQ */