Various fixes from initial attempts to integrate the SAMA5 SSC/I2C driver with the I2C character driver loopback test
This commit is contained in:
parent
1129c10a27
commit
65ba440e75
@ -297,9 +297,12 @@ int i2schar_main(int argc, char *argv[])
|
|||||||
ret = pthread_create(&transmitter, &attr, i2schar_transmitter, NULL);
|
ret = pthread_create(&transmitter, &attr, i2schar_transmitter, NULL);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
sched_unlock();
|
||||||
message("i2schar_main: ERROR: failed to Start transmitter thread: %d\n", ret);
|
message("i2schar_main: ERROR: failed to Start transmitter thread: %d\n", ret);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_setname_np(transmitter, "transmitter");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
|
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
|
||||||
@ -313,6 +316,7 @@ int i2schar_main(int argc, char *argv[])
|
|||||||
ret = pthread_create(&receiver, &attr, i2schar_receiver, NULL);
|
ret = pthread_create(&receiver, &attr, i2schar_receiver, NULL);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
sched_unlock();
|
||||||
message("i2schar_main: ERROR: failed to Start receiver thread: %d\n", ret);
|
message("i2schar_main: ERROR: failed to Start receiver thread: %d\n", ret);
|
||||||
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
|
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
|
||||||
message("i2schar_main: Waiting for the transmitter thread\n");
|
message("i2schar_main: Waiting for the transmitter thread\n");
|
||||||
@ -320,8 +324,11 @@ int i2schar_main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_setname_np(transmitter, "receiver");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
sched_unlock();
|
||||||
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
|
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
|
||||||
message("i2schar_main: Waiting for the transmitter thread\n");
|
message("i2schar_main: Waiting for the transmitter thread\n");
|
||||||
ret = pthread_join(transmitter, &result);
|
ret = pthread_join(transmitter, &result);
|
||||||
|
@ -94,6 +94,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg)
|
|||||||
struct audio_buf_desc_s desc;
|
struct audio_buf_desc_s desc;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
int nread;
|
int nread;
|
||||||
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -117,15 +118,17 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg)
|
|||||||
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
||||||
desc.u.ppBuffer = &apb;
|
desc.u.ppBuffer = &apb;
|
||||||
|
|
||||||
bufsize = apb_alloc(&desc);
|
ret = apb_alloc(&desc);
|
||||||
if (bufsize < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("i2schar_receiver: ERROR: failed to allocate buffer %d: %d\n",
|
message("i2schar_receiver: ERROR: failed to allocate buffer %d: %d\n",
|
||||||
i+1, bufsize);
|
i+1, ret);
|
||||||
close(fd);
|
close(fd);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bufsize = sizeof(struct ap_buffer_s) + CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
||||||
|
|
||||||
/* Then receifve into the buffer */
|
/* Then receifve into the buffer */
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -96,6 +96,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg)
|
|||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
int nwritten;
|
int nwritten;
|
||||||
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -120,15 +121,17 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg)
|
|||||||
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
desc.numbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
||||||
desc.u.ppBuffer = &apb;
|
desc.u.ppBuffer = &apb;
|
||||||
|
|
||||||
bufsize = apb_alloc(&desc);
|
ret = apb_alloc(&desc);
|
||||||
if (bufsize < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("i2schar_transmitter: ERROR: failed to allocate buffer %d: %d\n",
|
message("i2schar_transmitter: ERROR: failed to allocate buffer %d: %d\n",
|
||||||
i+1, bufsize);
|
i+1, ret);
|
||||||
close(fd);
|
close(fd);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bufsize = sizeof(struct ap_buffer_s) + CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
||||||
|
|
||||||
/* Fill the audio buffer with crap */
|
/* Fill the audio buffer with crap */
|
||||||
|
|
||||||
for (j = 0, ptr = apb->samp; j < CONFIG_EXAMPLES_I2SCHAR_BUFSIZE; j++)
|
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++;
|
*ptr++ = crap++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apb->nbytes = CONFIG_EXAMPLES_I2SCHAR_BUFSIZE;
|
||||||
|
|
||||||
/* Then send the buffer */
|
/* Then send the buffer */
|
||||||
|
|
||||||
do
|
do
|
||||||
|
Loading…
Reference in New Issue
Block a user