Subversion Repositories Code-Repo

Rev

Rev 120 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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