日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

MCU_通过windows串口API控制RTS和DTR

發布時間:2023/12/9 windows 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MCU_通过windows串口API控制RTS和DTR 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

用FLYMCU-ISP進行固件燒錄的教程比較多,一直比較好奇,RTS和DTR這兩個引腳是如何通過軟件完成的。網上問這個問題的也不少,正確答案不多見。今天查了一下,做個備注吧!

問題

MCUISP是怎樣判斷并控制RTS和DTR輸出的?

比如下面這個,OPENEDV上討論得比較多的電路(以下圖片均來自OpenEDV【1】),

回答

事實上這個問題很簡單,通過Windows串口API即可實現,我直接把該函數列到下面【2】,

EscapeCommFunction function

  • 12/05/2018
  • 2 minutes to read

Directs the specified communications device to perform an extended function.

Syntax

C++Copy

BOOL EscapeCommFunction(HANDLE hFile,DWORD dwFunc );

Parameters

hFile

A handle to the communications device. The?CreateFile?function returns this handle.

dwFunc

The extended function to be performed. This parameter can be one of the following values.

TABLE 1ValueMeaning

CLRBREAK

9

Restores character transmission and places the transmission line in a nonbreak state. The CLRBREAK extended function code is identical to the?ClearCommBreak?function.

CLRDTR

6

Clears the DTR (data-terminal-ready) signal.

CLRRTS

4

Clears the RTS (request-to-send) signal.

SETBREAK

8

Suspends character transmission and places the transmission line in a break state until the?ClearCommBreak?function is called (or?EscapeCommFunction?is called with the CLRBREAK extended function code). The SETBREAK extended function code is identical to the?SetCommBreak?function. Note that this extended function does not flush data that has not been transmitted.

SETDTR

5

Sends the DTR (data-terminal-ready) signal.

SETRTS

3

Sends the RTS (request-to-send) signal.

SETXOFF

1

Causes transmission to act as if an XOFF character has been received.

SETXON

2

Causes transmission to act as if an XON character has been received.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call?GetLastError.

Requirements

TABLE 2??
Minimum supported clientWindows?XP [desktop apps | UWP apps]
Minimum supported serverWindows Server?2003 [desktop apps | UWP apps]
Target PlatformWindows
Headerwinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

?

參考:

【1】http://www.openedv.com/posts/list/50030.htm

【2】https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-escapecommfunction

總結

以上是生活随笔為你收集整理的MCU_通过windows串口API控制RTS和DTR的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。