示例#1
0
        public RaspSPI(SPIMode DataMode, SPIBitOrder BitOrder,
                       SPIClockDivider ClockDivider, ChipSelect ChipSelect,
                       bool ChipSelectPolarity)
        {
            RaspExtern.SPI.bcm2835_spi_begin();

            this.DataMode           = DataMode;
            this.BitOrder           = BitOrder;
            this.ClockDivider       = ClockDivider;
            this.ChipSelect         = ChipSelect;
            this.ChipSelectPolarity = ChipSelectPolarity;
        }
        public MAX7219(int numberOfPanels = 1, Rotate rotate = Rotate.None, Transform transform = Transform.None, ChipSelect chipSelect = ChipSelect.CE0, string SPIControllerName = "SPI0")
        {
            this.PanelsPerFrame = numberOfPanels < 0 ? 0 : numberOfPanels;
            this.rotate = rotate;
            this.transform = transform;
            this.chipSelect = chipSelect;
            this.SPIControllerName = SPIControllerName;

            SendDataBytes = new byte[2 * PanelsPerFrame];

            Task.Run(() => InitSpi()).Wait();
            InitDisplay();
        }
示例#3
0
        public void EnableSPI(SPIMode DataMode             = SPIMode.MODE1,
                              SPIBitOrder BitOrder         = SPIBitOrder.Order_MSBFIRST,
                              SPIClockDivider ClockDivider = SPIClockDivider.Divider_256,
                              ChipSelect ChipSelect        = ChipSelect.CS0,
                              bool ChipSelectPolarity      = false)
        {
            if (spi != null)
            {
                spi.Dispose();
            }

            spi = new RaspSPI(DataMode, BitOrder, ClockDivider, ChipSelect, ChipSelectPolarity);
        }
示例#4
0
        public MAX7219(int numberOfPanels = 1, Rotate rotate = Rotate.None, Transform transform = Transform.None, ChipSelect chipSelect = ChipSelect.CE0, string SPIControllerName = "SPI0")
        {
            this.PanelsPerFrame    = numberOfPanels < 0 ? 0 : numberOfPanels;
            this.rotate            = rotate;
            this.transform         = transform;
            this.chipSelect        = chipSelect;
            this.SPIControllerName = SPIControllerName;

            SendDataBytes = new byte[2 * PanelsPerFrame];

            Task.Run(() => InitSpi()).Wait();
            InitDisplay();
        }
示例#5
0
        public MAX7219(int numberOfPanels = 1, Rotate rotate = Rotate.None, Transform transform = Transform.None, ChipSelect chipSelect = ChipSelect.CE0, BusId busId = BusId.BusId0)
        {
            this.PanelsPerFrame = numberOfPanels < 0 ? 0 : numberOfPanels;
            this.rotate         = rotate;
            this.transform      = transform;
            this.chipSelect     = chipSelect;
            this.busId          = busId;

            SendDataBytes = new byte[2 * PanelsPerFrame];

            InitializeSpi();
            InitializeDisplay();
        }
        private async Task InitSPI(ChipSelect cs) {
            try {
                var settings = new SpiConnectionSettings((int)cs);
                settings.ClockFrequency = 500000;// 10000000;
                settings.Mode = SpiMode.Mode0; //Mode3;

                string spiAqs = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME);
                var deviceInfo = await DeviceInformation.FindAllAsync(spiAqs);
                SpiMCP3200 = await SpiDevice.FromIdAsync(deviceInfo[0].Id, settings);
            }
            /* If initialization fails, display the exception and stop running */
            catch (Exception ex) {
                throw new Exception("SPI Initialization Failed", ex);
            }
        }
示例#7
0
        private async Task InitSPI(ChipSelect cs)
        {
            try {
                var settings = new SpiConnectionSettings((int)cs);
                settings.ClockFrequency = 500000;        // 10000000;
                settings.Mode           = SpiMode.Mode0; //Mode3;

                string spiAqs     = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME);
                var    deviceInfo = await DeviceInformation.FindAllAsync(spiAqs);

                SpiMCP3200 = await SpiDevice.FromIdAsync(deviceInfo[0].Id, settings);
            }
            /* If initialization fails, display the exception and stop running */
            catch (Exception ex) {
                throw new Exception("SPI Initialization Failed", ex);
            }
        }
示例#8
0
 public MCP3002(ChipSelect cs)
 {
     Task.Run(() => InitSPI(cs)).Wait();
 }
 public MCP3002(ChipSelect cs) {
     Task.Run(() => InitSPI(cs)).Wait();
 }
示例#10
0
 public static void BeginSpi(ChipSelect cs, ushort clkDivider)
 {
     bcm2835_spi_begin ();
     bcm2835_spi_chipSelect ((byte)cs);
     bcm2835_spi_setClockDivider (clkDivider);
 }
示例#11
0
 public static extern void bcm2835_spi_setChipSelectPolarity(ChipSelect cs, byte active);
示例#12
0
 public static extern void bcm2835_spi_chipSelect(ChipSelect cs);