Skip to content

Commit 87d58b3

Browse files
committed
STM32: add debug flags, fix hang in simplex SPI
1 parent 3a17a79 commit 87d58b3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ports/stm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ INC += -I../../supervisor/shared/usb
8181

8282
#Debugging/Optimization
8383
ifeq ($(DEBUG), 1)
84-
CFLAGS += -ggdb
84+
CFLAGS += -ggdb3
8585
# You may want to enable these flags to make setting breakpoints easier.
8686
CFLAGS += -fno-inline -fno-ipa-sra
8787
else
8888
CFLAGS += -Os -DNDEBUG
89-
CFLAGS += -ggdb
89+
CFLAGS += -ggdb3
9090
# TODO: Test with -flto
9191
# CFLAGS += -flto
9292
endif

ports/stm/common-hal/busio/SPI.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,11 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
238238

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

0 commit comments

Comments
 (0)