Skip to content

Commit

Permalink
replace waitDoingServices with macro in order to be able to actually …
Browse files Browse the repository at this point in the history
…respect the break_flag...
  • Loading branch information
Timm Korte committed Jun 27, 2016
1 parent 7718653 commit 8cf6e18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apps/xBridge2/xBridge2.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ typedef struct _command_buff
//create a static command structure to use.
static t_command_buff command_buff;

// macro to wait a specified number of milliseconds, whilst processing services.
#define waitDoingServices(wait_time, break_flag, bProtocolServices) \
do { \
XDATA uint32 start_wait; \
start_wait = getMs(); \
while ((getMs() - start_wait) < wait_time) { \
doServices(bProtocolServices); \
if(break_flag) break; \
delayMs(20); \
} \
if (break_flag && send_debug) { \
printf_fast("%lu returned from waitDoingServices after %lu of %d ms\r\n", getMs(), (getMs() - start_wait), wait_time); \
} \
} while (0)

void setFlag(uint8 ptr, uint8 val)
{
if(val)
Expand Down Expand Up @@ -844,6 +859,7 @@ void uartEnable() {
U1CSR |= 0x40; // Recevier enable
}

/**
// function to wait a specified number of milliseconds, whilst processing services.
void waitDoingServices (uint32 wait_time, volatile BIT break_flag, BIT bProtocolServices ) {
XDATA uint32 start_wait;
Expand All @@ -858,6 +874,7 @@ void waitDoingServices (uint32 wait_time, volatile BIT break_flag, BIT bProtocol
delayMs(20);
}
}
**/



Expand Down

0 comments on commit 8cf6e18

Please sign in to comment.