g.edge_cnt++;
}
+static noinline void do_to_step(void)
+{
+ g.frame_cnt++;
+
+ g.t_o = (g.t_o + 1) & STREAM_BUF_MASK;
+ if (g.t_o == g.t_i)
+ // done
+ attachInterruptVector(IRQ_PORTB, portb_isr_fixed);
+}
+
static void portb_isr_do_to_inc(void)
{
uint32_t isfr, th;
th = (GPIOB_PDIR >> CORE_PIN0_BIT) & 1;
GPIOD_PDOR = g.stream_to[g.t_o][th];
- if (th) {
- g.t_o = (g.t_o + 1) & STREAM_BUF_MASK;
- if (g.t_o == g.t_i)
- // done
- attachInterruptVector(IRQ_PORTB, portb_isr_fixed);
- g.frame_cnt++;
- }
- g.edge_cnt++;
+ if (th)
+ do_to_step();
}
static void portb_isr_do_to(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();
}
__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();
}
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:
NVIC_SET_PRIORITY(IRQ_PORTB, 0);
NVIC_SET_PRIORITY(IRQ_PORTC, 16);
+ SCB_SHPR1 = SCB_SHPR2 = SCB_SHPR3 = 0x10101010;
pinMode( 2, OUTPUT);
pinMode(14, OUTPUT);
printf("GPIOD PDDR, PDIR: %08x %08x\n", GPIOD_PDIR, GPIOD_PDDR);
printf("PORTB_PCR16: %08x\n", PORTB_PCR16);
printf("PORTC_PCR6: %08x\n", PORTC_PCR6);
+ printf("PORTD_PCR0: %08x\n", PORTD_PCR0);
asm("mrs %0, BASEPRI" : "=r"(ret));
- printf("BASEPRI: %d\n", ret);
+ printf("BASEPRI: %d, SHPR: %08x %08x %08x\n",
+ ret, SCB_SHPR1, SCB_SHPR2, SCB_SHPR3);
edge_cnt_last = g.edge_cnt;