From 6d8771fb182d835850111a3284148f1fdc37c52d Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Thu, 30 Sep 2004 08:31:42 +0000 Subject: Initial Checkin of support libs. We can now print strings and integers to the RS232 port --- Support_Libs/debug/debug.hcc | 33 +++++++++++++++++++++++++++++++++ Support_Libs/debug/debug.hch | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 Support_Libs/debug/debug.hcc create mode 100644 Support_Libs/debug/debug.hch diff --git a/Support_Libs/debug/debug.hcc b/Support_Libs/debug/debug.hcc new file mode 100644 index 0000000..2cc6bef --- /dev/null +++ b/Support_Libs/debug/debug.hcc @@ -0,0 +1,33 @@ +#include + +#include "pal_master.hch" + +#include "debug.hch" + +void print_hex_value(unsigned value) +{ + unsigned 8 ch; + unsigned 4 i; + unsigned 32 tempvalue; + + tempvalue = 0 @ value; + + for(i = 0;i < 8;i++) + { + ch = 0 @ (tempvalue\\28); + tempvalue <<= 4; + ch += (ch > 9) ? 0x37 : 0x30; + PalDataPortWrite(PalRS232PortCT(0), ch); + } + + PalDataPortWrite(PalRS232PortCT(0), 0x0A); + PalDataPortWrite(PalRS232PortCT(0), 0x0D); +} + +void print_string(unsigned 8 s[16]) { + unsigned 4 i; + + for(i = 0;('\0' != s[i]) || (0 < i);i++) { + PalDataPortWrite(PalRS232PortCT(0), s[i] +0x30); + } +} diff --git a/Support_Libs/debug/debug.hch b/Support_Libs/debug/debug.hch new file mode 100644 index 0000000..abd8bea --- /dev/null +++ b/Support_Libs/debug/debug.hch @@ -0,0 +1,33 @@ +/**************************************************************************** + * + * print_hex_value (unsigned value) + * + * Arguments: (typical) + * value: The integer which will be printed + * + * Description: (typical) + * This function will print the integer through the RS232 interface in a + * 32-bit hexadecimal representation. + * Pre: Value must be smaller or equal to 32-bits. + * RS232 must be available. + * Post: A hex representation of value is printed. + * + ****************************************************************************/ +void print_hex_value(unsigned value); + +/**************************************************************************** + * + * print_string (unsigned 8 value[16]) + * + * Arguments: (typical) + * value: An array of characters. + * + * Description: (typical) + * This function will print a string through the RS232 interface. + * Pre: Value must not be 16 characters in length. If less char's + * are used, termination with \0 is recommended. + * RS232 must be available. + * Post: The string is printed as is. + * + ****************************************************************************/ +void print_string(unsigned 8 s[16]); -- cgit v0.12