Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
TwoWire Class Referenceabstract

I2C (2-Wire)를 제어하기 위한 클래스 More...

#include <TwoWire.hpp>

Public Types

enum  MasterWriteError_t {
  SUCCESS = 0 , DATA_TOO_LONG = 1 , NACK_ON_ADDRESS = 2 , NACK_ON_DATA = 3 ,
  OTHER_ERROR = 4
}

Public Member Functions

virtual void begin ()
virtual void end ()=0
 2-wire 연결을 종료합니다.
virtual void setClock (uint32_t frequency)=0
 2-wire 연결에 사용할 클럭(단위: Hz)을 설정합니다.
void beginTransmission (uint8_t address)
 전송 시작을 설정합니다.
virtual MasterWriteError_t endTransmission (bool stop=true)=0
 송신 버퍼에 기록된 데이터를 전송하고 종료합니다.
virtual size_t requestFrom (uint8_t address, size_t length, bool stop=true)=0
 Master가 slave에게 데이터를 요청합니다.
uint8_t write (uint8_t val)
 전송할 데이터 1-byte를 내부 송신 버퍼에 기록합니다.
uint8_t write (const uint8_t *data, uint8_t len)
 전송할 데이터 byte array를 내부 버퍼에 기록합니다.
uint8_t available ()
 수신 버퍼에 데이터가 얼마나 남아있는지 확인합니다.
int read ()
 수신 버퍼로부터 1-byte 데이터를 읽습니다.
virtual void onReceive (void(*handler)(TwoWire &wire, uint8_t numBytes))
virtual void onRequest (void(*handler)(TwoWire &wire))

Public Attributes

uint16_t timeout = 10000
 Timeout을 설정합니다.

Protected Attributes

bool transmitting = false
bool sendStop = false
bool inRepStart = false
uint8_t rxBuffer [32]
uint8_t rxBufferIndex = 0
uint8_t rxBufferLength = 0
uint8_t txBuffer [32]
uint8_t txBufferIndex = 0
uint8_t txBufferLength = 0
uint8_t txAddress
void(* receiveHandler )(TwoWire &, uint8_t) = nullptr
void(* requestHandler )(TwoWire &) = nullptr

Detailed Description

I2C (2-Wire)를 제어하기 위한 클래스

Member Enumeration Documentation

◆ MasterWriteError_t

Enumerator
SUCCESS 

성공

DATA_TOO_LONG 

송신할 데이터가 너무 길어 실패

NACK_ON_ADDRESS 

주소에 대해 NACK 수신

NACK_ON_DATA 

Data 전송 중 NACK 수신

OTHER_ERROR 

Timeout을 포함한 기타 오류

86 {
91 SUCCESS = 0,
92
97 DATA_TOO_LONG = 1,
98
103 NACK_ON_ADDRESS = 2,
104
109 NACK_ON_DATA = 3,
110
115 OTHER_ERROR = 4,
116 };
@ OTHER_ERROR
Timeout을 포함한 기타 오류
Definition TwoWire.hpp:115
@ NACK_ON_DATA
Data 전송 중 NACK 수신
Definition TwoWire.hpp:109
@ DATA_TOO_LONG
송신할 데이터가 너무 길어 실패
Definition TwoWire.hpp:97
@ SUCCESS
성공
Definition TwoWire.hpp:91
@ NACK_ON_ADDRESS
주소에 대해 NACK 수신
Definition TwoWire.hpp:103

Member Function Documentation

◆ begin()

virtual void TwoWire::begin ( )
virtual

\begin 2-wire 연결을 시작합니다.

◆ endTransmission()

virtual MasterWriteError_t TwoWire::endTransmission ( bool stop = true)
pure virtual

송신 버퍼에 기록된 데이터를 전송하고 종료합니다.

Parameters
stop전송 후 STOP 신호 전송여부를 지정합니다.
Returns

◆ onReceive()

virtual void TwoWire::onReceive ( void(* handler )(TwoWire &wire, uint8_t numBytes))
inlinevirtual
166 {
167 this->receiveHandler = handler;
168 }

◆ onRequest()

virtual void TwoWire::onRequest ( void(* handler )(TwoWire &wire))
inlinevirtual
170 {
171 this->requestHandler = handler;
172 }

◆ requestFrom()

virtual size_t TwoWire::requestFrom ( uint8_t address,
size_t length,
bool stop = true )
pure virtual

Master가 slave에게 데이터를 요청합니다.

Parameters
stop전송 후 STOP 신호 전송여부를 지정합니다.
Returns
수신한 데이터의 크기. (단위: byte) 오류 발생시 발생 전까지 수신한 데이터의 크기를 반환합니다.

Member Data Documentation

◆ timeout

uint16_t TwoWire::timeout = 10000

Timeout을 설정합니다.

endTransmission() 및 requestFrom() 시 설정한 timeout을 경과하면 반환하게 합니다. 단위는 밀리초이며, 기본 값은 10초 입니다.


The documentation for this class was generated from the following file: