@@ -88,7 +88,6 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
88
88
#else
89
89
void serialEvent () __attribute__((weak));
90
90
void serialEvent () {}
91
- volatile static unsigned char serialEvent_flag = 0 ;
92
91
#define serialEvent_implemented
93
92
#if defined(USART_RX_vect)
94
93
SIGNAL (USART_RX_vect)
@@ -110,20 +109,17 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
110
109
#error UDR not defined
111
110
#endif
112
111
store_char (c, &rx_buffer);
113
- serialEvent_flag = 1 ;
114
112
}
115
113
#endif
116
114
117
115
#if defined(USART1_RX_vect)
118
116
void serialEvent1 () __attribute__((weak));
119
117
void serialEvent1 () {}
120
- volatile static unsigned char serialEvent1_flag = 0 ;
121
118
#define serialEvent1_implemented
122
119
SIGNAL (USART1_RX_vect)
123
120
{
124
121
unsigned char c = UDR1;
125
122
store_char (c, &rx_buffer1);
126
- serialEvent1_flag = 1 ;
127
123
}
128
124
#elif defined(SIG_USART1_RECV)
129
125
#error SIG_USART1_RECV
@@ -132,13 +128,11 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
132
128
#if defined(USART2_RX_vect) && defined(UDR2)
133
129
void serialEvent2 () __attribute__((weak));
134
130
void serialEvent2 () {}
135
- volatile static unsigned char serialEvent2_flag = 0 ;
136
131
#define serialEvent2_implemented
137
132
SIGNAL (USART2_RX_vect)
138
133
{
139
134
unsigned char c = UDR2;
140
135
store_char (c, &rx_buffer2);
141
- serialEvent2_flag = 1 ;
142
136
}
143
137
#elif defined(SIG_USART2_RECV)
144
138
#error SIG_USART2_RECV
@@ -147,52 +141,29 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
147
141
#if defined(USART3_RX_vect) && defined(UDR3)
148
142
void serialEvent3 () __attribute__((weak));
149
143
void serialEvent3 () {}
150
- volatile static unsigned char serialEvent3_flag = 0 ;
151
144
#define serialEvent3_implemented
152
145
SIGNAL (USART3_RX_vect)
153
146
{
154
147
unsigned char c = UDR3;
155
148
store_char (c, &rx_buffer3);
156
- serialEvent3_flag = 1 ;
157
149
}
158
150
#elif defined(SIG_USART3_RECV)
159
151
#error SIG_USART3_RECV
160
152
#endif
161
153
162
154
void serialEventRun (void )
163
155
{
164
- unsigned char flag, oldSREG;
165
156
#ifdef serialEvent_implemented
166
- oldSREG = SREG;
167
- noInterrupts ();
168
- flag = serialEvent_flag;
169
- serialEvent_flag = 0 ;
170
- SREG = oldSREG;
171
- if (flag) serialEvent ();
157
+ if (Serial.available ()) serialEvent ();
172
158
#endif
173
159
#ifdef serialEvent1_implemented
174
- oldSREG = SREG;
175
- noInterrupts ();
176
- flag = serialEvent1_flag;
177
- serialEvent1_flag = 0 ;
178
- SREG = oldSREG;
179
- if (flag) serialEvent1 ();
160
+ if (Serial1.available ()) serialEvent1 ();
180
161
#endif
181
162
#ifdef serialEvent2_implemented
182
- oldSREG = SREG;
183
- noInterrupts ();
184
- flag = serialEvent2_flag;
185
- serialEvent2_flag = 0 ;
186
- SREG = oldSREG;
187
- if (flag) serialEvent2 ();
163
+ if (Serial2.available ()) serialEvent2 ();
188
164
#endif
189
165
#ifdef serialEvent3_implemented
190
- oldSREG = SREG;
191
- noInterrupts ();
192
- flag = serialEvent3_flag;
193
- serialEvent3_flag = 0 ;
194
- SREG = oldSREG;
195
- if (flag) serialEvent3 ();
166
+ if (Serial3.available ()) serialEvent3 ();
196
167
#endif
197
168
}
198
169
0 commit comments