mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Wire Examples based on AVR ones of the same name (#5713)
* Wire Examples based on AVR ones of the same name * Overload for begin(), change in callback arg from int to size_t * Update master_reader.ino Astyle * Update master_writer.ino Astyle * Update slave_receiver.ino Remove warning * Update slave_receiver.ino Astyle
This commit is contained in:
@ -51,7 +51,7 @@ uint8_t TwoWire::txBufferLength = 0;
|
||||
|
||||
uint8_t TwoWire::transmitting = 0;
|
||||
void (*TwoWire::user_onRequest)(void);
|
||||
void (*TwoWire::user_onReceive)(int);
|
||||
void (*TwoWire::user_onReceive)(size_t);
|
||||
|
||||
static int default_sda_pin = SDA;
|
||||
static int default_scl_pin = SCL;
|
||||
@ -69,6 +69,16 @@ void TwoWire::begin(int sda, int scl){
|
||||
flush();
|
||||
}
|
||||
|
||||
void TwoWire::begin(int sda, int scl, uint8_t address){
|
||||
default_sda_pin = sda;
|
||||
default_scl_pin = scl;
|
||||
twi_setAddress(address);
|
||||
twi_init(sda, scl);
|
||||
twi_attachSlaveTxEvent(onRequestService);
|
||||
twi_attachSlaveRxEvent(onReceiveService);
|
||||
flush();
|
||||
}
|
||||
|
||||
void TwoWire::pins(int sda, int scl){
|
||||
default_sda_pin = sda;
|
||||
default_scl_pin = scl;
|
||||
@ -255,7 +265,7 @@ void TwoWire::onRequestService(void)
|
||||
user_onRequest();
|
||||
}
|
||||
|
||||
void TwoWire::onReceive( void (*function)(int) ) {
|
||||
void TwoWire::onReceive( void (*function)(size_t) ) {
|
||||
user_onReceive = function;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user