Wire (Member Function Version)
Wire (using member functions)
using TwoWire = mwx::periph_twowire<MWX_TWOWIRE_RCVBUFF>;
mwx::periph_wire<MWX_TWOWIRE_RCVBUFF>
can be referenced as TwoWire
.
The following typedefs are used for argument and return types:
typedef uint8_t size_type;
typedef uint8_t value_type;
In addition to this explanation, several argument types are defined for write()
and writer::operator()
:
uint8_t cmds[]={11,12};
...
Wire.write(cmds);
initializer_list<>
typeWire.write({11,12})
Wire
instanceThe instance and necessary initialization are handled within the library. In user code, call Wire.begin()
to start using it.
When using the requestFrom()
method, you can specify the size of a FIFO queue for temporary data storage. At compile time, set the number of bytes via the macro MWX_TWOWIRE_BUFF
. The default is 32 bytes.
Example:
-DMWX_TWOWIRE_BUFF=16
begin()
void begin(
const size_type u8mode = WIRE_100KHZ,
bool b_portalt = false)
Initializes the hardware.
Parameter | Description |
---|---|
u8mode | Specifies the bus frequency. Default is 100KHz (WIRE_CONF::WIRE_100KHZ ).You can specify WIRE_CONF::WIRE_??KHZ where ?? can be 50 , 66 , 80 , 100 , 133 , 160 , 200 , 266 , 320 , 400 . |
b_portalt | Changes the hardware pin assignment. |
void setup() {
...
Wire.begin();
...
}
void wakeup() {
...
Wire.begin();
...
}
There are two procedures for reading and writing. Use either as needed.
Member function version (using the member functions below for I/O)
requestFrom(), beginTransmission(), endTransmission(), write()
Helper class version (stream functionality available)
reader, writer
bool probe(uint8_t address)
Checks if the device specified by address
responds. Returns true
if the device exists.
setClock()
void setClock(uint32_t speed)
This is intended to change the bus frequency, but it performs no action.
Wire (using member functions)
Wire (How to use with helper classes)