diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp-target.h | 54 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/aic23.c | 112 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/audio.h | 48 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/dma.c | 466 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/dma.h | 46 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/tsc2100.c | 76 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp_image_helloworld.h | 62 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-target.h | 64 |
8 files changed, 464 insertions, 464 deletions
diff --git a/firmware/target/arm/tms320dm320/dsp-target.h b/firmware/target/arm/tms320dm320/dsp-target.h index f2c70826e8..eba611b174 100644 --- a/firmware/target/arm/tms320dm320/dsp-target.h +++ b/firmware/target/arm/tms320dm320/dsp-target.h @@ -1,27 +1,27 @@ -/*
- * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-#ifndef DSP_H
+/* + * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ +#ifndef DSP_H #define DSP_H -
-/* DSP memory is mapped into ARM space via HPIB. */
-#define DSP_(addr) (*(volatile unsigned short *)(0x40000 + ((addr) << 1)))
+ +/* DSP memory is mapped into ARM space via HPIB. */ +#define DSP_(addr) (*(volatile unsigned short *)(0x40000 + ((addr) << 1))) /* A "DSP image" is an array of these, terminated by raw_data_size_half = 0. */ struct dsp_section { @@ -34,9 +34,9 @@ struct dsp_section { /* Must define struct dsp_section before including the image. */ #include "dsp/dsp-image.h" -
+ void dsp_wake(void); -void dsp_load(const struct dsp_section *im);
+void dsp_load(const struct dsp_section *im); void dsp_reset(void); -
-#endif
+ +#endif diff --git a/firmware/target/arm/tms320dm320/dsp/aic23.c b/firmware/target/arm/tms320dm320/dsp/aic23.c index 72b9dfe069..8ffa5d4e70 100644 --- a/firmware/target/arm/tms320dm320/dsp/aic23.c +++ b/firmware/target/arm/tms320dm320/dsp/aic23.c @@ -1,60 +1,60 @@ -/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Maurus Cuelenaere
- *
+/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "audio.h"
-#include "registers.h"
-
-/* based on http://archopen.svn.sourceforge.net/viewvc/archopen/ArchOpen/trunk/libdsp/aic23.c?revision=213&view=markup */
-void audiohw_init(void)
-{
- /* port config */
-#if 0
- SPCR10 = 0; /* DLB = 0 ** RJUST = 0 ** CLKSTP = 0 ** DXENA = 0 ** ABIS = 0 ** RINTM = 0 ** RSYNCER = 0 ** RFULL = 0 ** RRDY = 0 ** RRST = 0 */
- SPCR20 = (1 << 9); /* FREE = 1 ** SOFT = 0 ** FRST = 0 ** GRST = 0 ** XINTM = 0 ** XSYNCER = 0 ** XEMPTY = 0 ** XRDY = 0 ** XRST = 0 */
- RCR10 = (1 << 8) | (2 << 5); /* RFRLEN1 = 1 ** RWDLEN1 = 2 */
- RCR20 = 0; /* RPHASE = 0 ** RFRLEN2 = 0 ** RWDLEN2 = 0 ** RCOMPAND = 0 ** RFIG = 0 ** RDATDLY = 0 */
- XCR10 = (1 << 8) | (2 << 5); /* XFRLEN1 = 1 ** XWDLEN1 = 2 */
- XCR20 = 0; /* XPHASE = 0 ** XFRLEN2 = 0 ** XWDLEN2 = 0 ** XCOMPAND = 0 ** XFIG = 0 ** XDATDLY = 0 */
- SRGR10 = 0; /* FWID = 0 ** CLKGDV = 0 */
- SRGR20 = 0; /* FREE = 0 ** CLKSP = 0 ** CLKSM = 0 ** FSGM = 0 ** FPER = 0 */
- PCR0 = (1 << 1) | 1; /* IDLEEN = 0 ** XIOEN = 0 ** RIOEN = 0 ** FSXM = 0 ** FSRM = 0 ** SCLKME = 0 ** CLKSSTAT = 0 ** DXSTAT = 0 ** DRSTAT = 0 ** CLKXM = 0 ** CLKRM = 0 ** FSXP = 0 ** FSRP = 0 ** CLKXP = 1 ** CLKRP = 1 */
-#else
- SPCR10 = 0;
- SPCR20 = 0x0200; /* SPCR : free running mode */
-
- RCR10 = 0x00A0;
- RCR20 = 0x00A1; /* RCR : 32 bit receive data length */
-
- XCR10 = 0x00A0;
- XCR20 = 0x00A0; /* XCR : 32 bit transmit data length */
-
- SRGR10 = 0;
- SRGR20 = 0x3000; /* SRGR 1 & 2 */
-
- PCR0 = 0x000E - 8; /* PCR : FSX, FSR active low, external FS/CLK source */
-#endif
-}
-
-void audiohw_postinit(void)
-{
- /* Trigger first XEVT0 */
- SPCR20 |= 1;
-}
+ * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "audio.h" +#include "registers.h" + +/* based on http://archopen.svn.sourceforge.net/viewvc/archopen/ArchOpen/trunk/libdsp/aic23.c?revision=213&view=markup */ +void audiohw_init(void) +{ + /* port config */ +#if 0 + SPCR10 = 0; /* DLB = 0 ** RJUST = 0 ** CLKSTP = 0 ** DXENA = 0 ** ABIS = 0 ** RINTM = 0 ** RSYNCER = 0 ** RFULL = 0 ** RRDY = 0 ** RRST = 0 */ + SPCR20 = (1 << 9); /* FREE = 1 ** SOFT = 0 ** FRST = 0 ** GRST = 0 ** XINTM = 0 ** XSYNCER = 0 ** XEMPTY = 0 ** XRDY = 0 ** XRST = 0 */ + RCR10 = (1 << 8) | (2 << 5); /* RFRLEN1 = 1 ** RWDLEN1 = 2 */ + RCR20 = 0; /* RPHASE = 0 ** RFRLEN2 = 0 ** RWDLEN2 = 0 ** RCOMPAND = 0 ** RFIG = 0 ** RDATDLY = 0 */ + XCR10 = (1 << 8) | (2 << 5); /* XFRLEN1 = 1 ** XWDLEN1 = 2 */ + XCR20 = 0; /* XPHASE = 0 ** XFRLEN2 = 0 ** XWDLEN2 = 0 ** XCOMPAND = 0 ** XFIG = 0 ** XDATDLY = 0 */ + SRGR10 = 0; /* FWID = 0 ** CLKGDV = 0 */ + SRGR20 = 0; /* FREE = 0 ** CLKSP = 0 ** CLKSM = 0 ** FSGM = 0 ** FPER = 0 */ + PCR0 = (1 << 1) | 1; /* IDLEEN = 0 ** XIOEN = 0 ** RIOEN = 0 ** FSXM = 0 ** FSRM = 0 ** SCLKME = 0 ** CLKSSTAT = 0 ** DXSTAT = 0 ** DRSTAT = 0 ** CLKXM = 0 ** CLKRM = 0 ** FSXP = 0 ** FSRP = 0 ** CLKXP = 1 ** CLKRP = 1 */ +#else + SPCR10 = 0; + SPCR20 = 0x0200; /* SPCR : free running mode */ + + RCR10 = 0x00A0; + RCR20 = 0x00A1; /* RCR : 32 bit receive data length */ + + XCR10 = 0x00A0; + XCR20 = 0x00A0; /* XCR : 32 bit transmit data length */ + + SRGR10 = 0; + SRGR20 = 0x3000; /* SRGR 1 & 2 */ + + PCR0 = 0x000E - 8; /* PCR : FSX, FSR active low, external FS/CLK source */ +#endif +} + +void audiohw_postinit(void) +{ + /* Trigger first XEVT0 */ + SPCR20 |= 1; +} diff --git a/firmware/target/arm/tms320dm320/dsp/audio.h b/firmware/target/arm/tms320dm320/dsp/audio.h index 7de2682d5d..93bc0e9c3c 100644 --- a/firmware/target/arm/tms320dm320/dsp/audio.h +++ b/firmware/target/arm/tms320dm320/dsp/audio.h @@ -1,28 +1,28 @@ -/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Maurus Cuelenaere
- *
+/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef AUDIO_H
-#define AUDIO_H
-
-void audiohw_init(void);
-void audiohw_postinit(void);
-
-#endif
+ * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef AUDIO_H +#define AUDIO_H + +void audiohw_init(void); +void audiohw_postinit(void); + +#endif diff --git a/firmware/target/arm/tms320dm320/dsp/dma.c b/firmware/target/arm/tms320dm320/dsp/dma.c index 3048d294b1..6e5cb71c2b 100644 --- a/firmware/target/arm/tms320dm320/dsp/dma.c +++ b/firmware/target/arm/tms320dm320/dsp/dma.c @@ -1,233 +1,233 @@ -/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Catalin Patulea
- * Copyright (C) 2008 by Maurus Cuelenaere
- * Copyright (C) 2009 by Karl Kurbjun
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "registers.h"
-#include "arm.h"
-#include "ipc.h"
-
-/* Size of data buffer in words (16 bit) */
-#define DSP_BUFFER_SIZE (0x1000)
-
-/* Put the "data" buffer in it's own .dma section so that it can
- * be handled in the linker.cmd. */
-#pragma DATA_SECTION (data, ".dma")
-
-/* This is the "data" buffer on the DSP side used for SARAM to McBSP (IIS) */
-static signed short data[DSP_BUFFER_SIZE];
-
-/* These two describe the location of the buffer on the ARM (set in DSPHINT) */
-volatile unsigned short sdem_addrh;
-volatile unsigned short sdem_addrl;
-
-/* This is the size of the ARM buffer (set in DSPHINT) */
-volatile unsigned short sdem_dsp_size;
-
-/* These two variables keep track of the buffer level in the DSP, dsp_level,
- * (SARAM to McBSP) and the level on the ARM buffer (sdem_level).
- * sdem_level is used in the main firmware to keep track of the current
- * playback status. dsp_level is only used in this function. */
-static unsigned short dsp_level;
-volatile unsigned short sdem_level;
-
-/* This is used to keep track of the last SDRAM to SARAM transfer */
-static unsigned short last_size;
-
-/* This tells us which half of the DSP buffer (data) is free */
-static unsigned short dma0_unlocked;
-
-/* This is used by the ARM to flag playback status and start/stop the DMA
- * transfers. */
-volatile unsigned short dma0_stopped;
-
-/* This is used to effectively flag whether the ARM has new data ready or not */
-short waiting;
-
-
-/* rebuffer sets up the next SDRAM to SARAM transfer and tells the ARM when DMA
- * needs a new buffer.
- *
- * Note: The upper limit on larger buffers is the size of a short. If larger
- * buffer sizes are needed the code on the ARM side needs to be changed to
- * update a full long.
- */
-void rebuffer(void)
-{
- unsigned long sdem_addr;
-
- if(dma0_stopped==1 || dma0_stopped==2) /* Stop / Pause */
- {
- /* Stop MCBSP DMA0 */
- DMPREC &= 0xFFFE;
- /* Shut the transmitter down */
- audiohw_stop();
-
- /* Stop the HPIB transfer if it is running */
- DMA_TRG = 0;
-
- /* Reset the following variables for DMA restart */
- sdem_level = 0;
- dsp_level = 0;
- last_size = 0;
-
- return;
- }
-
- /* If the sdem_level is equal to the buffer size the ARM code gave
- * (sdem_dsp_size) then reset the size and ask the arm for another buffer
- */
- if(sdem_level == sdem_dsp_size)
- {
- sdem_level=0;
-
- /* Get a new buffer (location and size) from ARM */
- status.msg = MSG_REFILL;
- waiting=1;
-
- /* trigger DSPHINT on the ARM */
- int_arm();
- }
-
- if(!waiting)
- {
- /* Size is in bytes (but forced 32 bit transfers). Comparison is
- * against DSP_BUFFER_SIZE because it is in words and this needs to
- * compare against half the total size in bytes. */
- if( dsp_level + sdem_dsp_size - sdem_level > DSP_BUFFER_SIZE)
- {
- last_size = DSP_BUFFER_SIZE - dsp_level;
- }
- else
- {
- last_size = sdem_dsp_size - sdem_level;
- }
-
- /* DSP addresses are 16 bit (word). dsp_level is in bytes so it needs to
- * be converted to words. */
- DSP_ADDRL = (unsigned short)data + dma0_unlocked + (dsp_level >> 1);
- DSP_ADDRH = 0;
-
- /* SDRAM addresses are 8 bit (byte)
- * Warning: These addresses are forced to 32 bit alignment!
- */
- sdem_addr = ((unsigned long)sdem_addrh << 16 | sdem_addrl) + sdem_level;
- SDEM_ADDRL = sdem_addr & 0xffff;
- SDEM_ADDRH = sdem_addr >> 16;
-
- /* Set the size of the SDRAM to SARAM transfer (demac transfer) */
- DMA_SIZE = last_size;
-
- DMA_CTRL = 0;
-
- /* These are just debug signals that are not used/needed right now */
- status.payload.refill._DMA_TRG = DMA_TRG;
- status.payload.refill._SDEM_ADDRH = SDEM_ADDRH;
- status.payload.refill._SDEM_ADDRL = SDEM_ADDRL;
- status.payload.refill._DSP_ADDRH = DSP_ADDRH;
- status.payload.refill._DSP_ADDRL = DSP_ADDRL;
-
- /* Start the demac transfer */
- DMA_TRG = 1;
- }
-}
-
-/* This interupt handler is for the SARAM (on DSP) to McBSP IIS DMA transfer.
- * It interupts at 1/2 empty and empty so that we can start filling a new buffer
- * from SDRAM when a half is free. dsp_level should always be full when this
- * interupt occurs except for the initial start. */
-interrupt void handle_dma0(void)
-{
- /* Byte offset to half-buffer locked by DMA0.
- 0 for top, DSP_BUFFER_SIZE/2 for bottom */
- unsigned short dma0_locked;
-
- IFR = 1 << 6;
-
- /* DMSRC0 is the beginning of the DMA0-locked SARAM half-buffer. */
- DMSA = 0x00 /* DMSRC0 (banked register, see page 133 of SPRU302B */;
-
- /* Note that these address offsets (dma0_locked and dma0_unlocked are in
- * words. */
- dma0_locked = DMSDN & (DSP_BUFFER_SIZE>>1);
- dma0_unlocked = dma0_locked ^ (DSP_BUFFER_SIZE>>1);
-
- dsp_level = 0;
-
- /* Start the SDRAM to SARAM copy */
- rebuffer();
-}
-
-/* This interupt handler runs every time a DMA transfer is complete from SDRAM
- * to the SARAM buffer. It is used to update the SARAM buffer level
- * (dsp_level), the SDRAM buffer level (sdem_level) and to rebuffer if the dsp
- * buffer is not full. */
-interrupt void handle_dmac(void) {
- IFR = 1 << 11; /* Clear interrupt */
-
- /* dsp_level and sdem_level are in bytes */
- dsp_level += last_size;
- sdem_level += last_size;
-
- /* compare to DSP_BUFFER_SIZE without a divide because it is in words and
- * we want half the total size in bytes. */
- if(dsp_level < DSP_BUFFER_SIZE)
- {
- rebuffer();
- }
-}
-
-void dma_init(void) {
- /* Initialize some of the global variables to known values avoiding the
- * .cinit section. */
- dsp_level = 0;
- sdem_level = 0;
-
- last_size = 0;
- dma0_unlocked = 0;
- dma0_stopped = 1;
-
- waiting = 0;
-
- /* Configure SARAM to McBSP DMA */
-
- /* Event XEVT0, 32-bit transfers, 0 frame count */
- DMSFC0 = 2 << 12 | 1 << 11;
-
- /* Interrupts generated, Half and full buffer.
- * ABU mode, From data space with postincrement, to data space with no
- * change
- */
- DMMCR0 = 1 << 14 | 1 << 13 |
- 1 << 12 | 1 << 8 | 1 << 6 | 1;
-
- /* Set the source (incrementing) location */
- DMSRC0 = (unsigned short)&data;
-
- /* Set the destination (static) location to the McBSP IIS interface */
- DMDST0 = (unsigned short)&DXR20;
-
- /* Set the size of the buffer */
- DMCTR0 = sizeof(data);
-
- /* Setup DMA0 interrupts and start the transfer */
- DMPREC = 2 << 6;
-}
+/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Catalin Patulea + * Copyright (C) 2008 by Maurus Cuelenaere + * Copyright (C) 2009 by Karl Kurbjun + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "registers.h" +#include "arm.h" +#include "ipc.h" + +/* Size of data buffer in words (16 bit) */ +#define DSP_BUFFER_SIZE (0x1000) + +/* Put the "data" buffer in it's own .dma section so that it can + * be handled in the linker.cmd. */ +#pragma DATA_SECTION (data, ".dma") + +/* This is the "data" buffer on the DSP side used for SARAM to McBSP (IIS) */ +static signed short data[DSP_BUFFER_SIZE]; + +/* These two describe the location of the buffer on the ARM (set in DSPHINT) */ +volatile unsigned short sdem_addrh; +volatile unsigned short sdem_addrl; + +/* This is the size of the ARM buffer (set in DSPHINT) */ +volatile unsigned short sdem_dsp_size; + +/* These two variables keep track of the buffer level in the DSP, dsp_level, + * (SARAM to McBSP) and the level on the ARM buffer (sdem_level). + * sdem_level is used in the main firmware to keep track of the current + * playback status. dsp_level is only used in this function. */ +static unsigned short dsp_level; +volatile unsigned short sdem_level; + +/* This is used to keep track of the last SDRAM to SARAM transfer */ +static unsigned short last_size; + +/* This tells us which half of the DSP buffer (data) is free */ +static unsigned short dma0_unlocked; + +/* This is used by the ARM to flag playback status and start/stop the DMA + * transfers. */ +volatile unsigned short dma0_stopped; + +/* This is used to effectively flag whether the ARM has new data ready or not */ +short waiting; + + +/* rebuffer sets up the next SDRAM to SARAM transfer and tells the ARM when DMA + * needs a new buffer. + * + * Note: The upper limit on larger buffers is the size of a short. If larger + * buffer sizes are needed the code on the ARM side needs to be changed to + * update a full long. + */ +void rebuffer(void) +{ + unsigned long sdem_addr; + + if(dma0_stopped==1 || dma0_stopped==2) /* Stop / Pause */ + { + /* Stop MCBSP DMA0 */ + DMPREC &= 0xFFFE; + /* Shut the transmitter down */ + audiohw_stop(); + + /* Stop the HPIB transfer if it is running */ + DMA_TRG = 0; + + /* Reset the following variables for DMA restart */ + sdem_level = 0; + dsp_level = 0; + last_size = 0; + + return; + } + + /* If the sdem_level is equal to the buffer size the ARM code gave + * (sdem_dsp_size) then reset the size and ask the arm for another buffer + */ + if(sdem_level == sdem_dsp_size) + { + sdem_level=0; + + /* Get a new buffer (location and size) from ARM */ + status.msg = MSG_REFILL; + waiting=1; + + /* trigger DSPHINT on the ARM */ + int_arm(); + } + + if(!waiting) + { + /* Size is in bytes (but forced 32 bit transfers). Comparison is + * against DSP_BUFFER_SIZE because it is in words and this needs to + * compare against half the total size in bytes. */ + if( dsp_level + sdem_dsp_size - sdem_level > DSP_BUFFER_SIZE) + { + last_size = DSP_BUFFER_SIZE - dsp_level; + } + else + { + last_size = sdem_dsp_size - sdem_level; + } + + /* DSP addresses are 16 bit (word). dsp_level is in bytes so it needs to + * be converted to words. */ + DSP_ADDRL = (unsigned short)data + dma0_unlocked + (dsp_level >> 1); + DSP_ADDRH = 0; + + /* SDRAM addresses are 8 bit (byte) + * Warning: These addresses are forced to 32 bit alignment! + */ + sdem_addr = ((unsigned long)sdem_addrh << 16 | sdem_addrl) + sdem_level; + SDEM_ADDRL = sdem_addr & 0xffff; + SDEM_ADDRH = sdem_addr >> 16; + + /* Set the size of the SDRAM to SARAM transfer (demac transfer) */ + DMA_SIZE = last_size; + + DMA_CTRL = 0; + + /* These are just debug signals that are not used/needed right now */ + status.payload.refill._DMA_TRG = DMA_TRG; + status.payload.refill._SDEM_ADDRH = SDEM_ADDRH; + status.payload.refill._SDEM_ADDRL = SDEM_ADDRL; + status.payload.refill._DSP_ADDRH = DSP_ADDRH; + status.payload.refill._DSP_ADDRL = DSP_ADDRL; + + /* Start the demac transfer */ + DMA_TRG = 1; + } +} + +/* This interupt handler is for the SARAM (on DSP) to McBSP IIS DMA transfer. + * It interupts at 1/2 empty and empty so that we can start filling a new buffer + * from SDRAM when a half is free. dsp_level should always be full when this + * interupt occurs except for the initial start. */ +interrupt void handle_dma0(void) +{ + /* Byte offset to half-buffer locked by DMA0. + 0 for top, DSP_BUFFER_SIZE/2 for bottom */ + unsigned short dma0_locked; + + IFR = 1 << 6; + + /* DMSRC0 is the beginning of the DMA0-locked SARAM half-buffer. */ + DMSA = 0x00 /* DMSRC0 (banked register, see page 133 of SPRU302B */; + + /* Note that these address offsets (dma0_locked and dma0_unlocked are in + * words. */ + dma0_locked = DMSDN & (DSP_BUFFER_SIZE>>1); + dma0_unlocked = dma0_locked ^ (DSP_BUFFER_SIZE>>1); + + dsp_level = 0; + + /* Start the SDRAM to SARAM copy */ + rebuffer(); +} + +/* This interupt handler runs every time a DMA transfer is complete from SDRAM + * to the SARAM buffer. It is used to update the SARAM buffer level + * (dsp_level), the SDRAM buffer level (sdem_level) and to rebuffer if the dsp + * buffer is not full. */ +interrupt void handle_dmac(void) { + IFR = 1 << 11; /* Clear interrupt */ + + /* dsp_level and sdem_level are in bytes */ + dsp_level += last_size; + sdem_level += last_size; + + /* compare to DSP_BUFFER_SIZE without a divide because it is in words and + * we want half the total size in bytes. */ + if(dsp_level < DSP_BUFFER_SIZE) + { + rebuffer(); + } +} + +void dma_init(void) { + /* Initialize some of the global variables to known values avoiding the + * .cinit section. */ + dsp_level = 0; + sdem_level = 0; + + last_size = 0; + dma0_unlocked = 0; + dma0_stopped = 1; + + waiting = 0; + + /* Configure SARAM to McBSP DMA */ + + /* Event XEVT0, 32-bit transfers, 0 frame count */ + DMSFC0 = 2 << 12 | 1 << 11; + + /* Interrupts generated, Half and full buffer. + * ABU mode, From data space with postincrement, to data space with no + * change + */ + DMMCR0 = 1 << 14 | 1 << 13 | + 1 << 12 | 1 << 8 | 1 << 6 | 1; + + /* Set the source (incrementing) location */ + DMSRC0 = (unsigned short)&data; + + /* Set the destination (static) location to the McBSP IIS interface */ + DMDST0 = (unsigned short)&DXR20; + + /* Set the size of the buffer */ + DMCTR0 = sizeof(data); + + /* Setup DMA0 interrupts and start the transfer */ + DMPREC = 2 << 6; +} diff --git a/firmware/target/arm/tms320dm320/dsp/dma.h b/firmware/target/arm/tms320dm320/dsp/dma.h index c55fc1507b..97ac44f8d5 100644 --- a/firmware/target/arm/tms320dm320/dsp/dma.h +++ b/firmware/target/arm/tms320dm320/dsp/dma.h @@ -1,32 +1,32 @@ -/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Maurus Cuelenaere
- *
+/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef DMA_H
-#define DMA_H
-
+ * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef DMA_H +#define DMA_H + void dma_init(void); void rebuffer(void); extern int waiting; -extern volatile unsigned short dma0_stopped;
-
-#endif
+extern volatile unsigned short dma0_stopped; + +#endif diff --git a/firmware/target/arm/tms320dm320/dsp/tsc2100.c b/firmware/target/arm/tms320dm320/dsp/tsc2100.c index 3a02eb92b4..51b09a8e94 100644 --- a/firmware/target/arm/tms320dm320/dsp/tsc2100.c +++ b/firmware/target/arm/tms320dm320/dsp/tsc2100.c @@ -1,46 +1,46 @@ -/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Catalin Patulea
- *
+/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Catalin Patulea + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "audio.h"
-#include "registers.h"
-
-void audiohw_init(void)
-{
- /* Configure McBSP */
- SPCR10 = 0; /* Receiver reset */
- SPCR20 = 3 << 4; /* Rate gen disabled, RINT=XSYNCERR, TX disabled for now */
- PCR0 = 1 << 1; /* Serial port pins, external frame sync, external clock,
- frame sync FSX is active-high,
- TX data sampled on falling clock */
- XCR10 = 0x00a0; /* 1 word per frame, 32 bits per word */
- XCR20 = 0; /* Single-phase, unexpected frame pulse restarts xfer,
- 0-bit data delay */
-}
-
-void audiohw_start(void)
-{
- /* Trigger first XEVT0 */
- SPCR20 |= 1;
+ * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "audio.h" +#include "registers.h" + +void audiohw_init(void) +{ + /* Configure McBSP */ + SPCR10 = 0; /* Receiver reset */ + SPCR20 = 3 << 4; /* Rate gen disabled, RINT=XSYNCERR, TX disabled for now */ + PCR0 = 1 << 1; /* Serial port pins, external frame sync, external clock, + frame sync FSX is active-high, + TX data sampled on falling clock */ + XCR10 = 0x00a0; /* 1 word per frame, 32 bits per word */ + XCR20 = 0; /* Single-phase, unexpected frame pulse restarts xfer, + 0-bit data delay */ } -
+ +void audiohw_start(void) +{ + /* Trigger first XEVT0 */ + SPCR20 |= 1; +} + void audiohw_stop(void) { /* Reset the transmitter */ diff --git a/firmware/target/arm/tms320dm320/dsp_image_helloworld.h b/firmware/target/arm/tms320dm320/dsp_image_helloworld.h index b98efc85d1..f266d2a38b 100644 --- a/firmware/target/arm/tms320dm320/dsp_image_helloworld.h +++ b/firmware/target/arm/tms320dm320/dsp_image_helloworld.h @@ -1,31 +1,31 @@ -#ifndef DSP_IMAGE_HELLOWORLD
-#define DSP_IMAGE_HELLOWORLD
-/*
- * This is just a dummy DSP image so that dsp-dm320.c compiles.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-static const struct dsp_section dsp_image_helloworld[] = {
- {NULL, 0, 0}
-};
-
-/* Symbol table, usable with the DSP_() macro (see dsp-target.h). */
-#define _status 0x0000
-#define _acked 0x0000
-
-#endif
+#ifndef DSP_IMAGE_HELLOWORLD +#define DSP_IMAGE_HELLOWORLD +/* + * This is just a dummy DSP image so that dsp-dm320.c compiles. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +static const struct dsp_section dsp_image_helloworld[] = { + {NULL, 0, 0} +}; + +/* Symbol table, usable with the DSP_() macro (see dsp-target.h). */ +#define _status 0x0000 +#define _acked 0x0000 + +#endif diff --git a/firmware/target/arm/tms320dm320/uart-target.h b/firmware/target/arm/tms320dm320/uart-target.h index 9be9ba51fe..b065442da6 100644 --- a/firmware/target/arm/tms320dm320/uart-target.h +++ b/firmware/target/arm/tms320dm320/uart-target.h @@ -1,32 +1,32 @@ -/*
- * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-#ifndef UART_H
-#define UART_H
-
-void uart_init(void);
-bool uart1_available(void);
-
-int uart1_gets_queue(char *, int);
-void uart1_puts(const char *str, int size);
-void uart1_gets(char *str, int size);
-void uart1_putc(char ch);
-
-void uart1_clear_queue(void);
-#endif
+/* + * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ +#ifndef UART_H +#define UART_H + +void uart_init(void); +bool uart1_available(void); + +int uart1_gets_queue(char *, int); +void uart1_puts(const char *str, int size); +void uart1_gets(char *str, int size); +void uart1_putc(char ch); + +void uart1_clear_queue(void); +#endif |