rename I2C terminology
This commit is contained in:
1 parent
7993737b59
commit
132f11de33
8 files changed
+24
-24
No files matched your search
@@ -46,7 +46,7 @@ TwoWire::TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn,
|
||||
}
|
||||
|
||||
void TwoWire::begin(void) {
|
||||
//Master Mode
|
||||
//Main Mode
|
||||
master = true;
|
||||
|
||||
*pincfg_reg(_uc_pinSCL) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
|
||||
@@ -72,7 +72,7 @@ void TwoWire::begin(void) {
|
||||
}
|
||||
|
||||
void TwoWire::begin(uint8_t address) {
|
||||
//Slave mode
|
||||
//Secondary mode
|
||||
master = false;
|
||||
|
||||
*pincfg_reg(_uc_pinSCL) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Wire.begin(); // join i2c bus (address optional for main)
|
||||
Serial.begin(9600); // start serial communication at 9600bps
|
||||
while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void loop()
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
||||
// step 4: request reading from sensor
|
||||
Wire.requestFrom(112, 2); // request 2 bytes from slave device #112
|
||||
Wire.requestFrom(112, 2); // request 2 bytes from secondary device #112
|
||||
|
||||
// step 5: receive reading from sensor
|
||||
if(2 <= Wire.available()) // if two bytes were received
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Wire.begin(); // join i2c bus (address optional for main)
|
||||
}
|
||||
|
||||
byte val = 0;
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
// Wire Master Reader
|
||||
// Wire Main Reader
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Reads data from an I2C/TWI slave device
|
||||
// Refer to the "Wire Slave Sender" example for use with this
|
||||
// Reads data from an I2C/TWI secondary device
|
||||
// Refer to the "Wire Secondary Sender" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Wire.begin(); // join i2c bus (address optional for main)
|
||||
Serial.begin(9600); // start serial for output
|
||||
while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
|
||||
Wire.requestFrom(2, 6); // request 6 bytes from secondary device #2
|
||||
|
||||
while(Wire.available()) // slave may send less than requested
|
||||
while(Wire.available()) // secondary may send less than requested
|
||||
{
|
||||
char c = Wire.read(); // receive a byte as character
|
||||
Serial.print(c); // print the character
|
||||
File renamed without changes.
+4
-4
@@ -1,9 +1,9 @@
|
||||
// Wire Master Writer
|
||||
// Wire Main Writer
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Writes data to an I2C/TWI slave device
|
||||
// Refer to the "Wire Slave Receiver" example for use with this
|
||||
// Writes data to an I2C/TWI secondary device
|
||||
// Refer to the "Wire Secondary Receiver" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Wire.begin(); // join i2c bus (address optional for main)
|
||||
}
|
||||
|
||||
byte x = 0;
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
// Wire Slave Receiver
|
||||
// Wire Secondary Receiver
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Receives data as an I2C/TWI slave device
|
||||
// Refer to the "Wire Master Writer" example for use with this
|
||||
// Receives data as an I2C/TWI secondary device
|
||||
// Refer to the "Wire Main Writer" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
@@ -25,7 +25,7 @@ void loop()
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// function that executes whenever data is received from master
|
||||
// function that executes whenever data is received from main
|
||||
// this function is registered as an event, see setup()
|
||||
void receiveEvent(int howMany)
|
||||
{
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
// Wire Slave Sender
|
||||
// Wire Secondary Sender
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Sends data as an I2C/TWI slave device
|
||||
// Refer to the "Wire Master Reader" example for use with this
|
||||
// Sends data as an I2C/TWI secondary device
|
||||
// Refer to the "Wire Main Reader" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
@@ -23,10 +23,10 @@ void loop()
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// function that executes whenever data is requested by master
|
||||
// function that executes whenever data is requested by main
|
||||
// this function is registered as an event, see setup()
|
||||
void requestEvent()
|
||||
{
|
||||
Wire.write("hello "); // respond with message of 6 bytes
|
||||
// as expected by master
|
||||
// as expected by main
|
||||
}
|
||||
Reference in new issue
Block a user