コード例 #1
0
        public ExtendedSpiConfiguration(
            Cpu.Pin ChipSelect_Port,
            bool ChipSelect_ActiveState,
            uint ChipSelect_SetupTime,
            uint ChipSelect_HoldTime,
            bool Clock_IdleState,
            bool Clock_Edge,
            uint Clock_RateKHz,
            SPI.SPI_module SPI_mod,
            Cpu.Pin BusyPin,
            bool BusyPin_ActiveState,
            uint BitsPerTransfer
            )
            : base(ChipSelect_Port, ChipSelect_ActiveState, ChipSelect_SetupTime, ChipSelect_HoldTime, Clock_IdleState, Clock_Edge, Clock_RateKHz, SPI_mod, BusyPin, BusyPin_ActiveState)
        {
            // Netduino's MCU can read/write 8 to 16 bits per transfer (variable-bit SPI)
            if (BitsPerTransfer < 8 || BitsPerTransfer > 16)
            {
                throw new ArgumentException();
            }

            // use reflection to set the custom protected "BitsPerTransfer" property on our base class
            Type      spiConfigurationType = typeof(SPI.Configuration);
            FieldInfo fieldInfo            = spiConfigurationType.GetField("Custom_BitsPerTransfer", BindingFlags.NonPublic | BindingFlags.Instance);

            fieldInfo.SetValue(this, BitsPerTransfer);
        }
コード例 #2
0
        override public void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi)
        {
            switch (spi_mod)
            {
            case SPI.SPI_module.SPI1:
                msk  = Pins.GPIO_PORT_PIN_23;
                miso = Pins.GPIO_PORT_PIN_26;
                mosi = Pins.GPIO_PORT_PIN_25;
                break;

            case SPI.SPI_module.SPI2:
                msk  = Pins.GPIO_PORT_PIN_36;
                miso = Pins.GPIO_PORT_PIN_11;
                mosi = Pins.GPIO_PORT_PIN_38;
                break;

            case SPI.SPI_module.SPI3:
                // These are the SSP3 pins that drive the CC2420 on the Mote2
                msk  = Pins.GPIO_PORT_PIN_34;
                miso = Pins.GPIO_PORT_PIN_41;
                mosi = Pins.GPIO_PORT_PIN_35;
                break;

            default:
                throw new NotSupportedException();
            }
        }
コード例 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="csPin">CS pin for SPI interface</param>
        /// <param name="spiModule">SPI module</param>
        /// <param name="clockRateKhz">SPI clock rate (defaults to 1MHZ in other constructors)</param>
        public LIS302DL(Cpu.Pin csPin, SPI.SPI_module spiModule, uint clockRateKhz)
        {
            var spiConfig = new SPI.Configuration(csPin, false, 0, 0, true, true, clockRateKhz, spiModule);

            _spi = new SPI(spiConfig);
            Init();
        }
コード例 #4
0
ファイル: SSD1351.cs プロジェクト: jwkent/Netduino.Foundation
 public SSD1351(Cpu.Pin chipSelectPin, Cpu.Pin dcPin, Cpu.Pin resetPin,
                uint width, uint height,
                SPI.SPI_module spiModule = SPI.SPI_module.SPI1,
                uint speedKHz            = 9500) : base(chipSelectPin, dcPin, resetPin, width, height, spiModule, speedKHz)
 {
     Initialize();
 }
コード例 #5
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;
 }
コード例 #6
0
        private byte[] _tmpPixel = new byte[12];    // Temporary buffer
        #endregion

        #region Constructor and Destructor
        /// <summary>
        /// WS2811Led constructor.
        /// </summary>
        /// <param name="striplength">Number of leds in the strip. Warning : will alocate a memory buffer 12 times this number.</param>
        /// <param name="SPImodule">The SPI module the strip is connected to. Only the MOSI line is used. SPI1 is used if parameter omited.</param>
        /// <param name="speed">The Hardwired speed of the strip. 800Khz is used if parameter is omited.</param>
        /// <param name="linearizationfactor">If set to a value >0 (default value=2.25) will build the lookup table using human linear perceived luminosity instead of direct PWM values.</param>
        public WS2811Led(int striplength, SPI.SPI_module SPImodule = SPI.SPI_module.SPI1, WS2811Speed speed = WS2811Speed.S800KHZ, double linearizationfactor = 2.25)
        {
            _StripLength    = striplength;
            _StripLightNb   = striplength * 3;  //For later speed optimizations
            _StripBufferLen = striplength * 12; //For later speed optimizations

            // Initialize SPI
            // Set clock edge to false to remove the failing initial LED
            _WS2811SPIConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, false, (uint)speed, SPImodule);
            try
            {
                _WS2811SPI = new SPI(_WS2811SPIConfig);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                throw;
            }


            // SPI Transmit buffer = 4 output byte per color, 3 colors per light
            _WS2811Buffer = new byte[4 * 3 * striplength];

            // Compute fast byte to SPI lookup table. By default the linearisation of human perceived luminosity is on (Weber–Fechner law)
            _WS2811Table = new byte[1024];
            BuildTable(linearizationfactor);

            //Clear all leds
            Clear();
            Transmit();
        }
コード例 #7
0
        /// <summary>
        ///     Create a new SPIBus operating in the specified mode.
        /// </summary>
        /// <remarks>
        ///     Mode    CPOL    CPHA
        ///     0       0       0
        ///     1       0       1
        ///     2       1       0
        ///     3       1       1
        /// </remarks>
        /// <param name="module">SPI module to configure.</param>
        /// <param name="chipSelect">Chip select pin.</param>
        /// <param name="mode">SPI Bus Mode - should be in the range 0 - 3.</param>
        /// <param name="speed">Speed of the SPI bus.</param>
        public SPIBus(SPI.SPI_module module, Cpu.Pin chipSelect, byte mode, ushort speed)
        {
            if (mode > 3)
            {
                throw new ArgumentException("SPI Mode should be in the range 0 - 3.");
            }
            byte cpha = 0;
            byte cpol = 0;

            switch (mode)
            {
            case 1:
                cpha = 1;
                break;

            case 2:
                cpol = 1;
                break;

            case 3:
                cpol = 1;
                cpha = 1;
                break;
            }
            Configure(module, chipSelect, cpha, cpol, speed);
            _spi = new SPI(_configuration);
        }
コード例 #8
0
        public ADC124S101(Cpu.Pin chipSelectPin,
                          float supplyVoltage,
                          uint clockRateKHz,
                          SPI.SPI_module spiModule)
        {
            if (chipSelectPin == Cpu.Pin.GPIO_NONE)
            {
                throw new ArgumentOutOfRangeException("chipSelectPin");
            }
            if (supplyVoltage <= 0.0f)
            {
                throw new ArgumentOutOfRangeException("supplyVoltage");
            }
            this.chipSelectPin = chipSelectPin;
            this.supplyVoltage = supplyVoltage;

            SPI.Configuration config = new SPI.Configuration(
                chipSelectPin,                                  //chip select port
                false,                                          //IC is accessed when chip select is low
                1,                                              //setup time 1 ms, is actually min 10 ns
                1,                                              //hold chip select 1 ms after transfer
                true,                                           //clock line is high if device is not selected
                false,                                          //data is sampled at falling edge of clock
                clockRateKHz,                                   //possible 10000 - 20000 KHz
                spiModule                                       //select SPI bus
                );
            this.spi = new SPI(config);
        }
コード例 #9
0
        override public void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi)
        {
            switch (spi_mod)
            {
            case SPI.SPI_module.SPI1:
                msk  = Pins.GPIO_PIN_B_13;
                miso = Pins.GPIO_PIN_B_14;
                mosi = Pins.GPIO_PIN_B_15;
                break;

            case SPI.SPI_module.SPI2:
                msk  = Pins.GPIO_PIN_A_5;
                miso = Pins.GPIO_PIN_B_4;
                mosi = Pins.GPIO_PIN_A_7;
                break;

            case SPI.SPI_module.SPI3:
                msk  = Pins.GPIO_PIN_C_10;
                miso = Pins.GPIO_PIN_C_11;
                mosi = Pins.GPIO_PIN_C_12;
                break;

            case SPI.SPI_module.SPI4:
                msk  = Pins.GPIO_PIN_E_2;
                miso = Pins.GPIO_PIN_E_13;
                mosi = Pins.GPIO_PIN_E_6;
                break;

            default:
                throw new NotSupportedException();
            }
        }
コード例 #10
0
ファイル: MCP2515.cs プロジェクト: sn4men/imBMW
        /// <summary>Initialize the CAN transceiver.</summary>
        /// <param name="baudrate">The selected baud rate.</param>
        /// <returns>True if configuration was successful.</returns>
        /// <remarks>Transceiver needs to be set to normal mode before starting TX/RX operations.</remarks>
        public bool InitCAN(SPI.SPI_module spiModule, Cpu.Pin chipSelect, byte[] baudrate)
        {
            if (baudrate.Length != 3)
            {
                throw new Exception("Baudrate settings should be 3-byte array of CNF1,2,3 registers.");
            }

            // Configure SPI
            var configSPI = new SPI.Configuration(chipSelect, LOW, 0, 0, HIGH, HIGH, 10000, spiModule);

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

            byte mode = (byte)(ReadRegister(CANSTAT) >> 5);

            if (mode != 0x04)
            {
                return(false);
            }
            else
            {
                SetCANBaud(baudrate);
                return(true);
            }
        }
コード例 #11
0
        public Adafruit1306OledDriver(
            Cpu.Pin dc,
            Cpu.Pin reset,
            Cpu.Pin chipSelect,
            SPI.SPI_module spiModule = SPI.SPI_module.SPI1,
            uint speedKHz            = 10000)
        {
            AutoRefreshScreen = true;

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

            this.Spi = new SPI(spiConfig);

            this.DcPin    = new OutputPort(dc, false);
            this.ResetPin = new OutputPort(reset, false);
        }
コード例 #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 PCD8544(Cpu.Pin chipSelectPin, Cpu.Pin dcPin, Cpu.Pin resetPin,
                       SPI.SPI_module spiModule = SPI.SPI_module.SPI1,
                       uint speedKHz            = 4000)
        {
            spiBuffer = new byte[Width * Height / 8];

            dataCommandPort = new OutputPort(dcPin, true);
            resetPort       = new OutputPort(resetPin, true);

            /*  var spiConfig = new SPI.Configuration(
             *    chipSelectPin,          // chip select port
             *    false,                  // IC is accessed when chip select is low
             *    0,                      // setup time 1 ms
             *    0,                      // hold chip select 1 ms after transfer
             *    false,                  // clock line is low if device is not selected
             *    true,                   // data is sampled at leading edge of clock
             *    speedKHz,               // clockrate is 4 kHz
             *    spiModule               // use first SPI bus
             *    );*/

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

            spi = new SPI(spiConfig);

            Initialize();
        }
コード例 #14
0
        /// <summary>
        /// Creates a new NeoPixelSPI with a given chip-select pin, using a given SPI module
        /// </summary>
        /// <param name="chipSelectPin">chip-select pin</param>
        /// <param name="spiModule">SPI module</param>
        public NeoPixelSPI(Cpu.Pin chipSelectPin, SPI.SPI_module spiModule)
        {
            uint speed = 6666; // 6.666 MHz

            SPI.Configuration spiConfig = new SPI.Configuration(chipSelectPin, false, 0, 0, false, true, speed, spiModule);
            this.spi = new SPI(spiConfig);
        }
コード例 #15
0
        public DisplayTFTSPIBase(Cpu.Pin chipSelectPin, Cpu.Pin dcPin, Cpu.Pin resetPin,
                                 uint width, uint height,
                                 SPI.SPI_module spiModule = SPI.SPI_module.SPI1,
                                 uint speedKHz            = 9500, bool idleClockState = false)
        {
            _width  = width;
            _height = height;

            spiBuffer = new byte[_width * _height * sizeof(ushort)];

            dataCommandPort = new OutputPort(dcPin, false);
            resetPort       = new OutputPort(resetPin, true);

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

            spi = new SPI(spiConfig);
        }
コード例 #16
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
     SPI.Configuration spiConfig = new SPI.Configuration(csPin, false, 0, 0, true, true, 10000, spiModule);
     _spi = new SPI(spiConfig);
     Init();
 }
コード例 #17
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;
 }
コード例 #18
0
        /// <summary>
        /// Creates a new instance of Lis302Dl class
        /// </summary>
        /// <param name="csPin">CS pin for SPI interface</param>
        /// <param name="spiModule">SPI module</param>
        /// <param name="Clock_Rate_KHZ">SPI clock rate (defaults to 1 MHz in other constructors)</param>
        /// <param name="config">LIS302DL configuration</param>
        public Lis302Dl(Cpu.Pin csPin, SPI.SPI_module spiModule, uint Clock_Rate_KHZ, Lis302Dl.Configuration config)
        {
            SPI.Configuration spiConfig = new SPI.Configuration(csPin, false, 0, 0, true, true, Clock_Rate_KHZ, spiModule);
            _spi = new SPI(spiConfig);

            this.config = config;
            Init();
        }
コード例 #19
0
 public CanMCP2515AdapterSettings(SPI.SPI_module spi, Cpu.Pin chipSelect, Cpu.Pin interrupt, CanSpeed speed, AdapterFrequency frequency)
     : base(speed)
 {
     SPI        = spi;
     ChipSelect = chipSelect;
     Interrupt  = interrupt;
     Frequency  = frequency;
 }
コード例 #20
0
        //--//
        public virtual void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi)
        {
            msk  = Cpu.Pin.GPIO_NONE;
            miso = Cpu.Pin.GPIO_NONE;
            mosi = Cpu.Pin.GPIO_NONE;

            NativeGetSpiPins(spi_mod, out msk, out miso, out mosi);
        }
コード例 #21
0
        public Mfrc522(SPI.SPI_module spiDevice, Cpu.Pin resetPowerDownPin, Cpu.Pin ssPin)
        {
            _resetPowerDown = new OutputPort(resetPowerDownPin, true);
            _ss             = new OutputPort(ssPin, true);

            _spi = new SPI(new SPI.Configuration(Pins.GPIO_NONE, false, 0, 0, false, true, 1000, spiDevice));

            Reset();
        }
コード例 #22
0
 /// <summary>
 ///     Create a new ADXL362 object using the specified SPI module.
 /// </summary>
 /// <param name="module">SPI module to use.</param>
 /// <param name="chipSelect">Chip select pin.</param>
 /// <param name="speed">Speed of the SPI bus.</param>
 public ADXL362(SPI.SPI_module module, Cpu.Pin chipSelect, ushort speed = 10)
 {
     //
     //  ADXL362 works in SPI mode 0 (CPOL = 0, CPHA = 0).
     //
     _adxl362 = new SPIBus(module, chipSelect, speed);
     Reset();
     Start();
 }
コード例 #23
0
 public static void MountSD(string path, SPI.SPI_module spi, Cpu.Pin chipSelect, Cpu.Pin cardDetect)
 {
     if (SdCardPath != null)
     {
         throw new NotSupportedException();
     }
     SDSPI_Mount(path, (uint)spi, (uint)chipSelect, (uint)cardDetect);
     SdCardPath = path;
 }
コード例 #24
0
ファイル: ST7735.cs プロジェクト: jwkent/Netduino.Foundation
        public ST7735(Cpu.Pin chipSelectPin, Cpu.Pin dcPin, Cpu.Pin resetPin,
                      uint width, uint height,
                      SPI.SPI_module spiModule = SPI.SPI_module.SPI1,
                      uint speedKHz            = 9500,
                      DisplayType displayType  = DisplayType.ST7735R) : base(chipSelectPin, dcPin, resetPin, width, height, spiModule, speedKHz)
        {
            this.displayType = displayType;

            Initialize();
        }
コード例 #25
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();
        }
コード例 #26
0
 public Configuration(Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState, uint ChipSelect_SetupTime, uint ChipSelect_HoldTime, bool Clock_IdleState, bool Clock_Edge, uint Clock_RateKHz, SPI.SPI_module SPI_mod)
 {
     this.ChipSelect_Port        = ChipSelect_Port;
     this.ChipSelect_ActiveState = ChipSelect_ActiveState;
     this.ChipSelect_SetupTime   = ChipSelect_SetupTime;
     this.ChipSelect_HoldTime    = ChipSelect_HoldTime;
     this.Clock_IdleState        = Clock_IdleState;
     this.Clock_Edge             = Clock_Edge;
     this.Clock_RateKHz          = Clock_RateKHz;
     this.SPI_mod = SPI_mod;
 }
コード例 #27
0
        /// <summary>
        /// Creates a new nRF8001 device interface.
        /// </summary>
        /// <param name="rstPin">The application controller pin that the nRF8001's RST pin is connected to.</param>
        /// <param name="reqPin">The application controller pin that the nRF8001's REQn pin is connected to.</param>
        /// <param name="rdyPin">The application controller pin that the nRF8001's RDYn pin is connected to.</param>
        /// <param name="spiModule">The SPI module to use for communication with the nRF8001.</param>
        public Nrf8001(Cpu.Pin rstPin, Cpu.Pin reqPin, Cpu.Pin rdyPin, SPI.SPI_module spiModule)
        {
            _rst = new OutputPort(rstPin, true);
            _req = new OutputPort(reqPin, true);
            _rdy = new InterruptPort(rdyPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
            _spi = new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 100, spiModule));

            State = Nrf8001State.Unknown;
            Reset();

            _rdy.OnInterrupt += OnRdyInterrupt;
        }
コード例 #28
0
    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);
    }
コード例 #29
0
 override public void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi)
 {
     if ((int)spi_mod == 0)
     {
         msk  = Pins.SPI0_SCLK;
         miso = Pins.SPI0_MISO;
         mosi = Pins.SPI0_MOSI;
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #30
0
        /// <summary>
        /// Defines a chain of RGB LEDs
        /// </summary>
        /// <param name="Chipset">The chipset used to daisychain the LEDs</param>
        /// <param name="LedCount">The amount of LEDs in the chain</param>
        /// <param name="SPI_Device">The SPI bus the chain is connected to</param>
        /// <param name="ChipSelect_Port">If there's a CS circuitry, specify it's pin</param>
        /// <param name="ChipSelect_ActiveState">If there's a CS circuitry, specify it's active state</param>
        public RgbLedStrip(Chipsets Chipset, int LedCount, SPI.SPI_module SPI_Device, Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState)
        {
            // The used chipset
            this._Chipset = Chipset;

            // Stores the amount of LEDs
            this.LedCount = LedCount;

            // Extends the arrays for the LED states and brightness
            this._LedState   = new byte[LedCount * 3];
            this._Brightness = new byte[LedCount];

            // Settings for the LPD8806 chip
            if (Chipset == Chipsets.LPD8806)
            {
                // Creates a new buffer (final 3 bytes should always be 0 and tells the chain we're done for now)
                this._Buffer = new byte[LedCount * 3 + 3];

                // Default sequence of the Adafruit strips
                this.Sequence = Sequences.GRB;
            }

            // Settings for the WS2801 chip
            if (Chipset == Chipsets.WS2801)
            {
                // Creates a new buffer
                this._Buffer = new byte[LedCount * 3];

                // Default sequence of the Adafruit chains
                this.Sequence = Sequences.RGB;
            }

            // Configures the SPI bus
            this._Conn = new MultiSPI(new SPI.Configuration(
                                          ChipSelect_Port: ChipSelect_Port,
                                          ChipSelect_ActiveState: ChipSelect_ActiveState,
                                          ChipSelect_SetupTime: 0,
                                          ChipSelect_HoldTime: 0,
                                          Clock_IdleState: false,
                                          Clock_Edge: true,
                                          Clock_RateKHz: 1000,
                                          SPI_mod: SPI_Device
                                          ));

            // Set brightness only half way, most LED strips are just way too bright imho
            this.SetBrightnessAll(128);
            // Turns off all LEDs
            this.SetColorAll(0);
            // Writes for the first time
            this.Write();
        }
コード例 #31
0
        override public void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi)
        {
            switch (spi_mod)
            {
            case SPI.SPI_module.SPI1:
                msk  = Pins.GPIO_PIN_6;
                miso = Pins.GPIO_PIN_7;
                mosi = Pins.GPIO_PIN_8;
                break;

            default:
                throw new NotSupportedException();
            }
        }
コード例 #32
0
ファイル: FEZ_Components.cs プロジェクト: yurivital/jas
 public TouchConfiguration(SPI.SPI_module channel, FEZ_Pin.Digital chipSelect, FEZ_Pin.Digital touchIRQ)
 {
     this.channel = channel;
     this.chipSelect = (Cpu.Pin)chipSelect;
     this.touchIRQ = (Cpu.Pin)touchIRQ;
 }
コード例 #33
0
        //internal static byte[] _encodedName;

        /// <summary>
        /// Start Networking!  If you want to use a static IP, make sure to set it before you start! 
        /// Note: This call may block for up to 15 seconds waiting for the IP Address assignment.  
        /// </summary>
        /// <param name="MacAddress">6-bytes the specify the Globally unique MAC address</param>
        /// <param name="name">Local Name of this device</param>
        /// <param name="spiBus"></param>
        /// <param name="resetPin"></param>
        /// <param name="interruptPin"></param>
        /// <param name="chipSelectPin"></param>
        public static void Start(byte[] MacAddress, string name, SPI.SPI_module spiBus, Cpu.Pin interruptPin, Cpu.Pin chipSelectPin)
        {
            Microsoft.SPOT.Debug.Assert(MacAddress != null, "MAC Address must be set to start networking.");
            Adapter.MacAddress = MacAddress;

            // Setting the Name to null will turn off naming...
            Adapter.Name = name;
            Adapter.SpiPort = spiBus;
            Adapter.IntPin = interruptPin;
            Adapter.CSPin = chipSelectPin;

            //if (responderThread.ThreadState == ThreadState.Running) return;

            //startupHold.Reset();

            //if (responderThread.ThreadState == ThreadState.Unstarted)
            //{
            //    responderThread.Start();
            //}
            //else if (responderThread.ThreadState == ThreadState.Stopped || responderThread.ThreadState == ThreadState.Suspended)
            //{
            //    Debug.WriteLine("Networking Thread being Restarted!  Threadstate: " + responderThread.ThreadState.ToString());
            //    responderThread.Abort();
            //    Thread.Sleep(10);
            //    responderThread = new Thread(MainService);
            //}

            MainService();

            if (!Adapter.DhcpDisabled && (Adapter.DomainNameServer == null || Adapter.Gateway == null || Adapter.IPAddress == null))
            {
                if (!startupHold.WaitOne(10000, true)) Debug.WriteLine("WARNING!  Time out while waiting for DHCP, check your Interface Profile and connections to ENC28J60 Controller");  // wait 10 seconds for DHCP and DNS assignment
            }
            else if (Adapter.DhcpDisabled && Adapter.IPAddress != null && Adapter.Gateway != null && GatewayMac == null)
            {
                if (!startupHold.WaitOne(10000, true)) Debug.WriteLine("WARNING!  Time out while waiting for Gateway to Respond to ARP request");  // wait 10 seconds for DHCP and DNS assignment
            }
            else
            {
                Debug.WriteLine("WARNING!  Networking is not properly configured to start.  ");
            }

        }
コード例 #34
0
 public SiliconStorageDevice(Cpu.Pin chipSelect, SPI.SPI_module spiModule)
 {
     _chipSelect = chipSelect;
     _spiModule = spiModule;
 }