andrzej-kaczmarek commented on a change in pull request #1680: app/pwm_test 
improvements and pwm_nrf52 fixes
URL: https://github.com/apache/mynewt-core/pull/1680#discussion_r263708203
 
 

 ##########
 File path: apps/pwm_test/src/pwm_shell.c
 ##########
 @@ -0,0 +1,455 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "os/mynewt.h"
+#include "os/os_dev.h"
+#include "console/console.h"
+#include "shell/shell.h"
+#include "pwm/pwm.h"
+#include "bsp/bsp.h"
+
+#include "pwm_shell.h"
+
+#if MYNEWT_VAL(SOFT_PWM)
+#define MAX_PWM_DEVICES (4 + MYNEWT_VAL(SOFT_PWM_DEVS))
+#else
+#define MAX_PWM_DEVICES (4)
+#endif
+static struct pwm_dev * pwm_devs[MAX_PWM_DEVICES];
+
+extern void pwm_init(struct pwm_dev *pwm_dev, int pin);
+
+static int
+store_pwm(char *pwm_name, struct pwm_dev *dev)
+{
+    int i;
+
+    if (pwm_name[0] == 's') {
+        /* in case of spwmx*/
+        i = atoi(pwm_name + 4);
+        /* starting from 4 we have soft pwms in the table */
+        i += 4;
+    } else {
+        i = atoi(pwm_name + 3);
 
 Review comment:
   so `pwm4` (if created by any BSP/MCU) will effectively overwrite `spwm0` :-)
   anyway, this is a test app so I do not think it really matters, but probably 
to support any number of different kind of PWMs with any names it would be 
better to just have a lookup table

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


With regards,
Apache Git Services

Reply via email to