From fb011d3c3b7cec45752676d6c4037ab32a37fcc2 Mon Sep 17 00:00:00 2001 From: Mimmo La Fauci Date: Mon, 4 Jun 2012 23:14:56 +0200 Subject: [PATCH] Fix issue compiler option --- WiFi/utility/debug.h | 9 +++++++++ WiFi/utility/spi_drv.cpp | 34 ++++++---------------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/WiFi/utility/debug.h b/WiFi/utility/debug.h index 437ec6c94..9f71055b2 100644 --- a/WiFi/utility/debug.h +++ b/WiFi/utility/debug.h @@ -50,6 +50,7 @@ #define WARN(args) do {} while (0); #endif +#if _DEBUG_SPI_ #define DBG_PIN2 5 #define DBG_PIN 4 @@ -64,5 +65,13 @@ #define TOGGLE_TRIGGER() SET_TRIGGER() \ delayMicroseconds(2); \ RST_TRIGGER() +#else +#define START() +#define END() +#define SET_TRIGGER() +#define RST_TRIGGER() +#define INIT_TRIGGER() +#define TOGGLE_TRIGGER() +#endif #endif diff --git a/WiFi/utility/spi_drv.cpp b/WiFi/utility/spi_drv.cpp index 8069b024d..ceef832c0 100644 --- a/WiFi/utility/spi_drv.cpp +++ b/WiFi/utility/spi_drv.cpp @@ -13,7 +13,9 @@ extern "C" { #define SLAVESELECT 10//ss #define SLAVEREADY 3 -#define DELAY_100NS asm volatile("nop") +#define DELAY_100NS do { asm volatile("nop"); }while(0); +#define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); }while(++ii 0) && (*readChar != waitChar)); -// -// return (*readChar == waitChar); -//} - - int SpiDrv::readAndCheckChar(char checkChar, char* readChar) { - //*readChar = spiTransfer(DUMMY_DATA); //get data byte getParam((uint8_t*)readChar); return (*readChar == checkChar); @@ -128,11 +112,8 @@ char SpiDrv::readChar() uint8_t readChar = 0; getParam(&readChar); return readChar; - //return spiTransfer(DUMMY_DATA); //get data byte } -//#define WAIT_START_CMD(x) waitSpiChar(START_CMD, &x) -//#define WAIT_START_CMD(x) readAndCheckChar(START_CMD, &x) #define WAIT_START_CMD(x) waitSpiChar(START_CMD) #define IF_CHECK_START_CMD(x) \ @@ -171,10 +152,7 @@ void SpiDrv::getParam(uint8_t* param) { // Get Params data *param = spiTransfer(DUMMY_DATA); - DELAY_100NS; - DELAY_100NS; - DELAY_100NS; - DELAY_100NS; + DELAY_TRANSFER(); } int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)