Пример #1
0
        // latch data into one of the PIO registers.
        // addr needs to be on of the PIO_xxx constants
        // returns true on success, false on failure
        private bool LatchRegister(byte addr, byte data)
        {
            bool rc;

            byte[] buf = new byte[1];
            buf[0] = data;
            rc     = OZY.Write_SPI(usb_dev_handle, 0, ADDR_DATA, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            if (!rc)
            {
                System.Console.WriteLine("Latch to ADDR_DATA failed\n");
                return(false);
            }
            buf[0] = addr;
            rc     = OZY.Write_SPI(usb_dev_handle, 0, ADDR_CTRL, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            if (!rc)
            {
                System.Console.WriteLine("Latch to ADDR_CTRL failed\n");
                return(false);
            }
            buf[0] = PIO_NONE;
            rc     = OZY.Write_SPI(usb_dev_handle, 0, ADDR_CTRL, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            if (!rc)
            {
                System.Console.WriteLine("Latch to ADDR_CTRL #2 failed\n");
                return(false);
            }
            return(true);
        }
Пример #2
0
        private void hScrollBar2_Scroll(object sender, ScrollEventArgs e)
        {
            byte[] buf     = BitConverter.GetBytes(hScrollBar2.Value); // gets 4 bytes
            byte[] tempbuf = new byte[4];

            if (buf.Length < 4)
            {
                return;
            }

            // put bytes in proper order MSB to LSB
            for (int i = 0; i < buf.Length; i++)
            {
                tempbuf[buf.Length - 1 - i] = buf[i];
            }

            buf = tempbuf;

            textBox1.Text = ((((float)hScrollBar2.Value * (float)100)) / (float)Math.Pow(2, 32)).ToString();
            textBox2.Text = buf[0].ToString("X2")
                            + ":" + buf[1].ToString("X2")
                            + ":" + buf[2].ToString("X2")
                            + ":" + buf[3].ToString("X2");

            // send to OZY register 0x01, 32 bits
            if (hdev != IntPtr.Zero)
            {
                OZY.Write_SPI(hdev, 0, 0x01, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            }
        }
Пример #3
0
        public bool readI2CByte(byte targetAddr)
        {
            bool result;

            result = OZY.Read_I2C(hdev, targetAddr, ref dummyByte);
            return(result);
        }
Пример #4
0
        public bool readI2CTwoBytes(byte targetAddr)
        {
            bool result;

            result = OZY.Read_I2C(hdev, targetAddr, ref dummyTwoBytes);
            return(result);
        }
Пример #5
0
        private void btnSendSR_Click(object sender, EventArgs e)
        {
            int cmd = Convert.ToInt32(txtSR.Text);

            byte[] buf = BitConverter.GetBytes(cmd);

            byte[] tempbuf = new byte[4];

            if (buf.Length < 4)
            {
                return;
            }

            // put bytes in proper order MSB to LSB
            for (int i = 0; i < buf.Length; i++)
            {
                tempbuf[buf.Length - 1 - i] = buf[i];
            }

            for (int i = 0; i < buf.Length; i++)
            {
                listBox1.Items.Add(buf[i]);
            }

            buf = tempbuf;
            // send to OZY register 0x02, 32 bits
            if (hdev != IntPtr.Zero)
            {
                OZY.Write_SPI(hdev, 0, 0x02, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            }
        }
Пример #6
0
        bool writeDataSPI(IntPtr hdev, byte val)
        {
            bool rc;

            byte[] buf = new byte[1];
            buf[0] = val;
            rc     = OZY.Write_SPI(usb_dev_handle, 0, ADDR_DATA, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf);
            Console.WriteLine("WriteSPI rc: " + rc);
            return(rc);
        }
Пример #7
0
        private void btnRd_Click(object sender, EventArgs e)
        {
            byte[] buf = new byte[4];

            if (hdev != IntPtr.Zero)
            {
                OZY.Read_SPI(hdev, 0, 0x02, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), ref buf);
            }

            for (int i = 0; i < buf.Length; i++)
            {
                listBox1.Items.Add(buf[i]);
            }
        }
Пример #8
0
        int readStatusSPI(IntPtr usb_dev_handle)
        {
            int rc;

            byte[] buf = new byte[1];

            buf[0] = 0x00;
            byte addr = 0x43;

            if ((OZY.Read_SPI(usb_dev_handle, 0, addr, OZY.SPI_EN_FPGA, OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1, ref buf)))
            {
                Console.WriteLine("Read from address " + addr.ToString("X") + " : " + buf[0].ToString("X"));
                Console.WriteLine("");
                rc = buf[0];
            }
            else
            {
                Console.WriteLine("Failed to read address " + addr);
                rc = -1;
            }
            return(rc);
        }
Пример #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello.");
            Console.WriteLine("arg count: " + args.Length);
            for (int j = 0; j < args.Length; j++)
            {
                Console.WriteLine(args[j]);
            }


            double new_freq;

            if (args[0].Equals("RESET"))
            {
                new_freq = 0;
            }
            else
            {
                new_freq = (double)float.Parse(args[0]);
            }

            IntPtr usb_dev_handle = IntPtr.Zero;

            try
            {
                usb_dev_handle = USB.InitFindAndOpenDevice(OZY_VID, OZY_PID);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }



            do
            {
                byte[] bytes = new byte[2];



                if (new_freq == 0.0)
                {
                    bytes[0] = 135;  // reset/mem ctl reg
                    bytes[1] = 0x80; // recall bit
                    if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                    {
                        Console.WriteLine("Failed to write reset to device");
                        break;
                    }
                    Console.WriteLine("Device Reset!");
                    break;
                }
                bytes[0] = 135; // reset/mem ctl reg
                bytes[1] = 0x1; // recall bit
                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to read NVM to RAM!");
                    break;
                }


                bytes    = new byte[1];
                bytes[0] = 0x7;  // want to start reading at addr 7;

                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to write to I2C addr 0x55");
                    break;
                }

                bytes = new byte[6];   // need to read 6 bytes
                bool rc;
                rc = OZY.Read_I2C(usb_dev_handle, SI570_ADDR, ref bytes);
                Console.WriteLine("Read_I2C returned: " + rc);
                for (int i = 0; i < bytes.Length; i++)
                {
                    Console.WriteLine("data[" + i + "]: " + bytes[i]);
                }

                int hs_div = (bytes[0] >> 5) & 7;
                int n1     = (bytes[0] & 0x1f) << 2;
                n1 |= (bytes[1] >> 6) & 3;

                Console.WriteLine("HS_DIV divider: " + HS_MAP[hs_div] + " (" + hs_div + ")");
                Console.WriteLine("N1: " + n1);

                // see the si570 data sheet for info on this -- ref freq is 38 bits -- 10 bits whole number, 28 bits
                // fractional
                int ref_freq = (bytes[1] & 0x3f) << 4;
                ref_freq |= (bytes[2] >> 4) & 0xf;

                int ref_lo = (bytes[5] & 0xff);
                ref_lo |= (bytes[4] & 0xff) << 8;
                ref_lo |= (bytes[3] & 0xff) << 16;
                ref_lo |= (bytes[2] & 0xf) << 24;


                Console.WriteLine("ref_whole: " + ref_freq + " reff_fractional: " + ref_lo);
                double reff = ref_lo / TWO_POWER28;
                reff += ref_freq;

                Console.WriteLine("Ref Freq: " + reff);

                double fxtal = (FREQ_NOMINAL * (1 + n1) * HS_MAP[hs_div]) / reff;


                Console.WriteLine("fxtal: " + fxtal);



                Console.WriteLine("new_freq: " + new_freq);
                double total_divide_max = FOSC_MAX / new_freq;
                double total_divide_min = FOSC_MIN / new_freq;

                // given the new freq, find a HS * N1 we can live with
                // between total_dive_min and total_divide_max

                int min_divide = (int)Math.Ceiling(total_divide_min);
                int max_divide = (int)Math.Floor(total_divide_max);


                int new_hs    = -1;
                int total_div = 0;

                for (int i = min_divide; i <= max_divide; i++)
                {
                    total_div = i;
                    new_hs    = findGoodHS(total_div);
                    if (new_hs > 0)
                    {
                        break;
                    }
                }

                if (new_hs <= 0)
                {
                    Console.WriteLine("could not find good HS divider!!\n");
                    break;
                }

                int new_n1 = total_div / new_hs;
                Console.WriteLine("hs: " + new_hs + " n1: " + new_n1);

                double f_osc = new_freq * new_n1 * new_hs;

                double new_reff = f_osc / fxtal;

                Console.WriteLine("f_osc: " + f_osc + " new_reff: " + new_reff);

                // debug stuff
                // new_reff = 43.3639223910868;
                // new_hs = 4;
                // new_n1 = 22;

                // calculate reffreq integer
                Console.WriteLine("new_reff (float): " + new_reff);
                uint new_reff_whole = (uint)Math.Floor(new_reff);
                Console.WriteLine("new_reff_whole: " + new_reff_whole);
                ulong reff_bytes = ((ulong)new_reff_whole) << 28;
                Console.WriteLine("reff bytes (whole): " + reff_bytes);
                double new_reff_fraction = new_reff - (double)new_reff_whole;
                Console.WriteLine("new_reff_fraction: " + new_reff_fraction);
                uint fractional_bytes = (uint)Math.Truncate((double)new_reff_fraction * (double)TWO_POWER28);
                Console.WriteLine("fractional bytes: " + fractional_bytes);
                reff_bytes |= fractional_bytes;
                Console.WriteLine("reff bytes: " + reff_bytes);



                byte[] new_regs = new byte[6];

                new_regs[5] = (byte)(reff_bytes & 0xff);
                new_regs[4] = (byte)((reff_bytes >> 8) & 0xff);
                new_regs[3] = (byte)((reff_bytes >> 16) & 0xff);
                new_regs[2] = (byte)((reff_bytes >> 24) & 0xff);

                new_regs[1] = (byte)(((ulong)(reff_bytes >> 32)) & 0x3f);
                --new_n1;
                new_regs[1] |= (byte)((new_n1 & 3) << 6);

                new_regs[0] = (byte)((new_n1 >> 2) & 0x1f);
                int new_hs_bits = -1;
                for (int j = 0; j < HS_MAP.Length; j++)
                {
                    if (HS_MAP[j] == new_hs)
                    {
                        new_hs_bits = j;
                        break;
                    }
                }
                if (new_hs_bits == -1)
                {
                    Console.WriteLine("Bad HS: " + new_hs);
                    break;
                }
                new_regs[0] |= (byte)(new_hs_bits << 5);

                for (int j = 0; j < new_regs.Length; j++)
                {
                    Console.WriteLine("newRegs[" + j + "]: " + new_regs[j]);
                }

                bytes    = new byte[2];
                bytes[0] = 137;  // freezo dco register
                bytes[1] = 0x10; // assert freeze bit
                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to Freeze DCO!");
                    break;
                }


                bytes    = new byte[7];
                bytes[0] = 0x7; // starting addr
                for (int j = 0; j < 6; j++)
                {
                    bytes[1 + j] = new_regs[j];
                }
                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to Write new regs!");
                    break;
                }



                bytes    = new byte[2];
                bytes[0] = 137; // freezo dco register
                bytes[1] = 0x0; // deassert freeze bit
                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to defrost DCO!");
                    break;
                }

                bytes[0] = 135;  // new freq reg
                bytes[1] = 0x40; // deassert freeze bit
                if (!(OZY.Write_I2C(usb_dev_handle, SI570_ADDR, bytes)))
                {
                    Console.WriteLine("Failed to assert new freq!");
                    break;
                }
            } while (false);

            Console.WriteLine("Closing USB device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #10
0
        static void Main(string[] args)
        {
            if ((args.Length != 2) || (args.Length == 0))
            {
                Console.WriteLine("usage: read_EEPROM <VID> <PID>");
                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);

            IntPtr usb_dev_handle = USB.InitFindAndOpenDevice(vid, pid);

            if ((OZY.Read_I2C_Speed(usb_dev_handle) == 1))
            {
                Console.WriteLine("I2C speed is 400kHz");
            }
            else
            {
                Console.WriteLine("I2C speed is 100kHz");
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #11
0
        static void Main(string[] args)
        {
            if ((args.Length != 4) || (args.Length == 0))
            {
                Console.WriteLine("usage: write_SPI <VID> <PID> <address in hex> <value in hex>");
                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 addr in Hex (0x0)");
                    return;
                }
                else
                {
                    args[2] = args[2].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify addr in Hex (0x0)");
                return;
            }

            int addr = int.Parse(args[2], NumberStyles.HexNumber);

            if (args[3].Length > 2)
            {
                if (args[3].Substring(0, 2) != "0x")
                {
                    Console.WriteLine("You must specify value in Hex (0x0)");
                    return;
                }
                else
                {
                    args[3] = args[3].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify value in Hex (0x0)");
                return;
            }

            int value = int.Parse(args[3], NumberStyles.HexNumber);

            libUSB_Interface.usb_bus bus;

            try
            {
                libUSB_Interface.usb_init();
                Console.WriteLine("finding busses...");
                libUSB_Interface.usb_find_busses();
                Console.WriteLine("finding devices...");
                libUSB_Interface.usb_find_devices();
                Console.WriteLine("usb_get_busses...");
                bus = libUSB_Interface.usb_get_busses();
                Console.WriteLine("bus location: " + bus.location.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle;

            try
            {
                usb_dev_handle = libUSB_Interface.usb_open(fdev);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            byte[] buf = new byte[1];
            addr = addr & 0x3F;

            buf[0] = (byte)value;

            if ((OZY.Write_SPI(usb_dev_handle, 0, (byte)addr, OZY.SPI_EN_FPGA, (OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1), buf)))
            {
                Console.WriteLine("Wrote to address: " + addr + " : " + value);
            }
            else
            {
                Console.WriteLine("Failed to write address: " + addr);
            }
            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #12
0
        static void Main(string[] args)
        {
            if ((args.Length != 3) || (args.Length == 0))
            {
                Console.WriteLine("usage: upload_FPGA <VID> <PID> <filename>");
                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);

            string filename = args[2];

            if (!(File.Exists(filename)))
            {
                Console.WriteLine(filename + " does not exist!");
                return;
            }

            libUSB_Interface.usb_bus bus;

            try
            {
                libUSB_Interface.usb_init();
                Console.WriteLine("finding busses...");
                libUSB_Interface.usb_find_busses();
                Console.WriteLine("finding devices...");
                libUSB_Interface.usb_find_devices();
                Console.WriteLine("usb_get_busses...");
                bus = libUSB_Interface.usb_get_busses();
                Console.WriteLine("bus location: " + bus.location.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle;

            try
            {
                usb_dev_handle = libUSB_Interface.usb_open(fdev);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            if (!(OZY.Load_FPGA(usb_dev_handle, filename)))
            {
                Console.WriteLine("FPGA LOAD FAILED!");
            }
            else
            {
                Console.WriteLine("FPGA LOAD SUCCEEDED!");
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #13
0
        static void Main(string[] args)
        {
            if ((args.Length < 5) || (args.Length == 0))
            {
                Console.WriteLine("usage: write_I2C <VID> <PID> <i2c_address in hex> <count in hex> <bytes in hex...>");
                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 i2c_addr in Hex (0x0)");
                    return;
                }
                else
                {
                    args[2] = args[2].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify i2c_addr in Hex (0x0)");
                return;
            }

            int i2c_addr = int.Parse(args[2], NumberStyles.HexNumber);

            if (args[3].Length > 2)
            {
                if (args[3].Substring(0, 2) != "0x")
                {
                    Console.WriteLine("You must specify count in Hex (0x0)");
                    return;
                }
                else
                {
                    args[3] = args[3].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify count in Hex (0x0)");
                return;
            }

            int count = int.Parse(args[3], NumberStyles.HexNumber);

            byte[] bytes = new byte[args.Length - 4];

            for (int i = 4; i < args.Length; i++)
            {
                if (args[i].Length > 2)
                {
                    if (args[i].Substring(0, 2) != "0x")
                    {
                        Console.WriteLine("You must specify bytes in Hex (0x0)");
                        return;
                    }
                    else
                    {
                        args[i] = args[i].Substring(2);
                    }
                }
                else
                {
                    Console.WriteLine("You must specify bytes in Hex (0x0)");
                    return;
                }

                bytes[i - 4] = byte.Parse(args[i], NumberStyles.HexNumber);
            }

            IntPtr usb_dev_handle = IntPtr.Zero;

            try
            {
                usb_dev_handle = USB.InitFindAndOpenDevice(vid, pid);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            if ((OZY.Write_I2C(usb_dev_handle, i2c_addr, bytes)))
            {
                Console.WriteLine("Wrote to address: " + i2c_addr);
            }
            else
            {
                Console.WriteLine("Failed to write address: " + i2c_addr);
            }
            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #14
0
        static void Main(string[] args)
        {
            if ((args.Length != 3) || (args.Length == 0))
            {
                Console.WriteLine("usage: set_CPUSpeed <VID> <PID> <value in hex {0x00=12MHz, 0x01=24MHz, 0x02=48MHz}> ");
                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_CPU_Speed(usb_dev_handle, value)))
            {
                Console.WriteLine("Set CPU speed successful");
                switch (value)
                {
                case 0:
                    Console.WriteLine("Set speed to 12 MHz");
                    break;

                case 1:
                    Console.WriteLine("Set speed to 24 MHz");
                    break;

                case 2:
                    Console.WriteLine("Set speed to 48 MHz");
                    break;

                default:
                    break;
                }
            }
            else
            {
                Console.WriteLine("Failed to set CPU speed");
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #15
0
        static void Main(string[] args)
        {
            if ((args.Length != 4) || (args.Length == 0))
            {
                Console.WriteLine("usage: set_LED <VID> <PID> <which_led = 0|1> <state = ON|OFF>");
                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);

            int which = int.Parse(args[2], NumberStyles.HexNumber);

            if (which > 1 || which < 0)
            {
                Console.WriteLine("Valid values for which_led are 0 or 1");
                return;
            }

            bool state;

            if (args[3] == "ON" ||
                args[3] == "on" ||
                args[3] == "On" ||
                args[3] == "1" ||
                args[3] == "true" ||
                args[3] == "TRUE" ||
                args[3] == "True")
            {
                state = true;
            }
            else if (args[3] == "OFF" ||
                     args[3] == "off" ||
                     args[3] == "Off" ||
                     args[3] == "0" ||
                     args[3] == "false" ||
                     args[3] == "FALSE" ||
                     args[3] == "False")
            {
                state = false;
            }
            else
            {
                Console.WriteLine("Valid values for state are ON or OFF");
                return;
            }

            libUSB_Interface.usb_bus bus;

            try
            {
                libUSB_Interface.usb_init();
                Console.WriteLine("finding busses...");
                libUSB_Interface.usb_find_busses();
                Console.WriteLine("finding devices...");
                libUSB_Interface.usb_find_devices();
                Console.WriteLine("usb_get_busses...");
                bus = libUSB_Interface.usb_get_busses();
                Console.WriteLine("bus location: " + bus.location.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle;

            try
            {
                usb_dev_handle = libUSB_Interface.usb_open(fdev);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            Console.WriteLine("Setting LED " + which.ToString() + " " + state.ToString());
            OZY.Set_LED(usb_dev_handle, which, state);

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #16
0
        static void Main(string[] args)
        {
            if ((args.Length != 4) || (args.Length == 0))
            {
                Console.WriteLine("usage: read_I2C <VID> <PID> <i2c_address in hex> <length in hex>");
                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 i2c_addr in Hex (0x0)");
                    return;
                }
                else
                {
                    args[2] = args[2].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify i2c_addr in Hex (0x0)");
                return;
            }

            int i2c_addr = int.Parse(args[2], NumberStyles.HexNumber);


            if (args[3].Length > 2)
            {
                if (args[3].Substring(0, 2) != "0x")
                {
                    Console.WriteLine("You must specify length in Hex (0x0)");
                    return;
                }
                else
                {
                    args[3] = args[3].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify length in Hex (0x0)");
                return;
            }

            int length = int.Parse(args[3], NumberStyles.HexNumber);


            libUSB_Interface.usb_init();
            Console.WriteLine("finding busses...");
            libUSB_Interface.usb_find_busses();
            Console.WriteLine("finding devices...");
            libUSB_Interface.usb_find_devices();
            Console.WriteLine("usb_get_busses...");
            libUSB_Interface.usb_bus bus = libUSB_Interface.usb_get_busses();
            Console.WriteLine("bus location: " + bus.location.ToString());

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle = libUSB_Interface.usb_open(fdev);

            Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());

            byte[] buf = new byte[length];

            if ((OZY.Read_I2C(usb_dev_handle, i2c_addr, ref buf)))
            {
                Console.WriteLine("Read from address " + i2c_addr + ":");
                for (int i = 0; i < buf.Length; i++)
                {
                    Console.Write(buf[i] + ":");
                }
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("Failed to read address " + i2c_addr);
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #17
0
        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...");
        }
Пример #18
0
        static void Main(string[] args)
        {
            if ((args.Length != 3) || (args.Length == 0))
            {
                Console.WriteLine("usage: read_SPI <VID> <PID> <address in hex>");
                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 addr in Hex (0x0)");
                    return;
                }
                else
                {
                    args[2] = args[2].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify addr in Hex (0x0)");
                return;
            }

            int addr = int.Parse(args[2], NumberStyles.HexNumber);

            libUSB_Interface.usb_init();
            Console.WriteLine("finding busses...");
            libUSB_Interface.usb_find_busses();
            Console.WriteLine("finding devices...");
            libUSB_Interface.usb_find_devices();
            Console.WriteLine("usb_get_busses...");
            libUSB_Interface.usb_bus bus = libUSB_Interface.usb_get_busses();
            Console.WriteLine("bus location: " + bus.location.ToString());

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle = libUSB_Interface.usb_open(fdev);

            Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());

            byte[] buf = new byte[1];

            buf[0] = 0x00;
            addr   = addr | 0x40;

            if ((OZY.Read_SPI(usb_dev_handle, 0, (byte)addr, OZY.SPI_EN_FPGA, OZY.SPI_FMT_MSB | OZY.SPI_FMT_HDR_1, ref buf)))
            {
                Console.WriteLine("Read from address " + addr.ToString("X") + " : " + buf[0].ToString("X"));
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("Failed to read address " + addr);
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #19
0
        static void Main(string[] args)
        {
            if ((args.Length != 2) || (args.Length == 0))
            {
                Console.WriteLine("usage: program_OZYEEPROM <VID> <PID>");
                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);

            libUSB_Interface.usb_bus bus;

            try
            {
                libUSB_Interface.usb_init();
                Console.WriteLine("finding busses...");
                libUSB_Interface.usb_find_busses();
                Console.WriteLine("finding devices...");
                libUSB_Interface.usb_find_devices();
                Console.WriteLine("usb_get_busses...");
                bus = libUSB_Interface.usb_get_busses();
                Console.WriteLine("bus location: " + bus.location.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle;

            try
            {
                usb_dev_handle = libUSB_Interface.usb_open(fdev);
                Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return;
            }

            byte[] buf = new byte[8];

            int i2c_addr = 0x51; // address of 24LC128 EEPROM

            buf[0] = 0xC0;       // C0 load
            buf[1] = 0xFE;       // low byte of VID
            buf[2] = 0xFF;       // high byte of VID
            buf[3] = 0xFF;       // low byte of PID
            buf[4] = 0x00;       // high byte of PID
            buf[5] = 0x01;       // low byte of DID <-- revision number
            buf[6] = 0x00;       // high byte of DID
            buf[7] = 0x00;       // configuration byte

            if ((OZY.Write_EEPROM(usb_dev_handle, i2c_addr, 0x00, buf)))
            {
                Console.WriteLine("Programming Successful!");
            }
            else
            {
                Console.WriteLine("Failed to program EEPROM");
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #20
0
        static void Main(string[] args)
        {
            if ((args.Length != 5) || (args.Length == 0))
            {
                Console.WriteLine("usage: write_EEPROM <VID> <PID> <i2c_address in hex> <start_pos in hex> <value in hex>");
                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 i2c_addr in Hex (0x0)");
                    return;
                }
                else
                {
                    args[2] = args[2].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify i2c_addr in Hex (0x0)");
                return;
            }

            int i2c_addr = int.Parse(args[2], NumberStyles.HexNumber);

            if (args[3].Length > 2)
            {
                if (args[3].Substring(0, 2) != "0x")
                {
                    Console.WriteLine("You must specify start_pos in Hex (0x0)");
                    return;
                }
                else
                {
                    args[3] = args[3].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify start_pos in Hex (0x0)");
                return;
            }

            int start = int.Parse(args[3], NumberStyles.HexNumber);

            if (args[4].Length > 2)
            {
                if (args[4].Substring(0, 2) != "0x")
                {
                    Console.WriteLine("You must specify value in Hex (0x0)");
                    return;
                }
                else
                {
                    args[4] = args[4].Substring(2);
                }
            }
            else
            {
                Console.WriteLine("You must specify value in Hex (0x0)");
                return;
            }
            int value = int.Parse(args[4], NumberStyles.HexNumber);

            libUSB_Interface.usb_init();
            Console.WriteLine("finding busses...");
            libUSB_Interface.usb_find_busses();
            Console.WriteLine("finding devices...");
            libUSB_Interface.usb_find_devices();
            Console.WriteLine("usb_get_busses...");
            libUSB_Interface.usb_bus bus = libUSB_Interface.usb_get_busses();
            Console.WriteLine("bus location: " + bus.location.ToString());

            Console.WriteLine("Checking for VID PID...");
            libUSB_Interface.usb_device fdev = USB.FindDevice(bus, vid, pid);
            if (fdev != null)
            {
                Console.WriteLine("Found VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
            }
            else
            {
                Console.WriteLine("did not find VID PID: " + vid.ToString("x") + " " + pid.ToString("x"));
                return;
            }

            Console.WriteLine("Trying to open device...");

            IntPtr usb_dev_handle = libUSB_Interface.usb_open(fdev);

            Console.WriteLine("Device handle is: " + usb_dev_handle.ToString());

            byte[] buf = new byte[1];

            buf[0] = (byte)value;

            if ((OZY.Write_EEPROM(usb_dev_handle, i2c_addr, start, buf)))
            {
                Console.WriteLine("Writing address " + i2c_addr);
            }
            else
            {
                Console.WriteLine("Failed to write address " + i2c_addr);
            }

            Console.WriteLine("Closing device...");
            libUSB_Interface.usb_close(usb_dev_handle);
            Console.WriteLine("done...");
        }
Пример #21
0
        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;
                    }
                }
            }
        }