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


C# Hardware.SPI类代码示例

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


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

示例1: OLED_sh1106

 public OLED_sh1106(ref SPI globalSPIDevice, OutputPort dcPin, OutputPort rsPin)
 {
     displayStr = "";
     spiDevice = globalSPIDevice;
     dataCommandPin = dcPin;
     resetOutputPort = rsPin;
 }
开发者ID:wjmwjm119,项目名称:NetduinoOLED,代码行数:7,代码来源:OLED_sh1106.cs

示例2: AudioShield

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

示例3: DriverChip

        public DriverChip(Microsoft.SPOT.Hardware.SPI spi, byte address)
        {
            this.spi = spi;
            this.address = address;

            init();
        }
开发者ID:galgalesh,项目名称:Splitflaps,代码行数:7,代码来源:DriverChip.cs

示例4: 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

示例5: LIS302DL

 /// <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();
 }
开发者ID:vic10us,项目名称:STM32F4Discovery-NETMF,代码行数:12,代码来源:LIS302DL.cs

示例6: 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

示例7: Main

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

示例8: Main

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

示例9: AdaFruitLPD8806

        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);
        }
开发者ID:Larouex,项目名称:herdrider,代码行数:25,代码来源:AdaFruitLPD8806.cs

示例10: Initialize

        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;
        }
开发者ID:BookSwapSteve,项目名称:LightSwitch,代码行数:26,代码来源:VS1053.cs

示例11: HttpWiflyImpl

 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;
 }
开发者ID:metroidprimedude,项目名称:ASEC-Robotics,代码行数:7,代码来源:WiFlyShield.cs

示例12: CpuProgrammer

        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);
        }
开发者ID:John-Leitch,项目名称:Blue-Racer-CPU,代码行数:31,代码来源:CpuProgrammer.cs

示例13: Main

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

示例14: GpioPwm

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

示例15: LEDStripSpi

        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();
        }
开发者ID:AndyCross,项目名称:netmfazurequeue,代码行数:8,代码来源:LEDStripSpi.cs


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