Skip to content

Commit 4040473

Browse files
committed
Remove trailing whitespace
1 parent 282faf0 commit 4040473

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

libraries/Wire/src/Wire.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
You should have received a copy of the GNU Lesser General Public
1616
License along with this library; if not, write to the Free Software
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18-
18+
1919
Modified 2012 by Todd Krein ([email protected]) to implement repeated starts
2020
Modified 2017 by Chuck Todd ([email protected]) to correct Unconfigured Slave Mode reboot
2121
*/
@@ -163,8 +163,8 @@ void TwoWire::beginTransmission(int address)
163163
// Originally, 'endTransmission' was an f(void) function.
164164
// It has been modified to take one parameter indicating
165165
// whether or not a STOP should be performed on the bus.
166-
// Calling endTransmission(false) allows a sketch to
167-
// perform a repeated start.
166+
// Calling endTransmission(false) allows a sketch to
167+
// perform a repeated start.
168168
//
169169
// WARNING: Nothing in the library keeps track of whether
170170
// the bus tenure has been properly ended with a STOP. It
@@ -207,7 +207,7 @@ size_t TwoWire::write(uint8_t data)
207207
// put byte in tx buffer
208208
txBuffer[txBufferIndex] = data;
209209
++txBufferIndex;
210-
// update amount in buffer
210+
// update amount in buffer
211211
txBufferLength = txBufferIndex;
212212
}else{
213213
// in slave send mode
@@ -249,7 +249,7 @@ int TwoWire::available(void)
249249
int TwoWire::read(void)
250250
{
251251
int value = -1;
252-
252+
253253
// get each successive byte on each call
254254
if(rxBufferIndex < rxBufferLength){
255255
value = rxBuffer[rxBufferIndex];
@@ -265,7 +265,7 @@ int TwoWire::read(void)
265265
int TwoWire::peek(void)
266266
{
267267
int value = -1;
268-
268+
269269
if(rxBufferIndex < rxBufferLength){
270270
value = rxBuffer[rxBufferIndex];
271271
}
@@ -294,7 +294,7 @@ void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
294294
// copy twi rx buffer into local read buffer
295295
// this enables new reads to happen in parallel
296296
for(uint8_t i = 0; i < numBytes; ++i){
297-
rxBuffer[i] = inBytes[i];
297+
rxBuffer[i] = inBytes[i];
298298
}
299299
// set rx iterator vars
300300
rxBufferIndex = 0;

libraries/Wire/src/utility/twi.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static volatile uint8_t twi_rxBufferIndex;
8787

8888
static volatile uint8_t twi_error;
8989

90-
/*
90+
/*
9191
* Function twi_init
9292
* Desc readys twi pins and sets twi bitrate
9393
* Input none
@@ -99,7 +99,7 @@ void twi_init(void)
9999
twi_state = TWI_READY;
100100
twi_sendStop = true; // default value
101101
twi_inRepStart = false;
102-
102+
103103
// activate internal pullups for twi.
104104
digitalWrite(SDA, 1);
105105
digitalWrite(SCL, 1);
@@ -118,7 +118,7 @@ void twi_init(void)
118118
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
119119
}
120120

121-
/*
121+
/*
122122
* Function twi_disable
123123
* Desc disables twi pins
124124
* Input none
@@ -134,7 +134,7 @@ void twi_disable(void)
134134
digitalWrite(SCL, 0);
135135
}
136136

137-
/*
137+
/*
138138
* Function twi_slaveInit
139139
* Desc sets slave address and enables interrupt
140140
* Input none
@@ -146,7 +146,7 @@ void twi_setAddress(uint8_t address)
146146
TWAR = address << 1;
147147
}
148148

149-
/*
149+
/*
150150
* Function twi_setClock
151151
* Desc sets twi bit rate
152152
* Input Clock Frequency
@@ -155,14 +155,14 @@ void twi_setAddress(uint8_t address)
155155
void twi_setFrequency(uint32_t frequency)
156156
{
157157
TWBR = ((F_CPU / frequency) - 16) / 2;
158-
158+
159159
/* twi bit rate formula from atmega128 manual pg 204
160160
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
161161
note: TWBR should be 10 or higher for master mode
162162
It is 72 for a 16mhz Wiring board with 100kHz TWI */
163163
}
164164

165-
/*
165+
/*
166166
* Function twi_readFrom
167167
* Desc attempts to become twi bus master and read a
168168
* series of bytes from a device on the bus
@@ -193,7 +193,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen
193193
twi_masterBufferIndex = 0;
194194
twi_masterBufferLength = length-1; // This is not intuitive, read on...
195195
// On receive, the previously configured ACK/NACK setting is transmitted in
196-
// response to the received byte before the interrupt is signalled.
196+
// response to the received byte before the interrupt is signalled.
197197
// Therefor we must actually set NACK when the _next_ to last byte is
198198
// received, causing that NACK to be sent in response to receiving the last
199199
// expected byte of data.
@@ -207,7 +207,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen
207207
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
208208
// We need to remove ourselves from the repeated start state before we enable interrupts,
209209
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
210-
// up. Also, don't enable the START interrupt. There may be one pending from the
210+
// up. Also, don't enable the START interrupt. There may be one pending from the
211211
// repeated start that we sent ourselves, and that would really confuse things.
212212
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
213213
do {
@@ -229,7 +229,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen
229229
for(i = 0; i < length; ++i){
230230
data[i] = twi_masterBuffer[i];
231231
}
232-
232+
233233
return length;
234234

235235
waiting_timedout:
@@ -238,7 +238,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen
238238
return 0;
239239
}
240240

241-
/*
241+
/*
242242
* Function twi_writeTo
243243
* Desc attempts to become twi bus master and write a
244244
* series of bytes to a device on the bus
@@ -273,16 +273,16 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait
273273
// initialize buffer iteration vars
274274
twi_masterBufferIndex = 0;
275275
twi_masterBufferLength = length;
276-
276+
277277
// copy data to twi buffer
278278
for(i = 0; i < length; ++i){
279279
twi_masterBuffer[i] = data[i];
280280
}
281-
281+
282282
// build sla+w, slave device address + w bit
283283
twi_slarw = TW_WRITE;
284284
twi_slarw |= address << 1;
285-
285+
286286
// if we're in a repeated start, then we've already sent the START
287287
// in the ISR. Don't do it again.
288288
//
@@ -291,11 +291,11 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait
291291
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
292292
// We need to remove ourselves from the repeated start state before we enable interrupts,
293293
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
294-
// up. Also, don't enable the START interrupt. There may be one pending from the
294+
// up. Also, don't enable the START interrupt. There may be one pending from the
295295
// repeated start that we sent outselves, and that would really confuse things.
296296
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
297297
do {
298-
TWDR = twi_slarw;
298+
TWDR = twi_slarw;
299299
} while(TWCR & _BV(TWWC));
300300
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
301301
}
@@ -307,7 +307,7 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait
307307
if (wait) {
308308
BUSYWAIT_WITH_TIMEOUT_UNTIL(twi_state != TWI_MTX, waiting_timedout);
309309
}
310-
310+
311311
if (twi_error == 0xFF)
312312
return 0; // success
313313
else if (twi_error == TW_MT_SLA_NACK)
@@ -323,7 +323,7 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait
323323
return 4;
324324
}
325325

326-
/*
326+
/*
327327
* Function twi_transmit
328328
* Desc fills slave tx buffer with data
329329
* must be called in slave tx event callback
@@ -341,22 +341,22 @@ uint8_t twi_transmit(const uint8_t* data, uint8_t length)
341341
if(TWI_BUFFER_LENGTH < (twi_txBufferLength+length)){
342342
return 1;
343343
}
344-
344+
345345
// ensure we are currently a slave transmitter
346346
if(TWI_STX != twi_state){
347347
return 2;
348348
}
349-
349+
350350
// set length and copy data into tx buffer
351351
for(i = 0; i < length; ++i){
352352
twi_txBuffer[twi_txBufferLength+i] = data[i];
353353
}
354354
twi_txBufferLength += length;
355-
355+
356356
return 0;
357357
}
358358

359-
/*
359+
/*
360360
* Function twi_attachSlaveRxEvent
361361
* Desc sets function called before a slave read operation
362362
* Input function: callback function to use
@@ -367,7 +367,7 @@ void twi_attachSlaveRxEvent( void (*function)(uint8_t*, int) )
367367
twi_onSlaveReceive = function;
368368
}
369369

370-
/*
370+
/*
371371
* Function twi_attachSlaveTxEvent
372372
* Desc sets function called before a slave write operation
373373
* Input function: callback function to use
@@ -378,7 +378,7 @@ void twi_attachSlaveTxEvent( void (*function)(void) )
378378
twi_onSlaveTransmit = function;
379379
}
380380

381-
/*
381+
/*
382382
* Function twi_reply
383383
* Desc sends byte or readys receive line
384384
* Input ack: byte indicating to ack or to nack
@@ -394,7 +394,7 @@ void twi_reply(uint8_t ack)
394394
}
395395
}
396396

397-
/*
397+
/*
398398
* Function twi_stop
399399
* Desc relinquishes bus master status
400400
* Input none
@@ -417,7 +417,7 @@ void twi_stop(void)
417417
twi_init();
418418
}
419419

420-
/*
420+
/*
421421
* Function twi_releaseBus
422422
* Desc releases bus control
423423
* Input none
@@ -451,7 +451,7 @@ ISR(TWI_vect)
451451
// Master Transmitter
452452
case TW_MT_SLA_ACK: // slave receiver acked address
453453
case TW_MT_DATA_ACK: // slave receiver acked data
454-
// if there is data to send, send it, otherwise stop
454+
// if there is data to send, send it, otherwise stop
455455
if(twi_masterBufferIndex < twi_masterBufferLength){
456456
// copy data to output register and ack
457457
TWDR = twi_masterBuffer[twi_masterBufferIndex++];
@@ -461,7 +461,7 @@ ISR(TWI_vect)
461461
twi_stop();
462462
else {
463463
twi_inRepStart = true; // we're gonna send the START
464-
// don't enable the interrupt. We'll generate the start, but we
464+
// don't enable the interrupt. We'll generate the start, but we
465465
// avoid handling the interrupt until we're in the next transaction,
466466
// at the point where we would normally issue the start.
467467
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
@@ -501,12 +501,12 @@ ISR(TWI_vect)
501501
twi_stop();
502502
else {
503503
twi_inRepStart = true; // we're gonna send the START
504-
// don't enable the interrupt. We'll generate the start, but we
504+
// don't enable the interrupt. We'll generate the start, but we
505505
// avoid handling the interrupt until we're in the next transaction,
506506
// at the point where we would normally issue the start.
507507
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
508508
twi_state = TWI_READY;
509-
}
509+
}
510510
break;
511511
case TW_MR_SLA_NACK: // address sent, nack received
512512
twi_stop();
@@ -553,7 +553,7 @@ ISR(TWI_vect)
553553
// nack back at master
554554
twi_reply(0);
555555
break;
556-
556+
557557
// Slave Transmitter
558558
case TW_ST_SLA_ACK: // addressed, returned ack
559559
case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack
@@ -582,7 +582,7 @@ ISR(TWI_vect)
582582
twi_reply(0);
583583
}
584584
break;
585-
case TW_ST_DATA_NACK: // received nack, we are done
585+
case TW_ST_DATA_NACK: // received nack, we are done
586586
case TW_ST_LAST_DATA: // received ack, but we are done already!
587587
// ack future responses
588588
twi_reply(1);

0 commit comments

Comments
 (0)