void cmd_sd_dir(uint8_t argc, char **argv);
#endif
+void cmd_pwm(uint8_t argc, char **argv);
+
#define CMD_NOPARAMS "This command has no parameters"
/**************************************************************************/
#ifdef CFG_SDCARD
{ "d", 0, 1, 0, cmd_sd_dir , "Dir (SD Card)" , "'d [<path>]'" },
#endif
+ { "pwm", 0, 2, 0, cmd_pwm, "PWM Control", "'pwm [<duty_cycle>] [<frequency>]'" },
+
+}
+
};
#endif
\ No newline at end of file
--- /dev/null
+/**************************************************************************/\r
+/*! \r
+ @file cmd_sysinfo.c\r
+ @author K. Townsend (microBuilder.eu)\r
+\r
+ @brief Code to execute for cmd_sysinfo in the 'core/cmd'\r
+ command-line interpretter.\r
+\r
+ @section LICENSE\r
+\r
+ Software License Agreement (BSD License)\r
+\r
+ Copyright (c) 2010, microBuilder SARL\r
+ All rights reserved.\r
+\r
+ Redistribution and use in source and binary forms, with or without\r
+ modification, are permitted provided that the following conditions are met:\r
+ 1. Redistributions of source code must retain the above copyright\r
+ notice, this list of conditions and the following disclaimer.\r
+ 2. Redistributions in binary form must reproduce the above copyright\r
+ notice, this list of conditions and the following disclaimer in the\r
+ documentation and/or other materials provided with the distribution.\r
+ 3. Neither the name of the copyright holders nor the\r
+ names of its contributors may be used to endorse or promote products\r
+ derived from this software without specific prior written permission.\r
+\r
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\r
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY\r
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*/\r
+/**************************************************************************/\r
+#include <stdio.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 "core/pwm/pwm.h"\r
+\r
+#ifdef CFG_PRINTF_UART\r
+ #include "core/uart/uart.h"\r
+#endif\r
+\r
+/**************************************************************************/\r
+/*! \r
+ PWM command handler\r
+*/\r
+/**************************************************************************/\r
+uint8_t pwmStarted = 0;\r
+\r
+void cmd_pwm(uint8_t argc, char **argv) {\r
+ int32_t frequencyTicks = 65535;\r
+ int32_t dutyCycle = 25;\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
+ }\r
+\r
+ if(! pwmStarted) {\r
+ printf("Initializing PWM%s", CFG_PRINTF_NEWLINE);\r
+ pwmInit();\r
+ }\r
+ \r
+ printf("Setting frequency ticks to %u%s", (uint16_t) frequencyTicks, CFG_PRINTF_NEWLINE);\r
+ pwmSetFrequencyInTicks(frequencyTicks);\r
+ printf("Setting duty cycle to %u%s", (uint16_t) dutyCycle, CFG_PRINTF_NEWLINE);\r
+ pwmSetDutyCycle(dutyCycle);\r
+ if(! pwmStarted) {\r
+ pwmStart();\r
+ pwmStarted = 1;\r
+ }\r
+}
\ No newline at end of file