Hello everybody,
I'm trying to realize a bridge I2C - SPI with a board that carries a PSoC 5LP. The board receives I2C packets from another board with Linux inside (commands like i2cset and i2cget) and converts them to SPI format towards a board with a camera sensor. The first board is a I2C master and the sensor is an SPI slave, so the PSoC implements an I2C slave and an SPI master.
The problem I am facing with is that I don't understand how to correctly detect, in the PSoC, that I have received a get or a a set instruction. It doesn't seem to exist any interrupt callback that signal that event; there are some flags, though, that are set in a odd way and, it seems, not constant sequence. Due to this behaviour and because I check these status flags to detect the sets and gets, sometimes after a get instruction (correctly detected) it also catch a get instruction, thus performing an undesidered write on SPI.
The pseudo code is the following:
while(1)
{
if(write status flags are set)
do spi write
else if(read status flags are set)
{
do spi read
copy data to i2c buffer
}
}
Does anyone know how to correctly detect the i2c packets? I'm using PSoC Creator 4.1 as IDE.
Thank you
I'm trying to realize a bridge I2C - SPI with a board that carries a PSoC 5LP. The board receives I2C packets from another board with Linux inside (commands like i2cset and i2cget) and converts them to SPI format towards a board with a camera sensor. The first board is a I2C master and the sensor is an SPI slave, so the PSoC implements an I2C slave and an SPI master.
The problem I am facing with is that I don't understand how to correctly detect, in the PSoC, that I have received a get or a a set instruction. It doesn't seem to exist any interrupt callback that signal that event; there are some flags, though, that are set in a odd way and, it seems, not constant sequence. Due to this behaviour and because I check these status flags to detect the sets and gets, sometimes after a get instruction (correctly detected) it also catch a get instruction, thus performing an undesidered write on SPI.
The pseudo code is the following:
while(1)
{
if(write status flags are set)
do spi write
else if(read status flags are set)
{
do spi read
copy data to i2c buffer
}
}
Does anyone know how to correctly detect the i2c packets? I'm using PSoC Creator 4.1 as IDE.
Thank you