Skip to content

Commit f348438

Browse files
committed
[Bugfix] Uart bool operator should return enabled state
1 parent eceebcc commit f348438

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cores/nRF5/Uart.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ size_t Uart::write(const uint8_t data)
246246
return 1;
247247
}
248248

249+
Uart::operator bool() {
250+
return nrfUart->ENABLE == UART_ENABLE_ENABLE_Enabled;
251+
}
252+
249253
#if defined(NRF52_SERIES)
250254
#define NRF_UART0_IRQn UARTE0_UART0_IRQn
251255
#elif defined(NRF51_SERIES)

cores/nRF5/Uart.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class Uart : public HardwareSerial
4747

4848
void IrqHandler();
4949

50-
operator bool() { return true; }
50+
operator bool();
5151

5252
private:
53-
NRF_UART_Type *nrfUart;
53+
NRF_UART_Type *nrfUart{nullptr};
5454
RingBuffer rxBuffer;
5555

5656
IRQn_Type IRQn;

0 commit comments

Comments
 (0)