官方例程中会出现这样的代码,请问__attribute__ ((interrupt(USCI_A0_VECTOR)))与__even_in_range(UCA0IV,4)的作用是什么?为什么不能直接判断UCA0IV的值而要调用__even_in_range函数???
[C]
纯文本查看 复制代码
#if defined(__
ti_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)#pragma vector=USCI_A0_VECTOR__interrupt void USCI_A0_ISR(void)#elif defined(__GNUC__)void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)#else#error Compiler not supported!#endif{ volatile unsigned int i; switch(__even_in_range(UCA0IV,4)) { case 0: break; // Vector 0 - no interrupt case 2: // Vector 2 - RXIFG while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? if (UCA0RXBUF==SLV_Data) // Test for correct character RX'd P1OUT |= 0x01; // If correct, light LED else P1OUT &= ~0x01; // If incorrect, clear LED MST_Data++; // Increment data SLV_Data++; UCA0TXBUF = MST_Data; // Send next value for(i = 20; i>0; i--); // Add time between transmissions to // make sure slave can process information break; case 4: break; // Vector 4 - TXIFG default: break; }}
一周热门 更多>