Skip to content

Commit b64fce0

Browse files
Merge branch 'aster94-master'
2 parents 39ced7a + 765a7da commit b64fce0

File tree

16 files changed

+82
-132
lines changed

16 files changed

+82
-132
lines changed

STM32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ All text above, and the splash screen below must be included in any redistributi
2222
//#endif
2323
#include <stdlib.h>
2424

25-
//#include <Wire.h>
25+
2626
#include <Wire.h>
27-
//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1
28-
//HardWire HWIRE(2,I2C_FAST_MODE); // I2c2
27+
//TwoWire WIRE(1,I2C_FAST_MODE); // I2c1
28+
//TwoWire WIRE(2,I2C_FAST_MODE); // I2c2
2929
#include "Adafruit_GFX.h"
3030
#include "Adafruit_SSD1306_STM32.h"
3131

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
STM32 adaption by Matthias Diro, 25.03.2015
22
Things to know:
3-
This adaption uses hardware I2C (hardwire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
3+
This adaption uses hardware I2C (now Wire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
44
To change it to Port I2C1:
5-
//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1
6-
HardWire HWIRE(2,I2C_FAST_MODE); // I2c2
5+
//TwoWire WIRE(1,I2C_FAST_MODE); // I2c1
6+
TwoWire WIRE(2,I2C_FAST_MODE); // I2c2

STM32F1/libraries/Adafruit_SSD1306/examples/ssd1306_128x64_i2c_STM32/ssd1306_128x64_i2c_STM32.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
STM32 adaption by Matthias Diro, tested with maple mini and heltec OLED 12864 I2c; adress: 0x3C (SPI should work, but I didn't own one)
33
Things to know:
4-
This adaption uses hardware I2C (hardwire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
4+
This adaption uses hardware I2C (now Wire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
55
further details: STM32_README.txt
66
*/
77
/*********************************************************************

STM32F1/libraries/OLED_I2C/OLED_I2C.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
*/
8888
#elif defined (__STM32F1__)
8989
#include "Arduino.h"
90-
//#include <HardWire.h>
90+
//#include <Wire.h>
9191
#include "hardware/arm/HW_STM32_defines.h"
9292
#endif
9393

STM32F1/libraries/OLED_I2C/hardware/arm/HW_STM32.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "Wire.h"
22
#define WIRE_WRITE HWIRE.write
33

4-
HardWire HWIRE(2,I2C_FAST_MODE); // stupid compiler
4+
TwoWire WIRE(2,I2C_FAST_MODE); // stupid compiler
55

66
void OLED::_convert_float(char *buf, double num, int width, byte prec)
77
{

STM32F1/libraries/Wire/SoftWire.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*****************************************************************************/
2626

2727
/**
28-
* @file Wire.cpp
28+
* @file SoftWire.cpp
2929
* @author Trystan Jones <[email protected]>
3030
* @brief Wire library, uses the WireBase to create the primary interface
3131
* while keeping low level interactions invisible to the user.
@@ -54,7 +54,7 @@
5454
* - always start with i2c_delay rather than end
5555
*/
5656

57-
void TwoWire::set_scl(bool state) {
57+
void SoftWire::set_scl(bool state) {
5858
I2C_DELAY(this->i2c_delay);
5959

6060
gpio_write_bit(sclDevice,sclBit, state);
@@ -65,30 +65,30 @@ void TwoWire::set_scl(bool state) {
6565
}
6666
}
6767

68-
void TwoWire::set_sda(bool state) {
68+
void SoftWire::set_sda(bool state) {
6969
I2C_DELAY(this->i2c_delay);
7070
gpio_write_bit(sdaDevice,sdaBit, state);
7171
//digitalWrite(this->sda_pin, state);
7272
}
7373

74-
void TwoWire::i2c_start() {
74+
void SoftWire::i2c_start() {
7575
set_sda(LOW);
7676
set_scl(LOW);
7777
}
7878

79-
void TwoWire::i2c_stop() {
79+
void SoftWire::i2c_stop() {
8080
set_sda(LOW);
8181
set_scl(HIGH);
8282
set_sda(HIGH);
8383
}
8484

85-
void TwoWire::i2c_repeated_start() {
85+
void SoftWire::i2c_repeated_start() {
8686
set_sda(HIGH);
8787
set_scl(HIGH);
8888
set_sda(LOW);
8989
}
9090

91-
bool TwoWire::i2c_get_ack() {
91+
bool SoftWire::i2c_get_ack() {
9292
set_scl(LOW);
9393
set_sda(HIGH);
9494
set_scl(HIGH);
@@ -98,19 +98,19 @@ bool TwoWire::i2c_get_ack() {
9898
return ret;
9999
}
100100

101-
void TwoWire::i2c_send_ack() {
101+
void SoftWire::i2c_send_ack() {
102102
set_sda(LOW);
103103
set_scl(HIGH);
104104
set_scl(LOW);
105105
}
106106

107-
void TwoWire::i2c_send_nack() {
107+
void SoftWire::i2c_send_nack() {
108108
set_sda(HIGH);
109109
set_scl(HIGH);
110110
set_scl(LOW);
111111
}
112112

113-
uint8 TwoWire::i2c_shift_in() {
113+
uint8 SoftWire::i2c_shift_in() {
114114
uint8 data = 0;
115115
set_sda(HIGH);
116116

@@ -124,7 +124,7 @@ uint8 TwoWire::i2c_shift_in() {
124124
return data;
125125
}
126126

127-
void TwoWire::i2c_shift_out(uint8 val) {
127+
void SoftWire::i2c_shift_out(uint8 val) {
128128
int i;
129129
for (i = 0; i < 8; i++) {
130130
set_sda(!!(val & (1 << (7 - i)) ) );
@@ -134,7 +134,7 @@ void TwoWire::i2c_shift_out(uint8 val) {
134134
}
135135

136136
//process needs to be updated for repeated start.
137-
uint8 TwoWire::process(uint8 stop) {
137+
uint8 SoftWire::process(uint8 stop) {
138138
itc_msg.xferred = 0;
139139

140140
uint8 sla_addr = (itc_msg.addr << 1);
@@ -183,18 +183,18 @@ uint8 TwoWire::process(uint8 stop) {
183183
}
184184

185185
// For compatibility with legacy code
186-
uint8 TwoWire::process(){
186+
uint8 SoftWire::process(){
187187
return process(true);
188188
}
189189

190190
// TODO: Add in Error Handling if pins is out of range for other Maples
191191
// TODO: Make delays more capable
192-
TwoWire::TwoWire(uint8 scl, uint8 sda, uint8 delay) : i2c_delay(delay) {
192+
SoftWire::SoftWire(uint8 scl, uint8 sda, uint8 delay) : i2c_delay(delay) {
193193
this->scl_pin=scl;
194194
this->sda_pin=sda;
195195
}
196196

197-
void TwoWire::begin(uint8 self_addr) {
197+
void SoftWire::begin(uint8 self_addr) {
198198
tx_buf_idx = 0;
199199
tx_buf_overflow = false;
200200
rx_buf_idx = 0;
@@ -210,7 +210,7 @@ void TwoWire::begin(uint8 self_addr) {
210210
set_sda(HIGH);
211211
}
212212

213-
void TwoWire::end()
213+
void SoftWire::end()
214214
{
215215
if (this->scl_pin)
216216
{
@@ -222,7 +222,7 @@ void TwoWire::end()
222222
}
223223
}
224224

225-
void TwoWire::setClock(uint32_t frequencyHz)
225+
void SoftWire::setClock(uint32_t frequencyHz)
226226
{
227227
switch(frequencyHz)
228228
{
@@ -236,11 +236,11 @@ void TwoWire::setClock(uint32_t frequencyHz)
236236
}
237237
}
238238

239-
TwoWire::~TwoWire() {
239+
SoftWire::~SoftWire() {
240240
this->scl_pin=0;
241241
this->sda_pin=0;
242242
}
243243

244244
// Declare the instance that the users of the library can use
245-
//TwoWire Wire(SCL, SDA, SOFT_STANDARD);
246-
//TwoWire Wire(PB6, PB7, SOFT_FAST);
245+
//SoftWire Wire(SCL, SDA, SOFT_STANDARD);
246+
//SoftWire Wire(PB6, PB7, SOFT_FAST);

STM32F1/libraries/Wire/SoftWire.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*****************************************************************************/
2626

2727
/**
28-
* @file Wire.h
28+
* @file SoftWire.h
2929
* @author Trystan Jones <[email protected]>
3030
* @brief Wire library, uses the WireBase to create the primary interface
3131
* while keeping low level interactions invisible to the user.
@@ -40,7 +40,7 @@
4040
#ifndef _SOFTWIRE_H_
4141
#define _SOFTWIRE_H_
4242

43-
#include "WireBase.h"
43+
#include "utility/WireBase.h"
4444
#include "wirish.h"
4545

4646
/*
@@ -60,7 +60,7 @@
6060

6161

6262

63-
class TwoWire : public WireBase {
63+
class SoftWire : public WireBase {
6464
public:
6565
uint8 i2c_delay;
6666
uint8 scl_pin;
@@ -136,7 +136,7 @@ class TwoWire : public WireBase {
136136
* Accept pin numbers for SCL and SDA lines. Set the delay needed
137137
* to create the timing for I2C's Standard Mode and Fast Mode.
138138
*/
139-
TwoWire(uint8 scl=SCL, uint8 sda=SDA, uint8 delay=SOFT_STANDARD);
139+
SoftWire(uint8 scl=SCL, uint8 sda=SDA, uint8 delay=SOFT_STANDARD);
140140

141141
/*
142142
* Sets pins SDA and SCL to OUPTUT_OPEN_DRAIN, joining I2C bus as
@@ -155,9 +155,9 @@ class TwoWire : public WireBase {
155155
/*
156156
* If object is destroyed, set pin numbers to 0.
157157
*/
158-
~TwoWire();
158+
~SoftWire();
159159
};
160160

161-
//extern TwoWire Wire;
161+
//extern SoftWire Wire;
162162

163-
#endif // _WIRE_H_
163+
#endif // _SOFTWIRE_H_

STM32F1/libraries/Wire/Wire.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*****************************************************************************/
2626

2727
/**
28-
* @file HardWire.cpp
28+
* @file TwoWire.cpp
2929
* @author Trystan Jones <[email protected]>
3030
* @brief Wire library, uses the hardware I2C available in the Maple to
3131
* interact with I2C slave devices.
@@ -38,7 +38,7 @@
3838

3939
#include "Wire.h"
4040

41-
uint8 HardWire::process(uint8 stop) {
41+
uint8 TwoWire::process(uint8 stop) {
4242
int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0);
4343
if (res == I2C_ERROR_PROTOCOL) {
4444
if (sel_hard->error_flags & I2C_SR1_AF) { /* NACK */
@@ -55,12 +55,12 @@ uint8 HardWire::process(uint8 stop) {
5555
return res;
5656
}
5757

58-
uint8 HardWire::process(){
58+
uint8 TwoWire::process(){
5959
return process(true);
6060
}
6161

6262
// TODO: Add in Error Handling if devsel is out of range for other Maples
63-
HardWire::HardWire(uint8 dev_sel, uint8 flags) {
63+
TwoWire::TwoWire(uint8 dev_sel, uint8 flags) {
6464
if (dev_sel == 1) {
6565
sel_hard = I2C1;
6666
} else if (dev_sel == 2) {
@@ -71,21 +71,21 @@ HardWire::HardWire(uint8 dev_sel, uint8 flags) {
7171
dev_flags = flags;
7272
}
7373

74-
HardWire::~HardWire() {
74+
TwoWire::~TwoWire() {
7575
i2c_disable(sel_hard);
7676
sel_hard = 0;
7777
}
7878

79-
void HardWire::begin(uint8 self_addr) {
79+
void TwoWire::begin(uint8 self_addr) {
8080
i2c_master_enable(sel_hard, dev_flags);
8181
}
8282

83-
void HardWire::end() {
83+
void TwoWire::end() {
8484
i2c_disable(sel_hard);
8585
sel_hard = 0;
8686
}
8787

88-
void HardWire::setClock(uint32_t frequencyHz)
88+
void TwoWire::setClock(uint32_t frequencyHz)
8989
{
9090
switch(frequencyHz)
9191
{
@@ -103,4 +103,4 @@ void HardWire::setClock(uint32_t frequencyHz)
103103
}
104104
}
105105

106-
HardWire Wire(1);
106+
TwoWire Wire(1);

STM32F1/libraries/Wire/Wire.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*****************************************************************************/
2626

2727
/**
28-
* @file HardWire.h
28+
* @file Wire.h
2929
* @author Trystan Jones <[email protected]>
3030
* @brief Wire library, uses the hardware I2C available in the Maple to
3131
* interact with I2C slave devices.
@@ -36,14 +36,14 @@
3636
* users easy interaction with the I2C Hardware in a familiar method.
3737
*/
3838

39-
#ifndef _HARDWIRE_H_
40-
#define _HARDWIRE_H_
39+
#ifndef _TWOWIRE_H_
40+
#define _TWOWIRE_H_
4141

42-
#include "WireBase.h"
42+
#include "utility/WireBase.h"
4343
#include "wirish.h"
4444
#include <libmaple/i2c.h>
4545

46-
class HardWire : public WireBase {
46+
class TwoWire : public WireBase {
4747
private:
4848
i2c_dev* sel_hard;
4949
uint8 dev_flags;
@@ -59,7 +59,7 @@ class HardWire : public WireBase {
5959
* Check if devsel is within range and enable selected I2C interface with
6060
* passed flags
6161
*/
62-
HardWire(uint8, uint8 = 0);
62+
TwoWire(uint8, uint8 = 0);
6363

6464
/*
6565
* Shuts down (disables) the hardware I2C
@@ -70,9 +70,9 @@ class HardWire : public WireBase {
7070
/*
7171
* Disables the I2C device and remove the device address.
7272
*/
73-
~HardWire();
73+
~TwoWire();
7474

7575
void begin(uint8 = 0x00);
7676
};
77-
extern HardWire Wire;
78-
#endif // _HARDWIRE_H_
77+
extern TwoWire Wire;
78+
#endif // _TWOWIRE_H_

0 commit comments

Comments
 (0)