public static int aa_i2c_write_ext(int aardvark, short slave_addr, AardvarkI2cFlags flags, short num_bytes, byte[] data_out, ref short num_written) { if (!AA_LIBRARY_LOADED) { return(-4); } short num = (short)tp_min((long)num_bytes, (long)data_out.Length); return(net_aa_i2c_write_ext(aardvark, slave_addr, flags, num, data_out, ref num_written)); }
// enum AardvarkI2cFlags (from declaration above) // AA_I2C_NO_FLAGS = 0x00 // AA_I2C_10_BIT_ADDR = 0x01 // AA_I2C_COMBINED_FMT = 0x02 // AA_I2C_NO_STOP = 0x04 // AA_I2C_SIZED_READ = 0x10 // AA_I2C_SIZED_READ_EXTRA1 = 0x20 /* Read a stream of bytes from the I2C slave device. */ public static int aa_i2c_read( int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort num_bytes, byte[] data_in ) { if (!AA_LIBRARY_LOADED) { return((int)AardvarkStatus.AA_INCOMPATIBLE_LIBRARY); } ushort data_in_num_bytes = (ushort)tp_min(num_bytes, data_in.Length); return(net_aa_i2c_read(aardvark, slave_addr, flags, data_in_num_bytes, data_in)); }
/* * Do an atomic write+read to an I2C slave device by first * writing a stream of bytes to the I2C slave device and then * reading a stream of bytes back from the same slave device. * This API function returns the number of bytes written into * the num_written variable and the number of bytes read into * the num_read variable. The return value of the function is * the status given as (read_status << 8) | (write_status). */ public static int aa_i2c_write_read( int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort out_num_bytes, byte[] out_data, ref ushort num_written, ushort in_num_bytes, byte[] in_data, ref ushort num_read ) { if (!AA_LIBRARY_LOADED) { return((int)AardvarkStatus.AA_INCOMPATIBLE_LIBRARY); } ushort out_data_out_num_bytes = (ushort)tp_min(out_num_bytes, out_data.Length); ushort in_data_in_num_bytes = (ushort)tp_min(in_num_bytes, in_data.Length); return(net_aa_i2c_write_read(aardvark, slave_addr, flags, out_data_out_num_bytes, out_data, ref num_written, in_data_in_num_bytes, in_data, ref num_read)); }
public static int aa_i2c_write( int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort num_bytes, byte[] data_out ) { if (!AA_LIBRARY_LOADED) { return((int)AardvarkStatus.AA_INCOMPATIBLE_LIBRARY); } ushort data_out_num_bytes = (ushort)tp_min(num_bytes, data_out.Length); try { return(net_aa_i2c_write(aardvark, slave_addr, flags, data_out_num_bytes, data_out)); } catch { Console.WriteLine("System memory access violation"); return(-1); } }
public static int aa_i2c_write_ext(int aardvark, short slave_addr, AardvarkI2cFlags flags, short num_bytes, byte[] data_out, ref short num_written) { if (!AA_LIBRARY_LOADED) { return -4; } short num = (short) tp_min((long) num_bytes, (long) data_out.Length); return net_aa_i2c_write_ext(aardvark, slave_addr, flags, num, data_out, ref num_written); }
private static extern int net_aa_i2c_write(int aardvark, short slave_addr, AardvarkI2cFlags flags, short num_bytes, [In] byte[] data_out);
private static extern int net_aa_i2c_write_ext(int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort num_bytes, [In] byte[] data_out, ref ushort num_written);
private static extern int net_aa_i2c_write_read(int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort out_num_bytes, [In] byte[] out_data, ref ushort num_written, ushort in_num_bytes, [Out] byte[] in_data, ref ushort num_read);
private static extern int net_aa_i2c_read_ext(int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort num_bytes, [Out] byte[] data_in, ref ushort num_read);
private static extern int net_aa_i2c_read(int aardvark, short slave_addr, AardvarkI2cFlags flags, short num_bytes, [Out] byte[] data_in);
/* * Do an atomic write+read to an I2C slave device by first * writing a stream of bytes to the I2C slave device and then * reading a stream of bytes back from the same slave device. * This API function returns the number of bytes written into * the num_written variable and the number of bytes read into * the num_read variable. The return value of the function is * the status given as (read_status << 8) | (write_status). */ public static int aa_i2c_write_read( int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort out_num_bytes, byte[] out_data, ref ushort num_written, ushort in_num_bytes, byte[] in_data, ref ushort num_read ) { if (!AA_LIBRARY_LOADED) return (int)AardvarkStatus.AA_INCOMPATIBLE_LIBRARY; ushort out_data_out_num_bytes = (ushort)tp_min(out_num_bytes, out_data.Length); ushort in_data_in_num_bytes = (ushort)tp_min(in_num_bytes, in_data.Length); return net_aa_i2c_write_read(aardvark, slave_addr, flags, out_data_out_num_bytes, out_data, ref num_written, in_data_in_num_bytes, in_data, ref num_read); }
/* * Write a stream of bytes to the I2C slave device. * This API function returns the number of bytes written into * the num_written variable. The return value of the function * is a status code. */ public static int aa_i2c_write_ext( int aardvark, ushort slave_addr, AardvarkI2cFlags flags, ushort num_bytes, byte[] data_out, ref ushort num_written ) { if (!AA_LIBRARY_LOADED) return (int)AardvarkStatus.AA_INCOMPATIBLE_LIBRARY; ushort data_out_num_bytes = (ushort)tp_min(num_bytes, data_out.Length); return net_aa_i2c_write_ext(aardvark, slave_addr, flags, data_out_num_bytes, data_out, ref num_written); }