Hi,
Here is one solution proposal (I'll test it first thing tomorrow morning), just in case some one could be interested on this topic.
Take a look at the generated driver source code (under the generated_code folder), this is how the device data looks like in my case, it could vary depending on PE parameters:
typedef struct {
uint32_t TxCommand; /* Current Tx command */
LDD_SPIMASTER_TError ErrFlag; /* Error flags */
uint16_t InpRecvDataNum; /* The counter of received characters */
uint8_t *InpDataPtr; /* The buffer pointer for received characters */
uint16_t InpDataNumReq; /* The counter of characters to receive by ReceiveBlock() */
uint16_t OutSentDataNum; /* The counter of sent characters */
uint8_t *OutDataPtr; /* The buffer pointer for data to be transmitted */
uint16_t OutDataNumReq; /* The counter of characters to be send by SendBlock() */
uint8_t SerFlag; /* Flags for serial communication */
LDD_RTOS_TISRVectorSettings SavedISRSettings_Interrupt; /* {MQXLite RTOS Adapter} Saved settings of allocated interrupt vector */
LDD_TUserData *UserData; /* User device data structure */
} ???_SPI_TDeviceData; /* Device data structure type */
The first field, TxCommand, holds the initial value for the command which the driver uses for pushing data into the TX FIFO. Most significant bit for this command (Continuous Peripheral Chip Select Enable) controls whether CS line is held asserted or not after last byte written to FIFO is streamed out. This bit is masked out (reset) when writing the last byte from the buffer.
Modifications are simple and take less than two minutes (literally):
- Add one boolean field in the device data: bool EndOfTransaction;
- Add one boolean parameter to funtion ???_SPI_SendBlock( ...etc..., bool EndOfTransaction );
- Add this line of code to function ???_SPI_SendBlock():
((?????_SPI_TDeviceDataPtr)DeviceDataPtr)->EndOfTransaction = EndOfTransaction;
---Note that it should be added before the call to function :SPI_PDD_EnableDmasInterrupts()--- - In the interrupt handling function, ???_SPI_Interrupt(), locate the following lines of codes:
if (DeviceDataPrv->OutSentDataNum == DeviceDataPrv->OutDataNumReq) {
TxCommand &= 0x7FFFFFFFU;
}
... and add one additional test condition for the EndOfTransaction, like this:
if (DeviceDataPrv->EndOfTransaction) {
TxCommand &= 0x7FFFFFFFU;
} - Not required at all, but, ...cross your fingers :smileywink:, I have not tested the code yet, it's just an idea.
When calling the function, writes chaining may be achieved by passing FALSE in parameter EndOfTransaction for all writes except for the last one.
One important thing, depending on CW IDE configuration PE is automatically called before every build so any change made on auto generated code will be lost. Kan gives all needed details for modifying this project option on his previous post.
It compiles in my project and seems to be correct with respect to the datasheet but that doesn't guarantee it works, It's still to be test.
If someone has tried this approach before, or has another working solution, please let us know.