static void Main() { int N_BITS = 4; M2k ctx = libm2k.m2kOpen(); M2kDigital dig = ctx.getDigital(); dig.setSampleRateIn(100000); dig.setSampleRateOut(100000); for (uint i = 0; i < N_BITS; i++) { dig.setDirection(i, DIO_DIRECTION.DIO_OUTPUT); dig.enableChannel(i, true); } VectorUS bufferOut = new VectorUS(); VectorUS bufferIn = new VectorUS(); for (ushort i = 0; i < (1 << N_BITS); i++) { bufferOut.Add(i); } dig.setCyclic(true); dig.push(bufferOut); bufferIn = dig.getSamples(1000); foreach (var val in bufferIn) { Console.Write(val + " \n"); } dig.stop(); libm2k.contextClose(ctx); }
public static void RefillThread() { for (int refills = 0; refills < NUMBER_OF_BUFFERS; refills++) { while (tmp_buffer.Count != 0) { refill_reset_event.WaitOne(); } if (tmp_buffer.Count == 0) { tmp_buffer = dig.getSamples(IN_NO_SAMPLES); } refill_reset_event.Set(); refill_reset_event.Reset(); } }