- /****** debug vars & defs & functions ***********************/
-#ifdef MACM_DEBUG
-#define HISTORY_ENTRIES 100
- typedef struct {
- int index;
- macState_t state;
- int place;
- } history_t;
-
- history_t history[HISTORY_ENTRIES];
- unsigned histIndex;
- void storeOldState(int p) {
- atomic {
- history[histIndex].index = histIndex;
- history[histIndex].state = macState;
- history[histIndex].place = p;
- histIndex++;
- if(histIndex >= HISTORY_ENTRIES) histIndex = 0;
- }
- }
-#else
- void storeOldState(int p) {};
-#endif
-
- void signalFailure(uint8_t place) {
-#ifdef MACM_DEBUG
- unsigned long i;
- atomic {
- for(;;) {
- call Led0.set();
- call Led1.clr();
- call Led2.clr();
- call Led3.clr();
-
- for(i = 0; i < 1000000; i++) {
- ;
- }
-
- (place & 1) ? call Led0.set() : call Led0.clr();
- (place & 2) ? call Led1.set() : call Led1.clr();
- (place & 4) ? call Led2.set() : call Led2.clr();
- (place & 8) ? call Led3.set() : call Led3.clr();
-
- for(i = 0; i < 1000000; i++) {
- ;
- }
-
- (macState & 1) ? call Led0.set() : call Led0.clr();
- (macState & 2) ? call Led1.set() : call Led1.clr();
- (macState & 4) ? call Led2.set() : call Led2.clr();
- (macState & 8) ? call Led3.set() : call Led3.clr();
-
- for(i = 0; i < 1000000; i++) {
- ;
- }
- }
- }
-#endif
- }
-
- void signalMacState() {
-#ifdef MACM_DEBUG
-/*
- (macState & 1) ? call Led0.set() : call Led0.clr();
- (macState & 2) ? call Led1.set() : call Led1.clr();
- (macState & 4) ? call Led2.set() : call Led2.clr();
- (macState & 8) ? call Led3.set() : call Led3.clr();
-*/
-#endif
- }
-