Merge branch 'dev' into ui

This commit is contained in:
Mario Hüttel 2020-04-20 01:21:08 +02:00
commit 5017bf7003
4 changed files with 27 additions and 8 deletions

View File

@ -30,7 +30,7 @@ CFILES += adc-meas.c
# Shellmatta
CFILES += shellmatta/src/shellmatta.c shellmatta/src/shellmatta_autocomplete.c shellmatta/src/shellmatta_escape.c shellmatta/src/shellmatta_history.c shellmatta/src/shellmatta_utils.c shellmatta/src/shellmatta_opt.c shell.c
INCLUDEPATH += -Ishellmatta/api
# DEFINES += -DSHELLMATTA_STRIP_PRINTF
DEFINES += -DSHELLMATTA_HELP_ALIAS=\"?\"
# RCC Manager
CFILES += stm-periph/clock-enable-manager.c

View File

@ -159,7 +159,7 @@ int calibration_sequence_shell_cmd(shellmatta_handle_t shell)
/* Check noise values */
if (dev > CALIBRATION_MAX_PEAK_PEAK_NOISE_OHM || dev2 > CALIBRATION_MAX_PEAK_PEAK_NOISE_OHM) {
shellmatta_printf(shell, "Calibration failed! Too much noise. Check you're hardware.\r\n");
shellmatta_printf(shell, "Calibration failed! Too much noise. Check your hardware.\r\n");
return -3;
}

View File

@ -24,6 +24,7 @@
#include <reflow-controller/adc-meas.h>
#include <reflow-controller/digio.h>
#include <stdlib.h>
#include <malloc.h>
#include <helper-macros/helper-macros.h>
#include <reflow-controller/systick.h>
#include <stm-periph/unique-id.h>
@ -201,12 +202,13 @@ static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
static shellmatta_retCode_t shell_meminfo(const shellmatta_handle_t handle,
const char *arguments,
uint32_t length)
{
(void)arguments;
(void)length;
struct mallinfo mi;
shellmatta_printf(handle,
"Stack pointer: %p\r\n"
@ -215,6 +217,15 @@ static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
read_stack_pointer(),
stack_check_get_usage(),
stack_check_get_free());
mi = mallinfo();
shellmatta_printf(handle, "\r\nDynamic Memory Management\r\n");
shellmatta_printf(handle, "Allocated bytes: %d\r\n", mi.arena, mi.arena);
shellmatta_printf(handle, "Number of free chunks: %d\r\n", mi.ordblks);
shellmatta_printf(handle, "Top-most, releasable space: %d\r\n", mi.keepcost);
shellmatta_printf(handle, "Total free space: %d\r\n", mi.fordblks);
shellmatta_printf(handle, "Total allocated space: %d\r\n", mi.uordblks);
return SHELLMATTA_OK;
}
@ -252,6 +263,8 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
if (strstr(arg, "--single-line"))
single_line = true;
shellmatta_printf(handle, "\r\n");
while (run_loop) {
uart_receive_data_with_dma(&shell_uart, &data , &len);
for (i = 0; i < len; i++) {
@ -351,11 +364,11 @@ static shellmatta_cmd_t cmd[10] = {
.next = &cmd[8],
},
{
.cmd = "get-stack-pointer",
.cmdAlias = "sp",
.helpText = "Get the stack pointer",
.cmd = "meminfo",
.cmdAlias = NULL,
.helpText = "Get information about memory usage",
.usageText = "",
.cmdFct = shell_get_sp,
.cmdFct = shell_meminfo,
.next = &cmd[9],
},
{
@ -374,7 +387,7 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
shellmatta_retCode_t ret;
ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer),
"\e[1;32mEnter command:\e[m\r\n", cmd, write_func);
"\e[1;32mReflow Controller>\e[m ", cmd, write_func);
if (ret != SHELLMATTA_OK)
handle = NULL;

View File

@ -89,6 +89,12 @@ int _write(int fd, const void *buf, int count)
{
if (fd == 1)
uart_send_array_with_dma(&shell_uart, (char *)buf, count);
else if (fd == 2) {
uart_send_string_with_dma(&shell_uart, "\e[31m");
uart_send_array_with_dma(&shell_uart, (char *)buf, count);
uart_send_string_with_dma(&shell_uart, "\e[m");
}
return count;
}