Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/omega2-pwm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-07-22 00:54:57 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-07-22 00:54:57 +0300
commit5202833f719deb071333bf547d0f4b886e1b43b4 (patch)
treec93e7aedead5e4b134c2851aaae800d1264a51cd
parent78af5ffc16e291845098b5386c6b45d4b4c52efd (diff)
Fixes
-rw-r--r--pwm.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/pwm.c b/pwm.c
index 63e0fff..4a4e23a 100644
--- a/pwm.c
+++ b/pwm.c
@@ -102,10 +102,8 @@ uint32_t devmem(uint32_t target, uint8_t size, uint8_t write, uint32_t value)
static void usage(const char *cmd)
{
fprintf(stderr,
- "\nUsage:\t%s pwm <channel> <frequency> <duty>\n",
- "\nUsage:\t%s melody <channel> <frequency> <duration_ms> [<frequency> <duration_ms> [<frequency> <duration_ms> ...]]\n",
- "\n",
- cmd, cmd);
+ "\nUsage:\t%s pwm <channel> <frequency> [duty]\n",
+ cmd);
}
static void pwm(uint8_t channel, uint32_t freq, uint8_t duty)
@@ -150,23 +148,23 @@ int main(int argc, char **argv)
uint32_t freq;
uint8_t duty = 50;
- if (sscanf(argv[1], "%d", &channel) != 1)
+ if ((sscanf(argv[1], "%d", &channel) != 1) || (channel > 3))
{
- fprintf(stderr, "Invalid number\n");
+ fprintf(stderr, "Invalid channel number\n");
exit(1);
}
if (sscanf(argv[2], "%d", &freq) != 1)
{
- fprintf(stderr, "Invalid number\n");
+ fprintf(stderr, "Invalid frequency number\n");
exit(1);
}
if (argc >= 4)
{
- if (sscanf(argv[3], "%d", &duty) != 1)
+ if ((sscanf(argv[3], "%d", &duty) != 1) || (duty > 100))
{
- fprintf(stderr, "Invalid number\n");
+ fprintf(stderr, "Invalid duty number\n");
exit(1);
}
}