aboutsummaryrefslogtreecommitdiff
path: root/platforms/chibios/drivers/spi_master.c
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2025-01-27 08:37:37 +1100
committerGitHub <noreply@github.com>2025-01-26 22:37:37 +0100
commitee63d39058deee162b794c62d7180d61f540914a (patch)
treeb5f181826176b74cfbac3de4aadad4230b4aa3b0 /platforms/chibios/drivers/spi_master.c
parent0747f887d6820da8903d60c751e9e04c92b72d4d (diff)
Unify spi_master headers (#24857)
* Move default config to .c file * Explicitly define PAL modes for boards with custom init * Unify spi_master headers
Diffstat (limited to 'platforms/chibios/drivers/spi_master.c')
-rw-r--r--platforms/chibios/drivers/spi_master.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c
index 414e5b10a3..f5e48edfda 100644
--- a/platforms/chibios/drivers/spi_master.c
+++ b/platforms/chibios/drivers/spi_master.c
@@ -15,8 +15,49 @@
*/
#include "spi_master.h"
+#include "chibios_config.h"
+#include <ch.h>
+#include <hal.h>
-#include "timer.h"
+#ifndef SPI_DRIVER
+# define SPI_DRIVER SPID2
+#endif
+
+#ifndef SPI_SCK_PIN
+# define SPI_SCK_PIN B13
+#endif
+
+#ifndef SPI_SCK_PAL_MODE
+# ifdef USE_GPIOV1
+# define SPI_SCK_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
+# else
+# define SPI_SCK_PAL_MODE 5
+# endif
+#endif
+
+#ifndef SPI_MOSI_PIN
+# define SPI_MOSI_PIN B15
+#endif
+
+#ifndef SPI_MOSI_PAL_MODE
+# ifdef USE_GPIOV1
+# define SPI_MOSI_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
+# else
+# define SPI_MOSI_PAL_MODE 5
+# endif
+#endif
+
+#ifndef SPI_MISO_PIN
+# define SPI_MISO_PIN B14
+#endif
+
+#ifndef SPI_MISO_PAL_MODE
+# ifdef USE_GPIOV1
+# define SPI_MISO_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
+# else
+# define SPI_MISO_PAL_MODE 5
+# endif
+#endif
static bool spiStarted = false;
#if SPI_SELECT_MODE == SPI_SELECT_MODE_NONE