From c33fe29c6b796f34ad52d68b2b764db624a2ad26 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Nov 2013 10:18:49 -0600 Subject: [PATCH] I2S character driver now supports configurable timeouts --- drivers/audio/Kconfig | 20 ++++++++++++++++++++ drivers/audio/i2schar.c | 16 ++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/audio/Kconfig b/drivers/audio/Kconfig index a29b14e548b..b94df1d3dee 100644 --- a/drivers/audio/Kconfig +++ b/drivers/audio/Kconfig @@ -15,6 +15,26 @@ config AUDIO_I2SCHAR not suitable for use in any real driver application in its current form. +if AUDIO_I2SCHAR + +config AUDIO_I2SCHAR_RXTIMEOUT + int "RX timeout" + default 0 + ---help--- + This is a fixed timeout value that will be used for all receiver + transfers. This is in units of system clock ticks (configurable). + The special value of zero disables RX timeouts. Default: 0 + +config AUDIO_I2SCHAR_TXTIMEOUT + int "TX timeout" + default 0 + ---help--- + This is a fixed timeout value that will be used for all transmitter + transfers. This is in units of system clock ticks (configurable). + The special value of zero disables RX timeouts. Default: 0 + +endif #AUDIO_I2SCHAR + config VS1053 bool "VS1053 codec chip" default n diff --git a/drivers/audio/i2schar.c b/drivers/audio/i2schar.c index e3f6986b106..4b55f37996f 100644 --- a/drivers/audio/i2schar.c +++ b/drivers/audio/i2schar.c @@ -61,7 +61,17 @@ /**************************************************************************** * Private Definitions ****************************************************************************/ +/* Configuration ************************************************************/ +#ifndef CONFIG_AUDIO_I2SCHAR_RXTIMEOUT +# define CONFIG_AUDIO_I2SCHAR_RXTIMEOUT 0 +#endif + +#ifndef CONFIG_AUDIO_I2SCHAR_TXTIMEOUT +# define CONFIG_AUDIO_I2SCHAR_TXTIMEOUT 0 +#endif + +/* Device naming ************************************************************/ #define DEVNAME_FMT "/dev/i2schar%d" #define DEVNAME_FMTLEN (12 + 3 + 1) @@ -268,7 +278,8 @@ static ssize_t i2schar_read(FAR struct file *filep, FAR char *buffer, /* Give the buffer to the I2S driver */ - ret = I2S_RECEIVE(priv->i2s, apb, i2schar_rxcallback, priv, 0); + ret = I2S_RECEIVE(priv->i2s, apb, i2schar_rxcallback, priv, + CONFIG_AUDIO_I2SCHAR_RXTIMEOUT); if (ret < 0) { i2sdbg("ERROR: I2S_RECEIVE returned: %d\n", ret); @@ -342,7 +353,8 @@ static ssize_t i2schar_write(FAR struct file *filep, FAR const char *buffer, /* Give the audio buffer to the I2S driver */ - ret = I2S_SEND(priv->i2s, apb, i2schar_txcallback, priv, 0); + ret = I2S_SEND(priv->i2s, apb, i2schar_txcallback, priv, + CONFIG_AUDIO_I2SCHAR_TXTIMEOUT); if (ret < 0) { i2sdbg("ERROR: I2S_SEND returned: %d\n", ret);