diff options
-rw-r--r-- | os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c | 2 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c | 2 | ||||
-rw-r--r-- | readme.txt | 2 | ||||
-rw-r--r-- | testhal/STM32/STM32F4xx/SPI/debug/STM32F4xx-SPI (OpenOCD, Flash and Run).launch | 2 | ||||
-rw-r--r-- | testhal/STM32/STM32F7xx/SPI/main.c | 20 |
5 files changed, 20 insertions, 8 deletions
diff --git a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c index 4be8cedc1..0cee5729b 100644 --- a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c +++ b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c @@ -422,7 +422,7 @@ void spi_lld_start(SPIDriver *spip) { STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD;
}
/* SPI setup and enable.*/
- spip->spi->CR1 = 0;
+ spip->spi->CR1 &= ~SPI_CR1_SPE;
spip->spi->CR1 = spip->config->cr1 | SPI_CR1_MSTR | SPI_CR1_SSM |
SPI_CR1_SSI;
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_SSOE | SPI_CR2_RXDMAEN |
diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c index 914249fe7..b3aafff07 100644 --- a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c +++ b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c @@ -425,7 +425,7 @@ void spi_lld_start(SPIDriver *spip) { }
/* SPI setup and enable.*/
- spip->spi->CR1 = 0;
+ spip->spi->CR1 &= ~SPI_CR1_SPE;
spip->spi->CR1 = spip->config->cr1 | SPI_CR1_MSTR;
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH | SPI_CR2_SSOE |
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
diff --git a/readme.txt b/readme.txt index 069bdb27c..e11192d5c 100644 --- a/readme.txt +++ b/readme.txt @@ -93,6 +93,8 @@ dependencies and configuration directories. This makes possible
to have multiple non-conflicting makefiles in the same project.
Updated the various platform.mk implementing "smart build" mode.
+- HAL: Fixed STM32 SPI problem in spi_lld_start() (bug #879)(backported
+ to 17.6.1 and 16.1.9).
- HAL: Fixed invalid STM32 CAN3 filters initialization (bug #878)
(backported to 17.6.1).
- HAL: Fixed missing CAN definitions in STM32L432 registry entry (bug #877)
diff --git a/testhal/STM32/STM32F4xx/SPI/debug/STM32F4xx-SPI (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F4xx/SPI/debug/STM32F4xx-SPI (OpenOCD, Flash and Run).launch index 03aa07db2..7d1aebba0 100644 --- a/testhal/STM32/STM32F4xx/SPI/debug/STM32F4xx-SPI (OpenOCD, Flash and Run).launch +++ b/testhal/STM32/STM32F4xx/SPI/debug/STM32F4xx-SPI (OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/></contentList>"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/></contentList>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
diff --git a/testhal/STM32/STM32F7xx/SPI/main.c b/testhal/STM32/STM32F7xx/SPI/main.c index 2b0c1744b..c9bc3696e 100644 --- a/testhal/STM32/STM32F7xx/SPI/main.c +++ b/testhal/STM32/STM32F7xx/SPI/main.c @@ -32,7 +32,7 @@ static const SPIConfig hs_spicfg = { NULL,
GPIOB,
GPIOB_ARD_D15,
- SPI_CR1_BR_0,
+ SPI_CR1_CPOL | SPI_CR1_BR_0,
SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
};
@@ -167,15 +167,25 @@ int main(void) { /*
* Starting the transmitter and receiver threads.
*/
- chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
- NORMALPRIO + 1, spi_thread_1, NULL);
- chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa),
- NORMALPRIO + 1, spi_thread_2, NULL);
+// chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
+// NORMALPRIO + 1, spi_thread_1, NULL);
+// chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa),
+// NORMALPRIO + 1, spi_thread_2, NULL);
/*
* Normal main() thread activity, in this demo it does nothing.
*/
+ uint8_t byte = 0x55;
while (true) {
chThdSleepMilliseconds(500);
+ spiStart(&SPID2, &hs_spicfg);
+
+ spiSelect(&SPID2);
+ spiSend(&SPID2, 1, &byte);
+ spiUnselect(&SPID2);
+
+ spiSelect(&SPID2);
+ spiSend(&SPID2, 1, &byte);
+ spiUnselect(&SPID2);
}
}
|