static void Main(string[] args) { if ((args.Length != 3) || (args.Length == 0)) { Console.WriteLine("usage: read_EEPROM <VID> <PID> <value in hex {0x00=100kHz, 0x01=400kHz}> "); return; } if (args[0].Length > 2) { if (args[0].Substring(0, 2) != "0x") { Console.WriteLine("You must specify VID in Hex (0x0)"); return; } else { args[0] = args[0].Substring(2); } } else { Console.WriteLine("You must specify VID in Hex (0x0)"); return; } int vid = int.Parse(args[0], NumberStyles.HexNumber); if (args[1].Length > 2) { if (args[1].Substring(0, 2) != "0x") { Console.WriteLine("You must specify PID in Hex (0x0)"); return; } else { args[1] = args[1].Substring(2); } } else { Console.WriteLine("You must specify PID in Hex (0x0)"); return; } int pid = int.Parse(args[1], NumberStyles.HexNumber); if (args[2].Length > 2) { if (args[2].Substring(0, 2) != "0x") { Console.WriteLine("You must specify value in Hex (0x0)"); return; } else { args[2] = args[2].Substring(2); } } else { Console.WriteLine("You must specify value in Hex (0x0)"); return; } int value = int.Parse(args[2], NumberStyles.HexNumber); IntPtr usb_dev_handle = USB.InitFindAndOpenDevice(vid, pid); if ((OZY.Set_I2C_Speed(usb_dev_handle, value))) { Console.WriteLine("Set I2C speed successful"); } else { Console.WriteLine("Failed to set I2C speed"); } Console.WriteLine("I2C SPEED: " + OZY.Read_I2C_Speed(usb_dev_handle).ToString()); Console.WriteLine("Closing device..."); libUSB_Interface.usb_close(usb_dev_handle); Console.WriteLine("done..."); }
public override void SetMicGain() { // This is used to set the MicGain and Line in when Ozy/Magister is used // The I2C settings are as follows: // For mic input and boost on/off // 1E 00 - Reset chip // 12 01 - set digital interface active // 08 15 - D/A on, mic input, mic 20dB boost // 08 14 - ditto but no mic boost // 0C 00 - All chip power on // 0E 02 - Slave, 16 bit, I2S // 10 00 - 48k, Normal mode // 0A 00 - turn D/A mute off // 00 00 - set Line in gain to 0 // For line input // 1E 00 - Reset chip // 12 01 - set digital interface active // 08 10 - D/A on, line input // 0C 00 - All chip power on // 0E 02 - Slave, 16 bit, I2S // 10 00 - 48k, Normal mode // 0A 00 - turn D/A mute off // 00 00 - set Line in gain to 0 if ((MainForm.PenneyPresent || MainForm.PennyLane) && (MainForm.Penny_version != 0) && (MainForm.KK_on == true)) // update mic gain on Penny or PennyLane TLV320 { byte[] Penny_TLV320 = new byte[2]; byte[] Penny_TLV320_data = new byte[16]; // need to select the config data depending on the Mic Gain (20dB) selected if (MainForm.MicGain20dB) { Penny_TLV320_data = new byte[] { 0x1e, 0x00, 0x12, 0x01, 0x08, 0x15, 0x0c, 0x00, 0x0e, 0x02, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00 } } ; else if (MainForm.LineIn) { Penny_TLV320_data = new byte[] { 0x1e, 0x00, 0x12, 0x01, 0x08, 0x10, 0x0c, 0x00, 0x0e, 0x02, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00 } } ; else { Penny_TLV320_data = new byte[] { 0x1e, 0x00, 0x12, 0x01, 0x08, 0x14, 0x0c, 0x00, 0x0e, 0x02, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00 } }; // set the I2C interface speed to 400kHZ if (!(OZY.Set_I2C_Speed(hdev, 1))) { MessageBox.Show("Unable to set I2C speed to 400kHz", "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // send the configuration data to the TLV320 on Penelope or PennyLane for (int x = 0; x < 16; x += 2) { Penny_TLV320[0] = Penny_TLV320_data[x]; Penny_TLV320[1] = Penny_TLV320_data[x + 1]; if (!(OZY.Write_I2C(hdev, 0x1b, Penny_TLV320))) { MessageBox.Show("Unable to configure TLV320 on Penelope via I2C", "System Eror!", MessageBoxButtons.OK, MessageBoxIcon.Error); // break out of the configuration loop break; } } } }