Skip to content

Commit 306b10d

Browse files
committed
follow up to #315
- Add SERIAL_INTERFACES_COUNT to all variants - Rename PIN_SERIAL_RX/TX & PIN_SERIAL1_RX/TX
1 parent b6bd051 commit 306b10d

File tree

14 files changed

+74
-76
lines changed

14 files changed

+74
-76
lines changed

cores/nRF5/HardwareSerial.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@
4949
#ifdef NRF52832_XXAA
5050
#define SERIAL_8N1 (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos)
5151
#define SERIAL_8E1 (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos)
52-
#elif NRF52840_XXAA
52+
#elif defined(NRF52840_XXAA)
5353
#define SERIAL_8N1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
5454
#define SERIAL_8N2 ((UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
5555
#define SERIAL_8E1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos))
5656
#define SERIAL_8E2 ((UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos))
57+
#else
58+
#error Unsupported MCU
5759
#endif
5860

5961
class HardwareSerial : public Stream

cores/nRF5/Uart.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void Uart::setPins(uint8_t pin_rx, uint8_t pin_tx)
6161

6262
void Uart::begin(unsigned long baudrate)
6363
{
64-
begin(baudrate, (uint8_t)SERIAL_8N1);
64+
begin(baudrate, (uint16_t)SERIAL_8N1);
6565
}
6666

6767
void Uart::begin(unsigned long baudrate, uint16_t config)
@@ -232,23 +232,27 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
232232
return sent;
233233
}
234234

235-
Uart SERIAL_PORT_HARDWARE( NRF_UARTE0, UARTE0_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
236-
237-
#ifdef SERIAL_PORT_HARDWARE1
238-
Uart SERIAL_PORT_HARDWARE1( NRF_UARTE1, UARTE1_IRQn, PIN_SERIAL2_RX, PIN_SERIAL2_TX );
239-
#endif
235+
//------------- Serial1 (or Serial in case of nRF52832) -------------//
236+
Uart SERIAL_PORT_HARDWARE( NRF_UARTE0, UARTE0_UART0_IRQn, PIN_SERIAL1_RX, PIN_SERIAL1_TX );
240237

241238
extern "C"
242239
{
243240
void UARTE0_UART0_IRQHandler()
244241
{
245242
SERIAL_PORT_HARDWARE.IrqHandler();
246243
}
244+
}
247245

248-
#ifdef SERIAL_PORT_HARDWARE1
246+
//------------- Serial2 -------------//
247+
#if SERIAL_INTERFACES_COUNT >= 2
248+
Uart Serial2( NRF_UARTE1, UARTE1_IRQn, PIN_SERIAL2_RX, PIN_SERIAL2_TX );
249+
250+
extern "C"
251+
{
249252
void UARTE1_IRQHandler()
250253
{
251-
SERIAL_PORT_HARDWARE1.IrqHandler();
254+
Serial2.IrqHandler();
252255
}
253-
#endif
254256
}
257+
#endif
258+

cores/nRF5/Uart.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,13 @@ class Uart : public HardwareSerial
9595

9696
#define SERIAL_PORT_HARDWARE Serial1
9797
#define SERIAL_PORT_HARDWARE_OPEN Serial1
98-
99-
#ifdef HAVE_HWSERIAL2
100-
#define SERIAL_PORT_HARDWARE1 Serial2
101-
#define SERIAL_PORT_HARDWARE_OPEN1 Serial2
102-
#endif
10398
#else
10499
#define SERIAL_PORT_MONITOR Serial
105100
#define SERIAL_PORT_HARDWARE Serial
106101
#endif
107102

108103
extern Uart SERIAL_PORT_HARDWARE;
109104

110-
#ifdef SERIAL_PORT_HARDWARE1
111-
extern Uart SERIAL_PORT_HARDWARE1;
105+
#if SERIAL_INTERFACES_COUNT >= 2
106+
extern Uart Serial2;
112107
#endif

keywords.txt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ writeChannel KEYWORD2
9696
# Constants (LITERAL1)
9797
#######################################
9898
INPUT_PULLDOWN LITERAL1
99+
INPUT_PULLUP LITERAL1
100+
INPUT_PULLUP_SENSE LITERAL1
101+
INPUT_PULLDOWN_SENSE LITERAL1
99102

100103
PIN_A0 LITERAL1
101104
PIN_A1 LITERAL1
@@ -107,17 +110,5 @@ PIN_A6 LITERAL1
107110
PIN_A7 LITERAL1
108111

109112
PIN_AREF LITERAL1
110-
PIN_NFC1 LITERAL1
111-
PIN_NFC2 LITERAL1
112-
113-
PIN_SERIAL_RX LITERAL1
114-
PIN_SERIAL_TX LITERAL1
115-
116-
PIN_SPI_MISO LITERAL1
117-
PIN_SPI_MOSI LITERAL1
118-
PIN_SPI_SCK LITERAL1
119-
120-
PIN_WIRE_SDA LITERAL1
121-
PIN_WIRE_SCL LITERAL1
122113

123114
ISR_DEFERRED LITERAL1

libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void connect_callback(uint16_t conn_handle)
313313
// Then schedule negotiation after a few seconds, we should not
314314
// negotiate here since it increases chance to conflict with other
315315
// on-going negotiation from central after connection
316-
negoTimer.setID((void*) conn_handle);
316+
negoTimer.setID((void*) ((uint32_t)conn_handle));
317317
negoTimer.start();
318318

319319
tft.println("Connected");

variants/circuitplayground_nrf52840/variant.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ static const uint8_t A9 = PIN_A9 ;
9191
/*
9292
* Serial interfaces
9393
*/
94-
// Serial
95-
#define PIN_SERIAL_RX (0)
96-
#define PIN_SERIAL_TX (1)
94+
#define SERIAL_INTERFACES_COUNT 1
95+
96+
#define PIN_SERIAL1_RX (0)
97+
#define PIN_SERIAL1_TX (1)
9798

9899
/*
99100
* SPI Interfaces

variants/clue_nrf52840/variant.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ static const uint8_t A7 = PIN_A7 ;
8585
/*
8686
* Serial interfaces
8787
*/
88-
// Serial
89-
#define PIN_SERIAL_RX (0)
90-
#define PIN_SERIAL_TX (1)
88+
#define SERIAL_INTERFACES_COUNT 1
89+
90+
#define PIN_SERIAL1_RX (0)
91+
#define PIN_SERIAL1_TX (1)
9192

9293
/*
9394
* SPI Interfaces

variants/feather_nrf52832/variant.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ static const uint8_t AREF = PIN_AREF;
8787
/*
8888
* Serial interfaces
8989
*/
90-
// Serial
91-
#define PIN_SERIAL_RX (8)
92-
#define PIN_SERIAL_TX (6)
90+
#define SERIAL_INTERFACES_COUNT 1
91+
92+
#define PIN_SERIAL1_RX (8)
93+
#define PIN_SERIAL1_TX (6)
9394

9495
/*
9596
* SPI Interfaces

variants/feather_nrf52840_express/variant.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ static const uint8_t AREF = PIN_AREF;
9393
/*
9494
* Serial interfaces
9595
*/
96-
// Serial
97-
#define PIN_SERIAL_RX (1)
98-
#define PIN_SERIAL_TX (0)
96+
#define SERIAL_INTERFACES_COUNT 1
97+
98+
#define PIN_SERIAL1_RX (1)
99+
#define PIN_SERIAL1_TX (0)
99100

100101
/*
101102
* SPI Interfaces

variants/itsybitsy_nrf52840_express/variant.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ static const uint8_t A6 = PIN_A6 ;
8989
/*
9090
* Serial interfaces
9191
*/
92-
// Serial
93-
#define PIN_SERIAL_RX (0)
94-
#define PIN_SERIAL_TX (1)
92+
#define SERIAL_INTERFACES_COUNT 1
93+
94+
#define PIN_SERIAL1_RX (0)
95+
#define PIN_SERIAL1_TX (1)
9596

9697
/*
9798
* SPI Interfaces

0 commit comments

Comments
 (0)