当前位置: 首页>>代码示例>>C#>>正文


C# SPI.Write方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Hardware.SPI.Write方法的典型用法代码示例。如果您正苦于以下问题:C# SPI.Write方法的具体用法?C# SPI.Write怎么用?C# SPI.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Hardware.SPI的用法示例。


在下文中一共展示了SPI.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        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

                }
            }
        }
开发者ID:bdk1417,项目名称:ledStripTest,代码行数:32,代码来源:Program.cs

示例2: Main

        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);
                }
            }
        }
开发者ID:wramsdell,项目名称:FPGA-Loader,代码行数:31,代码来源:Program.cs

示例3: WriteInternal

        public void WriteInternal(SPI spi)
        {
            var data = GetData();
            if(data == null)
                return;

            spi.Config = Configuration;
            spi.Write(data);
        }
开发者ID:ungood,项目名称:hellevator,代码行数:9,代码来源:SpiWriter.cs

示例4: Rail

        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);
        }
开发者ID:galgalesh,项目名称:Splitflaps,代码行数:12,代码来源:Rail.cs

示例5: ADXL345

        public ADXL345(Cpu.Pin pinCS, uint Freq)
        {
            spiConfig = new SPI.Configuration(
                pinCS,
                false,             // SS-pin active state
                10,                 // The setup time for the SS port
                10,                 // The hold time for the SS port
                true,              // The idle state of the clock
                true,             // The sampling clock edge
                Freq,              // The SPI clock rate in KHz
                SPI_Devices.SPI1   // The used SPI bus (refers to a MOSI MISO and SCLK pinset)
            );

            spiBus = new SPI(spiConfig);
            spiBus.Write(new byte[] { DATA_FORMAT, 0x00 });
            spiBus.Write(new byte[] { POWER_CTL, 0x08 });

            setOffsets(0, 0, 0);

            valueLocations = new byte[6] { DATAX0 | 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00 };
            values = new byte[6];
        }
开发者ID:RiekertLeibbrandt,项目名称:marencoLibraries,代码行数:22,代码来源:ADXL345.cs

示例6: InitCAN

        public bool InitCAN(enBaudRate baudrate, UInt16 filter0, UInt16 filter1, UInt16 mask)
        {
            // Configure SPI
            var configSPI = new SPI.Configuration(Pins.GPIO_PIN_D2, LOW, 0, 0, HIGH, HIGH, 10000, SPI.SPI_module.SPI1);  //a0 D10

            spi = new SPI(configSPI);

            // Write reset to the CAN transceiver.
            spi.Write(new byte[] { RESET });
            //Read mode and make sure it is config

            Thread.Sleep(100);
             {

                 SetMask(mask, filter0, false);
                 SetMask(mask, filter1, true);
                 SetCANBaud(baudrate);
                return true;
            }
        }
开发者ID:RiekertLeibbrandt,项目名称:marencoLibraries,代码行数:20,代码来源:MCP2515.cs

示例7: SetTerminate

 public static void SetTerminate(SPI spi, uint Data)
 {
     byte[] WriteBuffer = new byte[6];
     WriteBuffer[0] = 0x06; //Operand
     WriteBuffer[1] = 0x00; //Operand
     WriteBuffer[2] = (byte)(Data >> 24 & 0xFF);
     WriteBuffer[3] = (byte)(Data >> 16 & 0xFF);
     WriteBuffer[4] = (byte)(Data >> 8 & 0xFF);
     WriteBuffer[5] = (byte)(Data & 0xFF);
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:11,代码来源:Program.cs

示例8: SetRedLED

 public static void SetRedLED(SPI spi, bool state)
 {
     byte[] WriteBuffer = new byte[2];
     WriteBuffer[0] = 0x03; //Command
     WriteBuffer[1] = state?(byte)0x01:(byte)0x00; //Operand
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:7,代码来源:Program.cs

示例9: SetPinType

 public static void SetPinType(SPI spi, byte pin, PinType type)
 {
     byte[] WriteBuffer = new byte[2];
     switch (type)
     {
         case PinType.PinInput:
             WriteBuffer[0] = 0x08;
             break;
         case PinType.PinOutput:
             WriteBuffer[0] = 0x09;
             break;
         case PinType.PinPwm:
             WriteBuffer[0] = 0x0A;
             break;
         case PinType.PinInvertedPwm:
             WriteBuffer[0] = 0x0B;
             break;
         default:
             WriteBuffer[0] = 0x55;
             break;
     }
     WriteBuffer[1] = pin; //Operand
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:24,代码来源:Program.cs

示例10: SetPinState

 public static void SetPinState(SPI spi, byte pin, bool state)
 {
     byte[] WriteBuffer = new byte[6];
     if (pin < 32)
     {
         if (state)
         {
             WriteBuffer[0] = 0x0D;
         }
         else
         {
             WriteBuffer[0] = 0x0F;
         }
     }
     else
     {
         if (state)
         {
             WriteBuffer[0] = 0x0E;
         }
         else
         {
             WriteBuffer[0] = 0x10;
         }
     }
     WriteBuffer[1] = 0x00; //Operand
     int Data = 0x01 << pin;
     WriteBuffer[2] = (byte)(Data >> 24 & 0xFF);
     WriteBuffer[3] = (byte)(Data >> 16 & 0xFF);
     WriteBuffer[4] = (byte)(Data >> 8 & 0xFF);
     WriteBuffer[5] = (byte)(Data & 0xFF);
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:33,代码来源:Program.cs

示例11: SetMemory

 public static void SetMemory(SPI spi, byte address, uint Data)
 {
     byte[] WriteBuffer = new byte[6];
     WriteBuffer[0] = 0x01; //Operand
     WriteBuffer[1] = address; //Operand
     WriteBuffer[2] = (byte)(Data >> 24 & 0xFF);
     WriteBuffer[3] = (byte)(Data >> 16 & 0xFF);
     WriteBuffer[4] = (byte)(Data >> 8 & 0xFF);
     WriteBuffer[5] = (byte)(Data & 0xFF);
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:11,代码来源:Program.cs

示例12: PwmStop

 public static void PwmStop(SPI spi)
 {
     byte[] WriteBuffer = new byte[2];
     WriteBuffer[0] = 0x05; //Command
     WriteBuffer[1] = 0x00; //Operand
     spi.Write(WriteBuffer);
 }
开发者ID:wramsdell,项目名称:Netduino_Example,代码行数:7,代码来源:Program.cs

示例13: Start

        public void Start()
        {
            string decPcomp_out;
            sbyte sia0MSB, sia0LSB;
            sbyte sib1MSB, sib1LSB;
            sbyte sib2MSB, sib2LSB;
            sbyte sic12MSB, sic12LSB;
            sbyte sic11MSB, sic11LSB;
            sbyte sic22MSB, sic22LSB;
            int sia0, sib1, sib2, sic12, sic11, sic22;
            uint uiPadc, uiTadc;
            byte uiPH, uiPL, uiTH, uiTL;
            long lt1, lt2, lt3, si_c11x1, si_a11, si_c12x2;
            long si_a1, si_c22x2, si_a2, si_a1x1, si_y1, si_a2x2;
            float siPcomp, decPcomp;

            // start pressure & temp conversions
            // command byte + r/w bit
            const byte com1_writeData = 0x24;
            const byte com2_writeData = 0x00;
            byte[] WriteBuffer = { com1_writeData, com2_writeData };
            spi = new SPI(Configuration);
            spi.Write(WriteBuffer);
            Thread.Sleep(3);
        }
开发者ID:zgramana,项目名称:WeatherStation,代码行数:25,代码来源:MPL1151A.cs

示例14: calculatePressure

        /// <summary>
        /// 
        /// SPI interface for the MPL115A barometric sensor.
        /// Created by deepnarc, deepnarc at gmail.com
        /// 
        /// Netduino platform
        /// 
        /// Sensor Breakout---------Netduino
        /// ================================
        /// SDN---------------------optional
        /// CSN---------------------pin 0 (user definable)
        /// SDO---------------------pin 12
        /// SDI---------------------pin 11
        /// SCK---------------------pin 13
        /// GND---------------------GND
        /// VDO---------------------VCC (3.3V)
        /// 
        /// References: (1) Freescale Semiconductor, Application Note, AN3785, Rev 5, 7/2009 by John Young
        /// provided the code for the manipulations of the sensor coefficients; the original comments 
        /// were left in place without modification in that section. (2) Freescale Semiconductor, Document 
        /// Number: MPL115A1, Rev 6, 10/2011. (3) MPL115A1 SPI Digital Barometer Test Code Created on: 
        /// September 30, 2010 By: Jeremiah McConnell - miah at miah.com, Portions: Jim Lindblom - jim at 
        /// sparkfun.com. (4) MPL115A1 SPI Digital Barometer Test Code Created on: April 20, 2010 By: Jim 
        /// Lindblom - jim at sparkfun.com.
        /// 
        /// </summary>
        public static double calculatePressure()
        {
            SPI SPI_Out = new SPI(new SPI.Configuration(
                (Cpu.Pin)FEZ_Pin.Digital.Di7,    // SS-pin
                false,               // SS-pin active state
                0,                   // The setup time for the SS port
                0,                   // The hold time for the SS port
                false,               // The idle state of the clock
                true,                // The sampling clock edge
                1000,                // The SPI clock rate in KHz
                SPI.SPI_module.SPI1  // The used SPI bus (refers to a MOSI MISO and SCLK pinset)
                )
            );

            string decPcomp_out;
            sbyte sia0MSB, sia0LSB;
            sbyte sib1MSB, sib1LSB;
            sbyte sib2MSB, sib2LSB;
            sbyte sic12MSB, sic12LSB;
            sbyte sic11MSB, sic11LSB;
            sbyte sic22MSB, sic22LSB;
            int sia0, sib1, sib2, sic12, sic11, sic22;
            uint uiPadc, uiTadc;
            byte uiPH, uiPL, uiTH, uiTL;
            long lt1, lt2, lt3, si_c11x1, si_a11, si_c12x2;
            long si_a1, si_c22x2, si_a2, si_a1x1, si_y1, si_a2x2;
            float siPcomp;//, decPcomp;

            // start pressure & temp conversions
            // command byte + r/w bit
            const byte com1_writeData = 0x24 & 0x7F;
            const byte com2_writeData = 0x00 & 0x7F;
            byte[] WriteBuffer = { com1_writeData, com2_writeData };
            SPI_Out.Write(WriteBuffer);
            Thread.Sleep(3);

            // write(0x24, 0x00);	// Start Both Conversions
            // write(0x20, 0x00);	// Start Pressure Conversion
            // write(0x22, 0x00);	// Start temperature conversion
            // delay_ms(10);	    // Typical wait time is 3ms

            // read pressure
            // address byte + r/w bit
            // data byte + r/w bit
            const byte PRESHw_writeData = 0x00 | 0x80;
            const byte PRESHr_writeData = 0x00 | 0x80;
            const byte PRESLw_writeData = 0x02 | 0x80;
            const byte PRESLr_writeData = 0x00 | 0x80;
            const byte TEMPHw_writeData = 0x04 | 0x80;
            const byte TEMPHr_writeData = 0x00 | 0x80;
            const byte TEMPLw_writeData = 0x06 | 0x80;
            const byte TEMPLr_writeData = 0x00 | 0x80;
            const byte BLANK1r_writeData = 0x00 | 0x80;

            byte[] press_writeData = { PRESHw_writeData, PRESHr_writeData, PRESLw_writeData, PRESLr_writeData,
                                       TEMPHw_writeData, TEMPHr_writeData, TEMPLw_writeData, TEMPLr_writeData, BLANK1r_writeData };
            byte[] press_readBuffer = new byte[9];

            SPI_Out.WriteRead(press_writeData, press_readBuffer);

            uiPH = press_readBuffer[1];
            uiPL = press_readBuffer[3];
            uiTH = press_readBuffer[5];
            uiTL = press_readBuffer[7];

            uiPadc = (uint)uiPH << 8;
            uiPadc += (uint)uiPL & 0x00FF;
            uiTadc = (uint)uiTH << 8;
            uiTadc += (uint)uiTL & 0x00FF;

            // read coefficients
            // address byte + r/w bit
            // data byte + r/w bit
            const byte A0MSBw_writeData = 0x08 | 0x80;
//.........这里部分代码省略.........
开发者ID:zgramana,项目名称:WeatherStation,代码行数:101,代码来源:PressureSensor.cs

示例15: SyncDisplay

 public void SyncDisplay()
 {
     using (Microsoft.SPOT.Hardware.SPI spi = new SPI(_spiConfig))
     {
         spi.Write(_mainBuffer);
         spi.Write(_mainBuffer2);
     }
 }
开发者ID:HakanL,项目名称:NetduinoStuff,代码行数:8,代码来源:MatrixDisplay24x16.cs


注:本文中的Microsoft.SPOT.Hardware.SPI.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。