short READ_LED_STATE(short lednumber) { short ret_val; ret_val = -1; switch(lednumber) { case 0: {} case 1: {} case 2: { ret_val = mPORTDReadBits(1 << lednumber); break; } case 3: {} case 4: { ret_val = mPORTBReadBits(1 << (lednumber-3)); } default: { break; } } return ret_val; }
void sampleButtons() { //BTN1 samples[0] <<= 1; if(mPORTGReadBits(BIT_6)) samples[0] |= 0x01; //BTN2 samples[1] <<= 1; if(mPORTGReadBits(BIT_7)) samples[1] |= 0x01; //BTN3 samples[2] <<= 1; if(mPORTDReadBits(BIT_13)) samples[2] |= 0x01; //BTN_ROTARY bit 4 samples[3] <<= 1; if(mPORTFReadBits(BIT_4)) samples[3] |= 0x01; }
void setupCNModuleAnd_IR_PIR_Input() { //T2 used to sample IR Input signals setupTimer2(); //IR INPUT mPORTDSetPinsDigitalIn(BIT_7); //D5 IR Input (CN16 module, RD7) //PIR input mPORTBSetPinsDigitalIn(BIT_2); //A1 PIR Input (CN4 module, RB2) // setup the change notice options //(ensure that CN continues working in sleep mode) mCNOpen(CN_OFF | CN_IDLE_CON, CN16_ENABLE | CN4_ENABLE, CN16_PULLUP_ENABLE | CN4_PULLUP_ENABLE); // read port(s) to clear mismatch mPORTDReadBits(BIT_7); mPORTBReadBits(BIT_2); mPORTBReadBits(BIT_4); // configure interrupts and clear change notice interrupt flag ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_3); mCNClearIntFlag(); // Clear interrupt flag }