is it possible write to console without stdlibs? c/c++

前端 未结 4 1734
夕颜
夕颜 2021-02-19 20:10

I am programming on an arm microprocessor and am trying to debug using print statements via UART. I do not want to add stdlibs just for debugging. Is there a way to

4条回答
  •  离开以前
    2021-02-19 20:21

    The concept of "console" does not have much meaning outside of the context of the specific system you are using. Generally in embedded program there is no real concept of a console.

    What you are looking for is a way to get data out of your system. If you want to use the UART, and you are not using a high-level OS like GNU/linux, you will need to write your own I/O drivers. Generally this means first configuring the UART for the desired butrate/parity/flow control via register writes. For any type of robust IO you will want it to be interrupt driven, so you will need to write ISRs for tx and rx that utilize circular buffers.

    After you have that done, you can write your own printf like Mats indicated.

提交回复
热议问题