Subversion Repositories Code-Repo

Rev

Rev 114 | Rev 116 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
113 Kevin 1
#ifndef __maindefs_h
2
#define __maindefs_h
3
 
4
#include <p18f26j11.h>
5
#include <stdio.h>
6
 
7
//#define _DEBUG
114 Kevin 8
#define _BASE_STATION
9
//#define _REMOTE
10
 
11
#ifdef _BASE_STATION
115 Kevin 12
#define BASE_STATION_ADDRESS 2
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
113 Kevin 43
 
44
// Message type definitions
45
#define MSGTYPE_RESEND 1
46
 
47
#define MSGTYPE_TIMER0      10
48
#define MSGTYPE_TIMER1      11
49
#define MSGTYPE_TIMER2      12
50
#define MSGTYPE_TIMER3      13
51
#define MSGTYPE_TIMER4      14
52
#define MSGTYPE_TIMER5      15
53
#define MSGTYPE_TIMER6      16
54
#define MSGTYPE_TIMER8      17
55
#define MSGTYPE_MAIN1       20
56
#define	MSGTYPE_OVERRUN     30
57
#define MSGTYPE_UART_DATA   31
58
#define MSGTYPE_I2C_DBG     40
59
#define	MSGTYPE_I2C_DATA    41
60
#define MSGTYPE_I2C_REPLY   42
61
//#define MSGTYPE_I2C_RQST 43
62
 
63
// Unused (Used for I2C Master Mode)
64
#define MSGTYPE_I2C_MASTER_SEND_COMPLETE    43
65
#define MSGTYPE_I2C_MASTER_SEND_FAILED      44
66
#define MSGTYPE_I2C_MASTER_RECV_COMPLETE    45
67
#define MSGTYPE_I2C_MASTER_RECV_FAILED      46
68
 
69
#define MSGTYPE_ADC_NEWVALUE 50
70
 
71
#define MSGTYPE_XBEE_RX_AT_COMMAND_RESPONSE         60
72
#define MSGTYPE_XBEE_RX_DATA_PACKET                 61
73
#define MSGTYPE_XBEE_RX_DATA_TX_STATUS              62
74
#define MSGTYPE_XBEE_RX_IO_DATA_SAMPLE              63
75
#define MSGTYPE_XBEE_RX_EXPLICIT_COMMAND            64
76
#define MSGTYPE_XBEE_RX_REMOTE_AT_COMMAND_RESPONSE  65
77
#define MSGTYPE_XBEE_RX_ROUTE_RECORD                66
78
#define MSGTYPE_XBEE_RX_NODE_IDENTIFICATION         67
79
#define MSGTYPE_XBEE_RX_FRAME_MODEM_STATUS          68
80
 
81
#define MSGTYPE_PORTB_4_DOWN    70
82
#define MSGTYPE_PORTB_4_UP      71
83
#define MSGTYPE_PORTB_5_DOWN    72
84
#define MSGTYPE_PORTB_5_UP      73
85
#define MSGTYPE_PORTB_6_DOWN    74
86
#define MSGTYPE_PORTB_6_UP      75
87
#define MSGTYPE_PORTB_7_DOWN    76
88
#define MSGTYPE_PORTB_7_UP      77
89
 
90
#define MSGTYPE_INT1    80
91
 
92
enum I2C_STATE {
93
    I2C_STATE_IDLE,
94
    I2C_STATE_READ_ACC,
95
    I2C_STATE_READ_GYRO
96
};
97
 
98
enum XBEE_STATE {
99
    XBEE_STATE_WAITING_TO_JOIN,
114 Kevin 100
    XBEE_STATE_JOINED_NETWORK,
101
    XBEE_STATE_QUERY_PARENT
113 Kevin 102
};
103
 
104
#endif
105