aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-06-20 13:24:11 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-06-20 15:22:03 -0400
commit7ebddc4fca0e77904f56471c9f2759c2ff256e5a (patch)
tree8d8bf4a521e3a061254eda0661fc0809313c4c43
parent7b95d3277074468dd1d22c21c4f558d04c2f7247 (diff)
downloadlibrambutan-7ebddc4fca0e77904f56471c9f2759c2ff256e5a.tar.gz
librambutan-7ebddc4fca0e77904f56471c9f2759c2ff256e5a.zip
test-usart-dma.cpp: Update to demo working DMA interrupts.
-rw-r--r--examples/test-usart-dma.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/test-usart-dma.cpp b/examples/test-usart-dma.cpp
index b9c03f1..b09c6e8 100644
--- a/examples/test-usart-dma.cpp
+++ b/examples/test-usart-dma.cpp
@@ -60,18 +60,17 @@ void loop(void) {
USART_RX_DMA_CHANNEL);
if (irq_fired) {
USART_HWSER.println("** IRQ **");
- while (true)
- ;
+ irq_fired = 0;
}
USART_HWSER.print("[");
USART_HWSER.print(millis());
USART_HWSER.print("]\tISR bits: 0x");
uint8 isr_bits = dma_get_isr_bits(USART_DMA_DEV, USART_RX_DMA_CHANNEL);
- USART_HWSER.print((int32)isr_bits, HEX);
+ USART_HWSER.print(isr_bits, HEX);
USART_HWSER.print("\tCCR: 0x");
- USART_HWSER.print((int64)ch_regs->CCR, HEX);
+ USART_HWSER.print(ch_regs->CCR, HEX);
USART_HWSER.print("\tCNDTR: 0x");
- USART_HWSER.print((int64)ch_regs->CNDTR, HEX);
+ USART_HWSER.print(ch_regs->CNDTR, HEX);
USART_HWSER.print("\tBuffer contents: ");
for (int i = 0; i < BUF_SIZE; i++) {
USART_HWSER.print('\'');
@@ -84,8 +83,6 @@ void loop(void) {
USART_HWSER.println("** Clearing ISR bits.");
dma_clear_isr_bits(USART_DMA_DEV, USART_RX_DMA_CHANNEL);
}
-
- irq_fired = 0;
}
/* Configure USART receiver for use with DMA */
@@ -100,15 +97,14 @@ void init_dma_xfer(void) {
dma_setup_transfer(USART_DMA_DEV, USART_RX_DMA_CHANNEL,
&USART->regs->DR, DMA_SIZE_8BITS,
rx_buf, DMA_SIZE_8BITS,
- (DMA_MINC_MODE | DMA_CIRC_MODE | DMA_TRNS_CMPLT
- ));
+ (DMA_MINC_MODE | DMA_CIRC_MODE | DMA_TRNS_CMPLT));
dma_set_num_transfers(USART_DMA_DEV, USART_RX_DMA_CHANNEL, BUF_SIZE);
- // Currently not working:
- // dma_attach_interrupt(USART_DMA_DEV, USART_RX_DMA_CHANNEL, rx_dma_irq);
+ dma_attach_interrupt(USART_DMA_DEV, USART_RX_DMA_CHANNEL, rx_dma_irq);
dma_enable(USART_DMA_DEV, USART_RX_DMA_CHANNEL);
}
void rx_dma_irq(void) {
+ irq_fired = true;
}
// Force init to be called *first*, i.e. before static object allocation.