public void SetOutputGPIOPinValue(TJGPIOPins pin, uint value) { uint bitValue = (value << ((int)pin - 1)); GPIOOutputValues &= ~value; GPIOOutputValues |= bitValue; AardvarkApi.aa_gpio_set(handle, (byte)(GPIOOutputValues)); }
public void SetOutputGPIOPinValue(TJGPIOPins pin, uint value) { uint bitValue = (value << ((int)pin - 1)); GPIOOutputValues &= ~value; GPIOOutputValues |= bitValue; device.Functions.SetGpioPinVal((ushort)GPIOOutputValues); //AardvarkApi.aa_gpio_set(handle, (byte)(GPIOOutputValues)); }
// Returns true if pin is high, false if pin is low public uint GetInputGPIOPinValue(TJGPIOPins pin) { return ((uint)AardvarkApi.aa_gpio_get(handle) & (uint)pin) != 0 ? 1u : 0; }
// In mask, 1 = input, 0 = output public void SetGPIODirection(TJGPIOPins pinDirection) { // For Aardvark, 1 = output, 0 = input AardvarkApi.aa_gpio_direction(handle, (byte)(~pinDirection)); }
/// <summary> /// Starts connection with nRF and initializes it in RX mode. If init is successful, it starts listening for data /// and returns true /// </summary> /// <param name="handler">If a valid delegate is specified, it will be called each time the nRF receives a packet.</param> /// <returns></returns> public static bool Init(int cont, byte pipe, PacketReceivedHandler handler = null) { // Comment/uncomment the following lines to select the USB-to-SPI interface to use. Make sure the pin definitions above match th // actual hardware connections. // Uncomment the following two lines to use with MCP2210/Aardvark... make sure the IRQ and CE cables math the GPIO definitions if (cont == 0) { transceiver = new TJMCP2210SPITransceiver(); IRQPin = TJGPIOPins.TJGPIO_2; // Uncomment for MCP2210 CEPin = TJGPIOPins.TJGPIO_1; // Uncomment for MCP2210 } else if (cont == 1) { transceiver = new TJAardvarkSPITransceiver(); IRQPin = TJGPIOPins.TJGPIO_0; // Uncomment for aardvark CEPin = TJGPIOPins.TJGPIO_1; // Uncomment for aardvark } if (transceiver.Init()) { transceiver.SetGPIODirection(IRQPin); Mode = RFOpMode.RFRXMode; ConfigureRF(pipe); if (handler != null) PacketReceived = handler; TXPayloads = new ConcurrentQueue<byte[]>(); NewPackets = new ConcurrentQueue<byte[]>(); StartDispatchThreads(); return true; } return false; }
public uint GetInputGPIOPinValue(TJGPIOPins pin) { return ((uint)device.Functions.GetGpioPinVal() & (uint)pin) != 0 ? 1u : 0; }
public void SetGPIODirection(TJGPIOPins pinDirection) { device.Functions.SetGpioPinDir((ushort)pinDirection); }