Contiki 2.6

dma_intr.c

Go to the documentation of this file.
00001 /**
00002  * \file
00003  *         DMA driver ISRs
00004  * \author
00005  *         Original: Martti Huttunen <martti@sensinode.com>
00006  *         Port: Zach Shelby <zach@sensinode.com>
00007  *
00008  *         DMA interrupt routines, must be stored in HOME bank
00009  */
00010 
00011 #include <stdio.h>
00012 
00013 #include "contiki.h"
00014 
00015 #include "dev/dma.h"
00016 #include "cc2430_sfr.h"
00017 
00018 #if DMA_ON
00019 extern struct process * dma_callback[DMA_CHANNEL_COUNT];
00020 #endif
00021 
00022 /*---------------------------------------------------------------------------*/
00023 #ifdef HAVE_RF_DMA
00024 extern void rf_dma_callback_isr(void);
00025 #endif
00026 #ifdef SPI_DMA_RX
00027 extern void spi_rx_dma_callback(void);
00028 #endif
00029 /*---------------------------------------------------------------------------*/
00030 /**
00031  * DMA interrupt service routine.
00032  *
00033  * if callback defined a poll is made to that process
00034  */
00035 void
00036 dma_ISR(void) __interrupt (DMA_VECTOR)
00037 {
00038 #if DMA_ON
00039   uint8_t i;
00040 #endif
00041   EA=0;
00042   IRCON_DMAIF = 0;
00043 #ifdef HAVE_RF_DMA
00044   if((DMAIRQ & 1) != 0) {
00045     DMAIRQ &= ~1;
00046     DMAARM=0x81;
00047     rf_dma_callback_isr();
00048   }
00049 #endif
00050 #ifdef SPI_DMA_RX
00051   if((DMAIRQ & 0x08) != 0) {
00052     DMAIRQ &= ~(1 << 3);
00053     spi_rx_dma_callback();
00054   }
00055 #endif
00056 #if DMA_ON
00057   for(i = 0; i < DMA_CHANNEL_COUNT; i++) {
00058     if((DMAIRQ & (1 << i)) != 0) {
00059       DMAIRQ &= ~(1 << i);
00060       if(dma_callback[i] != 0) {
00061         process_poll(dma_callback[i]);
00062       }
00063     }
00064   }
00065 #endif
00066   EA = 1;
00067 }
00068 /*---------------------------------------------------------------------------*/