Skip to content

Commit 65f13b3

Browse files
James FosterWereCatfladyadamirzafahadhoward-wa9axq
authored
Update to latest from Adafruit; Update to Arduino-CI/action@stable-1.x (#9)
* Make compatible with Heltec's CubeCell Arduino-core The functions fast pin-I/O uses are currently missing, so don't define BUSIO_USE_FAST_PINIO. Also, we need typedef for BitOrder, but it refuses to compile without also including Arduino.h, at least under PlatformIO. * Update Adafruit_SPIDevice.h * Buffer arguments of write functions are changed to const so that the functions cannot change the content of the buffer. Also, if the I2C device's register address are define using const rather than #define, the functions can accept those too. * Applied clang formatting. * Added function description. * Update Adafruit_SPIDevice.cpp The SPI.cpp that the STM32 project uses does not have a transfer method with both a buffer and a length. Changes to this file uses a transfer method that just needs a single 8 bit character. * Update Adafruit_SPIDevice.cpp Added code to define 'i'. * Update Adafruit_SPIDevice.cpp Adjusted syntax of added 'for' statement * Update Adafruit_SPIDevice.cpp * Update Adafruit_SPIDevice.cpp Changing #ifdef construct to make STM32 a special case. * Updated #if #elif structure. Update #if #elif structure to avoid nested #ifdef's * Removed extra blank line * Update Adafruit_SPIDevice.cpp * Revert "Added function description." This reverts commit 0475316. * Write functions' description updated that explains why the buffer arguments are const. * Bump to 1.7.0 * Release memory allocated in constructors * Edit comment to match other functions. * Bump to 1.7.1 * Define the meaning of 'type' for BusIO Registers Addressed issue adafruit#19 by updating register consts with suggested descriptions. Co-Authored-By: jayjlawrence <1862335+jayjlawrence@users.noreply.github.com> * Bump to 1.7.2 * Remove duplicate definition of destructor. Co-authored-by: WereCatf <werecatf@gmail.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: DESKTOP\fahadmirza <fahadmirza8@gmail.com> Co-authored-by: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Co-authored-by: Dylan Herrada <33632497+dherrada@users.noreply.github.com> Co-authored-by: Stuart Feichtinger <stuart.feichtinger@gmail.com> Co-authored-by: jayjlawrence <1862335+jayjlawrence@users.noreply.github.com> Co-authored-by: James Foster <git@jgfoster.net>
1 parent c38129d commit 65f13b3

7 files changed

+37
-14
lines changed

.github/workflows/arduino_ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: Arduino-CI/action@v0.1.0
12+
- uses: Arduino-CI/action@stable-1.x

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit BusIO
2-
version=1.6.0
2+
version=1.7.2
33
author=Adafruit
44
maintainer=Adafruit <info@adafruit.com>
55
sentence=This is a library for abstracting away UART, I2C and SPI interfacing

src/Adafruit_BusIO_Register.h

+13
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,21 @@
77

88
typedef enum _Adafruit_BusIO_SPIRegType {
99
ADDRBIT8_HIGH_TOREAD = 0,
10+
/*!<
11+
* ADDRBIT8_HIGH_TOREAD
12+
* When reading a register you must actually send the value 0x80 + register
13+
* address to the device. e.g. To read the register 0x0B the register value
14+
* 0x8B is sent and to write 0x0B is sent.
15+
*/
1016
AD8_HIGH_TOREAD_AD7_HIGH_TOINC = 1,
17+
1118
ADDRBIT8_HIGH_TOWRITE = 2,
19+
/*!<
20+
* ADDRBIT8_HIGH_TOWRITE
21+
* When writing to a register you must actually send the value 0x80 +
22+
* the register address to the device. e.g. To write to the register 0x19 the
23+
* register value 0x99 is sent and to read 0x19 is sent.
24+
*/
1225
} Adafruit_BusIO_SPIRegType;
1326

1427
/*!

src/Adafruit_I2CDevice.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,19 @@ bool Adafruit_I2CDevice::detected(void) {
5858
/*!
5959
* @brief Write a buffer or two to the I2C device. Cannot be more than
6060
* maxBufferSize() bytes.
61-
* @param buffer Pointer to buffer of data to write
61+
* @param buffer Pointer to buffer of data to write. This is const to
62+
* ensure the content of this buffer doesn't change.
6263
* @param len Number of bytes from buffer to write
6364
* @param prefix_buffer Pointer to optional array of data to write before
64-
* buffer. Cannot be more than maxBufferSize() bytes.
65+
* buffer. Cannot be more than maxBufferSize() bytes. This is const to
66+
* ensure the content of this buffer doesn't change.
6567
* @param prefix_len Number of bytes from prefix buffer to write
6668
* @param stop Whether to send an I2C STOP signal on write
6769
* @return True if write was successful, otherwise false.
6870
*/
69-
bool Adafruit_I2CDevice::write(uint8_t *buffer, size_t len, bool stop,
70-
uint8_t *prefix_buffer, size_t prefix_len) {
71+
bool Adafruit_I2CDevice::write(const uint8_t *buffer, size_t len, bool stop,
72+
const uint8_t *prefix_buffer,
73+
size_t prefix_len) {
7174
if ((len + prefix_len) > maxBufferSize()) {
7275
// currently not guaranteed to work if more than 32 bytes!
7376
// we will need to find out if some platforms have larger
@@ -200,7 +203,7 @@ bool Adafruit_I2CDevice::read(uint8_t *buffer, size_t len, bool stop) {
200203
* @param stop Whether to send an I2C STOP signal between the write and read
201204
* @return True if write & read was successful, otherwise false.
202205
*/
203-
bool Adafruit_I2CDevice::write_then_read(uint8_t *write_buffer,
206+
bool Adafruit_I2CDevice::write_then_read(const uint8_t *write_buffer,
204207
size_t write_len, uint8_t *read_buffer,
205208
size_t read_len, bool stop) {
206209
if (!write(write_buffer, write_len, stop)) {

src/Adafruit_I2CDevice.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class Adafruit_I2CDevice {
1212
bool detected(void);
1313

1414
bool read(uint8_t *buffer, size_t len, bool stop = true);
15-
bool write(uint8_t *buffer, size_t len, bool stop = true,
16-
uint8_t *prefix_buffer = NULL, size_t prefix_len = 0);
17-
bool write_then_read(uint8_t *write_buffer, size_t write_len,
15+
bool write(const uint8_t *buffer, size_t len, bool stop = true,
16+
const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0);
17+
bool write_then_read(const uint8_t *write_buffer, size_t write_len,
1818
uint8_t *read_buffer, size_t read_len,
1919
bool stop = false);
2020
bool setSpeed(uint32_t desiredclk);

src/Adafruit_SPIDevice.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
7575
_spi = NULL;
7676
}
7777

78-
// Release memory allocated in constructors
78+
/*!
79+
* @brief Release memory allocated in constructors
80+
*/
7981
Adafruit_SPIDevice::~Adafruit_SPIDevice() {
8082
if (_spiSetting) {
8183
delete _spiSetting;
@@ -126,12 +128,15 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) {
126128
if (_spi) {
127129
// hardware SPI is easy
128130

129-
#ifdef SPARK
131+
#if defined(SPARK)
130132
_spi->transfer(buffer, buffer, len, NULL);
133+
#elif defined(STM32)
134+
for (size_t i = 0; i < len; i++) {
135+
_spi->transfer(buffer[i]);
136+
}
131137
#else
132138
_spi->transfer(buffer, len);
133139
#endif
134-
135140
return;
136141
}
137142

src/Adafruit_SPIDevice.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef enum _BitOrder {
1717
SPI_BITORDER_LSBFIRST = LSBFIRST,
1818
} BitOrder;
1919

20-
#elif defined(ESP32)
20+
#elif defined(ESP32) || defined(__ASR6501__)
2121

2222
// some modern SPI definitions don't have BitOrder enum and have different SPI
2323
// mode defines
@@ -47,7 +47,9 @@ typedef uint32_t BusIO_PortMask;
4747
!defined(ARDUINO_ARCH_MBED)
4848
typedef volatile uint32_t BusIO_PortReg;
4949
typedef uint32_t BusIO_PortMask;
50+
#if not defined(__ASR6501__)
5051
#define BUSIO_USE_FAST_PINIO
52+
#endif
5153

5254
#else
5355
#undef BUSIO_USE_FAST_PINIO

0 commit comments

Comments
 (0)