int main(void) { BYTE stBtn1; BYTE stBtn2; DeviceInit(); AppInit(); while(stBtn1!=stPressed && stBtn2!=stPressed) { mT5IntEnable(fFalse); stBtn1 = btnBtn1.stBtn; stBtn2 = btnBtn2.stBtn; mT5IntEnable(fTrue); } RightReverse; LeftReverse; SetLeftSpeed(dtcMtrMedium); SetRightSpeed(dtcMtrMedium); mCNIntEnable(fTrue); //Sensors will trigger while(fTrue); }
void setup_spi() { // TODO move it out of here INTDisableInterrupts(); mCNOpen(CN_ON | CN_IDLE_CON, CN1_ENABLE, CN1_PULLUP_ENABLE); mPORTCRead(); mCNSetIntPriority(6); // same as below mCNClearIntFlag(); mCNIntEnable(1); INTEnableInterrupts(); }
void enableCNModule(int userIsWatchingTV) { if(userIsWatchingTV) { //do not enable PIR input during TV operation it is useless mCNOpen(CN_ON | CN_IDLE_CON, CN16_ENABLE, CN16_PULLUP_ENABLE | CN4_PULLUP_ENABLE); } else { mCNOpen(CN_ON | CN_IDLE_CON, CN16_ENABLE | CN4_ENABLE, CN16_PULLUP_ENABLE | CN4_PULLUP_ENABLE); } mCNIntEnable(1); }
/*************************************************************************************************** InitKeyboard Initialise the keyboard and sound routines. ****************************************************************************************************/ void initKeyboard(void) { // enable pullups on the clock and data lines. // This stops them from floating and generating random chars when no keyboard is attached CNCONbits.ON = 1; // turn on Change Notification module P_PS2CLK_PULLUP = P_ON; // turn on the pullup for pin D6 also called CN15 P_PS2DAT_PULLUP = P_ON; // turn on the pullup for pin D7 also called CN16 // setup Change Notification interrupt P_PS2CLK_INT = P_ON; // enable PS2CLK (CN15) as a change interrupt mCNSetIntPriority(3); // set interrupt priority to 3 mCNClearIntFlag(); // clear the interrupt flag mCNIntEnable(1); // enable interrupt }