@@ -68,24 +68,6 @@ ISR(SPI_STC_vect)
68
68
interrupts (); // Fine, you were saying?
69
69
}
70
70
71
- // I2C byte receive interrupt routine
72
- // Note: this isn't an ISR. I'm using wire library (because it just works), so
73
- // Wire.onReceive(twiReceive); should be called
74
- void twiReceive (int rxCount)
75
- {
76
- while (Wire.available () > 0 ) // Do this while data is available in Wire buffer
77
- {
78
- unsigned int i = (buffer.head + 1 ) % BUFFER_SIZE; // read buffer head position and increment
79
- unsigned char c = Wire.read (); // Read data byte into c, from Wire data buffer
80
-
81
- if (i != buffer.tail ) // As long as the buffer isn't full, we can store the data in buffer
82
- {
83
- buffer.data [buffer.head ] = c; // Store the data into the buffer's head
84
- buffer.head = i; // update buffer head, since we stored new data
85
- }
86
- }
87
- }
88
-
89
71
// The display data is updated on a Timer interrupt
90
72
ISR (TIMER1_COMPA_vect)
91
73
{
@@ -128,24 +110,36 @@ void loop()
128
110
}
129
111
130
112
// This is effectively the UART0 byte received interrupt routine
131
- // ISR(USART_RX_vect)
132
113
void serialEvent ()
133
114
{
134
115
while (Serial.available ())
135
116
{
136
- // noInterrupts(); // We'll be quick...
137
-
138
117
unsigned int i = (buffer.head + 1 ) % BUFFER_SIZE; // read buffer head position and increment
139
- // unsigned char c = UDR0; // Read data byte into c, from UART0 data register
140
118
unsigned char c = Serial.read (); // Read data byte into c, from UART0 data register
141
119
142
120
if (i != buffer.tail ) // As long as the buffer isn't full, we can store the data in buffer
143
121
{
144
122
buffer.data [buffer.head ] = c; // Store the data into the buffer's head
145
123
buffer.head = i; // update buffer head, since we stored new data
146
124
}
125
+ }
126
+ }
147
127
148
- // interrupts(); // Okay, resume interrupts
128
+ // I2C byte receive interrupt routine
129
+ // Note: this isn't an ISR. I'm using wire library (because it just works), so
130
+ // Wire.onReceive(twiReceive); should be called
131
+ void twiReceive (int rxCount)
132
+ {
133
+ while (Wire.available ()) // Do this while data is available in Wire buffer
134
+ {
135
+ unsigned int i = (buffer.head + 1 ) % BUFFER_SIZE; // read buffer head position and increment
136
+ unsigned char c = Wire.read (); // Read data byte into c, from Wire data buffer
137
+
138
+ if (i != buffer.tail ) // As long as the buffer isn't full, we can store the data in buffer
139
+ {
140
+ buffer.data [buffer.head ] = c; // Store the data into the buffer's head
141
+ buffer.head = i; // update buffer head, since we stored new data
142
+ }
149
143
}
150
144
}
151
145
0 commit comments