From 55fec178bc630e3a52f46bcd74bc1bf319a1bc1a Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sun, 5 May 2002 22:13:00 +0000 Subject: Failed attempt to use DMA git-svn-id: svn://svn.rockbox.org/rockbox/trunk@453 a1c6a512-1295-4272-9138-f99709370657 --- firmware/test/i2c/Makefile | 5 +++-- firmware/test/i2c/app.lds | 20 ++++++++++++++++---- firmware/test/i2c/main.c | 45 ++++++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/firmware/test/i2c/Makefile b/firmware/test/i2c/Makefile index dcc0d2be7a..63f0eb6a10 100644 --- a/firmware/test/i2c/Makefile +++ b/firmware/test/i2c/Makefile @@ -9,8 +9,9 @@ INCLUDES=-I../.. -I../../drivers CFLAGS = -g -Wall -m1 -nostdlib -Wstrict-prototypes -fschedule-insns -fno-builtin $(INCLUDES) -DDEBUG AFLAGS += -small -relax -OBJS= crt0.o main.o ../../drivers/i2c.o ../../drivers/mas.o ../../debug.o \ - ../../common/sprintf.o mp3data.o +OBJS= ../../crt0.o main.o ../../drivers/i2c.o ../../drivers/mas.o \ + ../../debug.o ../../kernel.o ../../thread.o ../../common/sprintf.o \ + ../../panic.o mp3data.o %.o: %.S $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< diff --git a/firmware/test/i2c/app.lds b/firmware/test/i2c/app.lds index 4b7e5f4c6f..2aa374f8c1 100644 --- a/firmware/test/i2c/app.lds +++ b/firmware/test/i2c/app.lds @@ -2,22 +2,34 @@ ENTRY(start) OUTPUT_FORMAT(elf32-sh) SECTIONS { - .text 0x09018000 : + .text 0x09010000 : + { + *(.vectors) + . = ALIGN(0x200); + *(.init.text) + } + + .text : { - *(.rodata) *(.text) } .data : { + *(.rodata) *(.data) } + .rodata : + { + *(.rodata) + } + .bss : { *(.bss) - _end = . + 0x8000; - _stack = . + 0x9000; + _end = .; + _stack = . + 0x1000; _edata = .; } } diff --git a/firmware/test/i2c/main.c b/firmware/test/i2c/main.c index 746f1c7355..b5aecec733 100644 --- a/firmware/test/i2c/main.c +++ b/firmware/test/i2c/main.c @@ -82,8 +82,8 @@ void setup_sci0(void) /* Clear FER and PER */ SSR0 &= 0xe7; - /* Set interrupt D priority to 0 */ -// IPRD &= 0x0ff0; + /* Set interrupt ITU2 and SCI0 priority to 0 */ + IPRD &= 0x0ff0; /* set IRQ6 and IRQ7 to edge detect */ // ICR |= 0x03; @@ -98,7 +98,7 @@ void setup_sci0(void) IPRB = 0; /* Enable Tx (only!) */ - SCR0 |= 0x20; + SCR0 |= 0xa0; } int mas_tx_ready(void) @@ -106,12 +106,32 @@ int mas_tx_ready(void) return (SSR0 & SCI_TDRE); } +void init_dma(void) +{ + SAR3 = (unsigned int) mp3data; + DAR3 = 0xFFFFEC3; + CHCR3 = 0x1500; /* Single address destination, TXI0 */ + DTCR3 = 64000; + DMAOR = 0x0001; /* Enable DMA */ +} + +void start_dma(void) +{ + CHCR3 |= 1; +} + +void stop_dma(void) +{ + CHCR3 &= ~1; +} + int main(void) { char buf[40]; char str[32]; int i=0; + int dma_on = 0; /* Clear it all! */ SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); @@ -217,11 +237,15 @@ int main(void) i = 0; + init_dma(); + while(1) { /* Demand pin high? */ if(PBDR & 0x4000) { + start_dma(); +#if 0 /* More data to write? */ if(i < mp3datalen) { @@ -232,18 +256,13 @@ int main(void) TDR0 = fliptable[mp3data[i++]]; SSR0 &= ~SCI_TDRE; } +#endif + } + else + { + stop_dma(); } } while(1); } - -extern const void stack(void); - -const void* vectors[] __attribute__ ((section (".vectors"))) = -{ - main, /* Power-on reset */ - stack, /* Power-on reset (stack pointer) */ - main, /* Manual reset */ - stack /* Manual reset (stack pointer) */ -}; -- cgit v1.2.3