MSPM0G3507——解决printf重定向在其他位置不能用的问题(printf重定向的补充)

除了之前发的文章的printf重定向的代码之外,还要加上这样一段代码即可

int puts(const char *_ptr)
{
        int count = fputs(_ptr,stdout);
        count +=fputs("\n",stdout);
        return count;



}

完整的重定向:

int fputc(int c, FILE* stream)
{
	DL_UART_Main_transmitDataBlocking(UART_0_INST, c);
    return c;
}

int fputs(const char* restrict s, FILE* restrict stream)
{
    uint16_t i, len;
    len = strlen(s);
    for(i=0; i<len; i++)
    {
        DL_UART_Main_transmitDataBlocking(UART_0_INST, s[i]);
    }
    return len;
}


int puts(const char *_ptr)
{
        int count = fputs(_ptr,stdout);
        count +=fputs("\n",stdout);
        return count;



}

放在主函数即可

相关推荐
Sean_woo19982 个月前
【笔记】MSPM0G3507使用RT-Thread console——MSPM0G3507与RT_Thread(三)
笔记·mspm0g3507·rt-thread nano
幻想时刻@3 个月前
MSPM0G3507——读取引脚的高低电平方法(数字信号循迹模块)
mspm0g3507
幻想时刻@3 个月前
MSPG3507——蓝牙接收数据显示在OLED,滴答定时器延时500MS
mspm0g3507
幻想时刻@3 个月前
MSPM0G3507——定时器例程讲解2——TIMX_time_mode_capture_duty_and_period
mspm0g3507
幻想时刻@3 个月前
MSPM0G3507——GPIO例程讲解1——input_capture
mspm0g3507