Rev 277 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#include "defines.h"#include "IO.h"#include "MCP23009.h"void IO_Init(void) {// Set all pins to digital I/OANSELA = 0x0;ANSELB = 0x0;ANSELC = 0x0;// Enable weak pull-up if WPU bit is setOPTION_REGbits.nWPUEN = 0;// Initialize interrupt inputsLSM303_INT_TRIS = 1;L3GD20_INT_TRIS = 1;BTN_INT_TRIS = 1;// Initialize UART pinsUART_RX_TRIS = 1;UART_TX_TRIS = 0;// Initialize I2C address pinsI2C_ADDR_0_TRIS = 1;I2C_ADDR_1_TRIS = 1;I2C_ADDR_2_TRIS = 1;I2C_ADDR_3_TRIS = 1;// Enable the weak-pullup on the address pinsI2C_ADDR_0_WPU = 1;I2C_ADDR_1_WPU = 1;I2C_ADDR_2_WPU = 1;I2C_ADDR_3_WPU = 1;// Initialize I2C pins (dont really need to as the I2C code does it)I2C_1_CLK_TRIS = 1;I2C_1_DAT_TRIS = 1;I2C_2_CLK_TRIS = 1;I2C_2_DAT_TRIS = 1;// Set the CPS pinsCPS_L_TRIS = 1;CPS_R_TRIS = 1;CPS_L_ANSL = 1;CPS_R_ANSL = 1;CPS_R_WPU = 0;CPS_L_WPU = 0;}void IO_IOC_Enable(void) {// Clear all IOC flagsIOCAF = 0x0;IOCBF = 0x0;// Trigger interrupt on BTN_INT on falling edgeIOCANbits.IOCAN2 = 1;// Enable IOC interruptsINTCONbits.IOCIE = 1;}void IO_Interrupt(void) {Reset_Board(OP_STATE_ACTIVE);}