Fix issue compiler option

This commit is contained in:
Mimmo La Fauci 2012-06-04 23:14:56 +02:00
parent a69cd64d5b
commit fb011d3c3b
2 changed files with 15 additions and 28 deletions

View File

@ -50,6 +50,7 @@
#define WARN(args) do {} while (0); #define WARN(args) do {} while (0);
#endif #endif
#if _DEBUG_SPI_
#define DBG_PIN2 5 #define DBG_PIN2 5
#define DBG_PIN 4 #define DBG_PIN 4
@ -64,5 +65,13 @@
#define TOGGLE_TRIGGER() SET_TRIGGER() \ #define TOGGLE_TRIGGER() SET_TRIGGER() \
delayMicroseconds(2); \ delayMicroseconds(2); \
RST_TRIGGER() RST_TRIGGER()
#else
#define START()
#define END()
#define SET_TRIGGER()
#define RST_TRIGGER()
#define INIT_TRIGGER()
#define TOGGLE_TRIGGER()
#endif
#endif #endif

View File

@ -13,7 +13,9 @@ extern "C" {
#define SLAVESELECT 10//ss #define SLAVESELECT 10//ss
#define SLAVEREADY 3 #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<X);}
#define DELAY_TRANSFER() DELAY_SPI(10)
void SpiDrv::begin() void SpiDrv::begin()
{ {
@ -78,9 +80,8 @@ char SpiDrv::spiTransfer(volatile char data)
{ {
}; };
char result = SPDR; char result = SPDR;
DELAY_100NS; DELAY_TRANSFER();
DELAY_100NS;
//delayMicroseconds(SPI_TX_DELAY);
return result; // return the received byte return result; // return the received byte
} }
@ -99,25 +100,8 @@ int SpiDrv::waitSpiChar(unsigned char waitChar)
return (_readChar == waitChar); return (_readChar == waitChar);
} }
//int SpiDrv::waitSpiChar(char waitChar, char* readChar)
//{
// int timeout = TIMEOUT_CHAR;
// do{
// *readChar = spiTransfer(DUMMY_DATA); //get data byte
// if (*readChar == WAIT_CMD)
// {
// INFO1("WAIT");
// delayMicroseconds(WAIT_CHAR_DELAY);
// }
// }while((timeout-- > 0) && (*readChar != waitChar));
//
// return (*readChar == waitChar);
//}
int SpiDrv::readAndCheckChar(char checkChar, char* readChar) int SpiDrv::readAndCheckChar(char checkChar, char* readChar)
{ {
//*readChar = spiTransfer(DUMMY_DATA); //get data byte
getParam((uint8_t*)readChar); getParam((uint8_t*)readChar);
return (*readChar == checkChar); return (*readChar == checkChar);
@ -128,11 +112,8 @@ char SpiDrv::readChar()
uint8_t readChar = 0; uint8_t readChar = 0;
getParam(&readChar); getParam(&readChar);
return 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 WAIT_START_CMD(x) waitSpiChar(START_CMD)
#define IF_CHECK_START_CMD(x) \ #define IF_CHECK_START_CMD(x) \
@ -171,10 +152,7 @@ void SpiDrv::getParam(uint8_t* param)
{ {
// Get Params data // Get Params data
*param = spiTransfer(DUMMY_DATA); *param = spiTransfer(DUMMY_DATA);
DELAY_100NS; DELAY_TRANSFER();
DELAY_100NS;
DELAY_100NS;
DELAY_100NS;
} }
int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len) int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)