private void pe2a_mcp23s17_tr(byte device, byte txdata) { _bcm2835.bcm2835_gpio_write(Gpio_AI_CS3, Bcm2835.HIGH); _bcm2835.bcm2835_spi_chipSelect((byte)Bcm2835.bcm2835SPIChipSelect.BCM2835_SPI_CS1); _bcm2835.bcm2835_spi_setChipSelectPolarity((byte)Bcm2835.bcm2835SPIChipSelect.BCM2835_SPI_CS1, Bcm2835.LOW); var do_tbuf = new byte[3]; device = (byte)(device & 0xfe); // Clear last bit for a write do_tbuf[0] = device; do_tbuf[1] = setGPIOAorB; //from coming global val. do_tbuf[2] = txdata; _bcm2835.bcm2835_spi_transfern(do_tbuf, (uint)do_tbuf.Length); }
static int Main(string[] args) { // Will extract (from embedded resource) and compile the library // if it doesn't exist in the same directory as LibBcm2835.dll. Bcm2835.ExtractAndCompileLibraryIfNotExists(); // Grabbing the instance will dynamically load the libbcm2835.so // library, so make sure it's there before accessing this property. Bcm2835 bcm2835 = Bcm2835.Instance; // If you call this, it will not actually access the GPIO // Use for testing // bcm2835.bcm2835_set_debug(1); if (bcm2835.bcm2835_init() == 0) { return(1); } // Set the pin to be an output bcm2835.bcm2835_gpio_fsel(pin, Bcm2835.HIGH); while (true) { // Turn it on bcm2835.bcm2835_gpio_write(pin, Bcm2835.HIGH); // wait a bit bcm2835.bcm2835_delay(500); // turn it off bcm2835.bcm2835_gpio_write(pin, Bcm2835.LOW); // wait a bit bcm2835.bcm2835_delay(500); } bcm2835.bcm2835_close(); return(0); }