mlaz closed pull request #1169: nrf52_pwm: catch NRFX_PWM_EVT_STOPPED events
URL: https://github.com/apache/mynewt-core/pull/1169
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/apps/pwm_test/src/main.c b/apps/pwm_test/src/main.c
index 495e471fe8..dc0a715197 100644
--- a/apps/pwm_test/src/main.c
+++ b/apps/pwm_test/src/main.c
@@ -116,6 +116,9 @@ pwm_end_seq_handler(void* unused)
     } else {
         func_num++;
     }
+    rc = pwm_disable(pwm); /* Not needed but used for testing purposes. */
+    assert(rc == 0);
+
     rc = pwm_enable(pwm);
     assert(rc == 0);
 }
diff --git a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c 
b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
index a83ef3b632..f6f164b479 100644
--- a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
+++ b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
@@ -123,11 +123,12 @@ static void handler_0(nrfx_pwm_evt_type_t event_type)
         break;
 
     case NRFX_PWM_EVT_FINISHED :
-        instances[0].playing = false;
-        nrfx_pwm_uninit(&instances[0].drv_instance);
         instances[0].seq_end_handler(instances[0].seq_end_data);
         break;
 
+    case NRFX_PWM_EVT_STOPPED :
+        break;
+
     default:
         assert(0);
     }
@@ -145,11 +146,12 @@ static void handler_1(nrfx_pwm_evt_type_t event_type)
         break;
 
     case NRFX_PWM_EVT_FINISHED :
-        instances[1].playing = false;
-        nrfx_pwm_uninit(&instances[1].drv_instance);
         instances[1].seq_end_handler(instances[1].seq_end_data);
         break;
 
+    case NRFX_PWM_EVT_STOPPED :
+        break;
+
     default:
         assert(0);
     }
@@ -167,11 +169,12 @@ static void handler_2(nrfx_pwm_evt_type_t event_type)
         break;
 
     case NRFX_PWM_EVT_FINISHED :
-        instances[2].playing = false;
-        nrfx_pwm_uninit(&instances[2].drv_instance);
         instances[2].seq_end_handler(instances[2].seq_end_data);
         break;
 
+    case NRFX_PWM_EVT_STOPPED :
+        break;
+
     default:
         assert(0);
     }
@@ -190,11 +193,12 @@ static void handler_3(nrfx_pwm_evt_type_t event_type)
         break;
 
     case NRFX_PWM_EVT_FINISHED :
-        instances[3].playing = false;
-        nrfx_pwm_uninit(&instances[3].drv_instance);
         instances[3].seq_end_handler(instances[3].seq_end_data);
         break;
 
+    case NRFX_PWM_EVT_STOPPED :
+        break;
+
     default:
         assert(0);
     }
@@ -335,9 +339,7 @@ nrf52_pwm_close(struct os_dev *odev)
         return (EINVAL);
     }
 
-    if (!instances[inst_id].playing) {
-        nrfx_pwm_uninit(&instances[inst_id].drv_instance);
-    }
+    nrfx_pwm_uninit(&instances[inst_id].drv_instance);
     cleanup_instance(inst_id);
 
     if (os_started()) {
@@ -543,12 +545,8 @@ nrf52_pwm_disable(struct pwm_dev *dev)
         return (-EINVAL);
     }
 
-    if (!nrfx_pwm_stop(&instances[inst_id].drv_instance, true)) {
-        return (-EINVAL);
-    }
-    instances[inst_id].playing = false;
-
     nrfx_pwm_uninit(&instances[inst_id].drv_instance);
+    instances[inst_id].playing = false;
     return (0);
 }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to