Wire
Read/write two-wire serial (I2C) master (mwx::periph_wire)
Reads and writes two-wire serial (I2C) master.
Alias Definition
The mwx::periph_wire<MWX_TWOWIRE_RCVBUFF>
can be referred as TwoWire
.
Type Definitions
The following definition types describe the types of arguments and return values.
hint style="warning %}
Some APIs make calls where the STOP bit is not strictly handled.
write(), writer::operator() ()
has several arguments defined in addition to the ones described here.
fixed array type
uint8_t cmds[]={11,12};
...
Wire.write(cmds);
initializer_list<>
型Wire.write({11,12})
Initialization and termination
Wire Instance Creation
Instance creation and necessary initialization is done in the library. In user code, it is made available by calling Wire.begin()
.
When using the requestFrom()
method, you can specify the size of the FIFO queue for temporary data storage. At compile time, compile the macro MWX_TWOWIRE_BUFF
with the required number of bytes. The default is 32 bytes.
Example:
-DMWX_TWOWIRE_BUFF=16
begin()
Initialize hardware.
Performing any Wire operation without initialization will cause the TWELITE radio module to hang.
When waking from sleep, if the module was operating just before sleep, it will return to the previous state.
u8mode
Specifies the bus frequency. Default is 100Khz (WIRE_CONF::WIRE_100KHZ
)
The frequency is specified by WIRE_CONF::WIRE_? KHZ
and ? KHZ
can be 50
,66
,80
,100
,133
,160
,200
,266
,320
,400
.
b_portalt
Change hardware pin assignments.
Example
Reading and Writing
There are two types of read/write procedures. Select and use one of them.
Member function (input/output using the following member functions)
requestFrom(), beginTransmission(), endTransmission(), write()
Helper class (stream function available)
reader, writer
Others
Probe(Determine presence of device)
Checks if the device specified by address
is responding. If the device exists, true
is returned.
setClock()
The procedure is originally intended to change the bus frequency, but no action is taken.
最終更新