This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F28.0025万C:如何将scanf函数重定向到SCI?

Guru**** 2460650 points
Other Parts Discussed in Thread: C2000WARE

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1094665/tms320f280025c-how-to-redirect-the-scanf-function-to-sci

部件号:TMS320F28.0025万C
主题中讨论的其他部件:C2000WARE

各位专家,您好!  

您能否分享如何将'SCANF'函数重定向到SCI接口的方法或演示? 在C2000Ware演示的帮助下,我找到并实现了SCI上的打印功能,但客户希望进一步实现扫描功能。 感谢你的帮助。  

此致,  

意愿  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    我目前正在研究这方面所需的要求,以及是否可以为scanf扩展当前的示例。 我将在下周中作出答复。

    此致,

    文斯

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    您是否可以尝试以下(未经测试的)代码? 如果这还不够,我会联系我们,但我认为对“sci_ex4_stdout_redirect”C2000Ware示例所做的以下更改就足够了。

    示例所需的更改:

    在sci_ex4_sdout redirect.c文件中:

    1.将UartGetChar添加到声明中:

    //
    // Declarations
    //
    void UartSetup();
    void UartPutChar(uint16_t charToWrite);
    uint16_t UartGetChar();

    2.将UartGetChar函数添加到文件底部:

    uint16_t UartGetChar()
    {
        return SCI_readCharBlockingFIFO(SCIA_BASE)
    }

    在UART_drv.c文件中:

    1.将“UART_READ”函数更改为如下所示:

    /*****************************************************************************/
    /*                                                                           */
    /* UART_read() reads *at most* count bytes.                                  */
    /*                                                                           */
    /*****************************************************************************/
    int UART_read(int dev_fd, char *buf, unsigned count)
    {
        /*-----------------------------------------------------------------------*/
        /* Get chars using the SCI peripheral, blocking read wait for response   */
        /*-----------------------------------------------------------------------*/
        for (i=0; i < count; i++)
            buf[i] = UartGetChar();
    
        return count;
    }

    请告诉我这是否有效,如果不能,我将与驱动程序团队团队同步,以确定UART_drv*文件的必要更新。

    此致,

    文斯