Bug #9: Both TX and RX SPI init params had platform_ops = NULL, causing adf4382_init() -> no_os_spi_init() to fail with -EINVAL. Fixed by setting platform_ops = &stm32_spi_ops and passing stm32_spi_extra with correct CS port/pin for each device. Bug #10: stm32_spi_write_and_read() never toggled chip select. Since TX and RX ADF4382A share SPI4, every register write hit both PLLs. Rewrote stm32_spi.c to assert CS LOW before transfer and deassert HIGH after, using stm32_spi_extra metadata. Backward-compatible: legacy callers (e.g., AD9523) with cs_port=NULL skip CS management. Also widened chip_select from uint8_t to uint16_t in no_os_spi.h since STM32 GPIO_PIN_xx values (e.g., GPIO_PIN_14=0x4000) overflow uint8_t. 10/10 tests pass (8 original + 2 new regression tests).
This commit is contained in:
1 parent
397969348e
commit
3b32f67087
11 files changed
+325
-21
No files matched your search
@@ -2,6 +2,7 @@
|
||||
* stm32_hal_mock.c -- Spy/recording implementation of STM32 HAL stubs
|
||||
******************************************************************************/
|
||||
#include "stm32_hal_mock.h"
|
||||
#include "ad_driver_mock.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -262,3 +263,14 @@ void mock_tim_set_compare(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t Co
|
||||
.extra = htim
|
||||
});
|
||||
}
|
||||
|
||||
/* ========================= Mock stm32_spi_ops ===================== */
|
||||
|
||||
/* Stub SPI platform ops -- real adf4382a_manager.c references &stm32_spi_ops.
|
||||
* In tests, adf4382_init() is mocked so no_os_spi_init() is never called.
|
||||
* We provide a non-NULL struct so tests can assert platform_ops != NULL. */
|
||||
static int mock_spi_init_stub(void) { return 0; }
|
||||
|
||||
const struct no_os_spi_platform_ops stm32_spi_ops = {
|
||||
.init = mock_spi_init_stub,
|
||||
};
|
||||
Reference in new issue
Block a user