Commit 3d8d9147 authored by Raptor Engineering Development Team's avatar Raptor Engineering Development Team
Browse files

Add shell command for direct PWM control

Minor cleanup
parent 4b2f1290
......@@ -3457,7 +3457,7 @@ int kestrel_init(void)
initialize_i2c_master((uint8_t *)I2CMASTER4_BASE, 100000);
#ifdef SIMPLEPWM_BASE
initialize_pwm_controller(SIMPLEPWM_BASE);
initialize_pwm_controller((uint8_t*)SIMPLEPWM_BASE);
#endif
// Check for Aquila core presence
......
......@@ -12,8 +12,11 @@
#define WITH_ZEPHYR 1
#include "kestrel.h"
#include "simple_pwm.h"
#include "flash_filesystem.h"
#include <generated/mem.h>
#define KESTREL_CONSOLE_THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1)
static K_THREAD_STACK_DEFINE(kestrel_console_thread_stack, 16384);
static struct k_thread kestrel_console_thread_data;
......@@ -102,6 +105,10 @@ static void print_kestrel_memdump_command_usage(const struct shell *shell, char*
shell_print(shell, "Usage: %s <address> [length]", command_name);
}
static void print_kestrel_pwmcontrol_command_usage(const struct shell *shell, char* command_name) {
shell_print(shell, "Usage: %s <channel> <value>", command_name);
}
static int kestrel_shell_cmd_utility(const struct shell *shell, size_t argc, char **argv)
{
if (argc < 2) {
......@@ -183,6 +190,30 @@ static int kestrel_shell_cmd_memdump(const struct shell *shell, size_t argc, cha
return 0;
}
static int kestrel_shell_cmd_pwmcontrol(const struct shell *shell, size_t argc, char **argv)
{
int channel;
int value;
if (argc < 3) {
print_kestrel_pwmcontrol_command_usage(shell, argv[0]);
return -1;
}
channel = strtoul(argv[1], NULL, 16);
value = strtoul(argv[2], NULL, 16);
#ifdef SIMPLEPWM_BASE
set_pwm_value((uint8_t*)SIMPLEPWM_BASE, channel, value);
shell_print(shell, "");
#else
shell_print(shell, "[ERROR] No PWM controller available!");
#endif
return 0;
}
static int kestrel_shell_cmd_console(const struct shell *shell, size_t argc, char **argv)
{
const void *active_log_backend = NULL;
......@@ -222,6 +253,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_kestrel,
SHELL_CMD(reflash, NULL, "Simple Flash utility", kestrel_shell_cmd_reflash),
// Arbitrary memory dump command
SHELL_CMD(memdump, NULL, "Memory dump tool", kestrel_shell_cmd_memdump),
// PWM commands
SHELL_CMD(pwmcontrol, NULL, "PWM controller", kestrel_shell_cmd_pwmcontrol),
// Command list array terminator
SHELL_SUBCMD_SET_END
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment