Skip to content

Commit fb011d3

Browse files
committed
Fix issue compiler option
1 parent a69cd64 commit fb011d3

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

WiFi/utility/debug.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define WARN(args) do {} while (0);
5151
#endif
5252

53+
#if _DEBUG_SPI_
5354
#define DBG_PIN2 5
5455
#define DBG_PIN 4
5556

@@ -64,5 +65,13 @@
6465
#define TOGGLE_TRIGGER() SET_TRIGGER() \
6566
delayMicroseconds(2); \
6667
RST_TRIGGER()
68+
#else
69+
#define START()
70+
#define END()
71+
#define SET_TRIGGER()
72+
#define RST_TRIGGER()
73+
#define INIT_TRIGGER()
74+
#define TOGGLE_TRIGGER()
75+
#endif
6776

6877
#endif

WiFi/utility/spi_drv.cpp

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ extern "C" {
1313
#define SLAVESELECT 10//ss
1414
#define SLAVEREADY 3
1515

16-
#define DELAY_100NS asm volatile("nop")
16+
#define DELAY_100NS do { asm volatile("nop"); }while(0);
17+
#define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); }while(++ii<X);}
18+
#define DELAY_TRANSFER() DELAY_SPI(10)
1719

1820
void SpiDrv::begin()
1921
{
@@ -78,9 +80,8 @@ char SpiDrv::spiTransfer(volatile char data)
7880
{
7981
};
8082
char result = SPDR;
81-
DELAY_100NS;
82-
DELAY_100NS;
83-
//delayMicroseconds(SPI_TX_DELAY);
83+
DELAY_TRANSFER();
84+
8485
return result; // return the received byte
8586
}
8687

@@ -99,25 +100,8 @@ int SpiDrv::waitSpiChar(unsigned char waitChar)
99100
return (_readChar == waitChar);
100101
}
101102

102-
//int SpiDrv::waitSpiChar(char waitChar, char* readChar)
103-
//{
104-
// int timeout = TIMEOUT_CHAR;
105-
// do{
106-
// *readChar = spiTransfer(DUMMY_DATA); //get data byte
107-
// if (*readChar == WAIT_CMD)
108-
// {
109-
// INFO1("WAIT");
110-
// delayMicroseconds(WAIT_CHAR_DELAY);
111-
// }
112-
// }while((timeout-- > 0) && (*readChar != waitChar));
113-
//
114-
// return (*readChar == waitChar);
115-
//}
116-
117-
118103
int SpiDrv::readAndCheckChar(char checkChar, char* readChar)
119104
{
120-
//*readChar = spiTransfer(DUMMY_DATA); //get data byte
121105
getParam((uint8_t*)readChar);
122106

123107
return (*readChar == checkChar);
@@ -128,11 +112,8 @@ char SpiDrv::readChar()
128112
uint8_t readChar = 0;
129113
getParam(&readChar);
130114
return readChar;
131-
//return spiTransfer(DUMMY_DATA); //get data byte
132115
}
133116

134-
//#define WAIT_START_CMD(x) waitSpiChar(START_CMD, &x)
135-
//#define WAIT_START_CMD(x) readAndCheckChar(START_CMD, &x)
136117
#define WAIT_START_CMD(x) waitSpiChar(START_CMD)
137118

138119
#define IF_CHECK_START_CMD(x) \
@@ -171,10 +152,7 @@ void SpiDrv::getParam(uint8_t* param)
171152
{
172153
// Get Params data
173154
*param = spiTransfer(DUMMY_DATA);
174-
DELAY_100NS;
175-
DELAY_100NS;
176-
DELAY_100NS;
177-
DELAY_100NS;
155+
DELAY_TRANSFER();
178156
}
179157

180158
int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)

0 commit comments

Comments
 (0)