public GyroMPU6050(WirekiteDevice device, I2CPins i2cPins) { this.device = device; i2cPort = device.ConfigureI2CMaster(i2cPins, 100000); releasePort = true; InitSensor(); }
/// <summary> /// Configures an I2C port as a master /// </summary> /// <remarks> /// Each pin pair belongs to a specific I2C module. A single module can only /// be connected to a single pin pair at a time. /// </remarks> /// <param name="pins">the SCL/SDA pin pair for the port</param> /// <param name="frequency">the frequency of for the I2C communication (in Hz). If in doubt, use 100,000 Hz.</param> /// <returns>the I2C port ID</returns> public int ConfigureI2CMaster(I2CPins pins, int frequency) { ConfigRequest request = new ConfigRequest { Action = Message.ConfigActionConfigPort, PortType = Message.PortTypeI2C, PinConfig = (UInt16)pins, Value1 = (UInt32)frequency }; ConfigResponse response = SendConfigRequest(request); Port port = new Port(response.PortId, PortType.I2CPort, 10); _ports.AddPort(port); return(port.Id); }
public OLEDDisplay(WirekiteDevice device, I2CPins i2cPins) { this.device = device; i2cPort = device.ConfigureI2CMaster(i2cPins, 400000); releasePort = true; }