For my project I need to connect the cx3 (through i2c) with two slaves: a camera and another sensor.
During the initialization of the slaves I'm using the i2c configured in transfer mode thanks to the API CyU3PMipicsiInitializeI2c(); I cannot do differently because I need to write single bytes in different registers and with DMA transfer I can only write multiple of 16 bytes.
My goal is to read the data from the second sensor through i2c configured in DMA mode once the UVC app starts (the dma channel is connected between i2c slave and endpoint). Here come the problems:
- Once the UVC app starts, from time to time I'm still sending i2c data in transfer mode towards the camera (for features such as the change of resolution) and reading control bytes from the cx3 mipi csi receiver slave (the one whose address is 0000111, according to the cx3 TRM, page 8 sec 1.5). Is it possible to separate the two modes of the i2c (transfer and DMA) or should I constantly change the settings with the CyU3PI2cSetConfig() API, ie turning on the Dma mode before reading from the sensor and then turning it off immediately after the reading?
- To trigger the i2c DMA reading from the second slave I'm using an interrupt line coming from the sensor and connected to a GPIO of the cx3. I've used two reference designs to create the firmware, these are cyfxgpioapp and cyfxusbi2cdmamode, which I've found in the serialif_exaples folder of the SDK. What I'm doing right now is to set the trigger on the gpio associated to the interrupt, activate a callback function associated to it and in here setting an event through the CyU3PEventSet() API.
- At this point, should I create a thread that handles the DMA transfer? Is a thread in the cx3 always running in "time slices"? (if I understood correctly the cx3 is single core).
- If I should use a thread, how could I estimate the allocated memory for CyU3PMemAlloc()?
- Why isn't it possible to use a peripheral directly in the callback function? This is what I understood from the cyfxgpioapp (line 119 of cyfxgpioapp.c regarding the debug print).
I thank you in advance for your answer!