mirror of https://github.com/ARMmbed/mbed-os.git
MCUXpresso: Use SDK API for spi_master_block_write
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>pull/11308/head
parent
5691fc3b76
commit
cc70640ff4
|
@ -119,16 +119,21 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,16 +116,18 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
SPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
SPI_MasterTransferBlocking(spi_address[obj->instance], &(spi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total
|
||||||
|
});
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,16 +116,18 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
SPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
SPI_MasterTransferBlocking(spi_address[obj->instance], &(spi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total
|
||||||
|
});
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,16 +118,21 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,13 +141,17 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
{
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,13 +141,17 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
{
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,16 +118,21 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,16 +128,21 @@ int spi_master_write(spi_t *obj, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||||
char *rx_buffer, int rx_length, char write_fill) {
|
char *rx_buffer, int rx_length, char write_fill)
|
||||||
|
{
|
||||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
// Default write is done in each and every call, in future can create HAL API instead
|
||||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
DSPI_SetDummyData(spi_address[obj->spi.instance], write_fill);
|
||||||
char in = spi_master_write(obj, out);
|
|
||||||
if (i < rx_length) {
|
DSPI_MasterTransferBlocking(spi_address[obj->spi.instance], &(dspi_transfer_t) {
|
||||||
rx_buffer[i] = in;
|
.txData = (uint8_t *)tx_buffer,
|
||||||
}
|
.rxData = (uint8_t *)rx_buffer,
|
||||||
}
|
.dataSize = total,
|
||||||
|
.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous,
|
||||||
|
});
|
||||||
|
|
||||||
|
DSPI_ClearStatusFlags(spi_address[obj->spi.instance], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue