From f1058294a6a19cd8691a5a0a529d1be643656a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Thu, 9 Nov 2017 01:33:23 +0100 Subject: [PATCH] Wrap the whole debug_over_spi.[ch] files into #ifdef DEBUG_OVER_SPI to silence compiler warnings when it's not defined. --- left/src/debug_over_spi.c | 14 ++++---------- left/src/debug_over_spi.h | 7 +++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/left/src/debug_over_spi.c b/left/src/debug_over_spi.c index 28752ed..bd5524b 100644 --- a/left/src/debug_over_spi.c +++ b/left/src/debug_over_spi.c @@ -1,8 +1,9 @@ +#ifdef DEBUG_OVER_SPI + #include "debug_over_spi.h" #include "config.h" #include "fsl_gpio.h" -#ifdef DEBUG_OVER_SPI #define EXAMPLE_SPI_MASTER (SPI0) #define EXAMPLE_SPI_MASTER_SOURCE_CLOCK (kCLOCK_BusClk) @@ -16,19 +17,13 @@ spi_master_handle_t handle; static volatile bool masterFinished = true; -#endif - static void masterCallback(SPI_Type *base, spi_master_handle_t *masterHandle, status_t status, void *userData) { -#ifdef DEBUG_OVER_SPI masterFinished = true; -#endif } void DebugOverSpi_Init(void) { -#ifdef DEBUG_OVER_SPI - CLOCK_EnableClock(DEBUG_OVER_SPI_MOSI_CLOCK); CLOCK_EnableClock(DEBUG_OVER_SPI_SCK_CLOCK); @@ -45,12 +40,10 @@ void DebugOverSpi_Init(void) uint32_t srcFreq = CLOCK_GetFreq(EXAMPLE_SPI_MASTER_SOURCE_CLOCK); SPI_MasterInit(EXAMPLE_SPI_MASTER, &userConfig, srcFreq); SPI_MasterTransferCreateHandle(EXAMPLE_SPI_MASTER, &handle, masterCallback, NULL); -#endif } void DebugOverSpi_Send(uint8_t *tx, uint8_t len) { -#ifdef DEBUG_OVER_SPI if (masterFinished) { masterFinished = false; memcpy(srcBuff, tx, MIN(BUFFER_SIZE, len)); @@ -58,5 +51,6 @@ void DebugOverSpi_Send(uint8_t *tx, uint8_t len) xfer.dataSize = len; SPI_MasterTransferNonBlocking(EXAMPLE_SPI_MASTER, &handle, &xfer); } -#endif } + +#endif diff --git a/left/src/debug_over_spi.h b/left/src/debug_over_spi.h index a97d8ae..4fcd263 100644 --- a/left/src/debug_over_spi.h +++ b/left/src/debug_over_spi.h @@ -1,3 +1,5 @@ +#ifdef DEBUG_OVER_SPI + #ifndef __DEBUG_OVER_SPI_H__ #define __DEBUG_OVER_SPI_H__ @@ -25,3 +27,8 @@ void DebugOverSpi_Send(uint8_t *tx, uint8_t len); #endif + +#else + #define DebugOverSpi_Init() + #define DebugOverSpi_Send(tx, len) +#endif