Skip to content

Commit

Permalink
Merge pull request #11660 from shuopeng-deng/pr/spi-transfer-fix
Browse files Browse the repository at this point in the history
Fix dropped bytes on spi write
  • Loading branch information
0xc0170 authored Oct 15, 2019
2 parents b54315e + 9f03a1c commit a806237
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions targets/TARGET_Cypress/TARGET_PSOC6/cy_spi_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,12 @@ void spi_frequency(spi_t *obj, int hz)
int spi_master_write(spi_t *obj, int value)
{
struct spi_s *spi = cy_get_spi(obj);
uint32_t received;
if (CY_RSLT_SUCCESS != cyhal_spi_send(&(spi->hal_spi), (uint32_t)value)) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER_SPI, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_spi_send");
}
if (CY_RSLT_SUCCESS != cyhal_spi_recv(&(spi->hal_spi), &received)) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER_SPI, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_spi_recv");
int received;

if (CY_RSLT_SUCCESS != cyhal_spi_transfer(&(spi->hal_spi), (const uint8_t *)&value, 1, (uint8_t *)&received, 1, 0xff)) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER_SPI, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_spi_transfer");
}
return (int)received;
return received;
}

int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill)
Expand Down

0 comments on commit a806237

Please sign in to comment.