Exemplo n.º 1
0
        public STM32F0_ADC(Machine machine, double referenceVoltage, int externalEventFrequency, int dmaChannel = 0, IDMA dmaPeripheral = null) : base(machine)
        {
            if (dmaPeripheral == null)
            {
                if (dmaChannel != 0)
                {
                    throw new ConstructionException($"Unspecified DMA peripheral to use with channel number {dmaChannel}");
                }
            }
            else
            {
                if (dmaChannel <= 0 || dmaChannel > dmaPeripheral.NumberOfChannels)
                {
                    throw new ConstructionException($"Invalid 'dmaChannel' argument value: '{dmaChannel}'. Available channels: 1-{dma.NumberOfChannels}");
                }
            }

            DefineRegisters();

            IRQ                         = new GPIO();
            this.dmaChannel             = dmaChannel;
            this.dma                    = dmaPeripheral;
            this.referenceVoltage       = referenceVoltage;
            this.externalEventFrequency = externalEventFrequency;

            samplingThread  = machine.ObtainManagedThread(StartSampling, externalEventFrequency);
            channelSelected = new bool[ChannelsCount];
            sampleProvider  = new SensorSamplesFifo <ScalarSample> [ChannelsCount];
            for (var channel = 0; channel < ChannelsCount; channel++)
            {
                sampleProvider[channel] = new SensorSamplesFifo <ScalarSample>();
            }
            Reset();
        }
Exemplo n.º 2
0
        public IMXRT_ADC(Machine machine) : base(machine)
        {
            samplesFifos = new SensorSamplesFifo <ScalarSample> [NumberOfChannels];
            for (var i = 0; i < samplesFifos.Length; i++)
            {
                samplesFifos[i] = new SensorSamplesFifo <ScalarSample>();
            }

            conversionCompleteInterruptEnable = new IFlagRegisterField[NumberOfHardwareTriggers];
            inputChannel = new IValueRegisterField[NumberOfHardwareTriggers];
            cdata        = new IValueRegisterField[NumberOfHardwareTriggers];

            IRQ = new GPIO();
            DefineRegisters();
        }