summaryrefslogtreecommitdiff
path: root/apps/examples
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-11 15:18:57 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-11 15:18:57 -0600
commitb83fdc6a4c19a6e99c0ce10b98db5374519d5e79 (patch)
tree8e907ba687465a76995465aaea5b420973b16734 /apps/examples
parent35805fc983f9cd16b745f4326582e2f936e74cc5 (diff)
downloadnuttx-b83fdc6a4c19a6e99c0ce10b98db5374519d5e79.tar.gz
nuttx-b83fdc6a4c19a6e99c0ce10b98db5374519d5e79.tar.bz2
nuttx-b83fdc6a4c19a6e99c0ce10b98db5374519d5e79.zip
Various fixes from initial attempts to integrate the SAMA5 SSC/I2C driver with the I2C character driver loopback test
Diffstat (limited to 'apps/examples')
-rw-r--r--apps/examples/i2schar/i2schar_main.c7
-rw-r--r--apps/examples/i2schar/i2schar_receiver.c9
-rw-r--r--apps/examples/i2schar/i2schar_transmitter.c11
3 files changed, 21 insertions, 6 deletions
diff --git a/apps/examples/i2schar/i2schar_main.c b/apps/examples/i2schar/i2schar_main.c
index 2d5df3ce9..524a27550 100644
--- a/apps/examples/i2schar/i2schar_main.c
+++ b/apps/examples/i2schar/i2schar_main.c
@@ -297,9 +297,12 @@ int i2schar_main(int argc, char *argv[])
ret = pthread_create(&transmitter, &attr, i2schar_transmitter, NULL);
if (ret != OK)
{
+ sched_unlock();
message("i2schar_main: ERROR: failed to Start transmitter thread: %d\n", ret);
return EXIT_FAILURE;
}
+
+ pthread_setname_np(transmitter, "transmitter");
#endif
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
@@ -313,6 +316,7 @@ int i2schar_main(int argc, char *argv[])
ret = pthread_create(&receiver, &attr, i2schar_receiver, NULL);
if (ret != OK)
{
+ sched_unlock();
message("i2schar_main: ERROR: failed to Start receiver thread: %d\n", ret);
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
message("i2schar_main: Waiting for the transmitter thread\n");
@@ -320,8 +324,11 @@ int i2schar_main(int argc, char *argv[])
#endif
return EXIT_FAILURE;
}
+
+ pthread_setname_np(transmitter, "receiver");
#endif
+ sched_unlock();
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
message("i2schar_main: Waiting for the transmitter thread\n");
ret = pthread_join(transmitter, &result);
diff --git a/apps/examples/i2schar/i2schar_receiver.c b/apps/examples/i2schar/i2schar_receiver.c
index 40256d571..279076c6a 100644
--- a/apps/examples/i2schar/i2schar_receiver.c
+++ b/apps/examples/i2schar/i2schar_receiver.c
@@ -94,6 +94,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg)
struct audio_buf_desc_s desc;
int bufsize;
int nread;
+ int ret;
int fd;
int i;
@@ -117,15 +118,17 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg)
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
desc.u.ppBuffer = &apb;
- bufsize = apb_alloc(&desc);
- if (bufsize < 0)
+ ret = apb_alloc(&desc);
+ if (ret < 0)
{
message("i2schar_receiver: ERROR: failed to allocate buffer %d: %d\n",
- i+1, bufsize);
+ i+1, ret);
close(fd);
pthread_exit(NULL);
}
+ bufsize = sizeof(struct ap_buffer_s) + CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
+
/* Then receifve into the buffer */
do
diff --git a/apps/examples/i2schar/i2schar_transmitter.c b/apps/examples/i2schar/i2schar_transmitter.c
index 96717d2d0..601f9af39 100644
--- a/apps/examples/i2schar/i2schar_transmitter.c
+++ b/apps/examples/i2schar/i2schar_transmitter.c
@@ -96,6 +96,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg)
uint8_t *ptr;
int bufsize;
int nwritten;
+ int ret;
int fd;
int i;
int j;
@@ -120,15 +121,17 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg)
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
desc.u.ppBuffer = &apb;
- bufsize = apb_alloc(&desc);
- if (bufsize < 0)
+ ret = apb_alloc(&desc);
+ if (ret < 0)
{
message("i2schar_transmitter: ERROR: failed to allocate buffer %d: %d\n",
- i+1, bufsize);
+ i+1, ret);
close(fd);
pthread_exit(NULL);
}
+ bufsize = sizeof(struct ap_buffer_s) + CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
+
/* Fill the audio buffer with crap */
for (j = 0, ptr = apb->samp; j < CONFIG_EXAMPLES_I2SCHAR_BUFSIZE; j++)
@@ -136,6 +139,8 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg)
*ptr++ = crap++;
}
+ apb->nbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
+
/* Then send the buffer */
do