Пример #1
0
        void Initialize(GoSocket socket)
        {
            // now try to bind to the socket (and verify our module's uniqueId)
            if (!base.BindSocket(socket, _moduleGuid))
            {
                throw new ArgumentException();
            }

            // get socket's physical pins and SPI bus
            Cpu.Pin        socketGpioPin;
            SPI.SPI_module socketSpiModule;
            Cpu.Pin        socketSpiSlaveSelectPin;
            //
            socket.GetPhysicalResources(out socketGpioPin, out socketSpiModule, out socketSpiSlaveSelectPin);

            _spiConfig = new SPI.Configuration(socketSpiSlaveSelectPin, false, 0, 0, false, false, 500, socketSpiModule);
            _spi       = new SPI(_spiConfig);

            // wire up event handlers
            _interruptPort              = new InterruptPort((Cpu.Pin)socketGpioPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            _interruptPort.OnInterrupt += _interruptPort_OnInterrupt;

            // read initial button state
            _isPressed = !_interruptPort.Read();
        }
Пример #2
0
 public void Initialize(GoSocket socket, string mountPoint = "SD")
 {
     _mountPoint = mountPoint;
     SPI.SPI_module sdCardSpi;
     Cpu.Pin        sdCardChipSelect;
     Cpu.Pin        sdCardGPIO;
     socket.GetPhysicalResources(out sdCardGPIO, out sdCardSpi, out sdCardChipSelect);
     if (!BindSocket(socket))
     {
         throw new ApplicationException("socket already bound");
     }
     SetSocketPowerState(true);
     StorageDevice.MountSD(_mountPoint, sdCardSpi, sdCardChipSelect);
 }
Пример #3
0
        public void Initialize(GoSocket socket, uint speedKHz = 25000)
        {
            if (speedKHz < 5000 || speedKHz > 40000)
            {
                throw new ArgumentException("speedKHz");
            }
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            SPI.SPI_module displaySpi;
            Cpu.Pin        displayChipSelect;
            Cpu.Pin        displayGPIO;
            socket.GetPhysicalResources(out displayGPIO, out displaySpi, out displayChipSelect);
            if (!BindSocket(socket))
            {
                throw new InvalidOperationException("socket already bound");
            }

            SetSocketPowerState(false);
            Thread.Sleep(2000);
            SetSocketPowerState(true);
            Thread.Sleep(250);

            Spi = new SPI(new SPI.Configuration(
                              SPI_mod: displaySpi,
                              ChipSelect_Port: displayChipSelect,
                              ChipSelect_ActiveState: false,
                              ChipSelect_SetupTime: 0,
                              ChipSelect_HoldTime: 0,
                              Clock_IdleState: false,
                              Clock_Edge: false,
                              Clock_RateKHz: speedKHz));

            GoBusIrqPort              = new InterruptPort(displayGPIO, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
            GoBusIrqPort.OnInterrupt += OnGoBusIrq;

            WaitUntilModuleIsInitialized();
        }