Subversion Repositories Code-Repo

Rev

Rev 128 | Blame | Last modification | View Log | RSS feed

#ifndef __maindefs_h
#define __maindefs_h

#include <p18f27j13.h>
#include "uart.h"

// Option to enable/disable internal oscillator
#define USE_EXT_OSC

//#define UART1_RX_TO_BUFFER
#define UART1_RX_TO_XBEE

#define _DEBUG
//#define _TEST_UART
//#define _TEST_I2C_MASTER
//#define _TEST_I2C_SLAVE
//#define _TEST_SPI
//#define _TEST_NFC
//#define _TEST_LED_BACKPACK
//#define _TEST_SSD1306_OLED
//#define _TEST_SSD1331_OLED
//#define _TEST_ADC
#define _TEST_XBEE

// Enable or disable debug prints depending on project preprocessor (_DEBUG)
#ifdef _DEBUG
#define DBG_PRINT_MAIN(x) UART1_WriteS(x)
#define DBG_PRINT_UART(x) UART1_WriteS(x)
#define DBG_PRINT_I2C(x) UART1_WriteS(x)
#define DBG_PRINT_SPI(x) UART1_WriteS(x)
#define DBG_PRINT_XBEE(x) UART1_WriteS(x)
#define DBG_PRINT_PORTB_INT(x)
#define DBG_PRINT_INT(x) 
#define DBG_PRINT_BUFFER(x)
#else
#define DBG_PRINT_MAIN(x)
#define DBG_PRINT_UART(x)
#define DBG_PRINT_I2C(x)
#define DBG_PRINT_SPI(x)
#define DBG_PRINT_XBEE(x)
#define DBG_PRINT_PORTB_INT(x)
#define DBG_PRINT_INT(x)
#define DBG_PRINT_BUFFER(x)
#endif

// Pin allocations
#define ADC_AN0_TRIS            TRISAbits.TRISA0
#define ADC_AN1_TRIS            TRISAbits.TRISA1
#define ADC_AN2_TRIS            TRISAbits.TRISA2

#define XBEE_CTS_TRIS           TRISBbits.TRISB0
#define XBEE_CTS_LAT            LATBbits.LATB0
#define XBEE_CTS_PORT           PORTBbits.RB0
#define XBEE_RTS_TRIS           TRISBbits.TRISB1
#define XBEE_RTS_LAT            LATBbits.LATB1

#define SPI_MOSI_TRIS           TRISBbits.TRISB2
#define SPI_MISO_TRIS           TRISBbits.TRISB3
#define SPI_CLK_TRIS            TRISBbits.TRISB4
#define SPI_DC_SELECT_TRIS      TRISBbits.TRISB5
#define SPI_DC_SELECT_LAT       LATBbits.LATB5
#define SPI_RESET_TRIS          TRISBbits.TRISB6
#define SPI_RESET_LAT           LATBbits.LATB6
#define SPI_SLAVE_SELECT_TRIS   TRISBbits.TRISB7
#define SPI_SLAVE_SELECT_LAT    LATBbits.LATB7

#define NFC_IRQ_TRIS            TRISCbits.TRISC1
#define NFC_IRQ_PORT            PORTCbits.RC1
#define NFC_RESET_TRIS          TRISCbits.TRISC2
#define NFC_RESET_LAT           LATCbits.LATC2

#define I2C_CLK_TRIS            TRISCbits.TRISC3
#define I2C_DAT_TRIS            TRISCbits.TRISC4

#define UART1_RX_TRIS           TRISCbits.TRISC7
#define UART1_TX_TRIS           TRISCbits.TRISC6

// PPS bindings
#define PPS_SPI2_CLK_IN         7
#define PPS_SPI2_CLK_OUT        RPOR7
#define PPS_SPI2_MISO           6
#define PPS_SPI2_MOSI           RPOR5

#endif