#include <layer1/tpu_window.h>
#include <layer1/l23_api.h>
-#include <l1a_l23_interface.h>
+#include <l1ctl_proto.h>
struct l1s_state l1s;
tpu_end_scenario();
}
+/* Lost TDMA interrupt detection. This works by starting a hardware timer
+ * that is clocked by the same master clock source (VCTCXO). We expect
+ * 1875 timer ticks in the duration of a TDMA frame (5000 qbits / 1250 bits) */
+
/* Timer for detecting lost IRQ */
#define TIMER_TICKS_PER_TDMA 1875
+#define TIMER_TICK_JITTER 1
static int last_timestamp;
last_timestamp += (4*TIMER_TICKS_PER_TDMA);
diff = last_timestamp - timestamp;
- if (diff != 1875)
+
+ /* allow for a bit of jitter */
+ if (diff < TIMER_TICKS_PER_TDMA - TIMER_TICK_JITTER ||
+ diff > TIMER_TICKS_PER_TDMA + TIMER_TICK_JITTER)
printf("LOST!\n");
last_timestamp = timestamp;
* generated by TPU once every TDMA frame */
static void l1_sync(void)
{
+ uint16_t sched_flags;
+
putchart('+');
check_lost_frame();
}
/* execute the sched_items that have been scheduled for this
- * TDMA frame */
+ * TDMA frame (including setup/cleanup steps) */
+ sched_flags = tdma_sched_flag_scan();
+
+ if (sched_flags & TDMA_IFLG_TPU)
+ l1s_win_init();
+
tdma_sched_execute();
if (dsp_api.r_page_used) {
dsp_api.r_page ^= 1;
}
- //dsp_end_scenario();
+ if (sched_flags & TDMA_IFLG_DSP)
+ dsp_end_scenario();
+
+ if (sched_flags & TDMA_IFLG_TPU)
+ tpu_end_scenario();
/* schedule new / upcoming TDMA items */
mframe_schedule();
void l1s_dsp_abort(void)
{
/* abort right now */
- tdma_schedule(0, &l1s_abort_cmd, 0, 0, 0);
+ tdma_schedule(0, &l1s_abort_cmd, 0, 0, 0, 10);
}
void l1s_tx_apc_helper(void)