Ejemplo n.º 1
0
 static void TimerAOver(FM_ST ST)
 {
     /* status set if enabled */
     if ((ST.mode & 0x04) != 0) FM_STATUS_SET(ST, 0x01);
     /* clear or reload the counter */
     if (ST.timermodel == FM_TIMER_INTERVAL)
     {
         ST.TAC = (1024 - ST.TA);
         if (ST.Timer_Handler != null) ST.Timer_Handler(ST.index, 0, (int)ST.TAC, ST.TimerBase);
     }
     else ST.TAC = 0;
 }
Ejemplo n.º 2
0
 /* Timer B Overflow */
 static void TimerBOver(FM_ST ST)
 {
     /* status set if enabled */
     if ((ST.mode & 0x08) != 0) FM_STATUS_SET(ST, 0x02);
     /* clear or reload the counter */
     if (ST.timermodel == FM_TIMER_INTERVAL)
     {
         ST.TBC = (256 - ST.TB) << 4;
         if (ST.Timer_Handler != null) ST.Timer_Handler(ST.index, 1, (int)ST.TBC, ST.TimerBase);
     }
     else ST.TBC = 0;
 }
Ejemplo n.º 3
0
        static void FMSetMode(FM_ST ST, int n, int v)
        {
            /* b7 = CSM MODE */
            /* b6 = 3 slot mode */
            /* b5 = reset b */
            /* b4 = reset a */
            /* b3 = timer enable b */
            /* b2 = timer enable a */
            /* b1 = load b */
            /* b0 = load a */
            ST.mode = (uint)v;

            /* reset Timer b flag */
            if ((v & 0x20) != 0)
                FM_STATUS_RESET(ST, 0x02);
            /* reset Timer a flag */
            if ((v & 0x10) != 0)
                FM_STATUS_RESET(ST, 0x01);
            /* load b */
            if ((v & 0x02) != 0)
            {
                if (ST.TBC == 0)
                {
                    ST.TBC = (256 - ST.TB) << 4;
                    /* External timer handler */
                    if (ST.Timer_Handler != null) ST.Timer_Handler(n, 1, (int)ST.TBC, ST.TimerBase);
                }
            }
            else if (ST.timermodel == FM_TIMER_INTERVAL)
            {	/* stop interbval timer */
                if (ST.TBC != 0)
                {
                    ST.TBC = 0;
                    if (ST.Timer_Handler != null) ST.Timer_Handler(n, 1, 0, ST.TimerBase);
                }
            }
            /* load a */
            if ((v & 0x01) != 0)
            {
                if (ST.TAC == 0)
                {
                    ST.TAC = (1024 - ST.TA);
                    /* External timer handler */
                    if (ST.Timer_Handler != null) ST.Timer_Handler(n, 0, (int)ST.TAC, ST.TimerBase);
                }
            }
            else if (ST.timermodel == FM_TIMER_INTERVAL)
            {	/* stop interbval timer */
                if (ST.TAC != 0)
                {
                    ST.TAC = 0;
                    if (ST.Timer_Handler != null) ST.Timer_Handler(n, 0, 0, ST.TimerBase);
                }
            }
        }