debugcmds: Move debugging commands from basecmd.c to new file
Move the implementation of debug commands to their own file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
142b92b883
commit
d56f8407a5
|
@ -1,6 +1,6 @@
|
|||
# Main code build rules
|
||||
|
||||
src-y += sched.c command.c stepper.c basecmd.c gpiocmds.c endstop.c
|
||||
src-y += sched.c command.c stepper.c basecmd.c debugcmds.c gpiocmds.c endstop.c
|
||||
src-$(CONFIG_HAVE_GPIO_ADC) += adccmds.c
|
||||
src-$(CONFIG_HAVE_GPIO_SPI) += spicmds.c
|
||||
src-$(CONFIG_HAVE_GPIO_HARD_PWM) += pwmcmds.c
|
||||
|
|
|
@ -175,36 +175,6 @@ command_finalize_config(uint32_t *args)
|
|||
DECL_COMMAND(command_finalize_config, "finalize_config crc=%u");
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Group commands
|
||||
****************************************************************/
|
||||
|
||||
static struct timer group_timer;
|
||||
|
||||
static uint_fast8_t
|
||||
group_end_event(struct timer *timer)
|
||||
{
|
||||
shutdown("Missed scheduling of next event");
|
||||
}
|
||||
|
||||
void
|
||||
command_start_group(uint32_t *args)
|
||||
{
|
||||
sched_del_timer(&group_timer);
|
||||
group_timer.func = group_end_event;
|
||||
group_timer.waketime = args[0];
|
||||
sched_add_timer(&group_timer);
|
||||
}
|
||||
DECL_COMMAND(command_start_group, "start_group clock=%u");
|
||||
|
||||
void
|
||||
command_end_group(uint32_t *args)
|
||||
{
|
||||
sched_del_timer(&group_timer);
|
||||
}
|
||||
DECL_COMMAND(command_end_group, "end_group");
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Timing and load stats
|
||||
****************************************************************/
|
||||
|
@ -262,66 +232,6 @@ stats_task(void)
|
|||
DECL_TASK(stats_task);
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Register debug commands
|
||||
****************************************************************/
|
||||
|
||||
void
|
||||
command_debug_read8(uint32_t *args)
|
||||
{
|
||||
uint8_t *ptr = (void*)(size_t)args[0];
|
||||
uint16_t v = *ptr;
|
||||
sendf("debug_result val=%hu", v);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_read8, HF_IN_SHUTDOWN, "debug_read8 addr=%u");
|
||||
|
||||
void
|
||||
command_debug_read16(uint32_t *args)
|
||||
{
|
||||
uint16_t *ptr = (void*)(size_t)args[0];
|
||||
irqstatus_t flag = irq_save();
|
||||
uint16_t v = *ptr;
|
||||
irq_restore(flag);
|
||||
sendf("debug_result val=%hu", v);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_read16, HF_IN_SHUTDOWN, "debug_read16 addr=%u");
|
||||
|
||||
void
|
||||
command_debug_write8(uint32_t *args)
|
||||
{
|
||||
uint8_t *ptr = (void*)(size_t)args[0];
|
||||
*ptr = args[1];
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_write8, HF_IN_SHUTDOWN,
|
||||
"debug_write8 addr=%u val=%u");
|
||||
|
||||
void
|
||||
command_debug_write16(uint32_t *args)
|
||||
{
|
||||
uint16_t *ptr = (void*)(size_t)args[0];
|
||||
irqstatus_t flag = irq_save();
|
||||
*ptr = args[1];
|
||||
irq_restore(flag);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_write16, HF_IN_SHUTDOWN,
|
||||
"debug_write16 addr=%u val=%u");
|
||||
|
||||
void
|
||||
command_debug_ping(uint32_t *args)
|
||||
{
|
||||
uint8_t len = args[0];
|
||||
char *data = (void*)(size_t)args[1];
|
||||
sendf("pong data=%*s", len, data);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_ping, HF_IN_SHUTDOWN, "debug_ping data=%*s");
|
||||
|
||||
void
|
||||
command_debug_nop(uint32_t *args)
|
||||
{
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_nop, HF_IN_SHUTDOWN, "debug_nop data=%*s");
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Misc commands
|
||||
****************************************************************/
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
// Debugging commands.
|
||||
//
|
||||
// Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "sched.h" // sched_add_timer
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Group commands
|
||||
****************************************************************/
|
||||
|
||||
static struct timer group_timer;
|
||||
|
||||
static uint_fast8_t
|
||||
group_end_event(struct timer *timer)
|
||||
{
|
||||
shutdown("Missed scheduling of next event");
|
||||
}
|
||||
|
||||
void
|
||||
command_start_group(uint32_t *args)
|
||||
{
|
||||
sched_del_timer(&group_timer);
|
||||
group_timer.func = group_end_event;
|
||||
group_timer.waketime = args[0];
|
||||
sched_add_timer(&group_timer);
|
||||
}
|
||||
DECL_COMMAND(command_start_group, "start_group clock=%u");
|
||||
|
||||
void
|
||||
command_end_group(uint32_t *args)
|
||||
{
|
||||
sched_del_timer(&group_timer);
|
||||
}
|
||||
DECL_COMMAND(command_end_group, "end_group");
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Register debug commands
|
||||
****************************************************************/
|
||||
|
||||
void
|
||||
command_debug_read8(uint32_t *args)
|
||||
{
|
||||
uint8_t *ptr = (void*)(size_t)args[0];
|
||||
uint16_t v = *ptr;
|
||||
sendf("debug_result val=%hu", v);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_read8, HF_IN_SHUTDOWN, "debug_read8 addr=%u");
|
||||
|
||||
void
|
||||
command_debug_read16(uint32_t *args)
|
||||
{
|
||||
uint16_t *ptr = (void*)(size_t)args[0];
|
||||
irqstatus_t flag = irq_save();
|
||||
uint16_t v = *ptr;
|
||||
irq_restore(flag);
|
||||
sendf("debug_result val=%hu", v);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_read16, HF_IN_SHUTDOWN, "debug_read16 addr=%u");
|
||||
|
||||
void
|
||||
command_debug_write8(uint32_t *args)
|
||||
{
|
||||
uint8_t *ptr = (void*)(size_t)args[0];
|
||||
*ptr = args[1];
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_write8, HF_IN_SHUTDOWN,
|
||||
"debug_write8 addr=%u val=%u");
|
||||
|
||||
void
|
||||
command_debug_write16(uint32_t *args)
|
||||
{
|
||||
uint16_t *ptr = (void*)(size_t)args[0];
|
||||
irqstatus_t flag = irq_save();
|
||||
*ptr = args[1];
|
||||
irq_restore(flag);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_write16, HF_IN_SHUTDOWN,
|
||||
"debug_write16 addr=%u val=%u");
|
||||
|
||||
void
|
||||
command_debug_ping(uint32_t *args)
|
||||
{
|
||||
uint8_t len = args[0];
|
||||
char *data = (void*)(size_t)args[1];
|
||||
sendf("pong data=%*s", len, data);
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_ping, HF_IN_SHUTDOWN, "debug_ping data=%*s");
|
||||
|
||||
void
|
||||
command_debug_nop(uint32_t *args)
|
||||
{
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_debug_nop, HF_IN_SHUTDOWN, "debug_nop data=%*s");
|
Loading…
Reference in New Issue