void openserial_startOutput() { //schedule a task to get new status in the output buffer uint8_t debugPrintCounter; INTERRUPT_DECLARATION(); DISABLE_INTERRUPTS(); openserial_vars.debugPrintCounter = (openserial_vars.debugPrintCounter+1)%STATUS_MAX; debugPrintCounter = openserial_vars.debugPrintCounter; ENABLE_INTERRUPTS(); // print debug information switch (debugPrintCounter) { case STATUS_ISSYNC: if (debugPrint_isSync()==TRUE) { break; } case STATUS_ID: if (debugPrint_id()==TRUE) { break; } case STATUS_DAGRANK: if (debugPrint_myDAGrank()==TRUE) { break; } case STATUS_OUTBUFFERINDEXES: if (debugPrint_outBufferIndexes()==TRUE) { break; } case STATUS_ASN: if (debugPrint_asn()==TRUE) { break; } case STATUS_MACSTATS: if (debugPrint_macStats()==TRUE) { break; } case STATUS_SCHEDULE: if(debugPrint_schedule()==TRUE) { break; } case STATUS_BACKOFF: if(debugPrint_backoff()==TRUE) { break; } case STATUS_QUEUE: if(debugPrint_queue()==TRUE) { break; } case STATUS_NEIGHBORS: if (debugPrint_neighbors()==TRUE) { break; } case STATUS_KAPERIOD: if (debugPrint_kaPeriod()==TRUE) { break; } default: DISABLE_INTERRUPTS(); openserial_vars.debugPrintCounter=0; ENABLE_INTERRUPTS(); } // flush buffer uart_clearTxInterrupts(); uart_clearRxInterrupts(); // clear possible pending interrupts uart_enableInterrupts(); // Enable USCI_A1 TX & RX interrupt DISABLE_INTERRUPTS(); openserial_vars.mode=MODE_OUTPUT; if (openserial_vars.outputBufFilled) { #ifdef FASTSIM uart_writeCircularBuffer_FASTSIM( openserial_vars.outputBuf, &openserial_vars.outputBufIdxR, &openserial_vars.outputBufIdxW ); #else uart_writeByte(openserial_vars.outputBuf[openserial_vars.outputBufIdxR++]); #endif } else { openserial_stop(); } ENABLE_INTERRUPTS(); }
void openserial_startOutput() { //schedule a task to get new status in the output buffer uint8_t temp_openserial_debugPrintCounter; //to avoid many atomics INTERRUPT_DECLARATION(); DISABLE_INTERRUPTS(); openserial_vars.debugPrintCounter=(openserial_vars.debugPrintCounter+1)%STATUS_MAX; temp_openserial_debugPrintCounter = openserial_vars.debugPrintCounter; ENABLE_INTERRUPTS(); switch (temp_openserial_debugPrintCounter) { case STATUS_ISSYNC: if (debugPrint_isSync()==TRUE) { break; } case STATUS_ID: if (debugPrint_id()==TRUE) { break; } case STATUS_DAGRANK: if (debugPrint_myDAGrank()==TRUE) { break; } case STATUS_OUTBUFFERINDEXES: if(debugPrint_outBufferIndexes()==TRUE) { break; } case STATUS_ASN: if(debugPrint_asn()==TRUE) { break; } case STATUS_MACSTATS: if (debugPrint_macStats()==TRUE) { break; } case STATUS_SCHEDULE: if(debugPrint_schedule()==TRUE) { break; } case STATUS_QUEUE: if(debugPrint_queue()==TRUE) { break; } case STATUS_NEIGHBORS: if(debugPrint_neighbors()==TRUE) { break; } default: DISABLE_INTERRUPTS(); openserial_vars.debugPrintCounter=0; ENABLE_INTERRUPTS(); } //print out what's in the buffer now uart_clearTxInterrupts(); uart_clearRxInterrupts(); // clear possible pending interrupts uart_enableInterrupts(); // Enable USCI_A1 TX & RX interrupt DISABLE_INTERRUPTS(); openserial_vars.mode=MODE_OUTPUT; if (openserial_vars.somethingInOutputBuffer) { uart_writeByte(openserial_vars.output_buffer[output_buffer_index_read_increment()]); } else { openserial_stop(); } ENABLE_INTERRUPTS(); }
void task_openserial_debugPrint(void) { uint8_t debugPrintCounter; INTERRUPT_DECLARATION(); //<<<<<<<<<<<<<<<<<<<<<<< DISABLE_INTERRUPTS(); debugPrintCounter = openserial_vars.debugPrintCounter; ENABLE_INTERRUPTS(); //>>>>>>>>>>>>>>>>>>>>>>> if (openserial_vars.outputBufIdxW!=openserial_vars.outputBufIdxR) { return; } debugPrintCounter++; if (debugPrintCounter==STATUS_MAX) { debugPrintCounter = 0; } switch (debugPrintCounter) { case STATUS_ISSYNC: if (debugPrint_isSync()==TRUE) { break; } case STATUS_ID: if (debugPrint_id()==TRUE) { break; } case STATUS_DAGRANK: if (debugPrint_myDAGrank()==TRUE) { break; } case STATUS_OUTBUFFERINDEXES: if (debugPrint_outBufferIndexes()==TRUE) { break; } case STATUS_ASN: if (debugPrint_asn()==TRUE) { break; } case STATUS_MACSTATS: if (debugPrint_macStats()==TRUE) { break; } case STATUS_SCHEDULE: if(debugPrint_schedule()==TRUE) { break; } case STATUS_BACKOFF: if(debugPrint_backoff()==TRUE) { break; } case STATUS_QUEUE: if(debugPrint_queue()==TRUE) { break; } case STATUS_NEIGHBORS: if (debugPrint_neighbors()==TRUE) { break; } case STATUS_KAPERIOD: if (debugPrint_kaPeriod()==TRUE) { break; } case STATUS_JOINED: if (debugPrint_joined()==TRUE) { break; } default: debugPrintCounter=0; } //<<<<<<<<<<<<<<<<<<<<<<< DISABLE_INTERRUPTS(); openserial_vars.debugPrintCounter = debugPrintCounter; ENABLE_INTERRUPTS(); //>>>>>>>>>>>>>>>>>>>>>>> }