blob: 16c556493d88e8943dbc5f81b668528afef3cb59 (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include <stdlib.hch>
#include "pal_master.hch"
#include "debug.hch"
void print_hex_value(unsigned 32 value) {
unsigned char character;
unsigned 4 index;
/*
* We print 32 bits values max, so we only need 8 positions.
*/
for(index = 0; index != 8; index++) {
/*
* The 4 MSB equals one hex digit so we ignore the rest.
*/
character = 0 @ (value \\ 28);
/*
* To easly get our 4 MSB on the next run, we shift them here.
*/
value <<= 4;
/*
* We now have a value between 0 and f stored in our variable.
* We simply add the appropiate value to our character because
* only ascii characters make sense to be printed.
*/
character += (character > 9) ? 0x37 : 0x30;
PalDataPortWrite(PalRS232PortCT(0), character);
}
}
void print_string(unsigned char *string) {
unsigned 10 index;
/*
* We print all elements from the provided array until we encounter the
* '\0' character. Since standard C and Handel-C both end a string
* with the '\0' character. Since Handel-C init's var's to 0 this
* normally will never go wrong.
*/
for(index = 0; '\0' != string[index]; index++) {
PalDataPortWrite(PalRS232PortCT(0), string[index]);
}
}
void print_eol(void) {
/*
* To write a clean 'return' we have to both write the newline and
* carriage return symbol.
*/
PalDataPortWrite(PalRS232PortCT(0), 0x0a);
PalDataPortWrite(PalRS232PortCT(0), 0x0d);
}
void print_cr(void) {
/*
* Write the character that forces the cursor to go back to the
* beginning of the line.
*/
PalDataPortWrite(PalRS232PortCT(0), 0x0d);
}
void print_cls(void) {
/*
* Write the clearscreen character to the RS232 port.
*/
PalDataPortWrite(PalRS232PortCT(0), 0x0c);
}
|