Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Net.Sockets;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- using SecretLabs.NETMF.Hardware;
- using SecretLabs.NETMF.Hardware.NetduinoPlus;
- using System.IO.Ports;
- namespace SPITest
- {
- public class Program
- {
- private static SPI SPIBus;
- public static void Main()
- {
- // Defines the first SPI slave device with pin 10 as SS
- SPI.Configuration Device1 = new SPI.Configuration(
- Pins.GPIO_NONE, // 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
- false, // The sampling clock edge (this must be "true" for the 74HC595)
- 250, // The SPI clock rate in KHz
- SPI.SPI_module.SPI1 // The used SPI bus (refers to a MOSI MISO and SCLK pinset)
- );
- // Initializes the SPI bus, with the first slave selected
- SPIBus = new SPI(Device1);
- //DoWorkSlow();
- DoWorkFast();
- }
- private static void DoWorkFast()
- {
- //set-up the desired buffer
- byte[] bufferHighBit = new byte[] { 0xFF, 0xF0, 0x00 };
- byte[] bufferLowBit = new byte[] { 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 };
- while (true)
- {
- //SPIBus.Write(bufferLowBit);
- SPIBus.Write(bufferHighBit);
- }
- }
- private static void DoWorkSlow()
- {
- //set-up a one-byte buffer
- byte[] buffer = new byte[1];
- while (true)
- {
- for (int i = 0; i < 8; i++)
- {
- buffer[0] = (byte)i;
- SPIBus.Write(buffer);
- }
- Thread.Sleep(5);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement