Skip to content

Commit ae4d945

Browse files
committed
Fix erroneous boolean expression conversions
In fb90157, asserts were introduced changing the error checking style in large portions of the code base from `if(error_condition) fail();` to `assert(!error_condition);`. In doing so, not all boolean conditions were negated properly. This commit restores the original semantics of the error checks as they were before fb90157, (unless an error check has been changed upstream, in which case it is ignored). The practical effects of this commit is that it should restore proper I2C and SPI functionality on the LPC15XX and nRF51822, respectively.
1 parent 8623452 commit ae4d945

File tree

2 files changed

+2
-2
lines changed
  • libraries/mbed/targets/hal

2 files changed

+2
-2
lines changed

libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/spi_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
6969
obj->spi = (NRF_SPI_Type*)NC;
7070
obj->spis = (NRF_SPIS_Type*)spi;
7171
}
72-
MBED_ASSERT((int)obj->spi != NC && (int)obj->spis != NC);
72+
MBED_ASSERT((int)obj->spi != NC || (int)obj->spis != NC);
7373

7474
// pin out the spi pins
7575
if (ssel != NC) {//slave

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static inline void i2c_interface_enable(i2c_t *obj) {
4141
}
4242

4343
void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
44-
MBED_ASSERT((sda == P0_23) || (scl == P0_22));
44+
MBED_ASSERT((sda == P0_23) && (scl == P0_22));
4545

4646
// Enables clock for I2C0
4747
LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 13);

0 commit comments

Comments
 (0)