3
3
*
4
4
* Receives and decodes a pulse-width and transition encoded RF
5
5
* bitstream, received through a 433MHz receiver module into the PB0
6
- * ICP Input Capture pin .
6
+ * Input Capture Pin (ICP) .
7
7
*
8
8
* The transmitter is from the La Crosse WS-2355 Weather Station
9
9
* package, the RF transmitter is the integrated thermo/hygro station,
15
15
*
16
16
* Copyright 2009 Marc Alexander <marc.alexander@gmail .com>
17
17
* Copyright 2009 Jonathan Oxer <jon@oxer .com.au>
18
- * http://www.practicalarduino.com/projects/medium/ weather-station-receiver
18
+ * http://www.practicalarduino.com/projects/weather-station-receiver
19
19
*/
20
20
21
21
/**
@@ -83,25 +83,23 @@ const char strWindDirection[16][4] =
83
83
" W " , " WNW" , " NW " , " NNW"
84
84
};
85
85
86
+ // Comment out for a normal build
87
+ // Uncomment for a debug build
88
+ // #define DEBUG
86
89
87
90
/**
88
91
* Initial configuration
89
92
*/
90
93
void setup (void )
91
94
{
92
- Init_Ports ();
93
-
94
- // Note: This uses PORTB0 for the Input capture input, sets up and uses Timer/Counter1 registers,
95
- // and also uses PORTD6 and PORTD7 for test LEDs in testing
96
- Init_RF_Interpreters ();
97
-
98
95
Serial . begin( 38400 ); // using the serial port at 38400bps for debugging and logging
99
96
Serial . println( " Weather Station Receiver has powered up" );
100
-
101
- interrupts(); // Enable interrupts
97
+
98
+ Init_Ports ();
99
+ Init_RF_Interpreters ();
100
+ interrupts(); // Enable interrupts (NOTE: is this necessary? Should be enabled by default)
102
101
}
103
102
104
-
105
103
/**
106
104
* Main program loop
107
105
*/
@@ -110,7 +108,6 @@ void loop(void)
110
108
Packet_Converter_WS2355 ();
111
109
}
112
110
113
-
114
111
/**
115
112
* Initialise port initial state and data direction registers
116
113
*/
@@ -119,7 +116,6 @@ void Init_Ports()
119
116
DDRB = 0x2F ; // B00101111
120
117
}
121
118
122
-
123
119
/* --------------------------------------------------------------------------------------
124
120
Packet_Converter_WS2355
125
121
Inspect, validate and convert any fresh incoming packet data to the latest real world values
@@ -153,7 +149,7 @@ void Init_Ports()
153
149
8 = S 9 = SSW 10 = SW 11 = WSW
154
150
12 = W 13 = WNW 14 = NW 15 = NNW
155
151
156
- iiiiiiii = station ID byte. May not be using the top(lefT ) bit of this byte, but is using bits 0-6 at least.
152
+ iiiiiiii = station ID byte. May not be using the top(left ) bit of this byte, but is using bits 0-6 at least.
157
153
Every time the WS-2300-25S transmitter batteries are changed, it generates a new semi-random
158
154
station ID. The user is expected to power cycle the WS-2355 receiver which will then
159
155
'lock on' to the next received station ID.
@@ -174,87 +170,78 @@ void Packet_Converter_WS2355(void)
174
170
175
171
if ( bICP_WSR_PacketInputPointer != bICP_WSR_PacketOutputPointer )
176
172
{
177
- // ----------------------------------------------------------------------------
178
- // a fresh packet is ready to check and convert
179
- // Serial.print( CHAR_CR, BYTE );
180
- // Serial.print( CHAR_LF, BYTE );
173
+ // A fresh packet is ready to check and convert
174
+ #ifdef DEBUG
181
175
if ( (ulICP_Timestamp_262_144mS - ulWSR_LastTimestamp_262_144mS) > 8 )
182
176
{
183
- // extra CR/LF if there has been more than about 2 seconds since the last packet
184
- // Serial.print( CHAR_CR, BYTE );
185
- // Serial.print( CHAR_LF, BYTE );
177
+ // Blank separator line if there has been more than about 2 seconds since the last
178
+ // packet to make it easier to see what belongs with what
179
+ Serial . println();
186
180
}
181
+ #endif
182
+
183
+ #ifdef DEBUG
187
184
// print it in binary text out the serial port
188
- /* for( b = WSR_TIMESTAMP_BIT_OFFSET ; b < (WSR_RFPACKETBITSIZE+WSR_TIMESTAMP_BIT_OFFSET) ; b++ )
189
- // for( b = 0 ; b < (WSR_RFPACKETBITSIZE+WSR_TIMESTAMP_BIT_OFFSET) ; b++ )
185
+ Serial . print( " BINARY= " );
186
+ for ( b = WSR_TIMESTAMP_BIT_OFFSET ; b < (WSR_RFPACKETBITSIZE + WSR_TIMESTAMP_BIT_OFFSET ) ; b++ )
190
187
{
191
188
if ( (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][b >> 3 ] & (0x80 >> (b& 0x07 ))) != 0 )
192
189
{
193
190
Serial . print( ' 1' , BYTE );
194
- }
195
- else
196
- {
191
+ } else {
197
192
Serial . print( ' 0' , BYTE );
198
193
}
199
194
if ( b == 31 )
200
195
Serial . print( ' ' , BYTE ); // timestamp seperator
201
- } */
196
+ }
197
+ Serial . println();
198
+
202
199
// print it in hex text out the serial port
203
200
// Serial.print( ' ', BYTE );
204
- /*
201
+ Serial . print( " HEX= " );
205
202
for ( b = 0 ; b < ((WSR_RFPACKETBITSIZE + WSR_TIMESTAMP_BIT_OFFSET )/ 4 ) ; b += 2 )
206
203
{
207
- //one nibble at a time
204
+ // One nibble at a time
208
205
c = bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][b >> 1 ];
209
- //top nibble
210
- Serial.print( (c & 0xF0) >> 4, HEX ); //Serial.print( "0123456789ABCDEF"[(c & 0xF0) >> 4] );
211
- //bottom nibble, drop the last one since it's not part of the 52 incoming bits
206
+ // Top nibble
207
+ Serial . print( (c & 0xF0 ) >> 4 , HEX );
208
+ // Bottom nibble, drop the last one since it's not part of the 52 incoming bits
212
209
if ( b < (((WSR_RFPACKETBITSIZE + WSR_TIMESTAMP_BIT_OFFSET )/ 4 )- 1 ) )
213
- Serial.print( (c & 0x0F), HEX ); //Serial.print( "0123456789ABCDEF"[(c & 0x0F)] );
214
- //timestamp seperator
210
+ Serial . print( (c & 0x0F ), HEX );
211
+ // Timestamp seperator
215
212
if ( b == 6 )
216
213
Serial . print( ' ' , BYTE );
217
214
}
218
- */
215
+ Serial . println();
216
+ #endif
217
+
219
218
// ----------------------------------------------------------------------------
220
219
if ( PacketAndChecksum_OK_WS2355 )
221
220
{
222
- // fish out the station ID
221
+ // Extract the station ID
223
222
b = (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][5 ] << 4 );
224
223
b += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][6 ] >> 4 );
225
224
bWSR_StationTransmitterID = b;
226
- // test print to serial port with decimal place management
227
- // Serial.print( " st:" );
228
- // Serial.print( bWSR_StationTransmitterID, DEC );
229
-
230
- // Serial.print( " ok:" );
225
+ // Print to serial port
226
+ Serial . print( " STATIONID=" );
227
+ Serial . println( bWSR_StationTransmitterID, DEC );
231
228
232
- // bits 4 and 5 of this byte are the sensor/packet ID
229
+ // Bits 4 and 5 of this byte are the sensor/packet ID
233
230
b = bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][5 ];
234
231
b = (b >> 4 ) & 0x03 ;
235
232
switch ( b )
236
233
{
237
234
case 0 :
238
235
{
239
- // ----------------
240
- // 0: temperature
241
- // sensor/packet ID bits are 0x00, temperature is present in this packet
242
- // lower nibble of byte 7 is first temperature digit, take care of 3xx offset
236
+ // 0: temperature
237
+ // Sensor/packet ID bits are 0x00, temperature is present in this packet
238
+ // Lower nibble of byte 7 is first temperature digit, take care of 3xx offset
243
239
si = ((bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][7 ] & 0x0F ) * 100 );
244
240
si += ((bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ] >> 4 ) * 10 );
245
241
si += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ] & 0x0F );
246
242
siWSR_CurrentTemperature = (si - 300 );
247
243
248
- // test print to serial port with decimal place management
249
- /* Serial.print( ' ', BYTE );
250
- Serial.print( (siWSR_CurrentTemperature/10), DEC );
251
- Serial.print( '.', BYTE );
252
- if( siWSR_CurrentTemperature < 0 )
253
- Serial.print( ((0-siWSR_CurrentTemperature)%10), DEC );
254
- else
255
- Serial.print( (siWSR_CurrentTemperature%10), DEC );
256
- Serial.print( '?', BYTE ); */
257
-
244
+ // Print to serial port with decimal place management
258
245
Serial . print(" TEMPERATURE=" );
259
246
Serial . print( (siWSR_CurrentTemperature/ 10 ), DEC );
260
247
Serial . print( ' .' , BYTE );
@@ -263,49 +250,32 @@ void Packet_Converter_WS2355(void)
263
250
} else {
264
251
Serial . println( (siWSR_CurrentTemperature% 10 ), DEC );
265
252
}
266
-
267
253
break ;
268
254
}
269
255
case 1 :
270
256
{
271
- // ----------------
272
- // 1: humidity
257
+ // 1: humidity
273
258
// sensor/packet ID bits are 0x01, humidity is present in this packet
274
259
c = ((bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][7 ] & 0x0F ) * 10 );
275
260
c += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ] >> 4 );
276
261
bWSR_CurrentHumidity = c;
277
262
278
- // test print to serial port with decimal place management
279
- /* Serial.print( ' ', BYTE );
280
- Serial.print( bWSR_CurrentHumidity, DEC );
281
- Serial.println( "% RH" ); */
282
-
283
- // Simplified output format
263
+ // Print to serial port with decimal place management
284
264
Serial . print(" HUMIDITY=" );
285
265
Serial . println( bWSR_CurrentHumidity, DEC );
286
266
break ;
287
267
}
288
268
case 2 :
289
269
{
290
- // ----------------
291
- // 2: rainfall
270
+ // 2: rainfall
292
271
si = (sint)(bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][7 ] & 0x0F ) << 8 ;
293
272
si += bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ];
294
273
uiWSR_RainfallCount = (uint)si;
295
274
296
275
// killer (for the Arduino) long multiply here, put in for now to demo real mm of rainfall maths
297
276
ulWSR_Rainfall_mm_x10 = (((unsigned long )uiWSR_RainfallCount * 518 ) / 100 );
298
277
299
- // test print to serial port
300
- /* Serial.print( ' ', BYTE );
301
- Serial.print( uiWSR_RainfallCount, DEC );
302
- Serial.print( " rainfall, " );
303
- Serial.print( (ulWSR_Rainfall_mm_x10/10), DEC );
304
- Serial.print( '.', BYTE );
305
- Serial.print( (ulWSR_Rainfall_mm_x10%10), DEC );
306
- Serial.println( " mm" ); */
307
-
308
- // Simplified output format:
278
+ // Print to serial port
309
279
Serial . print(" RAINFALL=" );
310
280
Serial . print( (ulWSR_Rainfall_mm_x10/ 10 ), DEC );
311
281
Serial . print( ' .' , BYTE );
@@ -314,10 +284,9 @@ void Packet_Converter_WS2355(void)
314
284
}
315
285
case 3 :
316
286
{
317
- // ----------------
318
- // 3: wind direction and speed
319
- // sensor/packet ID bits are 0x03, wind data is present in this packet
320
- // wind direction
287
+ // 3: wind direction and speed
288
+ // Sensor/packet ID bits are 0x03, wind data is present in this packet
289
+ // Wind direction
321
290
bWSR_CurrentWindDirection = (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ] & 0x0F );
322
291
323
292
// wind speed, decimal value is metres per second * 10 (1 fixed deciml place)
@@ -326,55 +295,22 @@ void Packet_Converter_WS2355(void)
326
295
si += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][8 ] >> 4 );
327
296
uiWSR_CurrentWindSpeed_m_per_sec = (uint)si;
328
297
329
- // test print to serial port with decimal place management
330
- /* Serial.print( ' ', BYTE );
331
- Serial.print( strWindDirection[bWSR_CurrentWindDirection] );
332
- Serial.print( " (" );
333
- Serial.print( bWSR_CurrentWindDirection, DEC );
334
- Serial.print( ") wind, speed" ); */
335
-
336
- // Simplified output format
298
+ // Print to serial port with decimal place management
337
299
Serial . print(" WINDDIRECTION=" );
338
300
Serial . println( strWindDirection[bWSR_CurrentWindDirection] );
339
301
340
- /* Serial.print( ' ', BYTE );
341
- Serial.print( (uiWSR_CurrentWindSpeed_m_per_sec/10), DEC );
342
- Serial.print( '.', BYTE );
343
- Serial.print( (uiWSR_CurrentWindSpeed_m_per_sec%10), DEC );
344
- Serial.print( "m/s" );
345
- */
346
302
Serial . print(" WINDSPEED=" );
347
303
Serial . print( (uiWSR_CurrentWindSpeed_m_per_sec/ 10 ), DEC );
348
304
Serial . print( ' .' , BYTE );
349
305
Serial . println( (uiWSR_CurrentWindSpeed_m_per_sec% 10 ), DEC );
350
-
351
- // convert wind speed m/s to kmh and display also 100 raw = 10.0m/s, * 3.6 = km/h
352
- // si = uiWSR_CurrentWindSpeed_m_per_sec * 36 / 10;
353
- /* Serial.print( ' ', BYTE );
354
- Serial.print( (si/10), DEC );
355
- Serial.print( '.', BYTE );
356
- Serial.print( (si%10), DEC );
357
- Serial.print( "km/h" );
358
- Serial.print( ', Raw: ', BYTE ); */
359
-
360
- // Simplified output format
361
- /* Serial.print("WINDSPEED=");
362
- Serial.print( (si/10), DEC );
363
- Serial.print( '.', BYTE );
364
- Serial.println( (si%10), DEC ); */
365
-
366
306
break ;
367
307
}
368
308
default :
369
309
{
370
310
break ;
371
311
}
372
312
}
373
- // ----------------
374
-
375
- }
376
- else
377
- {
313
+ } else {
378
314
Serial . print( " bad checksum or packet header" );
379
315
}
380
316
@@ -397,23 +333,23 @@ byte PacketAndChecksum_OK_WS2355(void)
397
333
byte b;
398
334
byte c;
399
335
400
- // first check, last 4 bits of packet are sum of the previous 48 bits (12 nibbles)
401
- // don 't forget to offset past the timestamp in the first 4 bytes
336
+ // First check, last 4 bits of packet are sum of the previous 48 bits (12 nibbles)
337
+ // Don 't forget to offset past the timestamp in the first 4 bytes
402
338
c = 0 ;
403
339
for ( b = 4 ; b < 10 ; b++ )
404
340
{
405
- // checked a byte at a time, accumulate into c
341
+ // Checked a byte at a time, accumulate into c
406
342
c += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][b] >> 4 );
407
343
c += (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][b] & 0x0F );
408
344
}
409
345
c &= 0x0F ;
410
346
if ( c != (bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][10 ] >> 4 ) )
411
347
{
412
- return ( false ); // checksum does not match
348
+ return ( false ); // Checksum does not match
413
349
}
414
350
415
- // second check, first byte of packet must be 0x09 ( B00001001 ), appears to be
416
- // the main identifier for this station
351
+ // Second check, first byte of packet must be 0x09 ( B00001001 ), appears to be
352
+ // the main identifier for this station
417
353
if ( bICP_WSR_PacketData[bICP_WSR_PacketOutputPointer][4 ] != 0x09 )
418
354
{
419
355
return ( false );
@@ -442,10 +378,10 @@ void Init_RF_Interpreters(void)
442
378
DDRD |= B11000000 ; // (1<<PORTD6); //DDRD |= (1<<PORTD7); (example of B prefix)
443
379
GREEN_TESTLED_OFF (); // GREEN test led off
444
380
RED_TESTLED_ON (); // RED test led on
445
- // PORTD |= _BV(PORTD6); //GREEN led off (example of _BV macro)
446
- // PORTD &= ~_BV(PORTD7); //RED led on (example of _BV macro)
447
- // PORTD |= (1<<PORTD6); //GREEN led off (example of AVR studio style)
448
- // PORTD &= ~(1<<PORTD7); //RED led on (example of AVR studio style)
381
+ // PORTD |= _BV(PORTD6); //GREEN test led off (example of _BV macro)
382
+ // PORTD &= ~_BV(PORTD7); //RED test led on (example of _BV macro)
383
+ // PORTD |= (1<<PORTD6); //GREEN test led off (example of AVR studio style)
384
+ // PORTD &= ~(1<<PORTD7); //RED test led on (example of AVR studio style)
449
385
450
386
// ---------------------------------------------------------------------------------------------
451
387
// ICNC1: Input Capture Noise Canceler On, 4 successive equal ICP1 samples required for trigger (4*4uS = 16uS delayed)
@@ -480,10 +416,11 @@ ISR( TIMER1_OVF_vect )
480
416
--------------------------------------------------------------------------------------*/
481
417
ISR( TIMER1_CAPT_vect )
482
418
{
483
- // immediately grab the current capture time in case it triggers again and overwrites ICR1 with an unexpected new value
419
+ // Immediately grab the current capture time in case it triggers again and
420
+ // overwrites ICR1 with an unexpected new value
484
421
uiICP_CapturedTime = ICR1 ;
485
422
486
- // GREEN test led on (flicker for debug)
423
+ // GREEN test led on (flicker for debug)
487
424
GREEN_TESTLED_ON ();
488
425
489
426
// ----------------------------------------------------------------------------
@@ -493,9 +430,7 @@ GREEN_TESTLED_ON();
493
430
{
494
431
SET_INPUT_CAPTURE_FALLING_EDGE (); // previous period was low and just transitioned high
495
432
bICP_CapturedPeriodWasHigh = false ; // uiICP_CapturedPeriod about to be stored will be a low period
496
- }
497
- else
498
- {
433
+ } else {
499
434
SET_INPUT_CAPTURE_RISING_EDGE (); // previous period was high and transitioned low
500
435
bICP_CapturedPeriodWasHigh = true ; // uiICP_CapturedPeriod about to be stored will be a high period
501
436
}
@@ -556,14 +491,10 @@ void RF_Interpreter_WS2355( /*uiICP_CapturedPeriod, bICP_CapturedPeriodWasHigh*/
556
491
{
557
492
// short high, valid one bit
558
493
bValidBit = WSR_BIT_ONE ;
559
- }
560
- else if ( (uiICP_CapturedPeriod >= WSR_LONG_PERIOD_MIN ) && (uiICP_CapturedPeriod <= WSR_LONG_PERIOD_MAX ) )
561
- {
494
+ } else if ( (uiICP_CapturedPeriod >= WSR_LONG_PERIOD_MIN ) && (uiICP_CapturedPeriod <= WSR_LONG_PERIOD_MAX ) ) {
562
495
// long high, valid zero bit
563
496
bValidBit = WSR_BIT_ZERO ;
564
- }
565
- else
566
- {
497
+ } else {
567
498
// invalid high period, in the dead zone between short and long bit period lengths
568
499
WSR_RESET ();
569
500
}
@@ -588,77 +519,69 @@ void RF_Interpreter_WS2355( /*uiICP_CapturedPeriod, bICP_CapturedPeriodWasHigh*/
588
519
&= ~ (0x01 << (bICP_WSR_PacketInputBitPointer& 0x07 ));
589
520
bICP_WSR_PacketInputBitPointer++ ;
590
521
bICP_WSR_State = WSR_STATE_LOADING_BITSTREAM ;
591
- }
592
- else
593
- {
522
+ } else {
594
523
WSR_RESET ();
595
524
}
596
525
break ;
597
526
}
598
527
case WSR_STATE_LOADING_BITSTREAM :
599
528
{
600
- // ----------
601
- // potentially valid packet bitstream is on its way in, keep loading it up
529
+ // Potentially valid packet bitstream is on its way in, keep loading it up
602
530
if ( bValidBit == WSR_BIT_ZERO )
603
531
{
604
532
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][bICP_WSR_PacketInputBitPointer >> 3 ]
605
533
&= ~ (0x80 >> (bICP_WSR_PacketInputBitPointer& 0x07 ));
606
- }
607
- else
608
- {
534
+ } else {
609
535
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][bICP_WSR_PacketInputBitPointer >> 3 ]
610
536
|= (0x80 >> (bICP_WSR_PacketInputBitPointer& 0x07 ));
611
537
}
612
- // ----------
613
- // check at appropriate location of the incoming bitstream, if it is valid and throw away if not
538
+
539
+ // Check at appropriate location of the incoming bitstream, if it is valid and throw away if not
614
540
if ( bICP_WSR_PacketInputBitPointer == (WSR_TIMESTAMP_BIT_OFFSET + 4 ) )
615
541
{
616
- // 01234 01234
617
- // acceptable start to packet is 00001 or 00010 (lost the first 0), could optimise this but will leave with b for now for stability and debugging
542
+ // 01234 01234
543
+ // Acceptable start to packet is 00001 or 00010 (lost the first 0), could optimise
544
+ // this but will leave with b for now for stability and debugging
618
545
b = bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][4 /* bICP_WSR_PacketInputBitPointer >> 3*/ ];
619
546
b &= B11111000 ;
620
547
if ( b == B00010000 )
621
548
{
622
549
// valid packet 00010 start (with lost first zero), realign and continue
623
550
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][4 /* bICP_WSR_PacketInputBitPointer >> 3*/ ] = B00001000 ;
624
551
bICP_WSR_PacketInputBitPointer++ ; // move up one past the inserted missing bit
625
- }
626
- else if ( b != B00001000 )
627
- {
552
+ } else if ( b != B00001000 ) {
628
553
// invalid packet start, not 00001, reset
629
554
WSR_RESET ();
630
555
}
631
556
}
632
- // ----------
633
- // final check, has the last packet bit (52 bits total) come in, if so, mark this packet as done and move the major packet input pointer along
557
+
558
+ // Final check, has the last packet bit (52 bits total) come in? If so, mark this packet
559
+ // as done and move the major packet input pointer along
634
560
if ( bICP_WSR_PacketInputBitPointer == (WSR_TIMESTAMP_BIT_OFFSET + (WSR_RFPACKETBITSIZE - 1 )) )
635
561
{
636
- // got full packet, timestamp it for the main loop
562
+ // Got full packet, timestamp it for the main loop
637
563
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][0 ] = byte (ulICP_Timestamp_262_144mS >> 24 );
638
564
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][1 ] = byte (ulICP_Timestamp_262_144mS >> 16 );
639
565
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][2 ] = byte (ulICP_Timestamp_262_144mS >> 8 );
640
566
bICP_WSR_PacketData[bICP_WSR_PacketInputPointer][3 ] = byte (ulICP_Timestamp_262_144mS);
641
- // pointer and packet count
567
+ // Pointer and packet count
642
568
bICP_WSR_PacketInputPointer = ((bICP_WSR_PacketInputPointer+ 1 )& (WSR_PACKETARRAYSIZE - 1 ));// only the lower three bits are used for the 8 entry array
643
569
uiICP_WSR_ReceivedPacketCount++ ; // note will overflow and wrap, used for display of progress only
644
570
WSR_RESET ();
645
571
}
646
- // ----------
647
- // increment pointer to next new bit location
572
+
573
+ // Increment pointer to next new bit location
648
574
bICP_WSR_PacketInputBitPointer++ ;
649
575
break ;
650
576
}
651
577
}
652
578
}
653
579
// ----------------------------------------------------------------------------
654
- }
655
- else
656
- {
580
+ } else {
657
581
// ----------------------------------------------------------------------------
658
- // PERIOD OUT OF BOUNDS, DISCARD
659
- // This will throw away any out of range periods and reset the state machine, high or low.
582
+ // PERIOD OUT OF BOUNDS, DISCARD
583
+ // This will throw away any out of range periods and reset the state machine, high or low.
660
584
// ----------------------------------------------------------------------------
661
585
WSR_RESET ();
662
586
}
663
-
664
587
}
0 commit comments