PolarFire® SoC 移植 xprintf
1、xprintf 简介
ELM - Embedded String Functions
xprintf 是一个紧凑的字符串 I/O 库。它非常适合程序内存不足的微型微控制器来执行常规 printf 功能。推荐用途是:将格式化的字符串写入 LCD 或 UART 以及调试/维护控制台。
xprintf 可以配置配置选项以减小模块大小。
2、将 xprintf.c 和 xprintf.h 放到工程中
3、修改 xprintf.h 配置,因为 polarfire soc 64位处理器, 使能 XF_USE_LLI , 暂时没有使能 浮点打印 ,
#define XF_USE_OUTPUT 1 /* 1: Enable output functions */
#define XF_CRLF 0 /* 1: Convert \n ==> \r\n in the output char */
#define XF_USE_DUMP 0 /* 1: Enable put_dump function */
#define XF_USE_LLI 1 /* 1: Enable long long integer in size prefix ll */
#define XF_USE_FP 0 /* 1: Enable support for floating point in type e and f */
#define XF_DPC '.' /* Decimal separator for floating point */
#define XF_USE_INPUT 0 /* 1: Enable input functions */
#define XF_INPUT_ECHO 0 /* 1: Echo back input chars in xgets function */
4、 在 main.c 所在文件中,包含 xprintf.h , 初始化接口 调用如下
xdev_out(xprintf_output_c);
5、xprintf_output_c 函数编写
void xprintf_output_c( uint8_t ch )
{
MSS_UART_polled_tx(p_uartmap_u54_1, &ch, 1 );
}
6、测试打印输出接口
void x_system_task( void * arg )
{
for(;;)
{
xprintf( "tick:%llu\n", xTaskGetTickCount() );
vTaskDelay(1000);
}
}
输出结果

浙公网安备 33010602011771号