summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/util.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2009-04-04 22:08:58 +0200
committerMichael Buesch <mb@bu3sch.de>2009-04-04 22:08:58 +0200
commitde20d70112c89d0a144b5605e3bed1def78a6b87 (patch)
tree733cbf54fe15d5954fb69adc3ef5dfe10791e0a3 /pressure_control/firmware/util.c
parent734219d3cd138524b2fd0a17460409c4826eee19 (diff)
downloadcnc-de20d70112c89d0a144b5605e3bed1def78a6b87.tar.xz
cnc-de20d70112c89d0a144b5605e3bed1def78a6b87.zip
pressure_control: Add more debugging code
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware/util.c')
-rw-r--r--pressure_control/firmware/util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/pressure_control/firmware/util.c b/pressure_control/firmware/util.c
index 0056cbd..0f3b8b7 100644
--- a/pressure_control/firmware/util.c
+++ b/pressure_control/firmware/util.c
@@ -93,3 +93,37 @@ uint16_t crc16_block_update(uint16_t crc, const void *_data, uint16_t size)
return crc;
}
+
+uint8_t hexdigit_to_ascii(uint8_t digit)
+{
+ /* Convert a hexadecimal digit (0-F) to an ASCII character */
+ if (digit >= 0xA)
+ digit += 0x41 - 0xA;
+ else
+ digit += 0x30;
+ return digit;
+}
+
+void num16_to_ascii(uint8_t *buf, uint16_t v)
+{
+ uint16_t orig = v;
+
+ if (orig >= 10000) {
+ *buf++ = v / 10000 + '0';
+ v %= 10000;
+ }
+ if (orig >= 1000) {
+ *buf++ = v / 1000 + '0';
+ v %= 1000;
+ }
+ if (orig >= 100) {
+ *buf++ = v / 100 + '0';
+ v %= 100;
+ }
+ if (orig >= 10) {
+ *buf++ = v / 10 + '0';
+ v %= 10;
+ }
+ *buf++ = v + '0';
+ *buf = '\0';
+}
bues.ch cgit interface