aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2014-10-14 11:58:47 +0800
committerbryan newbold <bnewbold@twinleaf.com>2014-11-24 15:18:00 -0800
commitd91e4c67ea72425a9dd7d18862f93336ff12d23b (patch)
tree5462ce20ae59ee7ed0f761828e5e03167c7675e2 /wirish
parent476b8cebb31cdf00e56d3df20f1c4858d8a096a8 (diff)
downloadlibrambutan-d91e4c67ea72425a9dd7d18862f93336ff12d23b.tar.gz
librambutan-d91e4c67ea72425a9dd7d18862f93336ff12d23b.zip
HardwareSPI.cpp: allow for missing SPI peripherals
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish')
-rw-r--r--wirish/HardwareSPI.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/wirish/HardwareSPI.cpp b/wirish/HardwareSPI.cpp
index 94985eb..1acba76 100644
--- a/wirish/HardwareSPI.cpp
+++ b/wirish/HardwareSPI.cpp
@@ -2,6 +2,7 @@
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
+ * Copyright 2014 Google, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -59,23 +60,32 @@ static void enable_device(spi_dev *dev,
spi_mode mode);
static const spi_pins board_spi_pins[] __FLASH__ = {
+#if BOARD_HAVE_SPI1
{BOARD_SPI1_NSS_PIN,
BOARD_SPI1_SCK_PIN,
BOARD_SPI1_MISO_PIN,
BOARD_SPI1_MOSI_PIN},
+#else
+ {0, 0, 0, 0},
+#endif
+#if BOARD_HAVE_SPI2
{BOARD_SPI2_NSS_PIN,
BOARD_SPI2_SCK_PIN,
BOARD_SPI2_MISO_PIN,
BOARD_SPI2_MOSI_PIN},
-#ifdef STM32_HIGH_DENSITY
+#else
+ {0, 0, 0, 0},
+#endif
+#if BOARD_HAVE_SPI3
{BOARD_SPI3_NSS_PIN,
BOARD_SPI3_SCK_PIN,
BOARD_SPI3_MISO_PIN,
BOARD_SPI3_MOSI_PIN},
+#else
+ {0, 0, 0, 0},
#endif
};
-
/*
* Constructor
*/
@@ -235,12 +245,26 @@ static spi_baud_rate determine_baud_rate(spi_dev *dev, SPIFrequency freq);
static const spi_pins* dev_to_spi_pins(spi_dev *dev) {
switch (dev->clk_id) {
- case RCC_SPI1: return board_spi_pins;
- case RCC_SPI2: return board_spi_pins + 1;
-#ifdef STM32_HIGH_DENSITY
- case RCC_SPI3: return board_spi_pins + 2;
+ case RCC_SPI1:
+#if BOARD_HAVE_SPI1
+ return board_spi_pins;
+#else
+ return NULL;
+#endif
+ case RCC_SPI2:
+#if BOARD_HAVE_SPI2
+ return board_spi_pins + 1;
+#else
+ return NULL;
#endif
- default: return NULL;
+ case RCC_SPI3:
+#if BOARD_HAVE_SPI3
+ return board_spi_pins + 2;
+#else
+ return NULL;
+#endif
+ default:
+ return NULL;
}
}