/* util.c */ #include "rtxcapi.h" #include "rtxcuart.h" #include "kthread.h" #include "util.h" /* * These stubs are used to prevent pulling in some * standard libraries. The library versions of * these functions should be used when working with * C++ code, as they handle constructors and destructors. */ void atexit(void) {} void __main(void) {} void exit(int status) { while(1); } void printl(const char *buffer) { //extern unsigned int stat_txdropped; //&RA does not work/ #define USETRAP15 #ifdef USETRAP15 //asm ("nop"); asm (" MOVE.L 8(%A6),%D1"); asm (" move.l #0x0013, %d0"); asm (" trap #15"); #else unsigned int txdropped ; while (*buffer != '\0') /* loop till end of string */ { if(*buffer == '\n') (rtxcss_uart_tx('\r')); /*do { txdropped = stat_txdropped; rtxcss_uart_tx(*buffer); }while (txdropped != stat_txdropped); */ while(rtxcss_uart_tx(*buffer)<=0); buffer++; } #endif } void print_thread_id_message(void) { printl("Thread: "); switch(TS_GetThreadID()) { case THREAD1: printl("THREAD1"); break; case THREAD2: printl("THREAD2"); break; case THREAD3: printl("THREAD3"); break; default: printl("Unknown"); break; } } void print_state_message(unsigned int state) { if(state < 10) { printl(" State: "); rtxcss_uart_tx('0' + state); rtxcss_uart_tx('\r'); rtxcss_uart_tx('\n'); } } void itoa_q(long value, char* letters, int length, int radix) { //long radix 10; unsigned long uvalue=value; int ii; unsigned char *letter = letters+length; for(ii=0, *letter-- = 0;ii