follow up to #315
- Add SERIAL_INTERFACES_COUNT to all variants - Rename PIN_SERIAL_RX/TX & PIN_SERIAL1_RX/TX
This commit is contained in:
1 parent
b6bd051b52
commit
306b10dc7f
14 files changed
+72
-74
No files matched your search
@@ -49,11 +49,13 @@
|
||||
#ifdef NRF52832_XXAA
|
||||
#define SERIAL_8N1 (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos)
|
||||
#define SERIAL_8E1 (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos)
|
||||
#elif NRF52840_XXAA
|
||||
#elif defined(NRF52840_XXAA)
|
||||
#define SERIAL_8N1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
|
||||
#define SERIAL_8N2 ((UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
|
||||
#define SERIAL_8E1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos))
|
||||
#define SERIAL_8E2 ((UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos))
|
||||
#else
|
||||
#error Unsupported MCU
|
||||
#endif
|
||||
|
||||
class HardwareSerial : public Stream
|
||||
|
||||
+13
-9
@@ -61,7 +61,7 @@ void Uart::setPins(uint8_t pin_rx, uint8_t pin_tx)
|
||||
|
||||
void Uart::begin(unsigned long baudrate)
|
||||
{
|
||||
begin(baudrate, (uint8_t)SERIAL_8N1);
|
||||
begin(baudrate, (uint16_t)SERIAL_8N1);
|
||||
}
|
||||
|
||||
void Uart::begin(unsigned long baudrate, uint16_t config)
|
||||
@@ -232,11 +232,8 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
|
||||
return sent;
|
||||
}
|
||||
|
||||
Uart SERIAL_PORT_HARDWARE( NRF_UARTE0, UARTE0_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
|
||||
|
||||
#ifdef SERIAL_PORT_HARDWARE1
|
||||
Uart SERIAL_PORT_HARDWARE1( NRF_UARTE1, UARTE1_IRQn, PIN_SERIAL2_RX, PIN_SERIAL2_TX );
|
||||
#endif
|
||||
//------------- Serial1 (or Serial in case of nRF52832) -------------//
|
||||
Uart SERIAL_PORT_HARDWARE( NRF_UARTE0, UARTE0_UART0_IRQn, PIN_SERIAL1_RX, PIN_SERIAL1_TX );
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -244,11 +241,18 @@ extern "C"
|
||||
{
|
||||
SERIAL_PORT_HARDWARE.IrqHandler();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SERIAL_PORT_HARDWARE1
|
||||
//------------- Serial2 -------------//
|
||||
#if SERIAL_INTERFACES_COUNT >= 2
|
||||
Uart Serial2( NRF_UARTE1, UARTE1_IRQn, PIN_SERIAL2_RX, PIN_SERIAL2_TX );
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void UARTE1_IRQHandler()
|
||||
{
|
||||
SERIAL_PORT_HARDWARE1.IrqHandler();
|
||||
Serial2.IrqHandler();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-7
@@ -95,11 +95,6 @@ class Uart : public HardwareSerial
|
||||
|
||||
#define SERIAL_PORT_HARDWARE Serial1
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial1
|
||||
|
||||
#ifdef HAVE_HWSERIAL2
|
||||
#define SERIAL_PORT_HARDWARE1 Serial2
|
||||
#define SERIAL_PORT_HARDWARE_OPEN1 Serial2
|
||||
#endif
|
||||
#else
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial
|
||||
@@ -107,6 +102,6 @@ class Uart : public HardwareSerial
|
||||
|
||||
extern Uart SERIAL_PORT_HARDWARE;
|
||||
|
||||
#ifdef SERIAL_PORT_HARDWARE1
|
||||
extern Uart SERIAL_PORT_HARDWARE1;
|
||||
#if SERIAL_INTERFACES_COUNT >= 2
|
||||
extern Uart Serial2;
|
||||
#endif
|
||||
+3
-12
@@ -96,6 +96,9 @@ writeChannel KEYWORD2
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
INPUT_PULLDOWN LITERAL1
|
||||
INPUT_PULLUP LITERAL1
|
||||
INPUT_PULLUP_SENSE LITERAL1
|
||||
INPUT_PULLDOWN_SENSE LITERAL1
|
||||
|
||||
PIN_A0 LITERAL1
|
||||
PIN_A1 LITERAL1
|
||||
@@ -107,17 +110,5 @@ PIN_A6 LITERAL1
|
||||
PIN_A7 LITERAL1
|
||||
|
||||
PIN_AREF LITERAL1
|
||||
PIN_NFC1 LITERAL1
|
||||
PIN_NFC2 LITERAL1
|
||||
|
||||
PIN_SERIAL_RX LITERAL1
|
||||
PIN_SERIAL_TX LITERAL1
|
||||
|
||||
PIN_SPI_MISO LITERAL1
|
||||
PIN_SPI_MOSI LITERAL1
|
||||
PIN_SPI_SCK LITERAL1
|
||||
|
||||
PIN_WIRE_SDA LITERAL1
|
||||
PIN_WIRE_SCL LITERAL1
|
||||
|
||||
ISR_DEFERRED LITERAL1
|
||||
@@ -313,7 +313,7 @@ void connect_callback(uint16_t conn_handle)
|
||||
// Then schedule negotiation after a few seconds, we should not
|
||||
// negotiate here since it increases chance to conflict with other
|
||||
// on-going negotiation from central after connection
|
||||
negoTimer.setID((void*) conn_handle);
|
||||
negoTimer.setID((void*) ((uint32_t)conn_handle));
|
||||
negoTimer.start();
|
||||
|
||||
tft.println("Connected");
|
||||
|
||||
@@ -91,9 +91,10 @@ static const uint8_t A9 = PIN_A9 ;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (0)
|
||||
#define PIN_SERIAL_TX (1)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (0)
|
||||
#define PIN_SERIAL1_TX (1)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -85,9 +85,10 @@ static const uint8_t A7 = PIN_A7 ;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (0)
|
||||
#define PIN_SERIAL_TX (1)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (0)
|
||||
#define PIN_SERIAL1_TX (1)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -87,9 +87,10 @@ static const uint8_t AREF = PIN_AREF;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (8)
|
||||
#define PIN_SERIAL_TX (6)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (8)
|
||||
#define PIN_SERIAL1_TX (6)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -93,9 +93,10 @@ static const uint8_t AREF = PIN_AREF;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (1)
|
||||
#define PIN_SERIAL_TX (0)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (1)
|
||||
#define PIN_SERIAL1_TX (0)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -89,9 +89,10 @@ static const uint8_t A6 = PIN_A6 ;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (0)
|
||||
#define PIN_SERIAL_TX (1)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (0)
|
||||
#define PIN_SERIAL1_TX (1)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -94,9 +94,10 @@ static const uint8_t AREF = PIN_AREF;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (1)
|
||||
#define PIN_SERIAL_TX (0)
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX (1)
|
||||
#define PIN_SERIAL1_TX (0)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -91,23 +91,23 @@ static const uint8_t D19 = PIN_D4;
|
||||
static const uint8_t D20 = PIN_D5;
|
||||
|
||||
// LEDs
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 12)
|
||||
#define LED_STATE_ON 1
|
||||
#define LED_PRIMARY_IDX 0
|
||||
#define LED_RGB_RED_IDX 1
|
||||
#define LED_RGB_GREEN_IDX 2
|
||||
#define LED_RGB_BLUE_IDX 3
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 12)
|
||||
#define LED_STATE_ON 1
|
||||
#define LED_PRIMARY_IDX 0
|
||||
#define LED_RGB_RED_IDX 1
|
||||
#define LED_RGB_GREEN_IDX 2
|
||||
#define LED_RGB_BLUE_IDX 3
|
||||
|
||||
#define LED_RGB_RED_PIN _PINNUM(0, 13)
|
||||
#define LED_RGB_GREEN_PIN _PINNUM(0, 14)
|
||||
#define LED_RGB_BLUE_PIN _PINNUM(0, 15)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x202020
|
||||
#define LED_RGB_RED_PIN _PINNUM(0, 13)
|
||||
#define LED_RGB_GREEN_PIN _PINNUM(0, 14)
|
||||
#define LED_RGB_BLUE_PIN _PINNUM(0, 15)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x202020
|
||||
|
||||
static const uint8_t LED_BUILTIN = LED_PRIMARY_PIN;
|
||||
static const uint8_t LED_RGB_RED = LED_RGB_RED_PIN;
|
||||
static const uint8_t LED_RGB_GREEN = LED_RGB_GREEN_PIN;
|
||||
static const uint8_t LED_RGB_BLUE = LED_RGB_BLUE_PIN;
|
||||
static const uint8_t LED_BUILTIN = LED_PRIMARY_PIN;
|
||||
static const uint8_t LED_RGB_RED = LED_RGB_RED_PIN;
|
||||
static const uint8_t LED_RGB_GREEN = LED_RGB_GREEN_PIN;
|
||||
static const uint8_t LED_RGB_BLUE = LED_RGB_BLUE_PIN;
|
||||
|
||||
// Buttons
|
||||
#define BUTTONS_NUMBER 2
|
||||
@@ -146,12 +146,10 @@ static const uint8_t A5 = PIN_A5 ;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX PIN_D9
|
||||
#define PIN_SERIAL_TX PIN_D10
|
||||
#define PIN_SERIAL2_RX PIN_D5
|
||||
#define PIN_SERIAL2_TX PIN_D6
|
||||
//#define HAVE_HWSERIAL2 true // TODO: implement UARTE in Uart.cpp
|
||||
#define SERIAL_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SERIAL1_RX PIN_D9
|
||||
#define PIN_SERIAL1_TX PIN_D10
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
|
||||
@@ -94,11 +94,13 @@ static const uint8_t AREF = PIN_AREF;
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
#define HAVE_HWSERIAL2
|
||||
#define SERIAL_INTERFACES_COUNT 2
|
||||
|
||||
#define PIN_SERIAL_RX (33)
|
||||
#define PIN_SERIAL_TX (34)
|
||||
// Arduino Header D0, D1
|
||||
#define PIN_SERIAL1_RX (33) // P1.01
|
||||
#define PIN_SERIAL1_TX (34) // P1.02
|
||||
|
||||
// Connected to Jlink CDC
|
||||
#define PIN_SERIAL2_RX (8)
|
||||
#define PIN_SERIAL2_TX (6)
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ extern "C"
|
||||
// Bad things happen if the serial pins aren't defined. Instead
|
||||
// define them with an invalid pin number
|
||||
// Serial
|
||||
#define PIN_SERIAL_RX (3)
|
||||
#define PIN_SERIAL_TX (3)
|
||||
#define PIN_SERIAL1_RX (3)
|
||||
#define PIN_SERIAL1_TX (3)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in new issue
Block a user