상속: IDisposable
예제 #1
0
 public HttpWiflyImpl(HttpImplementationClient.RequestReceivedDelegate requestReceived, int localPort, DeviceType deviceType, SPI.SPI_module spiModule, Cpu.Pin chipSelect)
 {
     m_requestReceived = requestReceived;
     LocalPort = localPort;
     this.m_spiModule = spiModule;
     this.m_chipSelect = chipSelect;
 }
예제 #2
0
        public CpuProgrammer()
        {
            if (Instance != null)
            {
                throw new InvalidOperationException();
            }

            Instance = this;

            //_spiConfig = new SPI.Configuration(
            //    SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D10,
            //    false,
            //    0,
            //    0,
            //    false,
            //    true,
            //    5000,
            //    SPI_Devices.SPI1);

            _spiConfig = new SPI.Configuration(
                SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D10,
                false,
                20,
                20,
                false,
                true,
                2000,
                SPI_Devices.SPI1);

            _spi = new SPI(_spiConfig);
        }
예제 #3
0
 public OLED_sh1106(Cpu.Pin csPin, OutputPort dcPin, OutputPort rsPin)
 {
     displayStr = "";
     spiDevice = new SPI(new SPI.Configuration(csPin, false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));
     dataCommandPin = dcPin;
     resetOutputPort = rsPin;
 }
예제 #4
0
 public OLED_sh1106(ref SPI globalSPIDevice, OutputPort dcPin, OutputPort rsPin)
 {
     displayStr = "";
     spiDevice = globalSPIDevice;
     dataCommandPin = dcPin;
     resetOutputPort = rsPin;
 }
예제 #5
0
 public AudioShield(SPI.SPI_module module, Cpu.Pin dataSelectPin, Cpu.Pin cmdSelectPin, Cpu.Pin dreqPin)
 {
     dataConfig = new SPI.Configuration(dataSelectPin, false, 0, 0, false, true, 2000, module, dreqPin, false);
     cmdConfig = new SPI.Configuration(cmdSelectPin, false, 0, 0, false, true, 2000, module, dreqPin, false);
     dreq = new InputPort(dreqPin, false, Port.ResistorMode.PullUp);
     spi = new SPI(cmdConfig);
 }
예제 #6
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();
        }
예제 #7
0
        public DriverChip(Microsoft.SPOT.Hardware.SPI spi, byte address)
        {
            this.spi = spi;
            this.address = address;

            init();
        }
예제 #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="csPin">CS pin for SPI interface</param>
 /// <param name="spiModule">SPI module</param>
 public LIS302DL(Cpu.Pin csPin, SPI.SPI_module spiModule)
 {
     //The 302DL is a mode 3 device
     var spiConfig = new SPI.Configuration(csPin, false, 0, 0, true, true, 10000, spiModule);
     _spi = new SPI(spiConfig);
     Init();
 }
예제 #9
0
        public static void Main()
        {
            SPI.Configuration spiConfig = new SPI.Configuration(
                ShieldConfiguration.CurrentConfiguration.SpiChipSelectPin,
                false,
                100,
                100,
                false,
                true,
                1000,
                ShieldConfiguration.CurrentConfiguration.SpiModule
            );
            var spi = new SPI(spiConfig);
            var statusBuffer = new byte[2];

            // Watch the LEDs on UberShield. If they are showing the bootloader
            // flashing pattern, there's no SPI connectivity. If the lights
            // alternate off / red / green / redgreen then you're quad-winning.
            // If they're off, you're not in bootloader mode.

            while (true)
            {
                statusBuffer[0] = 0x01;
                for (byte counter = 0; counter <= 3; ++counter)
                {
                    statusBuffer[1] = (byte)((counter << 2) | 0x03);
                    spi.Write(statusBuffer);
                    Thread.Sleep(500);
                }
            }
        }
예제 #10
0
 public static void Main()
 {
     SPI.Configuration spiConfig = new SPI.Configuration(
         Pins.GPIO_PIN_D0,
         false,
         100,
         100,
         false,
         true,
         1000,
         SPI.SPI_module.SPI1
     );
     var spi = new SPI(spiConfig);
     var TxBuffer = new byte[6];
     var RxBuffer = new byte[6];
     PWMStop(spi);
     int i = 0;
     for (i = 0; i < 32; i++)
     {
         SetPWM(spi, (byte)i, i, i + 1, 80);
     }
     //            SetPWM(spi, 0, 1, 9, 13);
     SetTerminate(spi, 0);
     PWMStart(spi);
     GreenLEDOn(spi);
 }
예제 #11
0
 public static void Main()
 {
     
     SerialPort UART = new SerialPort("COM1", 9600);
     SPI.Configuration config = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10, false, 0, 0, true, true, 250, SPI.SPI_module.SPI1);
     SPI Spi = new SPI(config);
     UART.Open();
     string Datoreaded = "";
     byte[] datain = new byte[1];
     byte[] dataout = new byte[1];
     while (true)
     {
         // Sleep for 500 milliseconds
         Thread.Sleep(500);
         
         dataout[0] = (byte)0x55;
         datain[0] = (byte)0;
         Spi.WriteRead(dataout, datain);
         Datoreaded = datain[0].ToString();
         Datoreaded += "\n\r";
         byte[] buffer = Encoding.UTF8.GetBytes(Datoreaded);
         UART.Write(buffer, 0, buffer.Length);
         
     }
 }
예제 #12
0
        public AdaFruitLPD8806(int width, int height, Cpu.Pin chipSelect, SPI.SPI_module spiModule = SPI.SPI_module.SPI1, uint speedKHz = 10000)
        {
            Width = width;
            Height = height;
            PixelCount = Width * Height;
            PixelBufferEnd = (PixelCount - 1) * BytesPerPixel;
            FrameSize = Width * Height * BytesPerPixel;

            var spiConfig = new SPI.Configuration(
                SPI_mod: spiModule,
                ChipSelect_Port: chipSelect,
                ChipSelect_ActiveState: false,
                ChipSelect_SetupTime: 0,
                ChipSelect_HoldTime: 0,
                Clock_IdleState: false,
                Clock_Edge: true,
                Clock_RateKHz: speedKHz
                );

            spi = new SPI(spiConfig);

            pixelBuffer = new byte[PixelCount * BytesPerPixel];

            SetBackgroundColor(0,0,0);
        }
예제 #13
0
        public static void Initialize()
        {
            if (isInitialized)
                Shutdown();

            spi = new SPI(cmdConfig);
            reset = new OutputPort(Pins.GPIO_PIN_D13, true); // Unused pin.
            DREQ = new InputPort(Pins.GPIO_PIN_D3, false, Port.ResistorMode.PullUp);

            isInitialized = true;

            Reset();

            Command_Write(SCI_MODE, 0x800 | (1 << 2));
            Command_Write(SCI_CLOCKF, 7 << 13);
            Command_Write(SCI_VOL, 1);  // highest volume

            Debug.Print(Command_Read(SCI_VOL).ToString()); //  <------------ always returns 0

            if (Command_Read(SCI_VOL) != (0))
            {
                throw new Exception("Failed to initialize VS1053 encoder.");
            }

            spi.Config = dataConfig;
        }
예제 #14
0
        public static void Main()
        {
            int numLed = 32;
            var spi = new SPI(
                new SPI.Configuration(
                    Cpu.Pin.GPIO_NONE,
                    false,
                    0,
                    0,
                    false,
                    true,
                    2000,
                    SPI.SPI_module.SPI1));
            var colors = new byte[3 * numLed];
            var zeros = new byte[3 * ((numLed + 63) / 64)];

            while (true)
            {
                // all pixels off
                for (int i = 0; i < colors.Length; ++i) colors[i] = (byte)(0x80 | 0);
                // a progressive yellow/red blend
                for (byte i = 0; i < 32; ++i)
                {
                    colors[i * 3 + 1] = 0x80 | 32;
                    colors[i * 3 + 0] = (byte)(0x80 | (32 - i));
                    spi.Write(colors);
                    spi.Write(zeros);
                    Thread.Sleep(1000 / 32); // march at 32 pixels per second

                }
            }
        }
예제 #15
0
 public static void Main()
 {
     SPI.Configuration spiConfig = new SPI.Configuration(
         Pins.GPIO_PIN_D2,
         false,
         100,
         100,
         false,
         true,
         1000,
         SPI.SPI_module.SPI1
     );
     spi = new SPI(spiConfig);
     GP = new GpioPwm(spi);
     GP.PwmStop();
     byte channel;
     for (channel = 0; channel < 32; channel++)
     {
         GP.SetPwmParameter(channel, GpioPwm.PwmParameter.Rise, 0);
         GP.SetPwmParameter(channel, GpioPwm.PwmParameter.Fall, 0);
         GP.SetPwmParameter(channel, GpioPwm.PwmParameter.Period, 10000);
         GP.SetPinType(channel, GpioPwm.PinType.Input);
     }
     for (channel = 32; channel < 64; channel++)
     {
         GP.SetPinType(channel, GpioPwm.PinType.Input);
     }
     GP.SetGroupPin(GpioPwm.PinGroup.Lower, 0);
     GP.SetGroupPin(GpioPwm.PinGroup.Upper, 0);
     GP.PwmGo();
     pwmRunning = true;
     new Program();
 }
예제 #16
0
 public GpioPwm(SPI spiInt)
 {
     Spi = spiInt;
     if (!IsGpioPwmCore())
     {
         throw(new SystemException("Tried to instantiate a GpioPwm class, but no GPIO/PWM core running on UberShield."));
     }
 }
예제 #17
0
    public static void Mount(string path, SPI.SPI_module spi, Cpu.Pin chipSelect, Cpu.Pin cardDetect)
    {
        if (_sdCardPath != null)
            throw new NotSupportedException();

        MountNative(path, (uint) spi, (uint) chipSelect, (uint) cardDetect);
        _sdCardPath = path;
    }
        /// <summary>
        /// Create a new instance of the RGBStrip.
        /// </summary>
        /// <param name="ledCount">Number of pixels (leds) in the strip.</param>
        /// <param name="spi">The spi object to use</param>
        public RGBStrip(int ledCount, SPI spi)
        {
            _spi = spi;
            DimFactor = 1;

            CreateBuffers(ledCount);
            SetupDimValueSwitch();
        }
예제 #19
0
        public LEDStripSpi()
        {
            NumOfLEDs = 32;

            _data = new SPI(new SPI.Configuration(Pins.GPIO_NONE, false, 0, 0, false, true, 100, SPI.SPI_module.SPI1));

            post_frame();
        }
예제 #20
0
                /** ctor */
                public DisplayModule(PortDefinition port, OrientationType orientation)
                {
                    if (CTRE.Util.Contains(port.types, kModulePortType))
                    {
                        status = StatusCodes.OK;
                        _port  = port;

                        Port8Definition portDef = (Port8Definition)port;

                        if (portDef.Pin3 != Cpu.Pin.GPIO_NONE)
                        {
                            _outReset = new OutputPort(portDef.Pin3, false);
                        }

                        if (portDef.Pin4 != Cpu.Pin.GPIO_NONE)
                        {
                            _outBackLght = new OutputPort(portDef.Pin4, true);
                        }

                        _outRs = new OutputPort(portDef.Pin5, false);

                        /* alloc the working arrays */
                        _cache_1B     = new byte[1];
                        _cache_2W     = new ushort[2];
                        _cache_manyBs = new byte[1024];
                        _cache_manyWs = new ushort[1024];

                        SPI.Configuration spiConfiguration = new SPI.Configuration(portDef.Pin6, false, 0, 0, false, true, 12000, SPI.SPI_module.SPI4);
                        _spi = new Microsoft.SPOT.Hardware.SPI(spiConfiguration);

                        /* reset pulse if pin is available */
                        if (_outReset != null)
                        {
                            _outReset.Write(false);
                            Thread.Sleep(150);
                            _outReset.Write(true);
                        }
                        /* setup registers */
                        ConfigureDisplay();

                        /* fixup orientation */
                        _orientation = orientation;
                        ApplytOrientation();

                        /* empty screen */
                        ClearScreen();

                        /* start rendering thread */
                        var th = new Thread(RenderThread);
                        th.Priority = ThreadPriority.Lowest;
                        th.Start();
                    }
                    else
                    {
                        status = StatusCodes.PORT_MODULE_TYPE_MISMATCH;
                        Reporting.SetError(status);
                    }
                }
예제 #21
0
        public FL164KIF01(SPI spi)
        {
            _spi = spi;

            data1 = new byte[1];
            data2 = new byte[2];
            data4 = new byte[4];
            dataPage = new byte[PageSize + 4];
        }
예제 #22
0
        public Lm15Sgfnz07(SPI.SPI_module spi, Cpu.Pin cs, Cpu.Pin reset, Cpu.Pin rs)
        {
            var spiCfg = new SPI.Configuration(cs, false, 0, 0, true, true, 5000, spi);
            _spi = new SPI(spiCfg);
            _reset = new OutputPort(reset, true);
            _rs = new OutputPort(rs, false);

            Initialize();
        }
예제 #23
0
        void TestSPI()
        {
            SPI spi = new SPI(new SPI.Configuration((Cpu.Pin)28, false, 0, 0, false, false, 1, SPI.SPI_module.SPI1));
            byte[] write = new byte[] { 0, 0, 0 };
            byte[] read = new byte[] { 0, 0, 0 };

            spi.WriteRead(write, read, 2);
            spi.WriteRead(write, read, 2);
        }
예제 #24
0
        public void WriteInternal(SPI spi)
        {
            var data = GetData();
            if(data == null)
                return;

            spi.Config = Configuration;
            spi.Write(data);
        }
        //Good

        //Enables Write Status Register
        private void EWSR()
        {
            byte[] Temp = new byte[1];
            Temp[0] = (byte)OpCode.EWSR_EnableWriteStatReg;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            Delay();
        }
        //Good

        //Disables the Write Enable latch
        private void WRDI()
        {
            byte[] Temp = new byte[1];
            Temp[0] = (byte)OpCode.WRDI_WriteDisable;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            Delay();
        }
        /// <summary>
        /// Create a new instance of the RGBStrip.
        /// </summary>
        /// <param name="ledCount">Number of pixels (leds) in the strip.</param>
        public RGBStrip(int ledCount)
        {
            DimFactor = 1;

            _spi = new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE,
                false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));

            CreateBuffers(ledCount);
            SetupDimValueSwitch();
        }
        //Read the status register and returns the byte
        private byte ReadStatusRegister()
        {
            byte[] Temp   = new byte[1];
            byte[] TempIn = new byte[1];
            Temp[0] = (byte)OpCode.RDSR_ReadStatusReg;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.WriteRead(Temp, 0, 1, TempIn, 0, 1, 1);
            return(TempIn[0]);
        }
        //Good

        //Writes a byte to the status register
        private void WRSR(byte StatusIn)
        {
            byte[] Temp = new byte[2];
            Temp[0] = (byte)OpCode.WRSR_WriteStatusReg;
            Temp[1] = StatusIn;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            Delay();
        }
예제 #30
0
        public static void Main()
        {
            SPI.Configuration[] max6675SpiCfg;
            // variables that will be used to extract the information from
            // the incoming serial bits from the MAX6675 chip
            byte[] outBfr = new byte[2];
            byte[] inBfr = new byte[2];

            // data will be used to store the extracted information
            short data;
            double tempF;
            double tempC;
            double tempK;
            int count = 0;

            max6675SpiCfg = new SPI.Configuration[1];

            max6675SpiCfg[0] = new SPI.Configuration(
                Pins.GPIO_PIN_D8,       //  CS to digtalOut pin 9
                false,                  //  CS pin active state
                0,                      //  CS port set up time
                0,                      //  CS port hold time
                false,                  //  Idle state of clock
                true,                   //  Signal edge to sample on
                1000,                   //  Clock speed in KHz
                SPI_Devices.SPI1        //  Using SPI bus 1
                );

            // Creating a new instance of SPI object
            max6675Spi = new SPI (max6675SpiCfg[0]);

            //Reading from MAX6675 board and displaying data
            while(true)
            {
                max6675Spi.Config = max6675SpiCfg[0];
                max6675Spi.WriteRead(outBfr, inBfr);

                data = (short) (inBfr[0] << 5 | inBfr[1] >> 3);

                tempC = data / 4.0;
                tempK = tempC + 273.15;
                tempF = tempC * 1.8 + 32.0;

                // using debug to output the information to the computer screen
                Debug.Print(" Reading:" + count.ToString("F"));
                Debug.Print(" Temp F:" + tempF.ToString("F"));
                Debug.Print(" Temp C:" + tempC.ToString("F"));
                Debug.Print(" ");

                Thread.Sleep(500);

                count++;
            }
        }
예제 #31
0
        public void Initialize()
        {
            var spiConfig = new SPI.Configuration(_chipSelect, false, 0, 0, false, true, 12000, _spiModule);
            var spi = new SPI(spiConfig);

            // Instantiate the block driver
            var driver = new FL164KIF01BlockDriver(spi, Oxygen.Hardware.UserLed, 4);

            // Instantiate the file system passing the block driver for the underlying storage medium
            _tfs = new TinyFileSystem(driver);
        }
예제 #32
0
        public SpiFloorIndicator(SPI.SPI_module module, FEZ_Pin.Digital latchPin)
        {
            var config = new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 200, module);
            spi = new SPI(config);

            latch = new OutputPort((Cpu.Pin) latchPin, true);

            CurrentFloor = 1;

            timer = new ExtendedTimer(UpdateIndicator, null, DateTime.Now,
                TimeSpan.FromTicks(25 * TimeSpan.TicksPerMillisecond));
        }
예제 #33
0
        public Rail()
        {
            spi = new SPI(new SPI.Configuration(Pins.GPIO_PIN_D10, false, 200, 400, false, true, 100, SPI_Devices.SPI1));
            // write HAEN
            spi.Write(new byte[] { 0x40, 0x0A, 0x28 });

            driver = new Driver(spi, 0x42);
            driver2 = new Driver(spi, 0x48);
            driver3 = new Driver(spi, 0x40);
            driver4 = new Driver(spi, 0x4A);
            driver5 = new Driver(spi, 0x46);
        }
예제 #34
0
        /// <summary>
        /// Initializes a new SPI device
        /// </summary>
        /// <param name="config">The SPI-module configuration</param>
        public SPIExtension(SPI.Configuration config, bool useSoftwareChipSelect = false)
        {
            // The timing of the Netduino pin 4, Netduino Plus pin 4 and Netduino Mini pin 13 have a small bug, probably in the IC or NETMF itself.
            //
            // They all refer to the same pin ID on the AT91SAM7X512: (int)12
            // - SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D4
            // - SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D4
            // - SecretLabs.NETMF.Hardware.NetduinoMini.Pins.GPIO_PIN_13
            //
            // To work around this problem we use a software chip select. A bit slower, but it works.
            // We will include this work-around until the actual bug is fixed.
            bool SoftwareChipSelect = false;
            //if ((int)config.ChipSelect_Port == 12 && (
            //    Tools.HardwareProvider == "Netduino" || Tools.HardwareProvider == "NetduinoMini" || Tools.HardwareProvider == "NetduinoPlus"
            //))
            //{
            //    Debug.Print("MultiSPI: Software ChipSelect enabled to prevent timing issues");
            //    Debug.Print("MultiSPI: See http://netduino.codeplex.com/workitem/3 for more");
            //    SoftwareChipSelect = true;
            //}

            // Sets the configuration in a local value
            this.spiConfiguration = config;

            // When we use a software chipset we need to record some more details
            if (SoftwareChipSelect)
            {
                this.softwareCS = new OutputPort(config.ChipSelect_Port, !config.ChipSelect_ActiveState);
                this.softwareCS_ActiveState = config.ChipSelect_ActiveState;
                this.useSoftwareCS = true;
                // Copies the Configuration, but without Chip Select pin
                this.spiConfiguration = new SPI.Configuration(
                    Cpu.Pin.GPIO_NONE,
                    spiConfiguration.BusyPin_ActiveState,
                    spiConfiguration.ChipSelect_SetupTime,
                    spiConfiguration.ChipSelect_HoldTime,
                    spiConfiguration.Clock_IdleState,
                    spiConfiguration.Clock_Edge,
                    spiConfiguration.Clock_RateKHz,
                    spiConfiguration.SPI_mod,
                    spiConfiguration.BusyPin,
                    spiConfiguration.BusyPin_ActiveState
                );
            }

            // If no SPI Device exists yet, we create it's first instance
            if (spiDevice == null)
            {
                // Creates the SPI Device
                spiDevice = new SPI(this.spiConfiguration);
            }
        }
        private void Auto_Add_IncB(byte Data1, byte Data2)
        {
            WREN_AAI_Check();
            byte[] Temp = new byte[3];
            Temp[0] = (byte)OpCode.AAIWordProgram;
            Temp[1] = Data1;
            Temp[2] = Data2;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            Delay();
        }
 /// <summary>
 /// Code for using a 74HC595 Shift Register
 /// </summary>
 /// <param name="latchPin">Pin connected to register latch on the 74HC595</param>
 /// <param name="spiModule">SPI module being used to send data to the shift register</param>
 public ShiftRegister74HC595(Cpu.Pin latchPin, SPI.SPI_module spiModule, uint speedKHz = 1000) {
     var spiConfig = new SPI.Configuration(
         SPI_mod: spiModule,
         ChipSelect_Port: latchPin,
         ChipSelect_ActiveState: false,
         ChipSelect_SetupTime: 0,
         ChipSelect_HoldTime: 0,
         Clock_IdleState: false,
         Clock_Edge: true,
         Clock_RateKHz: speedKHz
         );
     Spi = new SPI(spiConfig);
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // dispose managed resources
         if (_spi != null)
         {
             _spi.Dispose();
             _spi = null;
         }
     }
     // free native resources
 }
        //Sector Erases the chip
        private void Sector_Erase(ulong Address)
        {
            byte[] Temp = new byte[4];
            Wait_Busy();
            WREN();
            Temp[0] = (byte)OpCode._4KBErase;
            Temp[1] = (byte)((Address & 0xFFFFFF) >> 16);
            Temp[2] = (byte)((Address & 0xFFFF) >> 8);
            Temp[3] = (byte)(Address & 0xFF);

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            DelayErase();
        }
        //Read multiple address and store data into byte buffer;
        public void ReadMultiple(ulong Address, int Numb_of_Bytes, byte[] DestBuffer)
        {
            byte[] Temp = new byte[4];
            Wait_Busy();
            byte Byte1 = (byte)((Address & 0xFFFFFF) >> 16);
            byte Byte2 = (byte)((Address & 0xFFFF) >> 8);
            byte Byte3 = (byte)(Address & 0xFF);

            Temp[0] = (byte)OpCode.Read;
            Temp[1] = Byte1;
            Temp[2] = Byte2;
            Temp[3] = Byte3;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.WriteRead(Temp, 0, 4, DestBuffer, 0, Numb_of_Bytes, 4);
        }
        //Good

        public uint ReadJedecID()
        {
            byte[] outBytes = new byte[4] {
                (byte)OpCode.JEDECID, 0x00, 0x00, 0x00
            };
            byte[] inBytes = new byte[4];

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.WriteRead(outBytes, inBytes);

            uint retval = inBytes[1];

            retval <<= 8;
            retval  |= inBytes[2];
            retval <<= 8;
            retval  |= inBytes[3];
            return(retval);
        }
        //Good


        //=======================================================================//

        private void Auto_Add_IncA(ulong Address, byte Data1, byte Data2)
        {
            byte[] Temp  = new byte[6];
            byte   Byte1 = (byte)((Address & 0xFFFFFF) >> 16);
            byte   Byte2 = (byte)((Address & 0xFFFF) >> 8);
            byte   Byte3 = (byte)(Address & 0xFF);

            Wait_Busy();
            WREN();
            Temp[0] = (byte)OpCode.AAIWordProgram;
            Temp[1] = Byte1;
            Temp[2] = Byte2;
            Temp[3] = Byte3;
            Temp[4] = Data1;
            Temp[5] = Data2;

            Microsoft.SPOT.Hardware.SPI _SPIDevice = Hardware.SPI1.Get(_Configuration);

            _SPIDevice.Write(Temp);
            Delay();
        }
        static void Main(string[] args)
        {
            SPI           SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1));
            OutputPort    nCE     = new OutputPort(Cpu.Pin.GPIO_Pin2, true);
            InterruptPort nINT    = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

            NRF24L01Plus n = new NRF24L01Plus();

            n.Initialize(SPIport, nCE, nINT);

            byte[] address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("First Address: " + ByteArrayToHexString(address));

            byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 };
            n.SetAddress(AddressSlot.Zero, b, false);

            address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("Second Address: " + ByteArrayToHexString(address));

            nCE.Dispose();
            nINT.Dispose();
        }