Example #1
0
        static Config()
        {
            Latch = new OutputPort(Pins.GPIO_PIN_D9, false);
            Device = new SPI.Configuration(
                ChipSelect_Port: Pins.GPIO_NONE, // SS-pin                          = slave select, not used
                ChipSelect_ActiveState: false, // SS-pin active state
                ChipSelect_SetupTime: 0, // The setup time for the SS port
                ChipSelect_HoldTime: 0, // The hold time for the SS port
                Clock_IdleState: true, // The idle state of the clock
                Clock_Edge: true, // The sampling clock edge
                Clock_RateKHz: 30000,
                // The SPI clock rate in KHz         ==> enough to start with, let's see how high we can take this later on
                SPI_mod: SPI.SPI_module.SPI1
                // The used SPI bus (refers to a MOSI MISO and SCLK pinset)   => default pins, also the ones used on the pwm shield
                // specifically: sin = 11, (netduino send, tlc in) and sclck = 13
                );
            // better to pass in the pins, and let the ports and pwms be managed insode the device

            Blank = new PWM(Pins.GPIO_PIN_D10);
            Gsclk = new PWM(Pins.GPIO_PIN_D6);

            LayerPorts=new[]
                         {
                             new OutputPort(Pins.GPIO_PIN_D5, false),
                             new OutputPort(Pins.GPIO_PIN_D4, false),
                             new OutputPort(Pins.GPIO_PIN_D3, false),
                             new OutputPort(Pins.GPIO_PIN_D2, false),
                             new OutputPort(Pins.GPIO_PIN_D7, false),
                             new OutputPort(Pins.GPIO_PIN_D8, false)
                         };
            SideLength = 6;
            TlcChannelCount = 112;
        }
Example #2
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);
         
     }
 }
Example #3
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);
        }
 /// <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();
 }
        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);
        }
Example #6
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();
 }
Example #7
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);
 }
Example #8
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);
 }
Example #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);
                }
            }
        }
Example #10
0
        public static void Upload(PageCollection pageCollection)
        {
            OutputPort onboardLed = new OutputPort(ShieldConfiguration.CurrentConfiguration.OnboardLedPin, true);

            SPI.Configuration spiConfig = new SPI.Configuration(
                ShieldConfiguration.CurrentConfiguration.SpiChipSelectPin,
                false,
                100,
                100,
                false,
                true,
                1000,
                ShieldConfiguration.CurrentConfiguration.SpiModule
            );
            var spi = new SpotSpi(spiConfig);
            var uploader = new Uploader(spi);

            if (uploader.IsShieldInBootloaderMode())
            {
                var uploadStatusIndicator = new UploadStatusIndicator(
                    spi
                    );

                try
                {
                    //var securityRegisterData = uploader.SecurityRegisterRead();
                    //var userData = new byte[Constants.SecurityRegisterUserFieldLength];
                    //Array.Copy(securityRegisterData, 4, userData, 0, userData.Length);
                    //var userDataString = new string(System.Text.Encoding.UTF8.GetChars(userData));
                    //Debug.Print("Programming \"" + userDataString + "\"");
                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Uploading;
                    uploader.UploadBitstream(pageCollection);
                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Succeeded;
                }
                catch
                {
                    // Any exception is a failed upload

                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Failed;
                    throw;
                }
                finally
                {
                    onboardLed.Write(false);
                }
            }
            else
            {
                // Flash the onboard LED to indicate upload failure due to
                // not being in bootstrapping mode

                Thread.Sleep(500);
                onboardLed.Write(false);
                Thread.Sleep(500);
                onboardLed.Write(true);
                Thread.Sleep(500);
                onboardLed.Write(false);
            }
        }
        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();
        }
 public void Deselect()
 {
     CurrentConfig = new SPI.Configuration(CurrentConfig.ChipSelect_Port,
                                           false,
                                           CurrentConfig.ChipSelect_SetupTime,
                                           CurrentConfig.ChipSelect_HoldTime,
                                           CurrentConfig.Clock_IdleState,
                                           CurrentConfig.Clock_Edge,
                                           CurrentConfig.Clock_RateKHz,
                                           CurrentConfig.SPI_mod);
 }
Example #13
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++;
            }
        }
        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);
        }
Example #15
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));
        }
Example #16
0
        /// <summary>
        /// Start SPI operations. Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO),
        /// P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) to alternate function ALT0,
        /// which enables those pins for SPI interface. You should call bcm2835_spi_end()
        /// when all SPI funcitons are complete to return the pins to their default functions
        /// </summary>
        /// <param name="config"></param>

        public SPI(SPI.Configuration config)
        {
            this.config = config;
            // initialize the io
            string[] arg = { "gpio", "load", "spi" };
            main(3, arg);
            //configure the right speed
            if (wiringPiSPISetup(config.SPI_mod, (int)(config.Clock_RateKHz * 1000)) < 0)
            {
                throw new Exception("Unable to initialize bcm2835.so library");
            }
        }
Example #17
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);
            }
        }
 /// <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);
 }
    uint _numPixels;         // strip's length

    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="color"> RGB value to initially set all LEDs to.  Pass OFF or 0 to start with LEDs off. </param>
    /// <param name="numPixels"> Number of pixels in strip.</param>
    /// <param name="spiModule"> Optional paramter for specifying which SPI module.  Omit this paramter to default to HERO S ports. </param>
    public HeroPixel(uint color, uint numPixels = 1, SPI.SPI_module spiModule = SPI.SPI_module.SPI4) 
    {
        _numPixels = (numPixels > 0) ? numPixels : 1;

        _pixels = new uint[_numPixels];
        _spiOut = new byte[kColorsPerPixel * kSpiBytesPerColor * _numPixels + 1]; // create array for output with +1 extra for START_OF_RST at the end

        setStripColor(color);

        // initialize SPI
        Configuration = new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, false, 9000, spiModule);
        SPIDevice = new SPI(Configuration);
    }
 public SpiDevice()
 {
     SPI.Configuration config = new SPI.Configuration(Pins.GPIO_NONE,
                                                      // Verify these values!
                                                      false,
                                                      0,
                                                      0,
                                                      false,
                                                      false,
                                                      48000,
                                                      SPI_Devices.SPI1);
     _device = new SPI(config);
 }
Example #21
0
        public L3G4200D()
        {
            // write your code here
            spi_settings = new SPI.Configuration(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D9
                                          , true
                                          , 100
                                          , 0
                                          , false
                                          , true
                                          , 100
                                          , SPI_Devices.SPI1
                                          );

            gyro_module = new SPI(spi_settings);
        }
        public Shifter74Hc595LcdTransferProvider(SPI.SPI_module spiBus, Cpu.Pin latchPin, BitOrder bitOrder)
        {
            _bitOrder = bitOrder;

            var spiConfig = new SPI.Configuration(
                latchPin,
                false, // active state
                0,     // setup time
                0,     // hold time
                false, // clock idle state
                true,  // clock edge
                1000,   // clock rate
                spiBus);

            _spi = new SPI(spiConfig);
        }
        public Lis302Dl(SPI.SPI_module spiModule, Cpu.Pin chipSelect)
        {
            var spiCfg = new SPI.Configuration(chipSelect, false,
                                               0, 0, //5,8
                                               true, true,
                                               5000, spiModule);

            _spi = new SPI(spiCfg);

            byte[] whoAmI = Read(WhoAmiReg, 1);
            if (whoAmI[0] != 0x3B)
                throw new InvalidOperationException("LIS302DL not available");

            Write(CtrlReg1, 0x47);
            _currentSensitivity = ToSensitivity(Scale.Full2K3);
        }
Example #24
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
     );
     var spi = new SPI(spiConfig);
     var GP = new GpioPwm(spi);
     //            LEDThrob(GP);
     ButtonLED(GP);
 }
Example #25
0
 public static void Main()
 {
     InterruptPort przycisk =
         new InterruptPort(Pins.GPIO_PIN_A_0, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLevelHigh);//przycisk
     var green = new PWM(Cpu.PWMChannel.PWM_0, 300, 0, false);//zielona
     var orange = new PWM(Cpu.PWMChannel.PWM_1, 300, 0, false);//pomaranczowa
     var red = new PWM(Cpu.PWMChannel.PWM_2, 300, 0, false); //czerwona
     var blue = new PWM(Cpu.PWMChannel.PWM_3, 300, 0, false);//niebieska
     green.Start();
     orange.Start();
     red.Start();
     blue.Start();
     int x = 0, y = 0, z = 0; 
     var timer = new System.Threading.Timer(TimerCallback, null, 0, 1000);
     SPI.Configuration MyConfig =
         new SPI.Configuration(Pins.GPIO_PIN_E_3, false, 0, 0, true, true, 1000, SPI.SPI_module.SPI1);
     MySPI = new SPI(MyConfig);
     Config();
     while (true)
     {
         red.DutyCycle = 0;
         green.DutyCycle = 0;
         blue.DutyCycle = 0;
         orange.DutyCycle = 0;
         if((ReadRegister(0x2D)>150)&&(ReadRegister(0x2D)<230))
         {
             red.DutyCycle = 1;
             green.DutyCycle = 1;
             blue.DutyCycle = 1;
             orange.DutyCycle = 1;
         }
         if ((ReadRegister(0x29) > 160) && (ReadRegister(0x29) < 230))
             blue.DutyCycle = 1;
         if ((ReadRegister(0x29) < 140) && (ReadRegister(0x29) > 20))
             orange.DutyCycle = 1;
         if ((ReadRegister(0x2B) > 160) && (ReadRegister(0x2B) < 230))
             red.DutyCycle = 1;
         if ((ReadRegister(0x2B) < 140) && (ReadRegister(0x2B) > 20))
             green.DutyCycle = 1;
         x = DateTime.Now.Millisecond;
         if (x + 200 >= 999) x -= 999;
         Debug.Print(ReadRegister(0x29).ToString() + " " + ReadRegister(0x2B).ToString() + " " + ReadRegister(0x2D).ToString() + " " + x);
         while (DateTime.Now.Millisecond<= x + 200) { }
     }
     
 }
        public Shifter74Hc595LcdTransferProvider(SPI.SPI_module spiBus, Cpu.Pin latchPin, BitOrder bitOrder, ShifterSetup setup)
            : base(setup)
        {
            _bitOrder = bitOrder;

            var spiConfig = new SPI.Configuration(
                Cpu.Pin.GPIO_NONE, //latchPin,
                false, // active state
                0,     // setup time
                0,     // hold time
                false, // clock idle state
                true,  // clock edge
                1000,   // clock rate
                spiBus);

            _spi = new SPI(spiConfig);
            _latchPort = new OutputPort(latchPin, true);
        }
Example #27
0
        public AD5206(Cpu.Pin csPin)
        {
            Configuration = new SPI.Configuration(
               csPin,             // /CS pin
               false,             // /CS active LOW
               0,                 // /CS setup time
               0,                 // /CS hold time
               false,             // clock low on idle
               true,              // rising edge data
               1000,              // SPI clock rate in KHz
               SPI_Devices.SPI1   // MOSI MISO and SCLK pinset
               );

            if (SPI == null)
            {
                SPI = new SPI(Configuration);
            }
        }
        public AdaFruitSSD1306(Cpu.Pin dc, Cpu.Pin reset, Cpu.Pin chipSelect, SPI.SPI_module spiModule = SPI.SPI_module.SPI1, uint speedKHz = 10000)
        {

            AutoRefreshScreen = false;

            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
                );

            dcPin = new OutputPort(dc, false);
            resetPin = new OutputPort(reset, false);
        }
Example #29
0
        public LPD6803(SPI.SPI_module spiModule, int numPixels)
        {
            var spiConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE, true, 0, 0, false, true, 500, spiModule);
            spi = new SPI(spiConfig);

            NumPixels = numPixels;

            // On a LPD6803, the PWM counter is shared with the data pin.
            // This means, when we send data, we must align the data to 256 bits (32 bytes, 16 ushorts)
            // We also have to consider the 4 byte header.
            var bufferLength = numPixels + 2;
            var alignment = 32 - (bufferLength % 32);
            bufferLength += alignment;
            Debug.Assert(bufferLength % 32 == 0);

            buffer = new ushort[bufferLength];

            new Thread(WriteLoop).Start();
        }
Example #30
0
        public LPD6803(SPI.SPI_module spiModule, int numPixels)
        {
            var spiConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE, true, 0, 0, false, true, 500, spiModule);
            spi = new SPI(spiConfig);

            NumPixels = numPixels;

            // On a LPD6803, the PWM counter is shared with the data pin.
            // This means, when we send data, we must align the data to 256 bits (32 bytes, 16 ushorts)
            // We also have to consider the 4 byte header.
            var bufferLength = numPixels + 2;
            var alignment = 32 - (bufferLength % 32);
            bufferLength += alignment;
            Debug.Assert(bufferLength % 32 == 0);

            buffer = new ushort[bufferLength];

            oc = new OutputCompare((Cpu.Pin) FEZ_Pin.Digital.Di10, false, 2);
            oc.Set(false, new uint[] {1, 1}, 0, 2, true);
        }
Example #31
0
        public Md5Chip()
        {
            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);

            _spi = new SPI(_spiConfig);
        }