Wire.endTransmission()

描述

結束傳送資料到從端,傳送資料開始於 beginTransmission()endTransmission() 會把 write() 寫入暫存區的資料傳送出去。

endTransmission() 可以選擇要提供或是不提供參數,當不提供該參數時預設為 true,這個參數被用來改變 endTransmission() 的行為,如果該參數為 trueendTransmission() 在傳送完請求後會傳送停止的指令,釋放 I2C 介面。如果該參數為 falseendTransmission() 在傳送完請求後會傳送重新啟動的指令,不去釋放 I2C 介面,使得其他的主端無法發送請求,這樣允許一個主端在控制時可以發送多個請求。

語法


Wire.endTransmission()
Wire.endTransmission(stop)

參數

stop(非必要):如果 stoptrue 傳送請求後釋放 I2C,如果 stopfalse 傳送請求後不釋放 I2C,型態為 boolean,預設為 true,詳見上面的描述

回傳

byte:回傳資料傳輸的狀態
-0:成功
-1:資料超過傳輸的暫存區
-2:在傳送位址時收到 NACK
-3:在傳送資料時收到 NACK
-4:其他錯誤

See also

Wire.beginTransmission()
Wire.write()


函式庫參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.