public void t1(PigpiodIf pigpiodIf, CancellationToken ct) { int v; Console.WriteLine("\r\nMode/PUD/read/write tests."); pigpiodIf.set_mode(GPIO, PigpiodIf.PI_INPUT); v = pigpiodIf.get_mode(GPIO); CHECK(1, 1, v, 0, 0, "set mode, get mode", ct); pigpiodIf.set_pull_up_down(GPIO, PigpiodIf.PI_PUD_UP); v = pigpiodIf.gpio_read(GPIO); CHECK(1, 2, v, 1, 0, "set pull up down, read", ct); pigpiodIf.set_pull_up_down(GPIO, PigpiodIf.PI_PUD_DOWN); v = pigpiodIf.gpio_read(GPIO); CHECK(1, 3, v, 0, 0, "set pull up down, read", ct); pigpiodIf.gpio_write(GPIO, PigpiodIf.PI_LOW); v = pigpiodIf.get_mode(GPIO); CHECK(1, 4, v, 1, 0, "write, get mode", ct); v = pigpiodIf.gpio_read(GPIO); CHECK(1, 5, v, 0, 0, "read", ct); pigpiodIf.gpio_write(GPIO, PigpiodIf.PI_HIGH); v = pigpiodIf.gpio_read(GPIO); CHECK(1, 6, v, 1, 0, "write, read", ct); }
public void t8(PigpiodIf pigpiodIf, CancellationToken ct) { int v; Console.WriteLine("\r\nBank read/write tests."); pigpiodIf.gpio_write(GPIO, 0); v = (int)pigpiodIf.read_bank_1() & (1 << GPIO); CHECK(8, 1, v, 0, 0, "read bank 1", ct); pigpiodIf.gpio_write(GPIO, 1); v = (int)pigpiodIf.read_bank_1() & (1 << GPIO); CHECK(8, 2, v, (1 << GPIO), 0, "read bank 1", ct); pigpiodIf.clear_bank_1(1 << GPIO); v = pigpiodIf.gpio_read(GPIO); CHECK(8, 3, v, 0, 0, "clear bank 1", ct); pigpiodIf.set_bank_1(1 << GPIO); v = pigpiodIf.gpio_read(GPIO); CHECK(8, 4, v, 1, 0, "set bank 1", ct); v = (int)pigpiodIf.read_bank_2(); if (v != 0) { v = 0; } else { v = 1; } CHECK(8, 5, v, 0, 0, "read bank 2", ct); v = pigpiodIf.clear_bank_2(0); CHECK(8, 6, v, 0, 0, "clear bank 2", ct); v = pigpiodIf.clear_bank_2(0xffffff); CHECK(8, 7, v, -42, 0, "clear bank 2", ct); v = pigpiodIf.set_bank_2(0); CHECK(8, 8, v, 0, 0, "set bank 2", ct); v = pigpiodIf.set_bank_2(0xffffff); CHECK(8, 9, v, -42, 0, "set bank 2", ct); }