Wrap the whole debug_over_spi.[ch] files into #ifdef DEBUG_OVER_SPI to silence compiler warnings when it's not defined.

This commit is contained in:
László Monda
2017-11-09 01:33:23 +01:00
parent e5865009f5
commit f1058294a6
2 changed files with 11 additions and 10 deletions
+4 -10
View File
@@ -1,8 +1,9 @@
#ifdef DEBUG_OVER_SPI
#include "debug_over_spi.h" #include "debug_over_spi.h"
#include "config.h" #include "config.h"
#include "fsl_gpio.h" #include "fsl_gpio.h"
#ifdef DEBUG_OVER_SPI
#define EXAMPLE_SPI_MASTER (SPI0) #define EXAMPLE_SPI_MASTER (SPI0)
#define EXAMPLE_SPI_MASTER_SOURCE_CLOCK (kCLOCK_BusClk) #define EXAMPLE_SPI_MASTER_SOURCE_CLOCK (kCLOCK_BusClk)
@@ -16,19 +17,13 @@ spi_master_handle_t handle;
static volatile bool masterFinished = true; static volatile bool masterFinished = true;
#endif
static void masterCallback(SPI_Type *base, spi_master_handle_t *masterHandle, status_t status, void *userData) static void masterCallback(SPI_Type *base, spi_master_handle_t *masterHandle, status_t status, void *userData)
{ {
#ifdef DEBUG_OVER_SPI
masterFinished = true; masterFinished = true;
#endif
} }
void DebugOverSpi_Init(void) void DebugOverSpi_Init(void)
{ {
#ifdef DEBUG_OVER_SPI
CLOCK_EnableClock(DEBUG_OVER_SPI_MOSI_CLOCK); CLOCK_EnableClock(DEBUG_OVER_SPI_MOSI_CLOCK);
CLOCK_EnableClock(DEBUG_OVER_SPI_SCK_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); uint32_t srcFreq = CLOCK_GetFreq(EXAMPLE_SPI_MASTER_SOURCE_CLOCK);
SPI_MasterInit(EXAMPLE_SPI_MASTER, &userConfig, srcFreq); SPI_MasterInit(EXAMPLE_SPI_MASTER, &userConfig, srcFreq);
SPI_MasterTransferCreateHandle(EXAMPLE_SPI_MASTER, &handle, masterCallback, NULL); SPI_MasterTransferCreateHandle(EXAMPLE_SPI_MASTER, &handle, masterCallback, NULL);
#endif
} }
void DebugOverSpi_Send(uint8_t *tx, uint8_t len) void DebugOverSpi_Send(uint8_t *tx, uint8_t len)
{ {
#ifdef DEBUG_OVER_SPI
if (masterFinished) { if (masterFinished) {
masterFinished = false; masterFinished = false;
memcpy(srcBuff, tx, MIN(BUFFER_SIZE, len)); memcpy(srcBuff, tx, MIN(BUFFER_SIZE, len));
@@ -58,5 +51,6 @@ void DebugOverSpi_Send(uint8_t *tx, uint8_t len)
xfer.dataSize = len; xfer.dataSize = len;
SPI_MasterTransferNonBlocking(EXAMPLE_SPI_MASTER, &handle, &xfer); SPI_MasterTransferNonBlocking(EXAMPLE_SPI_MASTER, &handle, &xfer);
} }
#endif
} }
#endif
+7
View File
@@ -1,3 +1,5 @@
#ifdef DEBUG_OVER_SPI
#ifndef __DEBUG_OVER_SPI_H__ #ifndef __DEBUG_OVER_SPI_H__
#define __DEBUG_OVER_SPI_H__ #define __DEBUG_OVER_SPI_H__
@@ -25,3 +27,8 @@
void DebugOverSpi_Send(uint8_t *tx, uint8_t len); void DebugOverSpi_Send(uint8_t *tx, uint8_t len);
#endif #endif
#else
#define DebugOverSpi_Init()
#define DebugOverSpi_Send(tx, len)
#endif