From 2fe52b570ec8425bfedc85bc55dc57dd38953e25 Mon Sep 17 00:00:00 2001 From: UT2UH Date: Wed, 11 Nov 2020 13:29:58 +0200 Subject: [PATCH] min max macros and Wire fixes --- cores/arduino/wiring_constants.h | 4 ++-- libraries/Wire/src/Wire.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cores/arduino/wiring_constants.h b/cores/arduino/wiring_constants.h index bb31dca..8af7d83 100644 --- a/cores/arduino/wiring_constants.h +++ b/cores/arduino/wiring_constants.h @@ -65,11 +65,11 @@ enum BitOrder { #endif // abs #ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) +#define min(a,b) (((a)<(b))?(a):(b)) #endif // min #ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) +#define max(a,b) (((a)>(b))?(a):(b)) #endif // max #define abs(x) ((x)>0?(x):-(x)) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 26e984c..95fadab 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -56,7 +56,8 @@ TwoWire::begin(uint8_t sda, uint8_t scl, uint32_t frequency) is_master_mode = true; - delete i2c_tx_buff, i2c_rx_buff; + delete i2c_tx_buff; + delete i2c_rx_buff; i2c_tx_buff = new RingBuffer(); i2c_rx_buff = new RingBuffer(); @@ -88,7 +89,8 @@ TwoWire::begin(uint16_t slave_address, uint8_t sda, uint8_t scl) plic_irq_register((plic_irq_t)(IRQN_I2C0_INTERRUPT + _i2c_num), maix_i2c_slave_irq, this); plic_irq_enable((plic_irq_t)(IRQN_I2C0_INTERRUPT + _i2c_num)); - delete i2c_tx_buff, i2c_rx_buff; + delete i2c_tx_buff; + delete i2c_rx_buff; i2c_tx_buff = new RingBuffer(); i2c_rx_buff = new RingBuffer();