Skip to content

Commit ebea46c

Browse files
committed
port SoftwareSerial close #62
- can receive data, and sending
1 parent bc65391 commit ebea46c

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

cores/nRF5/WInterrupts.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ static void __initialize()
4949
/*
5050
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
5151
* Replaces any previous function that was attached to the interrupt.
52+
*
53+
* \return Interrupt Mask
5254
*/
53-
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
55+
int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
5456
{
5557
if (!enabled) {
5658
__initialize();
5759
enabled = 1;
5860
}
5961

6062
if (pin >= PINS_COUNT) {
61-
return;
63+
return 0;
6264
}
6365

6466
pin = g_ADigitalPinMap[pin];
@@ -95,9 +97,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
9597

9698
NRF_GPIOTE->INTENSET = (1 << ch);
9799

98-
break;
100+
return (1 << ch);
99101
}
100102
}
103+
104+
return 0;
101105
}
102106

103107
/*

cores/nRF5/WInterrupts.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ typedef void (*voidFuncPtr)(void);
3939
/*
4040
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
4141
* Replaces any previous function that was attached to the interrupt.
42+
*
43+
* \return Interrupt Mask
4244
*/
43-
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
45+
int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
4446

4547
/*
4648
* \brief Turns off the given interrupt.

cores/nRF5/delay.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ extern void delay( uint32_t dwMs );
6666
static __inline__ void delayMicroseconds( uint32_t ) __attribute__((always_inline, unused)) ;
6767
static __inline__ void delayMicroseconds( uint32_t usec )
6868
{
69-
if ( usec == 0 )
70-
{
71-
return ;
72-
}
69+
// if ( usec == 0 )
70+
// {
71+
// return ;
72+
// }
7373

7474
nrf_delay_us(usec);
7575
}

libraries/SoftwareSerial/SoftwareSerial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ bool SoftwareSerial::stopListening()
109109

110110
void SoftwareSerial::end()
111111
{
112-
stopListening();
112+
stopListening();
113113
}
114114

115115
int SoftwareSerial::read()
@@ -326,4 +326,4 @@ void SoftwareSerial::setRX(uint8_t rx)
326326
_receiveBitMask = digitalPinToBitMask(rx);
327327
NRF_GPIO_Type * port = digitalPinToPort(rx);
328328
_receivePortRegister = portInputRegister(port);
329-
}
329+
}

libraries/SoftwareSerial/SoftwareSerial.h

-9
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,4 @@ class SoftwareSerial : public Stream
9191
static inline void handle_interrupt() __attribute__((__always_inline__));
9292
};
9393

94-
// Arduino 0012 workaround
95-
#undef int
96-
#undef char
97-
#undef long
98-
#undef byte
99-
#undef float
100-
#undef abs
101-
#undef round
102-
10394
#endif

libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
Receives from software serial, sends to hardware serial.
66
77
The circuit:
8-
* RX is digital pin 9 (connect to TX of other device)
9-
* TX is digital pin 10 (connect to RX of other device)
8+
* RX is digital pin A0 (connect to TX of other device)
9+
* TX is digital pin A1 (connect to RX of other device)
1010
1111
This example code is in the public domain.
1212
1313
*/
1414

1515
#include <SoftwareSerial.h>
1616

17-
SoftwareSerial mySerial(9, 10); // RX, TX
17+
SoftwareSerial mySerial(A0, A1); // RX, TX
1818

1919

2020
void setup()

0 commit comments

Comments
 (0)