| 107 |
Kevin |
1 |
#ifndef __maindefs_h
|
|
|
2 |
#define __maindefs_h
|
|
|
3 |
|
|
|
4 |
#include <p18f27j13.h>
|
|
|
5 |
#include <stdio.h>
|
|
|
6 |
|
|
|
7 |
//#define _DEBUG
|
| 111 |
Kevin |
8 |
#define _BASE_STATION
|
|
|
9 |
//#define _REMOTE
|
| 107 |
Kevin |
10 |
|
|
|
11 |
// Enable or disable debug prints depending on project preprocessor (_DEBUG)
|
|
|
12 |
#ifdef _DEBUG
|
|
|
13 |
#define DBG_PRINT_MAIN(x) printf(x)
|
| 109 |
Kevin |
14 |
#define DBG_PRINT_I2C(x)
|
| 107 |
Kevin |
15 |
#define DBG_PRINT_XBEE(x)
|
| 112 |
Kevin |
16 |
#define DBG_PRINT_PORTB_INT(x)
|
|
|
17 |
#define DBG_PRINT_INT(x)
|
| 111 |
Kevin |
18 |
#define DBG_PRINT_BUFFER(x)
|
| 107 |
Kevin |
19 |
#else
|
|
|
20 |
#define DBG_PRINT_MAIN(x)
|
|
|
21 |
#define DBG_PRINT_I2C(x)
|
|
|
22 |
#define DBG_PRINT_XBEE(x)
|
|
|
23 |
#define DBG_PRINT_PORTB_INT(x)
|
| 111 |
Kevin |
24 |
#define DBG_PRINT_INT(x)
|
|
|
25 |
#define DBG_PRINT_BUFFER(x)
|
| 107 |
Kevin |
26 |
#endif
|
|
|
27 |
|
|
|
28 |
// Message type definitions
|
|
|
29 |
#define MSGTYPE_RESEND 1
|
|
|
30 |
|
|
|
31 |
#define MSGTYPE_TIMER0 10
|
|
|
32 |
#define MSGTYPE_TIMER1 11
|
|
|
33 |
#define MSGTYPE_TIMER2 12
|
|
|
34 |
#define MSGTYPE_TIMER3 13
|
|
|
35 |
#define MSGTYPE_TIMER4 14
|
|
|
36 |
#define MSGTYPE_TIMER5 15
|
|
|
37 |
#define MSGTYPE_TIMER6 16
|
|
|
38 |
#define MSGTYPE_TIMER8 17
|
|
|
39 |
#define MSGTYPE_MAIN1 20
|
|
|
40 |
#define MSGTYPE_OVERRUN 30
|
|
|
41 |
#define MSGTYPE_UART_DATA 31
|
|
|
42 |
#define MSGTYPE_I2C_DBG 40
|
|
|
43 |
#define MSGTYPE_I2C_DATA 41
|
|
|
44 |
#define MSGTYPE_I2C_REPLY 42
|
|
|
45 |
//#define MSGTYPE_I2C_RQST 43
|
|
|
46 |
|
|
|
47 |
// Unused (Used for I2C Master Mode)
|
|
|
48 |
#define MSGTYPE_I2C_MASTER_SEND_COMPLETE 43
|
|
|
49 |
#define MSGTYPE_I2C_MASTER_SEND_FAILED 44
|
|
|
50 |
#define MSGTYPE_I2C_MASTER_RECV_COMPLETE 45
|
|
|
51 |
#define MSGTYPE_I2C_MASTER_RECV_FAILED 46
|
|
|
52 |
|
|
|
53 |
#define MSGTYPE_ADC_NEWVALUE 50
|
|
|
54 |
|
|
|
55 |
#define MSGTYPE_XBEE_RX_AT_COMMAND_RESPONSE 60
|
|
|
56 |
#define MSGTYPE_XBEE_RX_DATA_PACKET 61
|
|
|
57 |
#define MSGTYPE_XBEE_RX_DATA_TX_STATUS 62
|
|
|
58 |
#define MSGTYPE_XBEE_RX_IO_DATA_SAMPLE 63
|
|
|
59 |
#define MSGTYPE_XBEE_RX_EXPLICIT_COMMAND 64
|
|
|
60 |
#define MSGTYPE_XBEE_RX_REMOTE_AT_COMMAND_RESPONSE 65
|
|
|
61 |
#define MSGTYPE_XBEE_RX_ROUTE_RECORD 66
|
|
|
62 |
#define MSGTYPE_XBEE_RX_NODE_IDENTIFICATION 67
|
|
|
63 |
#define MSGTYPE_XBEE_RX_FRAME_MODEM_STATUS 68
|
|
|
64 |
|
|
|
65 |
#define MSGTYPE_PORTB_4_DOWN 70
|
|
|
66 |
#define MSGTYPE_PORTB_4_UP 71
|
|
|
67 |
#define MSGTYPE_PORTB_5_DOWN 72
|
|
|
68 |
#define MSGTYPE_PORTB_5_UP 73
|
|
|
69 |
#define MSGTYPE_PORTB_6_DOWN 74
|
|
|
70 |
#define MSGTYPE_PORTB_6_UP 75
|
|
|
71 |
#define MSGTYPE_PORTB_7_DOWN 76
|
|
|
72 |
#define MSGTYPE_PORTB_7_UP 77
|
|
|
73 |
|
| 112 |
Kevin |
74 |
#define MSGTYPE_INT1 80
|
| 107 |
Kevin |
75 |
|
| 112 |
Kevin |
76 |
enum I2C_STATE {
|
|
|
77 |
I2C_STATE_IDLE,
|
|
|
78 |
I2C_WAIT_WRITE_LENGTH_ACK,
|
|
|
79 |
I2C_WAIT_WRITE_DATA_ACK,
|
|
|
80 |
I2C_WAIT_REPLY_LENGTH,
|
|
|
81 |
I2C_WAIT_REPLY_DATA
|
|
|
82 |
};
|
|
|
83 |
|
| 107 |
Kevin |
84 |
#endif
|
|
|
85 |
|