SPI从机程序
0赞
发表于 1/11/2012 5:56:29 PM
阅读(3808)
#includevoid IRQ_Handler(void) __irq; // IRQ Funtion Prototype char i; char received_data[30]; int main(void) { GP4DAT = 0x04000000; // P4.2 configured as an output. LED is turned on IRQEN = SPI_SLAVE_BIT; GP1CON = 0x22220000; // configure SPI on SPM SPICON = 0x1409; // enable SPI slave mode while (1) { } } /********************************************************************/ /* */ /* Interrupt Service Rountine */ /* */ /********************************************************************/ void IRQ_Handler() __irq { GP4DAT ^= 0x00040000; // Complement P4.2 if ((IRQSTA & SPI_SLAVE_BIT) != 0) { received_data[i] = SPIRX; i++; SPITX = i; if (i==30) i=0; } return ; }
