Tool/software:
Hello,
I am trying to emulate an (mib)SPI slave with a rather cumbersome protocol.
Currently I am able to mimic the protocol on the SPI layer but not on the transport layer by using one transfer group on 16B (request 4B - response 12B) sent in the following manner:
MOSI: --- | x1 | x2 | x3 | x4 | -------- 15us ------- | NA | NA | NA | NA | NA | NA | NA | NA | NA |NA | NA | NA | ----- | a1 | a2 | a3 | a4 | -------- 15us ------- | NA | NA | NA | NA | NA | NA | NA | NA | NA |NA | NA | NA | ---
MISO: --- | NA1 | NA2 | NA3 | NA4 | ------- 15us ------- | y1 | y2 | y3 | y4 | y1 | y2 | y3 | y4 | y1 |y2 | y3 | y4 | ----- | NA1 | NA2 | NA3 | NA4 | ------- 15us ------- | x1 | x2 | x3 | x4 | x1 | x2 | x3 | x4 | x1 | x2 | x3 | x4 | ---
| TGx | ----- | TGx | |
NOTE: The response (a 4 x copy of the request in order to keep it simple) is delayed by one transmission of the transfer group TGx.
The problem however is that I need the response immediately, i.e. ~15us after receiving the request (i.e. something like this):
MOSI: --- | x1 | x2 | x3 | x4 | -------- 15us ------- | NA | NA | NA | NA | NA | NA | NA | NA | NA |NA | NA | NA | ----- | a1 | a2 | a3 | a4 | -------- 15us ------- | NA | NA | NA | NA | NA | NA | NA | NA | NA |NA | NA | NA | --- MISO: --- | NA1 | NA2 | NA3 | NA4 | ------- 15us ------- | x1 | x2 | x3 | x4 | x1 | x2 | x3 | x4 | x1 |x2 | x3 | x4 | ----- | NA1 | NA2 | NA3 | NA4 | ------- 15us ------- | a1 | a2 | a3 | a4 | a1 | a2 | a3 | a4 | a1 | a2 | a3 | a4 | --- | TGx | ------- 15us ------- | TGy | ----- | TGx | ------- 15us ------- | TGy |
I have made an attempt to control the transfer group and the data in TGy in the notification function "mibspiGroupNotification".
Basically by doing the following (pseudo code):
void mibspiGroupNotification(mibspiBASE_t *mibspi, uint32 group) { if (mibspi == mibspiREG1) { if (group == TGx) { /* Get TGx request data */ mibspiGetData(mibspiREG1, TGx, &g_TGx_rx_data[0]); /* Copy request data to TGy response/tx data buffer g_TGy_tx_data[0] */ ... // memcpy(...); /* Set TGy data */ mibspiSetData(mibspiREG1, TGy, &g_TGy_tx_data[0]); /* Clear enable of TGx */ mibspiREG1->TGCTRL[TGx] &= ~0x80000000U; /* Enable TGy */ mibspiREG1->TGCTRL[TGy] |= 0x80000000U; // mibspiTransfer(mibspiREG1, TGy); } else { /* Clear TGy */ mibspiREG1->TGCTRL[TGy] &= ~0x80000000U; /* Re-enable TGx */ mibspiREG1->TGCTRL[TGx] |= 0x80000000U; // mibspiTransfer(mibspiREG1, TGx); } } }
This approach seems to almost work, the problem is that I seem to send 1B of old/corrupted data before sending the intended data and by doing that disturbs the data content/order of the TGy buffer/response (as well as TGx).
Hence I wonder if my intended use case is possible?
Any ideas? Does it seems like something that should be possible to accomplish?
DISCLAIMER: I do not have a workspace/project that I can share at the moment, hence the reason for sharing only the necessary details needed in order to describe the issue at hand.