public void TestmodeOff() { var rddata = RBCP.Interpret(_rbcp.Read(DACAddress(0x01))); byte pt = (byte)(rddata.Item2[0] & 0xfb); _rbcp.Write(DACAddress(0x01), new byte[] { pt }); }
public void ADCChannelSwap() { byte[] channel_swap_addr = { 0x12, 0x00, 0x00, 0x00 }; var data = _rbcp.Read(channel_swap_addr); byte[] write_data = new byte[1]; if (RBCP.Interpret(data).Item2[0] == 0) { write_data[0] = 1; } else { write_data[0] = 0; } _rbcp.Write(channel_swap_addr, write_data); }
public void DACChannelSwap() { byte[] channel_swap_addr = { 0x22, 0x00, 0x00, 0x02 }; var data = _rbcp.Read(channel_swap_addr); byte[] write_data = new byte[1]; Console.WriteLine("Swap data: {0}", RBCP.Interpret(data).Item2[0]); Console.WriteLine("Swap data bool: {0}", RBCP.Interpret(data).Item2[0] == 0); if (RBCP.Interpret(data).Item2[0] == 0) { write_data[0] = 1; } else { write_data[0] = 0; } _rbcp.Write(channel_swap_addr, write_data); }
public void WritePhase(int channel, double frequency, double phase) { /* * // Address * byte mae = (byte)(channel >> 4); * byte ato = (byte)((channel - (mae << 4)) << 4); * var address = new byte[] {0x40, 0x00, mae, ato}; * // Phase offset * var phase_offset = (long)((phase / 360.0) * width_factor); * var poff_bytes = System.BitConverter.GetBytes(phase_offset).Take(4).ToList(); * // Phase increment * var phase_increment = (long)(frequency % Program.ADCSampleRate / Program.ADCSampleRate * width_factor); * var pinc_bytes = System.BitConverter.GetBytes(phase_increment).Take(4).ToList(); */ short towrite = (short)(4 * (channel) + 1); var address = new List <byte> { 0x40, 0x00 }; address.AddRange(BitConverter.GetBytes(towrite).Reverse()); // Write var target_freq = frequency > 0 ? frequency : (frequency % Program.ADCSampleRate) + Program.ADCSampleRate; Console.WriteLine("DEBUG freq: {0} Hz", target_freq); var phase_increment = (long)(target_freq / Program.ADCSampleRate * width_factor); Console.WriteLine("DEBUG pinc: {0}", phase_increment); var pinc_bytes = System.BitConverter.GetBytes(phase_increment).Take(4).ToList(); pinc_bytes.Reverse(); Console.WriteLine("DEBUG pinc bytes: {0}", BitConverter.ToString(pinc_bytes.ToArray())); var wr_data = pinc_bytes.ToArray(); var ret_data = _rbcp.Write(address.ToArray(), wr_data); var intprt_data = RBCP.Interpret(ret_data); if (!address.SequenceEqual(intprt_data.Item1) || !wr_data.SequenceEqual(intprt_data.Item2)) { throw new Exception("Wrote <-> Read do not match"); } _rbcp.Write(new byte[] { 0x70, 0, 0, 0 }, new byte[] { 0x01 }); }