2010-01-25 23:12:09 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* DMA driver ISRs
|
|
|
|
* \author
|
|
|
|
* Original: Martti Huttunen <martti@sensinode.com>
|
|
|
|
* Port: Zach Shelby <zach@sensinode.com>
|
|
|
|
*
|
|
|
|
* DMA interrupt routines, must be stored in HOME bank
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
|
|
|
|
#include "dev/dma.h"
|
|
|
|
#include "cc2430_sfr.h"
|
|
|
|
|
2012-03-05 16:28:06 +00:00
|
|
|
#if DMA_ON
|
2012-12-16 12:44:44 +00:00
|
|
|
extern struct process *dma_callback[DMA_CHANNEL_COUNT];
|
2012-03-05 16:28:06 +00:00
|
|
|
#endif
|
2010-01-25 23:12:09 +00:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
#ifdef HAVE_RF_DMA
|
|
|
|
extern void rf_dma_callback_isr(void);
|
|
|
|
#endif
|
|
|
|
#ifdef SPI_DMA_RX
|
|
|
|
extern void spi_rx_dma_callback(void);
|
|
|
|
#endif
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
|
|
* DMA interrupt service routine.
|
|
|
|
*
|
|
|
|
* if callback defined a poll is made to that process
|
|
|
|
*/
|
2012-09-07 13:48:15 +00:00
|
|
|
#pragma save
|
|
|
|
#if CC_CONF_OPTIMIZE_STACK_SIZE
|
|
|
|
#pragma exclude bits
|
|
|
|
#endif
|
2010-01-25 23:12:09 +00:00
|
|
|
void
|
2012-12-16 12:44:44 +00:00
|
|
|
dma_ISR(void) __interrupt(DMA_VECTOR)
|
2010-01-25 23:12:09 +00:00
|
|
|
{
|
2012-03-05 16:28:06 +00:00
|
|
|
#if DMA_ON
|
2010-01-25 23:12:09 +00:00
|
|
|
uint8_t i;
|
|
|
|
#endif
|
2012-12-16 12:44:44 +00:00
|
|
|
EA = 0;
|
2012-03-05 16:28:06 +00:00
|
|
|
IRCON_DMAIF = 0;
|
2010-01-25 23:12:09 +00:00
|
|
|
#ifdef HAVE_RF_DMA
|
|
|
|
if((DMAIRQ & 1) != 0) {
|
|
|
|
DMAIRQ &= ~1;
|
2012-12-16 12:44:44 +00:00
|
|
|
DMAARM = 0x81;
|
2010-01-25 23:12:09 +00:00
|
|
|
rf_dma_callback_isr();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef SPI_DMA_RX
|
|
|
|
if((DMAIRQ & 0x08) != 0) {
|
|
|
|
DMAIRQ &= ~(1 << 3);
|
|
|
|
spi_rx_dma_callback();
|
|
|
|
}
|
|
|
|
#endif
|
2012-03-05 16:28:06 +00:00
|
|
|
#if DMA_ON
|
|
|
|
for(i = 0; i < DMA_CHANNEL_COUNT; i++) {
|
|
|
|
if((DMAIRQ & (1 << i)) != 0) {
|
|
|
|
DMAIRQ &= ~(1 << i);
|
2010-01-25 23:12:09 +00:00
|
|
|
if(dma_callback[i] != 0) {
|
2012-03-05 16:28:06 +00:00
|
|
|
process_poll(dma_callback[i]);
|
2010-01-25 23:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
EA = 1;
|
|
|
|
}
|
2012-09-07 13:48:15 +00:00
|
|
|
#pragma restore
|
2010-01-25 23:12:09 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|