Skip to content

Commit 9f03a1c

Browse files
committed
fixed spi_master_write to support transfer of 8+ bits
remove an unnecessary cast
1 parent 1b14120 commit 9f03a1c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_spi_api.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,12 @@ void spi_frequency(spi_t *obj, int hz)
130130
int spi_master_write(spi_t *obj, int value)
131131
{
132132
struct spi_s *spi = cy_get_spi(obj);
133-
uint8_t received;
134-
uint8_t value_byte = (uint8_t)value;
133+
int received;
135134

136-
if (CY_RSLT_SUCCESS != cyhal_spi_transfer(&(spi->hal_spi), &value_byte, 1, &received, 1, 0xff)) {
135+
if (CY_RSLT_SUCCESS != cyhal_spi_transfer(&(spi->hal_spi), (const uint8_t *)&value, 1, (uint8_t *)&received, 1, 0xff)) {
137136
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER_SPI, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_spi_transfer");
138137
}
139-
return (int)received;
138+
return received;
140139
}
141140

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

0 commit comments

Comments
 (0)