From dbb566a2ae8116a4bc1458fb9b391a64db207f66 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Thu, 9 May 2024 15:56:57 +0200 Subject: [PATCH] SPI setup will not yield the exact selected speed. --- .../mfrc522_integration/mfrc522_rp2040_integration.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/mfrc522_integration/mfrc522_rp2040_integration.c b/third_party/mfrc522_integration/mfrc522_rp2040_integration.c index 0ec3fb6..c3b4bee 100644 --- a/third_party/mfrc522_integration/mfrc522_rp2040_integration.c +++ b/third_party/mfrc522_integration/mfrc522_rp2040_integration.c @@ -166,8 +166,12 @@ uint8_t mfrc522_interface_spi_init(void) gpio_set_function(MFRC522_CFG_SPI_CLK_GPIO, GPIO_FUNC_SPI); gpio_set_function(MFRC522_CFG_SPI_SS_GPIO, GPIO_FUNC_SPI); - uint baudrate = MFRC522_CFG_SPI_SPEED_MHZ; - return (baudrate == spi_init(spi0, baudrate)) ? 0 : 1; + /* + * From the manual: + * "There is no guarantee that the baudrate requested can be achieved exactly; + * the nearest will be chosen and returned" + */ + return !spi_init(spi0, MFRC522_CFG_SPI_SPEED_MHZ); } /**