summaryrefslogtreecommitdiffstats
path: root/hid/firmware/debug.h
blob: f38c78a447028e7c1303c9ba4258c9f966d01e11 (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
#ifndef DEBUG_H_
#define DEBUG_H_

#include "util.h"

#include <stdint.h>


void usart_tx(uint8_t data);
void usart_tx_hex8(uint8_t number);
void usart_tx_hex16(uint16_t number);
void usart_tx_1num_8bit(const char PROGPTR *d, uint8_t n);
void usart_tx_2num_8bit(const char PROGPTR *d1, uint8_t n1, const char PROGPTR *d2, uint8_t n2);
void usart_tx_1num_16bit(const char PROGPTR *d, uint16_t n);
void usart_tx_2num_16bit(const char PROGPTR *d1, uint16_t n1, const char PROGPTR *d2, uint16_t n2);
void usart_tx_string(const char PROGPTR *flash_string);
void usart_dump_mem(const void *_mem, uint8_t size);
void usart_init(void);

#define printstr(string_literal)	usart_tx_string(PSTR(string_literal))
#define printhex16(num)			usart_tx_hex16(num)
#define printhex8(num)			usart_tx_hex8(num)
#define print1num(description, num)	do { if (sizeof(num) == 1) \
						usart_tx_1num_8bit(PSTR(description), num); \
					else \
						usart_tx_1num_16bit(PSTR(description), num); \
					} while (0)
#define print2num(d1, n1, d2, n2)	do { if (sizeof(n1) == 1 && sizeof(n2) == 1) \
						usart_tx_2num_8bit(PSTR(d1), n1, PSTR(d2), n2); \
					else \
						usart_tx_2num_16bit(PSTR(d1), n1, PSTR(d2), n2); \
					} while (0)
#define dumpmem(mem_addr, size)		usart_dump_mem(mem_addr, size)


#endif /* DEBUG_H_ */
bues.ch cgit interface