Cx3: switching the i2c mode (Dma/register transfer)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
CoCo_4528381
Level 1
Level 1
First like given

Hello everyone!

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!

Regards,

Costantino

0 Likes
1 Solution
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi Costantino,

When you use Manual channel you need not use override mode. Override mode is used when user defined DMA buffer in the firmware is used for DMA transfers instead of DMA buffers allocated during channel creation. APIs are used for write and read DMA transfers respectively.

You can also refer DMA Channel in Override Mode in FX3/CX3 - KBA229098

For manual mode operation you can refer to C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\dma_examples\cyfxbulklpmanual

In the above example both the producer and consumer are USB endpoints which is different in your case.

Even when you use Manual mode: Perform CyU3PI2cSendCommand() (1) after successfully performing commitbuffer call while writing on I2c and (2) when you want to perform a read on I2c - Once the read is successful and when the DMA buffer is full you would receive dmacallback with CONS event.

Regards,

Hemanth 

Hemanth

View solution in original post

0 Likes
11 Replies