Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion firmware/project-firmware/usr/uInverter/cmd/cmd_uInverter.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static command_entry_t cmd_entry;
// Defines help content displayed for this command
// when user types "help" at command prompt
static command_help_t cmd_help[] = {
{ "stats <print/reset>", "Print or Reset statistics"},
{ "start", "Begin VSI output" },
{ "stop", "End VSI output" },
{ "freq <freq>", "Set the uInverter frequency" },
Expand Down Expand Up @@ -72,7 +73,15 @@ int cmd_uInverter(int argc, char **argv)
return CMD_SUCCESS;
}

if (argc == 3 && STREQ("stats", argv[1])){
if (STREQ("print", argv[2]))
return task_uInverter_stats_print() == SUCCESS ? CMD_SUCCESS : CMD_FAILURE;
if(STREQ("reset", argv[2]))
return task_uInverter_stats_reset() == SUCCESS ? CMD_SUCCESS : CMD_FAILURE;
}


return CMD_INVALID_ARGUMENTS;
}

#endif // APP_uInverter
#endif // APP_uInverter
15 changes: 14 additions & 1 deletion firmware/project-firmware/usr/uInverter/task_uInverter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "usr/uInverter/task_uInverter.h"
#include "sys/scheduler.h"
#include "drv/pwm.h"
#include "drv/cpu_timer.h"
#include <math.h>

// Scheduler TCB which holds task "context"
Expand All @@ -20,7 +21,9 @@ int task_uInverter_init(void){

// Fill TCB with parameters
scheduler_tcb_init(&tcb, task_uInverter_callback,
NULL, "vsi", TASK_UINVERTER_INTERVAL_USEC);
NULL, "uInverter", TASK_UINVERTER_INTERVAL_USEC);

task_stats_enable(&tcb.stats);

// Register task with scheduler
return scheduler_tcb_register(&tcb);
Expand Down Expand Up @@ -59,4 +62,14 @@ int task_uInverter_set_amplitude(double amplitude){
return SUCCESS;
}

int task_uInverter_stats_print(){
task_stats_print(&tcb.stats);
return SUCCESS;
}

int task_uInverter_stats_reset(){
task_stats_reset(&tcb.stats);
return SUCCESS;
}

#endif // APP_uInverter
5 changes: 4 additions & 1 deletion firmware/project-firmware/usr/uInverter/task_uInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ void task_uInverter_callback(void *arg);
int task_uInverter_set_frequency(double freq);
int task_uInverter_set_amplitude(double amplitude);

#endif // TASK_UINVERTER_H
int task_uInverter_stats_print();
int task_uInverter_stats_reset();

#endif // TASK_UINVERTER_H