This repository has been archived by the owner on Apr 13, 2021. It is now read-only.
/
debug.h
47 lines (39 loc) · 1.48 KB
/
debug.h
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
/*
* Copyright (C) 2011 Fergus Noble <fergusnoble@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SWIFTNAV_DEBUG_H
#define SWIFTNAV_DEBUG_H
#include <libopencm3/cm3/common.h>
#include "debug_messages.h"
#define DEBUG_MAGIC_1 0xBE
#define DEBUG_MAGIC_2 0xEF
#define DEBUG_MSG(msg_type, item) send_debug_msg(msg_type, sizeof(item), (u8*)&(item))
/* Define the type of our callback function
* for convenience.
*/
typedef void(*msg_callback_t)(u8 msg[]);
/* Define a linked list of message callbacks. */
typedef struct msg_callbacks_node {
u8 msg_type;
msg_callback_t cb;
struct msg_callbacks_node* next;
} msg_callbacks_node_t;
void debug_setup();
u32 debug_send_msg(u8 msg_type, u8 len, u8 buff[]);
void debug_register_callback(u8 msg_type, msg_callback_t cb, msg_callbacks_node_t* node);
msg_callback_t debug_find_callback(u8 msg_id);
void debug_process_messages();
#endif