Make it possible to subscribe to DMA events.
This commit is contained in:
parent
2780aef873
commit
0723f1fbc7
2 changed files with 42 additions and 17 deletions
|
@ -42,22 +42,26 @@
|
||||||
|
|
||||||
#include "contiki-msb430.h"
|
#include "contiki-msb430.h"
|
||||||
#include "dev/cc1020.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)
|
interrupt(DACDMA_VECTOR) irq_dacdma(void)
|
||||||
{
|
{
|
||||||
static unsigned char line;
|
|
||||||
|
|
||||||
if (DMA0CTL & DMAIFG) {
|
if (DMA0CTL & DMAIFG) {
|
||||||
DMA0CTL &= ~(DMAIFG | DMAIE);
|
DMA0CTL &= ~(DMAIFG | DMAIE);
|
||||||
line = 0;
|
if (subscribers[0] != NULL) {
|
||||||
process_post(&cc1020_sender_process, cc1020_event, &line);
|
process_post(subscribers[0], dma_event, NULL);
|
||||||
|
}
|
||||||
LPM_AWAKE();
|
LPM_AWAKE();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DMA1CTL & DMAIFG) {
|
if (DMA1CTL & DMAIFG) {
|
||||||
DMA1CTL &= ~(DMAIFG | DMAIE);
|
DMA1CTL &= ~(DMAIFG | DMAIE);
|
||||||
line = 1;
|
if (subscribers[1] != NULL) {
|
||||||
process_post(&cc1020_sender_process, cc1020_event, &line);
|
process_post(subscribers[1], dma_event, NULL);
|
||||||
|
}
|
||||||
LPM_AWAKE();
|
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
|
void
|
||||||
dma_transfer(unsigned char *buf, unsigned len)
|
dma_transfer(unsigned char *buf, unsigned len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,12 +28,18 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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
|
#ifndef DMA_H
|
||||||
#define 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);
|
void dma_transfer(unsigned char *, unsigned);
|
||||||
|
|
||||||
|
extern process_event_t dma_event;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue