Skip to content

Commit d9a8c63

Browse files
committed
K66F: Use DSPI SDK driver API's in spi block read
Signed-off-by: Mahadevan Mahesh <[email protected]>
1 parent 593fb3a commit d9a8c63

File tree

1 file changed

+11
-7
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F

1 file changed

+11
-7
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/spi_api.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,17 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
122122
char *rx_buffer, int rx_length, char write_fill) {
123123
int total = (tx_length > rx_length) ? tx_length : rx_length;
124124

125-
for (int i = 0; i < total; i++) {
126-
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
127-
char in = spi_master_write(obj, out);
128-
if (i < rx_length) {
129-
rx_buffer[i] = in;
130-
}
131-
}
125+
// Default write is done in each and every call, in future can create HAL API instead
126+
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
127+
128+
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t){
129+
.txData = (uint8_t *)tx_buffer,
130+
.rxData = (uint8_t *)rx_buffer,
131+
.dataSize = total,
132+
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
133+
});
134+
135+
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
132136

133137
return total;
134138
}

0 commit comments

Comments
 (0)