Topic

FAQ
Login Register
Compile Error (TLSR825x) / export string output using UART DMA
Nov 24, 2022 06:57

/

A

/A



I know that the "mini_printf" in the "printf.c" file within the "825x_BLE_SDK" is a port simulation.
I modified the source file to send this to UART DMA.
However, the basic C language header file was added as below to use the printf function.
An error occurs. Is there a solution?


#include <stdio.h>
#include <string.h>


Below are some of the codes I wrote to export string output using UART DMA.


voidcustomPrintFormat2(constchar *format, ...){
va_list ap;
char *buf, p;

buf = malloc(sizeof(char) * MAX_BUF_SIZE);
if(buf == NULL){
fprintf(stderr, "Memory allocation Error: %s[line: %d]", __FUNCTION__, __LINE__);
return;
}

va_start(ap, format);

while(*format){
p = *format++;
if(p == '%'){
p = *format++;
switch(p){
case'c':
sprintf(buf, "%s%c", buf, va_arg(ap, int));
break;
case'd':
sprintf(buf, "%s%d", buf, va_arg(ap, int));
break;
case'f':
sprintf(buf, "%s%f", buf, va_arg(ap, double));
break;
case'l':
if(*format++ == 'f'){
sprintf(buf, "%s%lf", buf, va_arg(ap, double));
}
break;
case's':
sprintf(buf, "%s%s", buf, va_arg(ap, char*));
break;
default:
sprintf(buf, "%s%%", buf);
break;
}
}else{
sprintf(buf, "%s%c", buf, p);
}
}

va_end(ap);


uart_dma_send((unsigned char*)&buf);
}



1 replies
TL_Soyo Nov 24, 2022 10:00
0
/A

Hi,

  Please avoid using the stdio, and use the printf taht we implemented