Skip to content

Commit b64442c

Browse files
committed
Revert "Merge branch 'Serial_attachInterrupt'"
This reverts commit 7339907, reversing changes made to 790ff2c.
1 parent 7339907 commit b64442c

File tree

2 files changed

+3
-81
lines changed

2 files changed

+3
-81
lines changed

Diff for: cores/arduino/UARTClass.cpp

+3-68
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414
You should have received a copy of the GNU Lesser General Public
1515
License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17-
18-
Modified 23 November 2019 by Georg Icking-Konert
1917
*/
2018

2119
#include <stdlib.h>
2220
#include <stdio.h>
2321
#include <string.h>
2422
#include "UARTClass.h"
25-
#include "Arduino.h"
2623

2724
// Constructors ////////////////////////////////////////////////////////////////
2825

@@ -34,9 +31,6 @@ UARTClass::UARTClass( Uart *pUart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer *p
3431
_pUart=pUart;
3532
_dwIrq=dwIrq;
3633
_dwId=dwId;
37-
38-
_isrRx = NULL;
39-
_isrTx = NULL;
4034
}
4135

4236
// Public Methods //////////////////////////////////////////////////////////////
@@ -168,58 +162,17 @@ size_t UARTClass::write( const uint8_t uc_data )
168162
{
169163
// Bypass buffering and send character directly
170164
_pUart->UART_THR = uc_data;
171-
172-
// if custom routine attached, activate TXBUFE interrupt -> delay call until transmission finished
173-
// must be done here explicitely because UART_TXRDY interrupt is not activated here
174-
if (_isrTx != NULL) {
175-
_pUart->UART_IER = UART_IER_TXEMPTY;
176-
}
177165
}
178-
179166
return 1;
180167
}
181168

182-
void UARTClass::attachInterrupt_Receive( isrRx_t fn )
183-
{
184-
// pause interrupts
185-
uint8_t oldISR = ((__get_PRIMASK() & 0x1) == 0 && (__get_FAULTMASK() & 0x1) == 0); noInterrupts();
186-
187-
// set custom function
188-
_isrRx = fn;
189-
190-
// restore old interrupt setting
191-
if (oldISR != 0) { interrupts(); }
192-
}
193-
194-
void UARTClass::attachInterrupt_Send( isrTx_t fn )
195-
{
196-
// pause interrupts
197-
uint8_t oldISR = ((__get_PRIMASK() & 0x1) == 0 && (__get_FAULTMASK() & 0x1) == 0); noInterrupts();
198-
199-
// set custom function for TX empty
200-
_isrTx = fn;
201-
202-
// restore old interrupt setting
203-
if (oldISR != 0) { interrupts(); }
204-
}
205-
206169
void UARTClass::IrqHandler( void )
207170
{
208171
uint32_t status = _pUart->UART_SR;
209172

210173
// Did we receive data?
211-
if ((status & UART_SR_RXRDY) == UART_SR_RXRDY) {
212-
213-
// custom function was attached -> call it with data and status byte
214-
if (_isrRx) {
215-
_isrRx(_pUart->UART_RHR, status);
216-
}
217-
// no custom function attached -> store data in ring buffer
218-
else {
219-
_rx_buffer->store_char(_pUart->UART_RHR);
220-
}
221-
222-
}
174+
if ((status & UART_SR_RXRDY) == UART_SR_RXRDY)
175+
_rx_buffer->store_char(_pUart->UART_RHR);
223176

224177
// Do we need to keep sending data?
225178
if ((status & UART_SR_TXRDY) == UART_SR_TXRDY)
@@ -232,29 +185,11 @@ void UARTClass::IrqHandler( void )
232185
{
233186
// Mask off transmit interrupt so we don't get it anymore
234187
_pUart->UART_IDR = UART_IDR_TXRDY;
235-
236-
// if custom routine attached, activate TXBUFE interrupt -> delay call until transmission finished
237-
if (_isrTx != NULL) {
238-
_pUart->UART_IER = UART_IER_TXEMPTY;
239-
}
240-
}
241-
242-
}
243-
244-
// Is data transmission finished? Used for call of attached custom function at end of transmission?
245-
if ((status & UART_SR_TXEMPTY) == UART_SR_TXEMPTY)
246-
{
247-
// Mask off interrupt so we don't get it anymore
248-
_pUart->UART_IDR = UART_IDR_TXEMPTY;
249-
250-
// if custom routine attached, call it
251-
if (_isrTx != NULL) {
252-
_isrTx();
253188
}
254189
}
255190

256191
// Acknowledge errors
257-
if ((status & UART_SR_OVRE) == UART_SR_OVRE || (status & UART_SR_FRAME) == UART_SR_FRAME || (status & UART_SR_RXBRK) == UART_SR_RXBRK)
192+
if ((status & UART_SR_OVRE) == UART_SR_OVRE || (status & UART_SR_FRAME) == UART_SR_FRAME)
258193
{
259194
// TODO: error reporting outside ISR
260195
_pUart->UART_CR |= UART_CR_RSTSTA;

Diff for: cores/arduino/UARTClass.h

-13
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
You should have received a copy of the GNU Lesser General Public
1515
License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17-
18-
Modified 23 November 2019 by Georg Icking-Konert
1917
*/
2018

2119
#ifndef _UART_CLASS_
@@ -33,8 +31,6 @@
3331
#define SERIAL_8M1 UARTClass::Mode_8M1
3432
#define SERIAL_8S1 UARTClass::Mode_8S1
3533

36-
// missing in CMSIS
37-
#define UART_SR_RXBRK (0x1u << 2)
3834

3935
class UARTClass : public HardwareSerial
4036
{
@@ -64,13 +60,6 @@ class UARTClass : public HardwareSerial
6460

6561
void IrqHandler(void);
6662

67-
typedef void (* isrRx_t)(uint8_t data, uint32_t status);
68-
typedef void (* isrTx_t)( void );
69-
void attachInterrupt_Receive( isrRx_t fn );
70-
void detachInterrupt_Receive( void ) { attachInterrupt_Receive( (isrRx_t) NULL); };
71-
void attachInterrupt_Send( isrTx_t fn );
72-
void detachInterrupt_Send( void ) { attachInterrupt_Send( (isrTx_t) NULL); };
73-
7463
operator bool() { return true; }; // UART always active
7564

7665
protected:
@@ -83,8 +72,6 @@ class UARTClass : public HardwareSerial
8372
IRQn_Type _dwIrq;
8473
uint32_t _dwId;
8574

86-
isrRx_t _isrRx;
87-
isrTx_t _isrTx;
8875
};
8976

9077
#endif // _UART_CLASS_

0 commit comments

Comments
 (0)