X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=megadrive.git;a=blobdiff_plain;f=main.c;h=96b895fbce352e9f293e86a17d3218f103012321;hp=794317b0f2af73e308c5a52fa27c106819cf860a;hb=6d4349fc1c542c6a70712f508b4fdaa9eb5f14ee;hpb=8e400118814010a69c98b468be02a6c750f4d4b1 diff --git a/main.c b/main.c index 794317b..96b895f 100644 --- a/main.c +++ b/main.c @@ -194,6 +194,33 @@ static void portc_isr_frameinc_do_from(void) g.frame_cnt++; } +static void choose_isrs(void) +{ + if (g.stream_enable_to) { + if (g.use_readinc) { + attachInterruptVector(IRQ_PORTB, portb_isr_do_to_inc); + attachInterruptVector(IRQ_PORTC, portc_isr_nop); + } + else { + attachInterruptVector(IRQ_PORTB, portb_isr_do_to); + attachInterruptVector(IRQ_PORTC, portc_isr_frameinc); + } + } + else if (g.stream_enable_from) { + g.use_pending = 1; + if (g.use_readinc) { + attachInterruptVector(IRQ_PORTB, + portb_isr_fixed_do_from); + attachInterruptVector(IRQ_PORTC, portc_isr_nop); + } + else { + attachInterruptVector(IRQ_PORTB, portb_isr_fixed); + attachInterruptVector(IRQ_PORTC, + portc_isr_frameinc_do_from); + } + } +} + static void udelay(uint32_t us) { uint32_t start = micros(); @@ -276,30 +303,8 @@ static void do_start_seq(void) } __disable_irq(); + choose_isrs(); g.stream_started = 1; - if (g.stream_enable_to) { - if (g.use_readinc) { - attachInterruptVector(IRQ_PORTB, portb_isr_do_to_inc); - attachInterruptVector(IRQ_PORTC, portc_isr_nop); - } - else { - attachInterruptVector(IRQ_PORTB, portb_isr_do_to); - attachInterruptVector(IRQ_PORTC, portc_isr_frameinc); - } - } - else if (g.stream_enable_from) { - g.use_pending = 1; - if (g.use_readinc) { - attachInterruptVector(IRQ_PORTB, - portb_isr_fixed_do_from); - attachInterruptVector(IRQ_PORTC, portc_isr_nop); - } - else { - attachInterruptVector(IRQ_PORTB, portb_isr_fixed); - attachInterruptVector(IRQ_PORTC, - portc_isr_frameinc_do_from); - } - } __enable_irq(); } @@ -350,6 +355,11 @@ static void do_usb(void *buf) g.stream_enable_to = pkt->enable.stream_to; g.stream_enable_from = pkt->enable.stream_from; g.use_readinc = pkt->enable.use_readinc; + if (pkt->enable.no_start_seq) { + GPIOD_PDOR = 0x3f; + choose_isrs(); + g.stream_started = 1; + } __enable_irq(); break; case PKT_STREAM_ABORT: