Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SPI Interrupt
- #pragma vector = 0x0C
- __interrupt void SPI_Interrupt()
- {
- if(SPI_SR_RXNE)
- {
- //Recieve buffer not empty
- return;
- }
- if(SPI_SR_TXE)
- {
- //Transmit Buffer Empty
- return;
- }
- if(SPI_SR_WKUP)
- {
- //Wakeup from halt by SPI SCK
- //Flag must be cleared by software
- SPI_SR_WKUP = 0;
- return;
- }
- if(SPI_SR_CRCERR)
- {
- //CRC error
- //Flag must be cleared by software
- SPI_SR_CRCERR = 0;
- return;
- }
- if(SPI_SR_MODF)
- {
- //Mode Fault
- //Must be cleared by Software
- //Both steps are required to clear this flag
- //See reference manual section 20.3.9 (page 269)
- (void)SPI_SR; //Read SPI_SR register
- //SPI_CR1 = ?; //Reset SPI_CR1
- //Todo: reset SPI_CR1
- return;
- }
- if(SPI_SR_OVR)
- {
- //Overrun
- //Must be cleared by software
- //Both reads are required to clear the flag
- //See reference manual section 20.3.9 (Page 270)
- (void)SPI_DR;
- (void)SPI_SR;
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment