Skip to content

Commit 4b18d39

Browse files
committed
use the typesafe replacement nullptr instead of NULL (since C++11)
1 parent 3561fd9 commit 4b18d39

5 files changed

+15
-15
lines changed

Adafruit_BusIO_Register.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice,
2121
uint8_t byteorder,
2222
uint8_t address_width) {
2323
_i2cdevice = i2cdevice;
24-
_spidevice = NULL;
24+
_spidevice = nullptr;
2525
_addrwidth = address_width;
2626
_address = reg_addr;
2727
_byteorder = byteorder;
@@ -50,7 +50,7 @@ Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice,
5050
uint8_t address_width) {
5151
_spidevice = spidevice;
5252
_spiregtype = type;
53-
_i2cdevice = NULL;
53+
_i2cdevice = nullptr;
5454
_addrwidth = address_width;
5555
_address = reg_addr;
5656
_byteorder = byteorder;
@@ -59,12 +59,12 @@ Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice,
5959

6060
/*!
6161
* @brief Create a register we access over an I2C or SPI Device. This is a
62-
* handy function because we can pass in NULL for the unused interface, allowing
63-
* libraries to mass-define all the registers
64-
* @param i2cdevice The I2CDevice to use for underlying I2C access, if NULL
65-
* we use SPI
66-
* @param spidevice The SPIDevice to use for underlying SPI access, if NULL
67-
* we use I2C
62+
* handy function because we can pass in nullptr for the unused interface,
63+
* allowing libraries to mass-define all the registers
64+
* @param i2cdevice The I2CDevice to use for underlying I2C access, if
65+
* nullptr we use SPI
66+
* @param spidevice The SPIDevice to use for underlying SPI access, if
67+
* nullptr we use I2C
6868
* @param reg_addr The address pointer value for the I2C/SMBus/SPI register,
6969
* can be 8 or 16 bits
7070
* @param type The method we use to read/write data to SPI (which is not

Adafruit_I2CDevice.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ bool Adafruit_I2CDevice::write(const uint8_t *buffer, size_t len, bool stop,
106106
_wire->beginTransmission(_addr);
107107

108108
// Write the prefix data (usually an address)
109-
if ((prefix_len != 0) && (prefix_buffer != NULL)) {
109+
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
110110
if (_wire->write(prefix_buffer, prefix_len) != prefix_len) {
111111
#ifdef DEBUG_SERIAL
112112
DEBUG_SERIAL.println(F("\tI2CDevice failed to write"));
@@ -128,7 +128,7 @@ bool Adafruit_I2CDevice::write(const uint8_t *buffer, size_t len, bool stop,
128128
DEBUG_SERIAL.print(F("\tI2CWRITE @ 0x"));
129129
DEBUG_SERIAL.print(_addr, HEX);
130130
DEBUG_SERIAL.print(F(" :: "));
131-
if ((prefix_len != 0) && (prefix_buffer != NULL)) {
131+
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
132132
for (uint16_t i = 0; i < prefix_len; i++) {
133133
DEBUG_SERIAL.print(F("0x"));
134134
DEBUG_SERIAL.print(prefix_buffer[i], HEX);

Adafruit_I2CDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Adafruit_I2CDevice {
1515

1616
bool read(uint8_t *buffer, size_t len, bool stop = true);
1717
bool write(const uint8_t *buffer, size_t len, bool stop = true,
18-
const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0);
18+
const uint8_t *prefix_buffer = nullptr, size_t prefix_len = 0);
1919
bool write_then_read(const uint8_t *write_buffer, size_t write_len,
2020
uint8_t *read_buffer, size_t read_len,
2121
bool stop = false);

Adafruit_SPIDevice.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
6969
_dataMode = dataMode;
7070
_begun = false;
7171
_spiSetting = new SPISettings(freq, dataOrder, dataMode);
72-
_spi = NULL;
72+
_spi = nullptr;
7373
}
7474

7575
/*!
@@ -123,7 +123,7 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) {
123123
// hardware SPI is easy
124124

125125
#if defined(SPARK)
126-
_spi->transfer(buffer, buffer, len, NULL);
126+
_spi->transfer(buffer, buffer, len, nullptr);
127127
#elif defined(STM32)
128128
for (size_t i = 0; i < len; i++) {
129129
_spi->transfer(buffer[i]);
@@ -325,7 +325,7 @@ bool Adafruit_SPIDevice::write(const uint8_t *buffer, size_t len,
325325

326326
#ifdef DEBUG_SERIAL
327327
DEBUG_SERIAL.print(F("\tSPIDevice Wrote: "));
328-
if ((prefix_len != 0) && (prefix_buffer != NULL)) {
328+
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
329329
for (uint16_t i = 0; i < prefix_len; i++) {
330330
DEBUG_SERIAL.print(F("0x"));
331331
DEBUG_SERIAL.print(prefix_buffer[i], HEX);

Adafruit_SPIDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Adafruit_SPIDevice {
7878
bool begin(void);
7979
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);
8080
bool write(const uint8_t *buffer, size_t len,
81-
const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0);
81+
const uint8_t *prefix_buffer = nullptr, size_t prefix_len = 0);
8282
bool write_then_read(const uint8_t *write_buffer, size_t write_len,
8383
uint8_t *read_buffer, size_t read_len,
8484
uint8_t sendvalue = 0xFF);

0 commit comments

Comments
 (0)