Ejemplo n.º 1
0
char *_debug_getstr(int *len)
{
    volatile int n = 0;;

    _debug_printf_flush();

    for(n=0;n<DEBUG_INPUT_BUFFER_SIZE;n++)
        debug_read_buf[n] = 0;

    if(ISDEBUGACTIVE())
        __read(0, debug_read_buf, DEBUG_INPUT_BUFFER_SIZE-1);

    if(len)
        *len = small_strlen(debug_read_buf);
    return debug_read_buf;
}
Ejemplo n.º 2
0
int _debug_printf_flush()
{
	uint8_t len, written;

	len = debug_buf_read_index <= debug_buf_write_index
			? debug_buf_write_index - debug_buf_read_index
			: DEBUG_OUTPUT_BUFFER_SIZE - debug_buf_read_index;

	if(!len)
		return 0;

	// The following if() disables semihosted writes when there is no hosted debugger
	// Otherwise, the target will halt when the semihost __write is called
	if(ISDEBUGACTIVE())
	    written = __write(0, &debug_write_buf[debug_buf_read_index], len);
	else
            written = 0;

	debug_buf_read_index = (debug_buf_read_index + written) % DEBUG_OUTPUT_BUFFER_SIZE;

	if(written != len)
		return written;
	return _debug_printf_flush() + written;
}
Ejemplo n.º 3
0
char *_debug_getstr(int *len)
{
    volatile int n = 0;;

#if CONFIG_DRIVER_PRINTF_REDLIBV2!=1
    _debug_printf_flush();
#endif

    for(n=0;n<DEBUG_INPUT_BUFFER_SIZE;n++)
        debug_read_buf[n] = 0;

    if(ISDEBUGACTIVE())
    {
#if CONFIG_DRIVER_PRINTF_REDLIBV2!=1
    	__read(0, debug_read_buf, DEBUG_INPUT_BUFFER_SIZE-1);
#else
    	__sys_read(0, debug_read_buf, DEBUG_INPUT_BUFFER_SIZE-1);
#endif
    }

    if(len)
        *len = small_strlen(debug_read_buf);
    return debug_read_buf;
}