Skip to content

Commit 55de1dc

Browse files
committed
ISO c++ doesn't support binary contants
however GNU c++ does
1 parent c3890dc commit 55de1dc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Tone.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static int8_t toneBegin(uint8_t _pin)
279279

280280
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
281281
{
282-
uint8_t prescalarbits = 0b001;
282+
uint8_t prescalarbits = 0x01;
283283
long toggle_count = 0;
284284
uint32_t ocr = 0;
285285
int8_t _timer;
@@ -295,38 +295,38 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
295295
if (_timer == 0 || _timer == 2)
296296
{
297297
ocr = F_CPU / frequency / 2 - 1;
298-
prescalarbits = 0b001; // ck/1: same for both timers
298+
prescalarbits = 0x01; // ck/1: same for both timers
299299
if (ocr > 255)
300300
{
301301
ocr = F_CPU / frequency / 2 / 8 - 1;
302-
prescalarbits = 0b010; // ck/8: same for both timers
302+
prescalarbits = 0x02; // ck/8: same for both timers
303303

304304
if (_timer == TIMER_WITH_FULL_PRESCALER && ocr > 255)
305305
{
306306
ocr = F_CPU / frequency / 2 / 32 - 1;
307-
prescalarbits = 0b011;
307+
prescalarbits = 0x03;
308308
}
309309

310310
if (ocr > 255)
311311
{
312312
ocr = F_CPU / frequency / 2 / 64 - 1;
313-
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0b011 : 0b100;
313+
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0x03 : 0x04;
314314

315315
if (_timer == TIMER_WITH_FULL_PRESCALER && ocr > 255)
316316
{
317317
ocr = F_CPU / frequency / 2 / 128 - 1;
318-
prescalarbits = 0b101;
318+
prescalarbits = 0x05;
319319
}
320320

321321
if (ocr > 255)
322322
{
323323
ocr = F_CPU / frequency / 2 / 256 - 1;
324-
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0b100 : 0b110;
324+
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0x04 : 0x06;
325325
if (ocr > 255)
326326
{
327327
// Can't do any better than /1024
328328
ocr = F_CPU / frequency / 2 / 1024 - 1;
329-
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0b101 : 0b111;
329+
prescalarbits = _timer != TIMER_WITH_FULL_PRESCALER ? 0x05 : 0x07;
330330
}
331331
}
332332
}
@@ -335,13 +335,13 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
335335
#if defined(TCCR0B)
336336
if (_timer == 0)
337337
{
338-
TCCR0B = (TCCR0B & 0b11111000) | prescalarbits;
338+
TCCR0B = (TCCR0B & 0xf8) | prescalarbits;
339339
}
340340
else
341341
#endif
342342
#if defined(TCCR2B)
343343
{
344-
TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
344+
TCCR2B = (TCCR2B & 0xf8) | prescalarbits;
345345
}
346346
#else
347347
{
@@ -354,30 +354,30 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
354354
// two choices for the 16 bit timers: ck/1 or ck/64
355355
ocr = F_CPU / frequency / 2 - 1;
356356

357-
prescalarbits = 0b001;
357+
prescalarbits = 0x01;
358358
if (ocr > 0xffff)
359359
{
360360
ocr = F_CPU / frequency / 2 / 64 - 1;
361-
prescalarbits = 0b011;
361+
prescalarbits = 0x03;
362362
}
363363

364364
if (_timer == 1)
365365
{
366366
#if defined(TCCR1B)
367-
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
367+
TCCR1B = (TCCR1B & 0xf8) | prescalarbits;
368368
#endif
369369
}
370370
#if defined(TCCR3B)
371371
else if (_timer == 3)
372-
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
372+
TCCR3B = (TCCR3B & 0xf8) | prescalarbits;
373373
#endif
374374
#if defined(TCCR4B)
375375
else if (_timer == 4)
376-
TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
376+
TCCR4B = (TCCR4B & 0xf8) | prescalarbits;
377377
#endif
378378
#if defined(TCCR5B)
379379
else if (_timer == 5)
380-
TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
380+
TCCR5B = (TCCR5B & 0xf8) | prescalarbits;
381381
#endif
382382

383383
}
@@ -486,7 +486,7 @@ void disableTimer(uint8_t _timer)
486486
TCCR2A = (1 << WGM20);
487487
#endif
488488
#if defined(TCCR2B) && defined(CS22)
489-
TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
489+
TCCR2B = (TCCR2B & 0xf8) | (1 << CS22);
490490
#endif
491491
#if defined(OCR2A)
492492
OCR2A = 0;

0 commit comments

Comments
 (0)