1.1 --- a/debug.c Sat Oct 20 19:19:30 2018 +0200
1.2 +++ b/debug.c Sat Oct 20 19:24:34 2018 +0200
1.3 @@ -20,14 +20,21 @@
1.4 #include "pic32_c.h"
1.5 #include "debug.h"
1.6
1.7 +/* Register output functions using UART1. */
1.8 +
1.9 +void rbits(uint32_t reg)
1.10 +{
1.11 + bits(REG(reg), 4);
1.12 +}
1.13 +
1.14 +void rhex(uint32_t reg)
1.15 +{
1.16 + hex(REG(reg), 4);
1.17 +}
1.18 +
1.19 /* Value output functions using UART1. */
1.20
1.21 -void bits(uint32_t reg)
1.22 -{
1.23 - vbits(REG(reg));
1.24 -}
1.25 -
1.26 -void vbits(uint32_t val)
1.27 +void bits(uint32_t val, int bytes)
1.28 {
1.29 uint32_t mask;
1.30
1.31 @@ -36,17 +43,14 @@
1.32 uart_write('1');
1.33 else
1.34 uart_write('0');
1.35 -
1.36 - uart_write('\r');
1.37 - uart_write('\n');
1.38 }
1.39
1.40 -void vhex(uint32_t val)
1.41 +void hex(uint32_t val, int bytes)
1.42 {
1.43 uint32_t mask;
1.44 - uint8_t digit, shift;
1.45 + uint8_t digit, shift, start = bytes * 8 - 4;
1.46
1.47 - for (mask = (0b1111 << 28), shift = 28; mask; mask >>= 4, shift -= 4)
1.48 + for (mask = (0b1111 << start), shift = start; mask; mask >>= 4, shift -= 4)
1.49 {
1.50 digit = (val & mask) >> shift;
1.51 if (digit > 9)
1.52 @@ -54,9 +58,6 @@
1.53 else
1.54 uart_write('0' + digit);
1.55 }
1.56 -
1.57 - uart_write('\r');
1.58 - uart_write('\n');
1.59 }
1.60
1.61
1.62 @@ -94,6 +95,12 @@
1.63 uart_write_char(1, c);
1.64 }
1.65
1.66 +void uart_write_nl(void)
1.67 +{
1.68 + uart_write('\r');
1.69 + uart_write('\n');
1.70 +}
1.71 +
1.72 void uart_write_string(const char *s)
1.73 {
1.74 while (*s)