static void pit_load(int t) { int l = pit.l[t] ? pit.l[t] : 0x10000; timer_process(); pit.newcount[t] = 0; pit.disabled[t] = 0; // pclog("pit_load: t=%i l=%x\n", t, l); switch (pit.m[t]) { case 0: /*Interrupt on terminal count*/ pit.count[t] = l; pit.c[t] = (int)((l << TIMER_SHIFT) * PITCONST); pit_set_out(t, 0); pit.thit[t] = 0; pit.enabled[t] = pit.gate[t]; break; case 1: /*Hardware retriggerable one-shot*/ pit.enabled[t] = 1; break; case 2: /*Rate generator*/ if (pit.initial[t]) { pit.count[t] = l - 1; pit.c[t] = (int)(((l - 1) << TIMER_SHIFT) * PITCONST); pit_set_out(t, 1); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; break; case 3: /*Square wave mode*/ if (pit.initial[t]) { pit.count[t] = l; pit.c[t] = (int)((((l + 1) >> 1) << TIMER_SHIFT) * PITCONST); pit_set_out(t, 1); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; // pclog("pit_load: square wave mode c=%x\n", pit.c[t]); break; case 4: /*Software triggered stobe*/ if (!pit.thit[t] && !pit.initial[t]) pit.newcount[t] = 1; else { pit.count[t] = l; pit.c[t] = (int)((l << TIMER_SHIFT) * PITCONST); pit_set_out(t, 0); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; break; case 5: /*Hardware triggered stobe*/ pit.enabled[t] = 1; break; }
static void pit_load(PIT *pit, int t) { int l = pit->l[t] ? pit->l[t] : 0x10000; timer_clock(); pit->newcount[t] = 0; pit->disabled[t] = 0; switch (pit->m[t]) { case 0: /*Interrupt on terminal count*/ pit->count[t] = l; pit->c[t] = (int64_t)((((int64_t) l) << TIMER_SHIFT) * PITCONST); pit_set_out(pit, t, 0); pit->thit[t] = 0; pit->enabled[t] = pit->gate[t]; break; case 1: /*Hardware retriggerable one-shot*/ pit->enabled[t] = 1; break; case 2: /*Rate generator*/ if (pit->initial[t]) { pit->count[t] = l - 1; pit->c[t] = (int64_t)(((((int64_t) l) - 1LL) << TIMER_SHIFT) * PITCONST); pit_set_out(pit, t, 1); pit->thit[t] = 0; } pit->enabled[t] = pit->gate[t]; break; case 3: /*Square wave mode*/ if (pit->initial[t]) { pit->count[t] = l; pit->c[t] = (int64_t)((((((int64_t) l) + 1LL) >> 1) << TIMER_SHIFT) * PITCONST); pit_set_out(pit, t, 1); pit->thit[t] = 0; } pit->enabled[t] = pit->gate[t]; break; case 4: /*Software triggered stobe*/ if (!pit->thit[t] && !pit->initial[t]) pit->newcount[t] = 1; else { pit->count[t] = l; pit->c[t] = (int64_t)((l << TIMER_SHIFT) * PITCONST); pit_set_out(pit, t, 0); pit->thit[t] = 0; } pit->enabled[t] = pit->gate[t]; break; case 5: /*Hardware triggered stobe*/ pit->enabled[t] = 1; break; }