forked from bradwood/Standalone-Arduino-AVR-ISP-programmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport.cpp
46 lines (42 loc) · 802 Bytes
/
support.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Useful message printing definitions
#include "optiLoader.h"
/*
* Low level support functions
*/
/*
* flashprint
* print a text string direct from flash memory to Serial
*/
void flashprint (const char p[])
{
byte c;
while (0 != (c = pgm_read_byte(p++))) {
Serial.write(c);
}
}
/*
* hexton
* Turn a Hex digit (0..9, A..F) into the equivalent binary value (0-16)
*/
byte hexton (byte h)
{
if (h >= '0' && h <= '9')
return(h - '0');
if (h >= 'A' && h <= 'F')
return((h - 'A') + 10);
error("Bad hex digit!");
}
/*
* pulse
* turn a pin on and off a few times; indicates life via LED
*/
#define PTIME 30
void pulse (int pin, int times) {
do {
digitalWrite(pin, HIGH);
delay(PTIME);
digitalWrite(pin, LOW);
delay(PTIME);
}
while (times--);
}