| 113 |
Kevin |
1 |
#ifndef __maindefs_h
|
|
|
2 |
#define __maindefs_h
|
|
|
3 |
|
|
|
4 |
#include <p18f26j11.h>
|
|
|
5 |
#include <stdio.h>
|
|
|
6 |
|
|
|
7 |
//#define _DEBUG
|
| 117 |
Kevin |
8 |
#define _BASE_STATION
|
|
|
9 |
//#define _REMOTE
|
| 114 |
Kevin |
10 |
|
|
|
11 |
#ifdef _BASE_STATION
|
| 116 |
Kevin |
12 |
#define BASE_STATION_ADDRESS 1
|
| 114 |
Kevin |
13 |
#define _SPI2_V2
|
|
|
14 |
#endif
|
|
|
15 |
#ifdef _REMOTE
|
| 113 |
Kevin |
16 |
#define _SPI2_V1
|
| 114 |
Kevin |
17 |
#endif
|
| 113 |
Kevin |
18 |
|
|
|
19 |
// Enable or disable debug prints depending on project preprocessor (_DEBUG)
|
|
|
20 |
#ifdef _DEBUG
|
|
|
21 |
#define DBG_PRINT_MAIN(x) printf(x)
|
|
|
22 |
#define DBG_PRINT_I2C(x)
|
|
|
23 |
#define DBG_PRINT_XBEE(x)
|
|
|
24 |
#define DBG_PRINT_PORTB_INT(x)
|
|
|
25 |
#define DBG_PRINT_INT(x)
|
|
|
26 |
#define DBG_PRINT_BUFFER(x) printf(x)
|
|
|
27 |
#else
|
|
|
28 |
#define DBG_PRINT_MAIN(x)
|
|
|
29 |
#define DBG_PRINT_I2C(x)
|
|
|
30 |
#define DBG_PRINT_XBEE(x)
|
|
|
31 |
#define DBG_PRINT_PORTB_INT(x)
|
|
|
32 |
#define DBG_PRINT_INT(x)
|
|
|
33 |
#define DBG_PRINT_BUFFER(x)
|
|
|
34 |
#endif
|
|
|
35 |
|
|
|
36 |
#define RETURNID_ACC 10
|
|
|
37 |
#define RETURNID_GYRO 11
|
| 114 |
Kevin |
38 |
#define RETURNID_CONN 12
|
|
|
39 |
#define RETURNID_BTN1 13
|
|
|
40 |
#define RETURNID_BTN2 14
|
| 115 |
Kevin |
41 |
#define RETURNID_NEW_REMOTE_SRC 15
|
|
|
42 |
#define RETURNID_NEW_REMOTE_CON 16
|
| 116 |
Kevin |
43 |
#define RETURNID_DATA_FIN 17
|
| 113 |
Kevin |
44 |
|
|
|
45 |
// Message type definitions
|
|
|
46 |
#define MSGTYPE_RESEND 1
|
|
|
47 |
|
|
|
48 |
#define MSGTYPE_TIMER0 10
|
|
|
49 |
#define MSGTYPE_TIMER1 11
|
|
|
50 |
#define MSGTYPE_TIMER2 12
|
|
|
51 |
#define MSGTYPE_TIMER3 13
|
|
|
52 |
#define MSGTYPE_TIMER4 14
|
|
|
53 |
#define MSGTYPE_TIMER5 15
|
|
|
54 |
#define MSGTYPE_TIMER6 16
|
|
|
55 |
#define MSGTYPE_TIMER8 17
|
|
|
56 |
#define MSGTYPE_MAIN1 20
|
|
|
57 |
#define MSGTYPE_OVERRUN 30
|
|
|
58 |
#define MSGTYPE_UART_DATA 31
|
|
|
59 |
#define MSGTYPE_I2C_DBG 40
|
|
|
60 |
#define MSGTYPE_I2C_DATA 41
|
|
|
61 |
#define MSGTYPE_I2C_REPLY 42
|
|
|
62 |
//#define MSGTYPE_I2C_RQST 43
|
|
|
63 |
|
|
|
64 |
// Unused (Used for I2C Master Mode)
|
|
|
65 |
#define MSGTYPE_I2C_MASTER_SEND_COMPLETE 43
|
|
|
66 |
#define MSGTYPE_I2C_MASTER_SEND_FAILED 44
|
|
|
67 |
#define MSGTYPE_I2C_MASTER_RECV_COMPLETE 45
|
|
|
68 |
#define MSGTYPE_I2C_MASTER_RECV_FAILED 46
|
|
|
69 |
|
|
|
70 |
#define MSGTYPE_ADC_NEWVALUE 50
|
|
|
71 |
|
|
|
72 |
#define MSGTYPE_XBEE_RX_AT_COMMAND_RESPONSE 60
|
|
|
73 |
#define MSGTYPE_XBEE_RX_DATA_PACKET 61
|
|
|
74 |
#define MSGTYPE_XBEE_RX_DATA_TX_STATUS 62
|
|
|
75 |
#define MSGTYPE_XBEE_RX_IO_DATA_SAMPLE 63
|
|
|
76 |
#define MSGTYPE_XBEE_RX_EXPLICIT_COMMAND 64
|
|
|
77 |
#define MSGTYPE_XBEE_RX_REMOTE_AT_COMMAND_RESPONSE 65
|
|
|
78 |
#define MSGTYPE_XBEE_RX_ROUTE_RECORD 66
|
|
|
79 |
#define MSGTYPE_XBEE_RX_NODE_IDENTIFICATION 67
|
|
|
80 |
#define MSGTYPE_XBEE_RX_FRAME_MODEM_STATUS 68
|
|
|
81 |
|
|
|
82 |
#define MSGTYPE_PORTB_4_DOWN 70
|
|
|
83 |
#define MSGTYPE_PORTB_4_UP 71
|
|
|
84 |
#define MSGTYPE_PORTB_5_DOWN 72
|
|
|
85 |
#define MSGTYPE_PORTB_5_UP 73
|
|
|
86 |
#define MSGTYPE_PORTB_6_DOWN 74
|
|
|
87 |
#define MSGTYPE_PORTB_6_UP 75
|
|
|
88 |
#define MSGTYPE_PORTB_7_DOWN 76
|
|
|
89 |
#define MSGTYPE_PORTB_7_UP 77
|
|
|
90 |
|
|
|
91 |
#define MSGTYPE_INT1 80
|
|
|
92 |
|
|
|
93 |
enum I2C_STATE {
|
|
|
94 |
I2C_STATE_IDLE,
|
|
|
95 |
I2C_STATE_READ_ACC,
|
|
|
96 |
I2C_STATE_READ_GYRO
|
|
|
97 |
};
|
|
|
98 |
|
|
|
99 |
enum XBEE_STATE {
|
|
|
100 |
XBEE_STATE_WAITING_TO_JOIN,
|
| 114 |
Kevin |
101 |
XBEE_STATE_JOINED_NETWORK,
|
|
|
102 |
XBEE_STATE_QUERY_PARENT
|
| 113 |
Kevin |
103 |
};
|
|
|
104 |
|
|
|
105 |
#endif
|
|
|
106 |
|