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.
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 @@
{
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 @@
{
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);