25,8 → 25,6 |
#include "base_INTERRUPTS.h" |
#include "base_I2C.h" |
|
__persistent int temp; |
|
void Pins_Init(void) { |
// Set all pins to digital I/O |
ANSELA = 0x0; |
37,28 → 35,28 |
|
// Set buttons as inputs and enable weak pull-ups |
BTN_L_N_TRIS = 1; |
BTN_L_N_WPU = 1; |
BTN_L_N_WPU = 1; |
BTN_L_S_TRIS = 1; |
BTN_L_S_WPU = 1; |
BTN_L_S_WPU = 1; |
|
BTN_R_N_TRIS = 1; |
BTN_R_N_WPU = 1; |
BTN_R_N_WPU = 1; |
BTN_R_E_TRIS = 1; |
BTN_R_E_WPU = 1; |
BTN_R_E_WPU = 1; |
BTN_R_S_TRIS = 1; |
BTN_R_S_WPU = 1; |
BTN_R_S_WPU = 1; |
BTN_R_W_TRIS = 1; |
BTN_R_W_WPU = 1; |
BTN_R_W_WPU = 1; |
|
// Set leds as outputs and initialize to off |
LED_1_TRIS = 0; |
LED_1_LAT = 0; |
LED_1_LAT = 0; |
LED_2_TRIS = 0; |
LED_2_LAT = 0; |
LED_2_LAT = 0; |
LED_3_TRIS = 0; |
LED_3_LAT = 0; |
LED_3_LAT = 0; |
LED_4_TRIS = 0; |
LED_4_LAT = 0; |
LED_4_LAT = 0; |
} |
|
// Function to read button status into a data structure |
81,8 → 79,8 |
} |
|
int main(void) { |
char buffer[32]; |
char result, length; |
uint8_t buffer[32]; |
uint8_t result, length; |
|
// Set internal oscillator speed to 32MHz |
OSCCONbits.SPLLEN = 1; // 4x PLL enable (overwritten by config bits) |
101,6 → 99,7 |
Interrupt_Init(); |
Interrupt_Enable(); |
|
// Check for received data over I2C |
while (1) { |
do { |
result = I2C_Get_Status(); |