Exemplo n.º 1
0
        public void WriteDoubleWord(long offset, uint value)
        {
            switch ((Registers)offset)
            {
            case Registers.InterruptMask:
                interruptMask = value;
                break;

            case Registers.EventMask:
                eventMask = value;
                break;

            case Registers.RisingTriggerSelection:
                risingTrigger = value;
                break;

            case Registers.FallingTriggerSelection:
                fallingTrigger = value;
                break;

            case Registers.SoftwareInterruptEvent:
                var allNewAndOld = softwareInterrupt | value;
                var bitsToSet    = allNewAndOld ^ softwareInterrupt;
                BitHelper.ForeachActiveBit(bitsToSet, (x) =>
                {
                    if (BitHelper.IsBitSet(interruptMask, x))
                    {
                        Connections[gpioMapping[x]].Set();
                    }
                });
                break;

            case Registers.PendingRegister:
                pending           &= ~value;
                softwareInterrupt &= ~value;
                BitHelper.ForeachActiveBit(value, (x) =>
                {
                    Connections[gpioMapping[x]].Unset();
                });
                break;

            default:
                this.LogUnhandledWrite(offset, value);
                break;
            }
        }
Exemplo n.º 2
0
        private void DefineRegisters()
        {
            Registers.Request.Define(this)
            .WithValueField(0, 10, FieldMode.Write, writeCallback: (_, value) => BitHelper.ForeachActiveBit(value, x => systemDma.InitTransfer(x, true)), name: "dma_req")
            .WithReservedBits(11, 5)
            .WithValueField(16, 10, FieldMode.Write, writeCallback: (_, value) => BitHelper.ForeachActiveBit(value, x => systemDma.InitTransfer(x, false)), name: "dma_req")
            .WithReservedBits(27, 5)
            ;

            Registers.Active.Define(this)
            .WithValueField(0, 10, FieldMode.Read, name: "dma_active")     //it always returns 0, as the transfer is instant. Keeping this field for possible future latching etc
            .WithReservedBits(11, 21)
            ;

            // this register is effectively a scratchpad
            Registers.SramTimingAdjust.Define(this)
            .WithReservedBits(0, 1)
            .WithFlag(1, name: "sdma_sram_rme")
            .WithValueField(2, 4, name: "sdma_sram_rm")
            .WithReservedBits(6, 26)
            ;
        }