You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/06/21 19:32:36 UTC

[mynewt-core] branch master updated (057f6ff -> 01760b7)

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


    from 057f6ff  Merge pull request #2622 from vikrant-proxy/nrf52-periph-fix
     new 9f9b731  hw/drivers/i2s: Fix i2s_write
     new 01760b7  hw/drivers/i2s: Fix nrf5x driver stop

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c | 8 ++++----
 hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c   | 8 ++++----
 hw/drivers/i2s/src/i2s.c                 | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

[mynewt-core] 02/02: hw/drivers/i2s: Fix nrf5x driver stop

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 01760b74dbb68fe6191df4e04fd7930bc54b5950
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Jun 14 12:53:48 2021 +0200

    hw/drivers/i2s: Fix nrf5x driver stop
    
    If i2s device (i2s out) was opened and it
    was never used and then close. NRFX assert
    would fire.
    
    Now nrfx_i2s_stop is not called from i2s_driver_stop
    when it was never started.
---
 hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c | 8 ++++----
 hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c   | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c b/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
index fc73b81..df3a498 100644
--- a/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
+++ b/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
@@ -155,10 +155,10 @@ i2s_driver_stop(struct i2s *i2s)
 {
     struct i2s_sample_buffer *buffer;
 
-    nrf52_i2s.running = false;
-    nrfx_i2s_stop();
-
-    assert(nrf52_i2s.i2s->state == I2S_STATE_STOPPED);
+    if (nrf52_i2s.running) {
+        nrf52_i2s.running = false;
+        nrfx_i2s_stop();
+    }
 
     while (NULL != (buffer = i2s_driver_buffer_get(i2s))) {
         i2s_driver_buffer_put(i2s, buffer);
diff --git a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
index e9284dd..751d93c 100644
--- a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
+++ b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
@@ -170,10 +170,10 @@ i2s_driver_stop(struct i2s *i2s)
 {
     struct i2s_sample_buffer *buffer;
 
-    i2s_nrfx.running = false;
-    nrfx_i2s_stop();
-
-    assert(i2s_nrfx.i2s->state == I2S_STATE_STOPPED);
+    if (i2s_nrfx.running) {
+        i2s_nrfx.running = false;
+        nrfx_i2s_stop();
+    }
 
     while (NULL != (buffer = i2s_driver_buffer_get(i2s))) {
         i2s_driver_buffer_put(i2s, buffer);

[mynewt-core] 01/02: hw/drivers/i2s: Fix i2s_write

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 9f9b731c0d1eaa5fb04553a0debd48d9ca47e1f5
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Jun 14 11:59:17 2021 +0200

    hw/drivers/i2s: Fix i2s_write
    
    Synchronous function for easy write to i2s base speaker
    was not setting up sample_count field.
    If this filed was not setup in other way (as it could
    potentially be) i2s drivers would just drop empty
    buffers and no sound would emitted.
---
 hw/drivers/i2s/src/i2s.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/drivers/i2s/src/i2s.c b/hw/drivers/i2s/src/i2s.c
index 3a78a83..7930c56 100644
--- a/hw/drivers/i2s/src/i2s.c
+++ b/hw/drivers/i2s/src/i2s.c
@@ -180,7 +180,6 @@ i2s_close(struct i2s *i2s)
 int
 i2s_write(struct i2s *i2s, void *samples, uint32_t sample_buffer_size)
 {
-    uint32_t sample_pair_size = (i2s->sample_size_in_bytes * 2);
     size_t sample_count;
     struct i2s_sample_buffer *buffer;
 
@@ -193,15 +192,16 @@ i2s_write(struct i2s *i2s, void *samples, uint32_t sample_buffer_size)
     }
 
     /* Calculate buffer size */
-    sample_count = sample_buffer_size / sample_pair_size;
+    sample_count = sample_buffer_size / i2s->sample_size_in_bytes;
     if (buffer->capacity < sample_count) {
         sample_count = buffer->capacity;
     }
 
-    sample_buffer_size = sample_count * sample_pair_size;
+    sample_buffer_size = sample_count * i2s->sample_size_in_bytes;
 
     /* Move data to buffer */
     memcpy(buffer->sample_data, samples, sample_buffer_size);
+    buffer->sample_count = sample_count;
 
     /* Pass buffer to output device */
     i2s_buffer_put(i2s, buffer);