Ejemplo n.º 1
0
        private void DoInterrupt(PICInterruptType Type)
        {
            // Set Flags
            switch (Type)
            {
            case PICInterruptType.PIT_RB0INT:
                controller.SetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_INTF, true);
                break;

            case PICInterruptType.PIT_TIMER:
                controller.SetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_T0IF, true);
                break;

            case PICInterruptType.PIT_PORTB:
                controller.SetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_RBIF, true);
                break;

            case PICInterruptType.PIT_EEPROM:
                // No Flag for EEPROM....
                break;
            }

            controller.SetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_GIE, false);

            controller.PushCallStack(controller.GetPC());
            controller.SetPC_11Bit(INTERRUPT_SERVICE_ADDRESS);
        }
Ejemplo n.º 2
0
        public bool AddInterrupt(PICInterruptType t)
        {
            if (!isEnabled(t))
            {
                return(false);
            }

            Queue.Add(new PICInterrupt()
            {
                Type = t, Delay = INTERRUPT_DELAY
            });

            return(true);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            Queue.ForEach(p => p.Delay--);

            for (int i = Queue.Count - 1; i >= 0; i--)
            {
                if (isEnabled() && Queue[i].Delay <= 0)
                {
                    PICInterruptType Type = Queue[i].Type;
                    Queue.RemoveAt(i);

                    DoInterrupt(Type);

                    return;
                }
            }
        }
Ejemplo n.º 4
0
        private bool isEnabled(PICInterruptType t)
        {
            switch (t)
            {
            case PICInterruptType.PIT_RB0INT:
                return(isEnabled() && controller.GetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_INTE));

            case PICInterruptType.PIT_TIMER:
                return(isEnabled() && controller.GetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_T0IE));

            case PICInterruptType.PIT_PORTB:
                return(isEnabled() && controller.GetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_RBIE));

            case PICInterruptType.PIT_EEPROM:
                return(isEnabled() && controller.GetUnbankedRegisterBit(PICMemory.ADDR_INTCON, PICMemory.INTCON_BIT_EEIE));

            default:
                return(false);
            }
        }
Ejemplo n.º 5
0
 public void DoInterrupt(PICInterruptType Type)
 {
     WakeUp();
     Interrupt.AddInterrupt(Type);
 }