Make it possible to subscribe to DMA events.

This commit is contained in:
nvt-se 2007-08-16 13:51:57 +00:00
parent 2780aef873
commit 0723f1fbc7
2 changed files with 42 additions and 17 deletions

View file

@ -42,22 +42,26 @@
#include "contiki-msb430.h"
#include "dev/cc1020.h"
#include "dev/dma.h"
static struct process *subscribers[DMA_LINES];
process_event_t dma_event;
interrupt(DACDMA_VECTOR) irq_dacdma(void)
{
static unsigned char line;
if (DMA0CTL & DMAIFG) {
DMA0CTL &= ~(DMAIFG | DMAIE);
line = 0;
process_post(&cc1020_sender_process, cc1020_event, &line);
if (subscribers[0] != NULL) {
process_post(subscribers[0], dma_event, NULL);
}
LPM_AWAKE();
}
if (DMA1CTL & DMAIFG) {
DMA1CTL &= ~(DMAIFG | DMAIE);
line = 1;
process_post(&cc1020_sender_process, cc1020_event, &line);
if (subscribers[1] != NULL) {
process_post(subscribers[1], dma_event, NULL);
}
LPM_AWAKE();
}
@ -70,6 +74,21 @@ interrupt(DACDMA_VECTOR) irq_dacdma(void)
}
}
void
dma_init(void)
{
dma_event = process_alloc_event();
}
int
dma_subscribe(int line, struct process *p)
{
if (line >= DMA_LINES)
return -1;
subscribers[line] = p;
}
void
dma_transfer(unsigned char *buf, unsigned len)
{

View file

@ -28,12 +28,18 @@
*
* This file is part of the Contiki operating system.
*
* $Id: dma.h,v 1.3 2007/07/05 08:35:13 nvt-se Exp $
* $Id: dma.h,v 1.4 2007/08/16 13:51:57 nvt-se Exp $
*/
#ifndef DMA_H
#define DMA_H
#define DMA_LINES 2
void dma_init(void);
int dma_subscribe(int, struct process *);
void dma_transfer(unsigned char *, unsigned);
extern process_event_t dma_event;
#endif