tjump
|
I think you are mixing your user terms for the SRV. Direct commnads are not related to the C interpreter (picoC). Direct commands for reading I2C devices are in the form irab, iRab, iMabc. The C interpreter is picoC. Reading I2C with picoC commands differ depending on what you want to read. There is the generic process to read I2C devices in the form 'readi2c(x, y);' where 'x' is the I2C device address (int device) and 'y' is the port on the device (int register). However, if you are using one of the ADC devices already pre-configured for the SRV, to read these analog devices the code is in the form 'analog(x);' where 'x' is the port of the analog device (int channel). Now, to your specific device at address 0x50 your are correct with the first part of your 'read' request: readi2c(0x50, y); but what you put in for 'y' depends on the device. It will most likely be in hex form (0x..) but probably not 0x00. For instance, there is a digital I/O used on the RCM with eight ports. A picoC read request for this device looks like: readi2c(0x27, 0x12); to read bank A ports (ports 1 - 8) readi2c(0x27, 0x13); to read bank B ports (ports 1 - 8) Now, once you've read the device you must specify what to do with the data? If you simply want to see what the value is you need to call a print function 'print(f)' so the value of your read is displayed. Example: int x; x = readi2c(0x27, 0x13); printf("%d\n", (x & 0x02)); exit(); In this example, the digital I/O is read (all eight ports have a value), but only the value of port 2 is displayed per the print(f) statement. So, you need to understand what your device offers as options to read to know what value to put into the 'y' section of the read statement; then you need to understand what you want to do with the data. T. Jump
|