I have a board (the DSP4YOU AVB-DG board), which puts I2C_SCL on PORT_4A[0] and SDA on PORT_4B[0]. This board's software uses the older module_i2c, rather than lib_i2c, and the board works fine when using their software.
I'm repurposing the board, and having trouble getting lib_i2c to work with this setup.
The I2C address that gets sent seems to have little to do with the I2C address that is passed it :-)
Code: Select all
#include <xs1.h>
#include <platform.h>
#include <i2s.h>
#include <gpio.h>
#include <i2c.h>
#include <stdio.h>
port p_sda = XS1_PORT_4A;
port p_scl = XS1_PORT_4B;
void run_tile_1(client i2c_master_if i2c)
{
uint8_t data[2];
i2c_res_t res;
data[0]=0xff;
data[1] = 0xff;
res = i2c.read(1, data, 1, 1);
res = i2c.read(2, data, 1, 1);
res = i2c.read(4, data, 1, 1);
res = i2c.read(8, data, 1, 1);
res = i2c.read(16, data, 1, 1);
res = i2c.read(32, data, 1, 1);
res = i2c.read(64, data, 1, 1);
res = i2c.read(128, data, 1, 1);
while(1);
}
int main(void)
{
i2c_master_if i2c[1];
par {
on tile[1] : i2c_master(i2c, 1, p_scl, p_sda, 100);
on tile[1] : run_tile_1(i2c[0]);
}
return 0;
}
addr in read() (decimal), addr on bus (binary)
1, 0000000
2, 0000000
4, 0100000,
8, 0000000,
16, 0000000,
32, 0000000,
64, 1000000,
128, 0000000,
Other than the SDA and SCL, there is nothing connected to ports 4A and 4B.
Any idea what could be going on? It seems like the 4-bit ports are throwing the library off.