Topic

FAQ
Login Register
How can I print a string to DMA? (TLSR 825x )
Dec 12, 2022 08:59

/

A

/A

I want to send the output of "mini_printf" to DMA, not port simulation.
I modified it as below, but the string is not properly printed.
Using "uart_put_char(span);" outputs properly to port simulation.
However, it does not work properly to print this out to DMA.
Reference was made to the SDK source code.

How can I print a string to DMA?


The purpose of using DMA is to use UART communication with other modules by default as DMA, and I want to use it as a debug at the same time.
There are currently no normal ports left.



intmini_printf(constchar *format, ...){

    charspan;
    unsignedlongj;
    char *s;
    //char *msg;
    va_list arg_ptr;
    va_start(arg_ptr, format);

    uart_data_ttrans_buff = {0,   {0, } };

    unsignedchari=0;

    while((span = *(format++))){
        if(span != '%'){
            //uart_put_char(span);
            trans_buff.data[i]=span;
            i++;

        }else{
            span = *(format++);
            if(span == 'c'){
                j = va_arg(arg_ptr,int);//get value of char
                uart_put_char(j);
            }elseif(span == 'd'){
                j = va_arg(arg_ptr,int);//get value of char
                #if0
                if(j<0){
                    uart_put_char('-');
                    j = -j;
                }
                #endif
                puti(j,DECIMAL_OUTPUT);
            }elseif(span == 's'){
                s = va_arg(arg_ptr,char *);//get string value
                puts(s);
            }elseif(span == 'o'){
                j = va_arg(arg_ptr,unsignedint);//get octal value
                puti(j,OCTAL_OUTPUT);
            }elseif(span == 'x'){
                    j = va_arg(arg_ptr,unsignedint);//get hex value
                    puti(j,HEX_OUTPUT);
            }elseif(span == 0){
                break;
            }else{
                uart_put_char(span);
            }
        }

    }
    va_end(arg_ptr);

    trans_buff.dma_len = i;
    uart_dma_send((unsignedchar*)&trans_buff);

    return0;
}



1 replies
TL_Soyo Dec 12, 2022 10:39
0
/A

Hi,

  please refer to the source code to achieve your  own functions.at the same time you can download driver SDK for reference.