STM32: add debug flags, fix hang in simplex SPI

This commit is contained in:
Lucian Copeland 2020-07-01 17:48:10 -04:00
parent 3a17a79bf2
commit 87d58b3b0a
2 changed files with 7 additions and 4 deletions

View File

@ -81,12 +81,12 @@ INC += -I../../supervisor/shared/usb
#Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb
CFLAGS += -ggdb3
# You may want to enable these flags to make setting breakpoints easier.
CFLAGS += -fno-inline -fno-ipa-sra
else
CFLAGS += -Os -DNDEBUG
CFLAGS += -ggdb
CFLAGS += -ggdb3
# TODO: Test with -flto
# CFLAGS += -flto
endif

View File

@ -238,8 +238,11 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
self->handle.Instance = SPIx;
self->handle.Init.Mode = SPI_MODE_MASTER;
// Direction change only required for RX-only, see RefMan RM0090:884
self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES;
// Implementing one-directional recieve-only SPI as per [RefMan RM0090:884]
// results in BSY bit related hangs. Using MOSI as an IO works fine without it,
// so it's unclear why this mode is present in the first place.
//self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES;
self->handle.Init.Direction = SPI_DIRECTION_2LINES;
self->handle.Init.DataSize = SPI_DATASIZE_8BIT;
self->handle.Init.CLKPolarity = SPI_POLARITY_LOW;
self->handle.Init.CLKPhase = SPI_PHASE_1EDGE;