Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 150 → Rev 151

/PIC Stuff/PIC_27J13/defines.h
10,7 → 10,7
// Option to disable SPI MISO
#define SPI2_WRITE_ONLY
 
#define _DEBUG
//#define _DEBUG
 
//#define _TEST_UART
//#define _TEST_I2C_MASTER
28,7 → 28,6
//#define _TEST_OLED_CHAR
//#define _TEST_BMP
 
 
// Enable or disable debug prints depending on project preprocessor (_DEBUG)
#ifdef _DEBUG
#define DBG_PRINT_MAIN(x) UART1_WriteS(x)
43,6 → 42,7
#define DBG_PRINT_BMP(x)
#else
#define DBG_PRINT_MAIN(x)
#define DBG_PRINT_MAIN_F(x)
#define DBG_PRINT_UART(x)
#define DBG_PRINT_I2C(x)
#define DBG_PRINT_SPI(x)
121,4 → 121,3
//#define PPS_UART2_TX RPOR6
 
#endif
 
/PIC Stuff/PIC_27J13/interrupts.c
14,7 → 14,7
// priority interrupts, but this code is not setup for that and this nesting
// is not enabled.
 
void interrupt_init() {
void Interrupt_Init() {
// Peripheral interrupts can have their priority set to high or low
// Decide on the priority of the enabled peripheral interrupts (0 is low, 1 is high)
 
39,7 → 39,7
// INTCON3bits.INT1IE = 1;
}
 
void interrupt_enable() {
void Interrupt_Enable() {
// Peripheral interrupts can have their priority set to high or low.
// Enable both high-priority interrupts and low-priority interrupts
RCONbits.IPEN = 1;
47,31 → 47,11
INTCONbits.GIEL = 1;
}
 
//int interrupt_in_high_interrupt_routine() {
// return (!INTCONbits.GIEH);
//}
//
//int interrupt_low_int_active() {
// return (!INTCONbits.GIEL);
//}
//
//int interrupt_in_low_interrupt_routine() {
// if (INTCONbits.GIEL == 1) {
// return (0);
// } else if (interrupt_in_high_interrupt_routine()) {
// return (0);
// } else {
// return (1);
// }
//}
//
//int interrupt_in_main_routine() {
// if ((!interrupt_in_low_interrupt_routine()) && (!interrupt_in_high_interrupt_routine())) {
// return (1);
// } else {
// return (0);
// }
//}
void Interrupt_Disable() {
RCONbits.IPEN = 0;
INTCONbits.GIEH = 0;
INTCONbits.GIEL = 0;
}
 
// Set up the interrupt vectors
void InterruptHandlerHigh();
/PIC Stuff/PIC_27J13/interrupts.h
9,21 → 9,11
// enabling interrupts if sleep_high_interrupt_if_okay() is called!
 
// Initialize the interrupts
void interrupt_init(void);
void Interrupt_Init(void);
 
// enable the interrupts (high and low priority)
void interrupt_enable(void);
void Interrupt_Enable(void);
 
// Are we calling from a high-priority interrupt?
int interrupt_in_high_interrupt_routine(void);
void Interrupt_Disable(void);
 
// Is a low-priority interrupt active?
int interrupt_low_int_active(void);
 
// Are we calling from a low-priority interrupt?
int interrupt_in_low_interrupt_routine(void);
 
// Are we calling this from the "main" routine (i.e., not an interrrupt handler?)
int interrupt_in_main_routine(void);
 
#endif
/PIC Stuff/PIC_27J13/main.c
77,8 → 77,8
 
UART1_Init(); // Initialize the UART handler code
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
116,8 → 116,8
 
I2C_Configure_Master(I2C_100KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
183,8 → 183,8
 
I2C_Configure_Slave(0x24);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
232,8 → 232,8
 
I2C_Configure_Master(I2C_400KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
373,8 → 373,8
 
I2C_Configure_Master(I2C_400KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
425,8 → 425,8
UART1_Init(); // Initialize the UART handler code
SPI2_Init(SPI2_FOSC_8); // Initialize the SPI module
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
470,8 → 470,8
SPI2_Init(SPI2_FOSC_4); // Initialize the SPI module
SSD1306_Init(); // Initialize the OLED code
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
586,8 → 586,8
SPI2_Init(SPI2_FOSC_64); // Initialize the SPI module
SSD1331_Init(); // Initialize the OLED code
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
720,8 → 720,8
// I2C_Configure_Master(I2C_400KHZ);
SSD1306_Begin(SSD1306_SWITCHCAPVCC);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
779,8 → 779,8
UART1_Init(); // Initialize the UART handler code
XBee_Init();
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
939,8 → 939,8
 
I2C_Configure_Master(I2C_400KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
1025,8 → 1025,8
Timer1_Init();
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
LED_BLUE_TRIS = 0;
LED_RED_TRIS = 0;
1059,8 → 1059,8
I2C_Configure_Master(I2C_100KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
LUX_Begin();
1108,8 → 1108,8
// UART1_Init();
NHD_Init();
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
NHD_Begin(16, 2);
1142,8 → 1142,8
I2C_Configure_Master(I2C_100KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
BMP_Begin(BMP085_ULTRAHIGHRES);
 
1186,8 → 1186,8
I2C_Configure_Master(I2C_400KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
Interrupt_Enable(); // Enable high-priority interrupts and low-priority interrupts
Interrupt_Init(); // Initialize the interrupt priorities
 
NHD_Begin(16, 2);
1198,14 → 1198,13
// Changing the integration time gives you a longer time over which to sense light
// longer timelines are slower, but are good in very low light situtations!
LUX_SetTiming(TSL2561_INTEGRATIONTIME_13MS); // shortest integration time (bright light)
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light)
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light)
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)
 
while (1) {
lum = LUX_GetFullLuminosity();
ir = lum >> 16;
full = lum & 0xFFFF;
// NHD_Clear();
NHD_Set_Cursor(0, 0);
NHD_Write_String("I: %d ", ir);
NHD_Write_String("V: %d ", full - ir);
/PIC Stuff/PIC_27J13/nbproject/private/private.xml
1,4 → 1,13
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/main.c</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/temp_BMP085.c</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/interrupts.c</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/defines.h</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/temp_BMP085.h</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/uart.h</file>
<file>file:/C:/Users/Kevin/Documents/Code/PIC_27J13/interrupts.h</file>
</open-files>
</project-private>