Commit a629080f authored by Sandeep Mistry's avatar Sandeep Mistry

Move Serial definition from variant to core in Uart

parent 6c89cab3
...@@ -112,4 +112,8 @@ void loop( void ) ; ...@@ -112,4 +112,8 @@ void loop( void ) ;
// Interrupts // Interrupts
#define digitalPinToInterrupt(P) ( P ) #define digitalPinToInterrupt(P) ( P )
#ifdef __cplusplus
#include "Uart.h"
#endif // __cplusplus
#endif // Arduino_h #endif // Arduino_h
...@@ -146,3 +146,25 @@ size_t Uart::write(const uint8_t data) ...@@ -146,3 +146,25 @@ size_t Uart::write(const uint8_t data)
return 1; return 1;
} }
#if defined(NRF52)
Uart Serial( NRF_UART0, UARTE0_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
extern "C"
{
void UARTE0_UART0_IRQHandler()
{
Serial.IrqHandler();
}
}
#elif defined(NRF51)
Uart Serial( NRF_UART0, UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
extern "C"
{
void UART0_IRQHandler()
{
Serial.IrqHandler();
}
}
#endif
...@@ -51,3 +51,27 @@ class Uart : public HardwareSerial ...@@ -51,3 +51,27 @@ class Uart : public HardwareSerial
uint8_t uc_pinRX; uint8_t uc_pinRX;
uint8_t uc_pinTX; uint8_t uc_pinTX;
}; };
#ifdef __cplusplus
extern Uart Serial;
#endif
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_HARDWARE Serial
...@@ -60,13 +60,3 @@ const uint32_t g_ADigitalPinMap[] = { ...@@ -60,13 +60,3 @@ const uint32_t g_ADigitalPinMap[] = {
18, 18,
17 17
}; };
Uart Serial( NRF_UART0, UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
extern "C"
{
void UART0_IRQHandler()
{
Serial.IrqHandler();
}
}
...@@ -25,10 +25,6 @@ ...@@ -25,10 +25,6 @@
#include "WVariant.h" #include "WVariant.h"
#ifdef __cplusplus
#include "Uart.h"
#endif // __cplusplus
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
...@@ -114,37 +110,4 @@ static const uint8_t SCK1 = PIN_SPI1_SCK ; ...@@ -114,37 +110,4 @@ static const uint8_t SCK1 = PIN_SPI1_SCK ;
} }
#endif #endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
/* =========================
* ===== SERCOM DEFINITION
* =========================
*/
extern Uart Serial;
#endif
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_HARDWARE Serial
#endif #endif
...@@ -56,13 +56,3 @@ const uint32_t g_ADigitalPinMap[] = { ...@@ -56,13 +56,3 @@ const uint32_t g_ADigitalPinMap[] = {
// AREF // AREF
2 2
}; };
Uart Serial( NRF_UART0, UARTE0_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );
extern "C"
{
void UARTE0_UART0_IRQHandler()
{
Serial.IrqHandler();
}
}
...@@ -25,10 +25,6 @@ ...@@ -25,10 +25,6 @@
#include "WVariant.h" #include "WVariant.h"
#ifdef __cplusplus
#include "Uart.h"
#endif // __cplusplus
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
...@@ -112,33 +108,4 @@ static const uint8_t SCK = PIN_SPI_SCK ; ...@@ -112,33 +108,4 @@ static const uint8_t SCK = PIN_SPI_SCK ;
* Arduino objects - C++ only * Arduino objects - C++ only
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
#ifdef __cplusplus
/* =========================
* ===== SERCOM DEFINITION
* =========================
*/
extern Uart Serial;
#endif
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_HARDWARE Serial
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment