diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-11-10 11:46:45 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-11-10 11:46:45 -0600 |
commit | 74b1c008ebb18a8b3b9155a5c902906b95a9c96f (patch) | |
tree | 8812cb4ea8b93f45fee924383a408958a0594bfb | |
parent | b6f65ea46230955a33e42c46dc30c5e428d3dd08 (diff) | |
download | nuttx-74b1c008ebb18a8b3b9155a5c902906b95a9c96f.tar.gz nuttx-74b1c008ebb18a8b3b9155a5c902906b95a9c96f.tar.bz2 nuttx-74b1c008ebb18a8b3b9155a5c902906b95a9c96f.zip |
SAMA5 SSC: Add support for loopback mode. Plus unrelated Make.defs file from the last checkin
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sama5/Kconfig | 22 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_ssc.c | 29 | ||||
-rw-r--r-- | nuttx/libc/audio/Make.defs | 43 |
4 files changed, 96 insertions, 1 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index dd38995af..fca89d458 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6025,3 +6025,6 @@ that must be available to audio applications. If it was left in the audio/ directory then it would not be available to applications in the NuttX Kernel build (2013-11-10). + * arch/arm/src/sama5/sam_ssc.c and Kconfig: Add configurable support + for SSC loopback mode (2013-11-10). + diff --git a/nuttx/arch/arm/src/sama5/Kconfig b/nuttx/arch/arm/src/sama5/Kconfig index 74f211034..9caed8f56 100644 --- a/nuttx/arch/arm/src/sama5/Kconfig +++ b/nuttx/arch/arm/src/sama5/Kconfig @@ -1528,6 +1528,17 @@ config SAMA5_SSC0_MCKDIV_SAMPLERATE divider to obtain that bitrate (up to 4095). If the bitrate can be realized by dividing down the MCK/2, a compile time error will occur. +config SAMA5_SSC0_LOOPBACK + bool "Loopback mode" + default n + depends on SAMA5_SSC0_TX && SAMA5_SSC0_RX + ---help--- + If both the receiver and transmitter are enabled, then the SSC can + be configured in loopback mode. This setting selects SSC loopback + and will cause the LOOP bit to be set in the SSC_RFMR regsiter. In + this case, RD is connected to TD, RF is connected to TF and RK is + connected to TK. + endif # SAMA5_SSC0 if SAMA5_SSC1 @@ -1669,6 +1680,17 @@ config SAMA5_SSC1_MCKDIV_SAMPLERATE divider to obtain that bitrate (up to 4095). If the bitrate can be realized by dividing down the MCK/2, a compile time error will occur. +config SAMA5_SSC1_LOOPBACK + bool "Loopback mode" + default n + depends on SAMA5_SSC1_TX && SAMA5_SSC1_RX + ---help--- + If both the receiver and transmitter are enabled, then the SSC can + be configured in loopback mode. This setting selects SSC loopback + and will cause the LOOP bit to be set in the SSC_RFMR regsiter. In + this case, RD is connected to TD, RF is connected to TF and RK is + connected to TK. + endif # SAMA5_SSC1 config SAMA5_SSC_DMADEBUG diff --git a/nuttx/arch/arm/src/sama5/sam_ssc.c b/nuttx/arch/arm/src/sama5/sam_ssc.c index 7cdd21e80..05c140167 100644 --- a/nuttx/arch/arm/src/sama5/sam_ssc.c +++ b/nuttx/arch/arm/src/sama5/sam_ssc.c @@ -260,6 +260,7 @@ struct sam_ssc_s uint16_t master:1; /* True: Master mode transfers */ uint16_t rx:1; /* True: RX transfers supported */ uint16_t tx:1; /* True: TX transfers supported */ + uint16_t loopback:1; /* True: Loopback mode */ uint16_t sscno:1; /* SSC controller number (0 or 1) */ uint16_t rxclk:2; /* Receiver clock source. See SSC_CLKSRC_* definitions */ uint16_t txclk:2; /* Transmitter clock source. See SSC_CLKSRC_* definitions */ @@ -2132,7 +2133,7 @@ static int ssc_rx_configure(struct sam_ssc_s *priv) * Currently hardcoded to: * * SSC_RFMR_DATLEN(n) 'n' deterimined by configuration - * SSC_RFMR_LOOP Loop mode not selected + * SSC_RFMR_LOOP Determined by configuration * SSC_RFMR_MSBF Most significant bit first * SSC_RFMR_DATNB(n) Data number 'n' per frame (hard-coded) * SSC_RFMR_FSLEN(0) Receive frame sync length = 0 @@ -2144,6 +2145,14 @@ static int ssc_rx_configure(struct sam_ssc_s *priv) regval = (SSC_RFMR_DATLEN(CONFIG_SAMA5_SSC0_DATALEN - 1) | SSC_RFMR_MSBF | SSC_RFMR_DATNB(SSC_DATNB - 1) | SSC_RFMR_FSLEN(0) | SSC_RFMR_FSOS_NONE | SSC_RFMR_FSLENEXT(0)); + + /* Loopback mode? */ + + if (priv->loopback) + { + regval |= SSC_RFMR_LOOP; + } + ssc_putreg(priv, SAM_SSC_RFMR_OFFSET, regval); #else @@ -2614,6 +2623,15 @@ static void ssc0_configure(struct sam_ssc_s *priv) #endif /* CONFIG_SAMA5_SSC0_TX */ + /* Set/clear loopback mode */ + +#if defined(CONFIG_SAMA5_SSC0_TX) && defined(CONFIG_SAMA5_SSC0_TX) && \ + defined(SAMA5_SSC0_LOOPBACK) + priv->loopback = true; +#else + priv->loopback = false; +#endif + /* Does the receiver or transmitter need to have the MCK divider set up? */ #if defined(SSC0_HAVE_MCK2) @@ -2740,6 +2758,15 @@ static void ssc1_configure(struct sam_ssc_s *priv) #endif /* CONFIG_SAMA5_SSC1_TX */ + /* Set/clear loopback mode */ + +#if defined(CONFIG_SAMA5_SSC1_TX) && defined(CONFIG_SAMA5_SSC1_TX) && \ + defined(SAMA5_SSC1_LOOPBACK) + priv->loopback = true; +#else + priv->loopback = false; +#endif + /* Does the receiver or transmitter need to have the MCK divider set up? */ #if defined(SSC1_HAVE_MCK2) diff --git a/nuttx/libc/audio/Make.defs b/nuttx/libc/audio/Make.defs new file mode 100644 index 000000000..a611e3270 --- /dev/null +++ b/nuttx/libc/audio/Make.defs @@ -0,0 +1,43 @@ +############################################################################ +# libc/audio/Make.defs +# +# Copyright (C) 2013 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_AUDIO),y) +CSRCS += lib_buffer.c + +# Add the misc directory to the build + +DEPPATH += --dep-path audio +VPATH += :audio +endif |