Skip to content

Commit 5fde088

Browse files
committed
Replacing uint8_t with byte for better consistency with the Arduino way.
1 parent 24623b0 commit 5fde088

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

ThreadsafeIO/examples/ts_spi/ts_spi.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
static int const BMP388_CS_PIN = 2;
1212
static int const BMP388_INT_PIN = 6;
13-
static uint8_t const BMP388_CHIP_ID_REG_ADDR = 0x00;
13+
static byte const BMP388_CHIP_ID_REG_ADDR = 0x00;
1414

1515
static size_t constexpr NUM_THREADS = 20;
1616

@@ -81,7 +81,7 @@ byte bmp388_read_reg(byte const reg_addr)
8181
{
8282
byte const write_buf[3] =
8383
{
84-
static_cast<uint8_t>(0x80 | reg_addr), /* REG_ADDR, if MSBit is set -> READ access */
84+
static_cast<byte>(0x80 | reg_addr), /* REG_ADDR, if MSBit is set -> READ access */
8585
0, /* Dummy byte. */
8686
0 /* REG_VAL is output on SDO */
8787
};

ThreadsafeIO/src/IoTransaction.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* INCLUDE
1010
**************************************************************************************/
1111

12-
#include <stdint.h>
12+
#include <Arduino.h>
1313

1414
#include <mbed.h>
15+
1516
#include <SharedPtr.h>
1617

1718
/**************************************************************************************
@@ -26,20 +27,20 @@ class IoRequest
2627
{
2728
public:
2829

29-
IoRequest(uint8_t const * const write_buf_, size_t const bytes_to_write_, uint8_t * read_buf_, size_t const bytes_to_read_)
30+
IoRequest(byte const * const write_buf_, size_t const bytes_to_write_, byte * read_buf_, size_t const bytes_to_read_)
3031
: write_buf{write_buf_}
3132
, bytes_to_write{bytes_to_write_}
3233
, read_buf{read_buf_}
3334
, bytes_to_read{bytes_to_read_}
3435
{ }
3536

36-
IoRequest(uint8_t const & write_buf_, uint8_t & read_buf_)
37+
IoRequest(byte const & write_buf_, byte & read_buf_)
3738
: IoRequest{&write_buf_, 1, &read_buf_, 1}
3839
{ }
3940

40-
uint8_t const * const write_buf{nullptr};
41+
byte const * const write_buf{nullptr};
4142
size_t const bytes_to_write{0};
42-
uint8_t * read_buf{nullptr};
43+
byte * read_buf{nullptr};
4344
size_t const bytes_to_read{0};
4445

4546
};

ThreadsafeIO/src/spi/SpiBusDeviceConfig.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
* INCLUDE
1010
**************************************************************************************/
1111

12-
#include <functional>
1312
#include <Arduino.h>
13+
1414
#include <SPI.h>
1515

16+
#include <functional>
17+
1618
/**************************************************************************************
1719
* CLASS DECLARATION
1820
**************************************************************************************/
@@ -25,7 +27,7 @@ class SpiBusDeviceConfig
2527
typedef std::function<void(void)> SpiDeselectFunc;
2628

2729

28-
SpiBusDeviceConfig(SPISettings const & spi_settings, SpiSelectFunc spi_select, SpiDeselectFunc spi_deselect, uint8_t const fill_symbol = 0xFF)
30+
SpiBusDeviceConfig(SPISettings const & spi_settings, SpiSelectFunc spi_select, SpiDeselectFunc spi_deselect, byte const fill_symbol = 0xFF)
2931
: _spi_settings{spi_settings}
3032
, _spi_select{spi_select}
3133
, _spi_deselect{spi_deselect}
@@ -36,15 +38,15 @@ class SpiBusDeviceConfig
3638
SPISettings settings () const { return _spi_settings; }
3739
void select () const { if (_spi_select) _spi_select(); }
3840
void deselect () const { if (_spi_deselect) _spi_deselect(); }
39-
uint8_t fill_symbol() const { return _fill_symbol; }
41+
byte fill_symbol() const { return _fill_symbol; }
4042

4143

4244
private:
4345

4446
SPISettings _spi_settings;
4547
SpiSelectFunc _spi_select{nullptr};
4648
SpiDeselectFunc _spi_deselect{nullptr};
47-
uint8_t _fill_symbol{0xFF};
49+
byte _fill_symbol{0xFF};
4850

4951
};
5052

ThreadsafeIO/src/spi/SpiDispatcher.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ void SpiDispatcher::processSpiIoRequest(SpiIoTransaction * spi_io_transaction)
136136
bytes_received < io_request->bytes_to_read;
137137
bytes_received++, bytes_sent++)
138138
{
139-
uint8_t tx_byte = 0;
139+
byte tx_byte = 0;
140140

141141
if (bytes_sent < io_request->bytes_to_write)
142142
tx_byte = io_request->write_buf[bytes_sent];
143143
else
144144
tx_byte = config->fill_symbol();
145145

146-
uint8_t const rx_byte = SPI.transfer(tx_byte);
146+
byte const rx_byte = SPI.transfer(tx_byte);
147147

148148
io_request->read_buf[bytes_received] = rx_byte;
149149
}

ThreadsafeIO/src/wire/WireDispatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void WireDispatcher::processWireIoRequest(WireIoTransaction * wire_io_transactio
144144
{
145145
Wire.requestFrom(config->slave_addr(), io_request->bytes_to_read, config->stop());
146146

147-
while(Wire.available() != io_request->bytes_to_read)
147+
while(Wire.available() != static_cast<int>(io_request->bytes_to_read))
148148
{
149149
/* TODO: Insert a timeout. */
150150
}

0 commit comments

Comments
 (0)