SHARE
TWEET

Untitled

a guest Aug 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void pcint_isr_func(volatile u8t * PINx, u8t & changed_bits, u8t offset){
  2.     u8t registerBit = 0;
  3.     bool callable = false;
  4.     for( ; registerBit < sizeof(changed_bits)*8; ++registerBit){
  5.     if(is_bit_on(changed_bits, registerBit)){
  6.         break;
  7.     }
  8.     }
  9.     u8t pcint_no = registerBit+offset;
  10.     switch (pc_int_isr_vect[pcint_no].edge) {
  11.     case ANY_EDGE:
  12.     callable = true;
  13.     break;
  14.     case RISING:
  15.     if (*PINx &  bitValue(registerBit)) {
  16.         callable = true;
  17.     }
  18.     break;
  19.     case LOW_LEVEL:
  20.     case FALLING:
  21.     if (*PINx & (1<<registerBit) == 0 ) {
  22.         callable = true;
  23.     }
  24.     break;
  25.     default:
  26.     return;
  27.  
  28.     }
  29.     if(callable){
  30.     if( nullptr !=  pc_int_isr_vect[pcint_no].user_cb){
  31.         pc_int_isr_vect[pcint_no].user_cb(registerBit+offset);
  32.     }
  33.     else if(nullptr != pc_int_isr_vect[pcint_no].context) {
  34.         SystemEventHandler::call_int_callback(pc_int_isr_vect[pcint_no].context, pcint_no);
  35.     }
  36.     }
  37.  
  38. }
  39.  
  40. volatile u8t port_b_history = PINB; // start whith pulled-up pins ;
  41. ISR(PCINT0_vect){
  42.     u8t changed_bits = PINB ^ port_b_history;
  43.     port_b_history = PINB;
  44.     pcint_isr_func(&port_b_history, changed_bits, 0);
  45.  
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top