summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2018-05-08 20:06:55 +0200
committerDamien George <damien.p.george@gmail.com>2018-07-18 17:12:26 +1000
commit5925004da3c4656e07493f203c981a7000bdcbde (patch)
treeaa966d4dc43ad572ce1f75521973dd95d0ad2c46
parent774638e2a90957b60dcd247c7f498b68d3c6bcc9 (diff)
nrf/modules/machine/spi: Move enable-guard to prevent wrong includes
This patch moves the check of SPI configuration before including any SPI header files. As targets might disable SPI support, current code ends up in including SPIM if not SPI is configured. Hence, this is why the check whether the module is enabled should be done before including headers.
-rw-r--r--ports/nrf/modules/machine/spi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/nrf/modules/machine/spi.c b/ports/nrf/modules/machine/spi.c
index 5ea5d5320..b15c89ec6 100644
--- a/ports/nrf/modules/machine/spi.c
+++ b/ports/nrf/modules/machine/spi.c
@@ -29,8 +29,11 @@
#include <stdio.h>
#include <string.h>
-#include "py/nlr.h"
#include "py/runtime.h"
+
+#if MICROPY_PY_MACHINE_HW_SPI
+
+#include "py/nlr.h"
#include "py/mphal.h"
#include "extmod/machine_spi.h"
#include "pin.h"
@@ -42,8 +45,6 @@
#include "nrfx_spim.h"
#endif
-#if MICROPY_PY_MACHINE_HW_SPI
-
/// \moduleref pyb
/// \class SPI - a master-driven serial protocol
///