From 5925004da3c4656e07493f203c981a7000bdcbde Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Tue, 8 May 2018 20:06:55 +0200 Subject: [PATCH] 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. --- ports/nrf/modules/machine/spi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/nrf/modules/machine/spi.c b/ports/nrf/modules/machine/spi.c index 5ea5d53204..b15c89ec67 100644 --- a/ports/nrf/modules/machine/spi.c +++ b/ports/nrf/modules/machine/spi.c @@ -29,8 +29,11 @@ #include #include -#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 ///