Skip to content

Commit 405b1d5

Browse files
committed
Fix: Use only camel case for class member functions.
This fixes #63.
1 parent 34071c7 commit 405b1d5

22 files changed

+44
-43
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ As a result this interruption by the scheduler will break Wire I/O access for bo
4949
The mechanisms implemented in this library allow any thread to dispatch an I/O request asynchronously and either continue its operation or [yield](https://en.wikipedia.org/wiki/Yield_(multithreading)) control to the next scheduled thread. All I/O requests are stored in a queue and are executed within a high-priority I/O thread after a [context-switch](https://en.wikipedia.org/wiki/Context_switch). An example of this can be seen [here](examples/Threadsafe_IO/Threadsafe_SPI/Threadsafe_SPI.ino).
5050

5151
### :relieved: Convenient API
52-
Although you are free to directly manipulate I/O requests and responses (e.g. [Threadsafe_Wire](examples/Threadsafe_IO/Threadsafe_Wire/Threadsafe_Wire.ino)) there are convenient `read`/`write`/`write_then_read` abstractions inspired by the [Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO) library (e.g. [Threadsafe_Wire_BusIO](examples/Threadsafe_IO/Threadsafe_Wire_BusIO/Threadsafe_Wire_BusIO.ino)).
52+
Although you are free to directly manipulate I/O requests and responses (e.g. [Threadsafe_Wire](examples/Threadsafe_IO/Threadsafe_Wire/Threadsafe_Wire.ino)) there are convenient `read`/`write`/`writeThenRead` abstractions inspired by the [Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO) library (e.g. [Threadsafe_Wire_BusIO](examples/Threadsafe_IO/Threadsafe_Wire_BusIO/Threadsafe_Wire_BusIO.ino)).
5353

5454
## :zap: Caveats
5555

Diff for: docs/04-threadsafe-wire.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ byte lsm6dsox_read_reg(byte const reg_addr)
5252
}
5353
```
5454

55-
### Synchronous thread-safe `Wire` access with `transfer_and_wait`
55+
### Synchronous thread-safe `Wire` access with `transferAndWait`
5656
([`examples/Threadsafe_IO/Wire`](../examples/Threadsafe_IO/Wire))
5757

58-
As the use of the `transfer` API might be difficult to grasp there's also a synchronous API call combining the request of the transfer and waiting for its result using `transfer_and_wait`.
58+
As the use of the `transfer` API might be difficult to grasp there's also a synchronous API call combining the request of the transfer and waiting for its result using `transferAndWait`.
5959
```C++
6060
byte lsm6dsox_read_reg(byte const reg_addr)
6161
{
6262
byte write_buffer = reg_addr;
6363
byte read_buffer = 0;
6464

6565
IoRequest request(write_buffer, read_buffer);
66-
IoResponse response = transfer_and_wait(lsm6dsox, request); /* Transmit IO request for execution and wait for completion of request. */
66+
IoResponse response = transferAndWait(lsm6dsox, request); /* Transmit IO request for execution and wait for completion of request. */
6767

6868
return read_buffer;
6969
}
@@ -78,7 +78,7 @@ For further simplification [Adafruit_BusIO](https://github.com/adafruit/Adafruit
7878
byte lsm6dsox_read_reg(byte reg_addr)
7979
{
8080
byte read_buffer = 0;
81-
lsm6dsox.wire().write_then_read(&reg_addr, 1, &read_buffer, 1);
81+
lsm6dsox.wire().writeThenRead(&reg_addr, 1, &read_buffer, 1);
8282
return read_buffer;
8383
}
8484
```

Diff for: docs/05-threadsafe-spi.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ byte bmp388_read_reg(byte const reg_addr)
4444
}
4545
```
4646
47-
### Synchronous thread-safe `SPI` access with `transfer_and_wait`
47+
### Synchronous thread-safe `SPI` access with `transferAndWait`
4848
([`examples/Threadsafe_IO/SPI`](../examples/Threadsafe_IO/SPI))
4949
50-
As the use of the `transfer` API might be difficult to grasp there's also a synchronous API call combining the request of the transfer and waiting for its result using `transfer_and_wait`.
50+
As the use of the `transfer` API might be difficult to grasp there's also a synchronous API call combining the request of the transfer and waiting for its result using `transferAndWait`.
5151
```C++
5252
byte bmp388_read_reg(byte const reg_addr)
5353
{
5454
/* REG_ADDR | DUMMY_BYTE | REG_VAL is on SDO */
5555
byte read_write_buffer[] = {0x80 | reg_addr, 0, 0};
5656
5757
IoRequest request(read_write_buffer, sizeof(read_write_buffer), nullptr, 0);
58-
IoResponse response = transfer_and_wait(bmp388, request);
58+
IoResponse response = transferAndWait(bmp388, request);
5959
6060
auto value = read_write_buffer[2];
6161
return value;
@@ -74,7 +74,7 @@ byte bmp388_read_reg(byte const reg_addr)
7474
byte write_buffer[2] = {0x80 | reg_addr, 0};
7575
byte read_buffer = 0;
7676

77-
bmp388.spi().write_then_read(write_buffer, sizeof(write_buffer), &read_buffer, sizeof(read_buffer));
77+
bmp388.spi().writeThenRead(write_buffer, sizeof(write_buffer), &read_buffer, sizeof(read_buffer));
7878
return read_buffer;
7979
}
8080
```

Diff for: examples/Breaks_4/Thread.inot

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BusDevice lsm6dsox(Wire, LSM6DSOX_ADDRESS);
2121
byte lsm6dsox_read_reg(byte reg_addr)
2222
{
2323
byte read_buf = 0;
24-
lsm6dsox.wire().write_then_read(&reg_addr, 1, &read_buf, 1);
24+
lsm6dsox.wire().writeThenRead(&reg_addr, 1, &read_buf, 1);
2525
return read_buf;
2626
}
2727

Diff for: examples/Threadsafe_IO/SPI/SPI.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ byte bmp388_read_reg(byte const reg_addr)
7070
byte read_write_buf[] = {static_cast<byte>(0x80 | reg_addr), 0, 0};
7171

7272
IoRequest req(read_write_buf, sizeof(read_write_buf), nullptr, 0);
73-
IoResponse rsp = transfer_and_wait(bmp388, req);
73+
IoResponse rsp = transferAndWait(bmp388, req);
7474

7575
return read_write_buf[2];
7676
}

Diff for: examples/Threadsafe_IO/SPI_BusIO/SPI_BusIO.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* with different client devices on the same SPI bus.
55
*
66
* This example uses Adafruit_BusIO style read(), write(),
7-
* write_then_read() APIs.
7+
* writeThenRead() APIs.
88
*/
99

1010
/**************************************************************************************
@@ -70,7 +70,7 @@ byte bmp388_read_reg(byte const reg_addr)
7070
byte write_buf[2] = {static_cast<byte>(0x80 | reg_addr), 0};
7171
byte read_buf = 0;
7272

73-
bmp388.spi().write_then_read(write_buf, sizeof(write_buf), &read_buf, sizeof(read_buf));
73+
bmp388.spi().writeThenRead(write_buf, sizeof(write_buf), &read_buf, sizeof(read_buf));
7474
return read_buf;
7575
}
7676

Diff for: examples/Threadsafe_IO/Serial_GlobalPrefixSuffix/Serial_GlobalPrefixSuffix.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void setup()
2626
Serial.begin(9600);
2727
while (!Serial) { }
2828

29-
Serial.global_prefix(serial_log_message_prefix);
30-
Serial.global_suffix(serial_log_message_suffix);
29+
Serial.globalPrefix(serial_log_message_prefix);
30+
Serial.globalSuffix(serial_log_message_suffix);
3131

3232
Thread_1.start();
3333
Thread_2.start();

Diff for: examples/Threadsafe_IO/Wire/Wire.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ byte lsm6dsox_read_reg(byte const reg_addr)
6767
byte read_buf = 0;
6868

6969
IoRequest req(write_buf, read_buf);
70-
IoResponse rsp = transfer_and_wait(lsm6dsox, req);
70+
IoResponse rsp = transferAndWait(lsm6dsox, req);
7171

7272
return read_buf;
7373
}

Diff for: examples/Threadsafe_IO/Wire_BusIO/Wire_BusIO.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* with different client devices on the same Wire bus.
55
*
66
* This example uses Adafruit_BusIO style read(), write(),
7-
* write_then_read() APIs.
7+
* writeThenRead() APIs.
88
*/
99

1010
/**************************************************************************************
@@ -64,7 +64,7 @@ void loop()
6464
byte lsm6dsox_read_reg(byte reg_addr)
6565
{
6666
byte read_buf = 0;
67-
lsm6dsox.wire().write_then_read(&reg_addr, 1, &read_buf, 1);
67+
lsm6dsox.wire().writeThenRead(&reg_addr, 1, &read_buf, 1);
6868
return read_buf;
6969
}
7070

Diff for: keywords.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ block KEYWORD2
3434
unblock KEYWORD2
3535
prefix KEYWORD2
3636
suffix KEYWORD2
37-
global_prefix KEYWORD2
38-
global_suffix KEYWORD2
37+
globalPrefix KEYWORD2
38+
globalSuffix KEYWORD2
3939
spi KEYWORD2
4040
wire KEYWORD2
4141
read KEYWORD2
4242
write KEYWORD2
43-
write_then_read KEYWORD2
43+
writeThenRead KEYWORD2
44+
transferAndWait KEYWORD2
4445

4546
#######################################
4647
# Constants (LITERAL1)

Diff for: src/io/serial/SerialDispatcher.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ void SerialDispatcher::suffix(SuffixInjectorCallbackFunc func)
202202
iter->suffix_func = func;
203203
}
204204

205-
void SerialDispatcher::global_prefix(PrefixInjectorCallbackFunc func)
205+
void SerialDispatcher::globalPrefix(PrefixInjectorCallbackFunc func)
206206
{
207207
mbed::ScopedLock<rtos::Mutex> lock(_mutex);
208208
_global_prefix_callback = func;
209209
}
210210

211-
void SerialDispatcher::global_suffix(SuffixInjectorCallbackFunc func)
211+
void SerialDispatcher::globalSuffix(SuffixInjectorCallbackFunc func)
212212
{
213213
mbed::ScopedLock<rtos::Mutex> lock(_mutex);
214214
_global_suffix_callback = func;

Diff for: src/io/serial/SerialDispatcher.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class SerialDispatcher : public arduino::HardwareSerial
6363
typedef std::function<String(String const &, String const &)> SuffixInjectorCallbackFunc;
6464
void prefix(PrefixInjectorCallbackFunc func);
6565
void suffix(SuffixInjectorCallbackFunc func);
66-
void global_prefix(PrefixInjectorCallbackFunc func);
67-
void global_suffix(SuffixInjectorCallbackFunc func);
66+
void globalPrefix(PrefixInjectorCallbackFunc func);
67+
void globalSuffix(SuffixInjectorCallbackFunc func);
6868

6969

7070
private:

Diff for: src/io/spi/SpiBusDevice.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ IoResponse SpiBusDevice::transfer(IoRequest & req)
4545

4646
bool SpiBusDevice::read(uint8_t * buffer, size_t len, uint8_t sendvalue)
4747
{
48-
SpiBusDeviceConfig config(_config.spi(), _config.settings(), _config.select_func(), _config.deselect_func(), sendvalue);
48+
SpiBusDeviceConfig config(_config.spi(), _config.settings(), _config.selectFunc(), _config.deselectFunc(), sendvalue);
4949
IoRequest req(nullptr, 0, buffer, len);
5050
IoResponse rsp = SpiDispatcher::instance().dispatch(&req, &config);
5151
rsp->wait();
@@ -60,9 +60,9 @@ bool SpiBusDevice::write(uint8_t * buffer, size_t len)
6060
return true;
6161
}
6262

63-
bool SpiBusDevice::write_then_read(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, uint8_t sendvalue)
63+
bool SpiBusDevice::writeThenRead(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, uint8_t sendvalue)
6464
{
65-
SpiBusDeviceConfig config(_config.spi(), _config.settings(), _config.select_func(), _config.deselect_func(), sendvalue);
65+
SpiBusDeviceConfig config(_config.spi(), _config.settings(), _config.selectFunc(), _config.deselectFunc(), sendvalue);
6666
IoRequest req(write_buffer, write_len, read_buffer, read_len);
6767
IoResponse rsp = SpiDispatcher::instance().dispatch(&req, &config);
6868
rsp->wait();

Diff for: src/io/spi/SpiBusDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SpiBusDevice : public BusDeviceBase
4444

4545
bool read(uint8_t * buffer, size_t len, uint8_t sendvalue = 0xFF);
4646
bool write(uint8_t * buffer, size_t len);
47-
bool write_then_read(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, uint8_t sendvalue = 0xFF);
47+
bool writeThenRead(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, uint8_t sendvalue = 0xFF);
4848

4949

5050
private:

Diff for: src/io/spi/SpiBusDeviceConfig.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class SpiBusDeviceConfig
6464
SPISettings settings () const { return _spi_settings; }
6565
void select () const { if (_spi_select) _spi_select(); }
6666
void deselect () const { if (_spi_deselect) _spi_deselect(); }
67-
byte fill_symbol() const { return _fill_symbol; }
67+
byte fillSymbol () const { return _fill_symbol; }
6868

69-
SpiSelectFunc select_func () const { return _spi_select; }
70-
SpiDeselectFunc deselect_func() const { return _spi_deselect; }
69+
SpiSelectFunc selectFunc () const { return _spi_select; }
70+
SpiDeselectFunc deselectFunc() const { return _spi_deselect; }
7171

7272
private:
7373

Diff for: src/io/spi/SpiDispatcher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void SpiDispatcher::processSpiIoRequest(SpiIoTransaction * spi_io_transaction)
158158
size_t bytes_received = 0;
159159
for(; bytes_received < io_request->bytes_to_read; bytes_received++)
160160
{
161-
uint8_t const tx_byte = config->fill_symbol();
161+
uint8_t const tx_byte = config->fillSymbol();
162162
uint8_t const rx_byte = config->spi().transfer(tx_byte);
163163

164164
io_request->read_buf[bytes_received] = rx_byte;

Diff for: src/io/util/util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* FUNCTION DEFINITION
2727
**************************************************************************************/
2828

29-
IoResponse transfer_and_wait(BusDevice & dev, IoRequest & req)
29+
IoResponse transferAndWait(BusDevice & dev, IoRequest & req)
3030
{
3131
IoResponse rsp = dev.transfer(req);
3232
rsp->wait();

Diff for: src/io/util/util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
* FUNCTION DECLARATION
3131
**************************************************************************************/
3232

33-
IoResponse transfer_and_wait(BusDevice & dev, IoRequest & req);
33+
IoResponse transferAndWait(BusDevice & dev, IoRequest & req);
3434

3535
#endif /* ARDUINO_THREADS_UTIL_H_ */

Diff for: src/io/wire/WireBusDevice.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ IoResponse WireBusDevice::transfer(IoRequest & req)
4545

4646
bool WireBusDevice::read(uint8_t * buffer, size_t len, bool stop)
4747
{
48-
WireBusDeviceConfig config(_config.wire(), _config.slave_addr(), _config.restart(), stop);
48+
WireBusDeviceConfig config(_config.wire(), _config.slaveAddr(), _config.restart(), stop);
4949
IoRequest req(nullptr, 0, buffer, len);
5050
IoResponse rsp = WireDispatcher::instance().dispatch(&req, &config);
5151
rsp->wait();
@@ -55,20 +55,20 @@ bool WireBusDevice::read(uint8_t * buffer, size_t len, bool stop)
5555
bool WireBusDevice::write(uint8_t * buffer, size_t len, bool stop)
5656
{
5757
bool const restart = !stop;
58-
WireBusDeviceConfig config(_config.wire(), _config.slave_addr(), restart, _config.stop());
58+
WireBusDeviceConfig config(_config.wire(), _config.slaveAddr(), restart, _config.stop());
5959
IoRequest req(buffer, len, nullptr, 0);
6060
IoResponse rsp = WireDispatcher::instance().dispatch(&req, &config);
6161
rsp->wait();
6262
return true;
6363
}
6464

65-
bool WireBusDevice::write_then_read(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, bool stop)
65+
bool WireBusDevice::writeThenRead(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, bool stop)
6666
{
6767
/* Copy the Wire parameters from the device and modify only those
6868
* which can be modified via the parameters of this function.
6969
*/
7070
bool const restart = !stop;
71-
WireBusDeviceConfig config(_config.wire(), _config.slave_addr(), restart, _config.stop());
71+
WireBusDeviceConfig config(_config.wire(), _config.slaveAddr(), restart, _config.stop());
7272
/* Fire off the IO request and await its response. */
7373
IoRequest req(write_buffer, write_len, read_buffer, read_len);
7474
IoResponse rsp = WireDispatcher::instance().dispatch(&req, &config);

Diff for: src/io/wire/WireBusDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class WireBusDevice : public BusDeviceBase
4444

4545
bool read(uint8_t * buffer, size_t len, bool stop = true);
4646
bool write(uint8_t * buffer, size_t len, bool stop = true);
47-
bool write_then_read(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, bool stop = false);
47+
bool writeThenRead(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, bool stop = false);
4848

4949

5050
private:

Diff for: src/io/wire/WireBusDeviceConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class WireBusDeviceConfig
4444

4545

4646
inline arduino::HardwareI2C & wire() { return _wire; }
47-
inline byte slave_addr() const { return _slave_addr; }
47+
inline byte slaveAddr() const { return _slave_addr; }
4848
inline bool restart() const { return _restart; }
4949
inline bool stop() const { return _stop; }
5050

Diff for: src/io/wire/WireDispatcher.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void WireDispatcher::processWireIoRequest(WireIoTransaction * wire_io_transactio
138138

139139
if (io_request->bytes_to_write > 0)
140140
{
141-
config->wire().beginTransmission(config->slave_addr());
141+
config->wire().beginTransmission(config->slaveAddr());
142142

143143
size_t bytes_written = 0;
144144
for (; bytes_written < io_request->bytes_to_write; bytes_written++)
@@ -155,7 +155,7 @@ void WireDispatcher::processWireIoRequest(WireIoTransaction * wire_io_transactio
155155

156156
if (io_request->bytes_to_read > 0)
157157
{
158-
config->wire().requestFrom(config->slave_addr(), io_request->bytes_to_read, config->stop());
158+
config->wire().requestFrom(config->slaveAddr(), io_request->bytes_to_read, config->stop());
159159

160160
while(config->wire().available() != static_cast<int>(io_request->bytes_to_read))
161161
{

0 commit comments

Comments
 (0)