Merge pull request #3431 from hierophect/stm32-spi-writevalue

STM32: Change SPI Read to acknowledge write_value
This commit is contained in:
Dan Halbert 2020-09-18 19:46:21 -04:00 committed by GitHub
commit 8cf0171c06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -102,7 +102,8 @@ CFLAGS += $(INC) -Werror -Wall -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(C_DEFS)
# Undo some warnings.
# STM32 HAL uses undefined preprocessor variables, shadowed variables, casts that change alignment reqs
CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align
# You can add your own temporary suppression by setting ADD_CFLAGS in the make command
CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align $(ADD_CFLAGS)
CFLAGS += -mthumb -mabi=aapcs-linux

View File

@ -25,6 +25,7 @@
* THE SOFTWARE.
*/
#include <stdbool.h>
#include <string.h>
#include "shared-bindings/busio/SPI.h"
#include "py/mperrno.h"
@ -349,7 +350,13 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
if (self->miso == NULL) {
mp_raise_ValueError(translate("No MISO Pin"));
}
HAL_StatusTypeDef result = HAL_SPI_Receive (&self->handle, data, (uint16_t)len, HAL_MAX_DELAY);
HAL_StatusTypeDef result = HAL_OK;
if (self->mosi == NULL) {
result = HAL_SPI_Receive(&self->handle, data, (uint16_t)len, HAL_MAX_DELAY);
} else {
memset(data, write_value, len);
result = HAL_SPI_TransmitReceive(&self->handle, data, data, (uint16_t)len, HAL_MAX_DELAY);
}
return result == HAL_OK;
}