Merge branch 'master' of gitlab:wintermute/hackover2013-badge-firmware
[hackover2013-badge-firmware.git] / project / commands / cmd_pwm.c
index 00e7de4..3d070d5 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************************************/\r
 /*! \r
     @file     cmd_sysinfo.c\r
 /**************************************************************************/\r
 /*! \r
     @file     cmd_sysinfo.c\r
-    @author   K. Townsend (microBuilder.eu)\r
+    @author   Miceuz\r
 \r
     @brief    Code to execute for cmd_sysinfo in the 'core/cmd'\r
               command-line interpretter.\r
 \r
     @brief    Code to execute for cmd_sysinfo in the 'core/cmd'\r
               command-line interpretter.\r
@@ -10,7 +10,7 @@
 \r
     Software License Agreement (BSD License)\r
 \r
 \r
     Software License Agreement (BSD License)\r
 \r
-    Copyright (c) 2010, microBuilder SARL\r
+    Copyright (c) 2012, microBuilder SARL\r
     All rights reserved.\r
 \r
     Redistribution and use in source and binary forms, with or without\r
     All rights reserved.\r
 \r
     Redistribution and use in source and binary forms, with or without\r
 \r
 #include "projectconfig.h"\r
 #include "core/cmd/cmd.h"\r
 \r
 #include "projectconfig.h"\r
 #include "core/cmd/cmd.h"\r
-#include "core/systick/systick.h"\r
-#include "core/iap/iap.h"\r
 #include "project/commands.h"       // Generic helper functions\r
 #include "project/commands.h"       // Generic helper functions\r
-#include "core/pwm/pwm.h"\r
 \r
 \r
-#ifdef CFG_PRINTF_UART\r
-  #include "core/uart/uart.h"\r
-#endif\r
+#ifdef CFG_PWM\r
+  #include "core/pwm/pwm.h"\r
 \r
 /**************************************************************************/\r
 /*! \r
 \r
 /**************************************************************************/\r
 /*! \r
@@ -58,40 +54,31 @@ uint8_t pwmStarted = 0;
 \r
 void cmd_pwm(uint8_t argc, char **argv) {\r
     int32_t frequencyTicks = 65535;\r
 \r
 void cmd_pwm(uint8_t argc, char **argv) {\r
     int32_t frequencyTicks = 65535;\r
-    int32_t dutyCycle = 25;\r
+    int32_t dutyCycle = CFG_PWM_DEFAULT_DUTYCYCLE;\r
     \r
     \r
-    if(argc > 0) {\r
-        getNumber (argv[0], &dutyCycle);\r
-        if(dutyCycle < 1 || dutyCycle > 100) {\r
-            printf("Invalid duty cycle. Duty cycle must be [1 .. 65535]%s", CFG_PRINTF_NEWLINE);\r
-            return;\r
-        }\r
-\r
-        if(argc > 1) {\r
-            getNumber (argv[1], &frequencyTicks);\r
-            if(frequencyTicks < 0 || frequencyTicks > 0xffff) {\r
-                printf("Invalid frequency. Frequency must be [1 .. 65535]%s", CFG_PRINTF_NEWLINE);\r
-                return;\r
-            }\r
-        } else {\r
-            frequencyTicks = 65535;\r
-        }\r
-    } else {\r
-        dutyCycle = 25;\r
-\r
+    getNumber (argv[0], &dutyCycle);\r
+    if(dutyCycle < 1 || dutyCycle > 100) \r
+    {\r
+      printf("Invalid duty cycle [1..65535]%s", CFG_PRINTF_NEWLINE);\r
+      return;\r
     }\r
 \r
     }\r
 \r
-    if(! pwmStarted) {\r
-        printf("Initializing PWM%s", CFG_PRINTF_NEWLINE);\r
-        pwmInit();\r
+    getNumber (argv[1], &frequencyTicks);\r
+    if(frequencyTicks < 0 || frequencyTicks > 0xffff) \r
+    {\r
+      printf("Invalid frequency [1..65535]%s", CFG_PRINTF_NEWLINE);\r
+      return;\r
     }\r
     }\r
-    \r
-    printf("Setting frequency ticks to %u%s", (uint16_t) frequencyTicks, CFG_PRINTF_NEWLINE);\r
+\r
+    printf("Setting frequency: %u ticks%s", (uint16_t) frequencyTicks, CFG_PRINTF_NEWLINE);\r
     pwmSetFrequencyInTicks(frequencyTicks);\r
     pwmSetFrequencyInTicks(frequencyTicks);\r
-    printf("Setting duty cycle to %u%s", (uint16_t) dutyCycle, CFG_PRINTF_NEWLINE);\r
+    printf("Setting duty cycle: %u%%%s", (uint16_t) dutyCycle, CFG_PRINTF_NEWLINE);\r
     pwmSetDutyCycle(dutyCycle);\r
     pwmSetDutyCycle(dutyCycle);\r
-    if(! pwmStarted) {\r
-        pwmStart();\r
-        pwmStarted = 1;\r
+    if(! pwmStarted) \r
+    {\r
+      printf("Initializing PWM%s", CFG_PRINTF_NEWLINE);\r
+      pwmStart();\r
+      pwmStarted = 1;\r
     }\r
     }\r
-}
\ No newline at end of file
+}\r
+#endif\r
This page took 0.030237 seconds and 4 git commands to generate.