Beispiel #1
0
/** 
 * send a value y in ascii (hex)) to the debug serial port, 
 *  ex: WATCH_BYTE('2', bcount);
 *  ->  @2:FF
*/
void WATCH_BYTE( char x, uint8_t y)
{ 
__SERIAL_CAPTURE();
    DEBUG_putch('@'); _LOG_BYTE(x); DEBUG_putch(':'); 
    _LOG_BYTE(y); DEBUG_putch('\n'); 
__SERIAL_RELEASE();
}
Beispiel #2
0
/** send nth breakpoint and wait for the user to send back a char
 *  ex: BREAK_NUM(0x17);
 *  ->  17>    
 */
void BREAK(uint8_t x) 
{ 
__SERIAL_CAPTURE();    
    DEBUG_putch('#');  _LOG_BYTE(x);
    DEBUG_putch('>');  _DEBUG_Ack(); 
__SERIAL_RELEASE();
 }
Beispiel #3
0
// send a byte in asci(hex) to the serial port
void _LOG_BYTE( uint8_t b)
{
    char c = ((b >> 4) & 0x0f) + '0';    
    DEBUG_putch((c > '9') ? c + 7 : c);
    c = (b & 0x0f) + '0';
    DEBUG_putch((c > '9') ? c + 7 : c);
}
Beispiel #4
0
/** 
 * send a value y in ascii (hex)) to the debug serial port, 
 *  ex: WATCH_WORD('7', wcount);
 *  ->  @7:12AB
*/
void WATCH_WORD( char x, uint8_t w)  
{
__SERIAL_CAPTURE();
    DEBUG_putch('@'); _LOG_BYTE(x); DEBUG_putch(':'); 
    _LOG_BYTE((w)>>8);  _LOG_BYTE((w)); 
    DEBUG_putch('\n'); 
__SERIAL_RELEASE();
}
Beispiel #5
0
	void DEBUG_printf(const char* Str, ...)
	{
		va_list ap;
		va_start(ap, Str);
		while(*Str) {
			if(*Str == '%') {
				*Str++;
				switch(*Str) {
					/*** characters ***/
					case 'c': {
						const char c = (const char) va_arg (ap, const char);
						DEBUG_putch(c);
						*Str++;
						break;
					}
					/*** integers ***/
					case 'd':
					case 'i':
					{
						uint32_t c = va_arg (ap, uint32_t);
						uint8_t s[32]={0};
						itoa_s (c, 10, s);
						DEBUG_print((const char*) s);
						*Str++;		// go to next character
						break;
					}
					/*** display in hex ***/
					case 'X':
					case 'x':
					{
						uint32_t c = va_arg (ap, uint32_t);
						uint8_t s[32]={0};
						itoa_s (c,16,s);
						DEBUG_print((const char*) s);
						*Str++;		// go to next character
						break;
					}
					/*** strings ***/
					case 's':
					{
						const char *s = va_arg (ap, const char*);
						DEBUG_print((const char*) s);
						*Str++;		// go to next character
						break;
					}
					case '%':
					{
						DEBUG_putch('%');
						*Str++;
						break;
					}
				}
			} else {
Beispiel #6
0
// wait for user acknowledge, return char (absorb '/r')    
char _DEBUG_Ack(void)
{   char c;
    do{ 
        while(!EUSART_DataReady);   // wait 
        c = EUSART_Read();
        DEBUG_putch(c);            // echo
    } while (c == '\r');            // absorb
    return c;
}
Beispiel #7
0
// display breakpoint number, then respond to console
void BREAK_DBG(uint8_t x)
{
    char s[DEBUG_STR_SIZE], *ptr, c;    // input command string
    const char *sep = ",: ";            // valid separators
    uint8_t len = 0;
    
__SERIAL_CAPTURE();    
    // show breakpoint # first 
    DEBUG_putch('#');  _LOG_BYTE(x);
    
    // main console loop
    while(1){ 
        // prompt
        DEBUG_putch('\n');
        DEBUG_putch(':');      
        // receive command string
        while(1) {
            c = _DEBUG_Ack();
            if (c == '\n') 
                break;
            else if ((c < ' ') || (c > '~')) 
                continue;
            else if (len < DEBUG_STR_SIZE-1) {         
                s[len++] = c; s[len] = '\0';
            }
        }
        // process command string
        ptr = strtok(s, sep);
        while(ptr != NULL) {
            switch(toupper(*ptr++)) {
            case 'R': // read a byte/word from address
                switch(toupper(*ptr)) {
                case 'B': // read byte
                    ptr = strtok(NULL, sep);
                    uint16_t addr = xtoi(ptr);  // get addr
                    _LOG_BYTE(*(uint8_t*)addr);
                    break;
                case 'W': // read word
                    ptr = strtok(NULL, sep);
                    uint16_t addr = xtoi(ptr);  // get addr
                    _LOG_BYTE(*(uint8_t*)addr);
                    _LOG_BYTE(*(uint8_t*)(addr+1));
                    break;
                default:   // command not recognized
                    DEBUG_putch('?');
//                    _debug_puts("->valid commands are: RB, RW");                        
                }
                break;
            case 'W': // write a byte/word to memory
                switch(toupper(*ptr)) {
                case 'B': // write byte
                    ptr = strtok(NULL, sep);
                    uint16_t addr = xtoi(ptr);  // get addr
                    ptr = strtok(NULL, sep);
                    uint8_t value = xtoi(ptr);  // get value
                    *(uint8_t*)addr = value;
                    DEBUG_putch('!');                    
                    break;
                case 'W': // write word
                    ptr = strtok(NULL, sep);
                    uint16_t addr = xtoi(ptr);  // get addr
                    ptr = strtok(NULL, sep);
                    uint8_t value = xtoi(ptr);  // get value
                    *(uint8_t*)addr = value;
                    DEBUG_putch('!');                    
                    break;
                default:   // command not recognized
                    DEBUG_putch('?');                    
//                    _debug_puts("->valid commands are: WB, WW");                        
                }
                break;
            case 'C': // continue executing from where you left
                __SERIAL_RELEASE();
                return;
            default:   // command not recognized
                DEBUG_putch('?');
//                _debug_puts("->valid commands are: R, W, C");
            }
            ptr = strtok(NULL, sep);
        } // switch
        len = 0;
    } // console loop
}
Beispiel #8
0
/** 
 * send a char to the debug serial port, 
 *  ex: LOG_CHAR('*');
 *  ->  *
 */
void LOG_CHAR(char x)     
{
__SERIAL_CAPTURE();
    DEBUG_putch((x)); 
__SERIAL_RELEASE();
}
Beispiel #9
0
void _debug_puts(char*s)
{
    while(*s) DEBUG_putch(*s++);
    DEBUG_putch('\n');
}