| 119 |
Kevin |
1 |
#ifndef __maindefs_h
|
|
|
2 |
#define __maindefs_h
|
|
|
3 |
|
|
|
4 |
#include <p18f27j13.h>
|
| 120 |
Kevin |
5 |
#include "uart.h"
|
| 119 |
Kevin |
6 |
|
| 127 |
Kevin |
7 |
// Option to enable/disable internal oscillator
|
| 128 |
Kevin |
8 |
#define USE_EXT_OSC
|
| 127 |
Kevin |
9 |
|
|
|
10 |
//#define UART1_RX_TO_BUFFER
|
|
|
11 |
#define UART1_RX_TO_XBEE
|
|
|
12 |
|
| 126 |
Kevin |
13 |
#define _DEBUG
|
| 121 |
Kevin |
14 |
//#define _TEST_UART
|
|
|
15 |
//#define _TEST_I2C_MASTER
|
|
|
16 |
//#define _TEST_I2C_SLAVE
|
|
|
17 |
//#define _TEST_SPI
|
|
|
18 |
//#define _TEST_NFC
|
|
|
19 |
//#define _TEST_LED_BACKPACK
|
|
|
20 |
//#define _TEST_SSD1306_OLED
|
| 122 |
Kevin |
21 |
//#define _TEST_SSD1331_OLED
|
| 126 |
Kevin |
22 |
//#define _TEST_ADC
|
| 127 |
Kevin |
23 |
#define _TEST_XBEE
|
| 119 |
Kevin |
24 |
|
|
|
25 |
// Enable or disable debug prints depending on project preprocessor (_DEBUG)
|
|
|
26 |
#ifdef _DEBUG
|
| 126 |
Kevin |
27 |
#define DBG_PRINT_MAIN(x) UART1_WriteS(x)
|
|
|
28 |
#define DBG_PRINT_UART(x) UART1_WriteS(x)
|
|
|
29 |
#define DBG_PRINT_I2C(x) UART1_WriteS(x)
|
|
|
30 |
#define DBG_PRINT_SPI(x) UART1_WriteS(x)
|
| 127 |
Kevin |
31 |
#define DBG_PRINT_XBEE(x) UART1_WriteS(x)
|
| 119 |
Kevin |
32 |
#define DBG_PRINT_PORTB_INT(x)
|
|
|
33 |
#define DBG_PRINT_INT(x)
|
|
|
34 |
#define DBG_PRINT_BUFFER(x)
|
|
|
35 |
#else
|
|
|
36 |
#define DBG_PRINT_MAIN(x)
|
|
|
37 |
#define DBG_PRINT_UART(x)
|
|
|
38 |
#define DBG_PRINT_I2C(x)
|
| 121 |
Kevin |
39 |
#define DBG_PRINT_SPI(x)
|
| 119 |
Kevin |
40 |
#define DBG_PRINT_XBEE(x)
|
|
|
41 |
#define DBG_PRINT_PORTB_INT(x)
|
|
|
42 |
#define DBG_PRINT_INT(x)
|
|
|
43 |
#define DBG_PRINT_BUFFER(x)
|
|
|
44 |
#endif
|
|
|
45 |
|
| 129 |
Kevin |
46 |
// Pin allocations
|
|
|
47 |
#define ADC_AN0_TRIS TRISAbits.TRISA0
|
|
|
48 |
#define ADC_AN1_TRIS TRISAbits.TRISA1
|
|
|
49 |
#define ADC_AN2_TRIS TRISAbits.TRISA2
|
|
|
50 |
|
|
|
51 |
#define XBEE_CTS_TRIS TRISBbits.TRISB0
|
|
|
52 |
#define XBEE_CTS_LAT LATBbits.LATB0
|
|
|
53 |
#define XBEE_CTS_PORT PORTBbits.RB0
|
|
|
54 |
#define XBEE_RTS_TRIS TRISBbits.TRISB1
|
|
|
55 |
#define XBEE_RTS_LAT LATBbits.LATB1
|
|
|
56 |
|
|
|
57 |
#define SPI_MOSI_TRIS TRISBbits.TRISB2
|
|
|
58 |
#define SPI_MISO_TRIS TRISBbits.TRISB3
|
|
|
59 |
#define SPI_CLK_TRIS TRISBbits.TRISB4
|
|
|
60 |
#define SPI_DC_SELECT_TRIS TRISBbits.TRISB5
|
|
|
61 |
#define SPI_DC_SELECT_LAT LATBbits.LATB5
|
|
|
62 |
#define SPI_RESET_TRIS TRISBbits.TRISB6
|
|
|
63 |
#define SPI_RESET_LAT LATBbits.LATB6
|
|
|
64 |
#define SPI_SLAVE_SELECT_TRIS TRISBbits.TRISB7
|
|
|
65 |
#define SPI_SLAVE_SELECT_LAT LATBbits.LATB7
|
|
|
66 |
|
|
|
67 |
#define NFC_IRQ_TRIS TRISCbits.TRISC1
|
|
|
68 |
#define NFC_IRQ_PORT PORTCbits.RC1
|
|
|
69 |
#define NFC_RESET_TRIS TRISCbits.TRISC2
|
|
|
70 |
#define NFC_RESET_LAT LATCbits.LATC2
|
|
|
71 |
|
|
|
72 |
#define I2C_CLK_TRIS TRISCbits.TRISC3
|
|
|
73 |
#define I2C_DAT_TRIS TRISCbits.TRISC4
|
|
|
74 |
|
|
|
75 |
#define UART1_RX_TRIS TRISCbits.TRISC7
|
|
|
76 |
#define UART1_TX_TRIS TRISCbits.TRISC6
|
|
|
77 |
|
|
|
78 |
// PPS bindings
|
|
|
79 |
#define PPS_SPI2_CLK_IN 7
|
|
|
80 |
#define PPS_SPI2_CLK_OUT RPOR7
|
|
|
81 |
#define PPS_SPI2_MISO 6
|
|
|
82 |
#define PPS_SPI2_MOSI RPOR5
|
|
|
83 |
|
| 130 |
Kevin |
84 |
//#define PPS_UART2_RX 5
|
|
|
85 |
//#define PPS_UART2_TX RPOR6
|
|
|
86 |
|
| 119 |
Kevin |
87 |
#endif
|
|
|
88 |
|