Merge branch 'dev' into ui

This commit is contained in:
2020-04-27 19:28:32 +02:00
17 changed files with 240 additions and 30 deletions

View File

@@ -18,6 +18,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stm32/stm32f4xx.h>
#include <cmsis/core_cm4.h>
#include <reflow-controller/shell.h>
#include <stm-periph/uart.h>
#include <string.h>
@@ -30,7 +32,7 @@
#include <stm-periph/unique-id.h>
#include <reflow-controller/calibration.h>
#include <reflow-controller/temp-converter.h>
#include <fatfs/ff.h>
#include <reflow-controller/stack-check.h>
#include <reflow-controller/rotary-encoder.h>
@@ -275,8 +277,11 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
shellmatta_printf(handle, "\x1b[1A\x1b[150D\x1b[K");
shell_cmd_pt1000_res(handle, "", 0UL);
led_set(0, led_status);
led_set(1, !led_status);
led_set(1, led_status);
if (adc_pt1000_check_error() & ADC_PT1000_WATCHDOG_ERROR) {
led_set(0, 1);
}
led_status ^= 0x1;
systick_wait_ms(150);
@@ -288,6 +293,43 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
(void)length;
(void)arguments;
DIR dir;
FRESULT res;
FILINFO fno;
res = f_opendir(&dir, "/");
if (res != FR_OK) {
shellmatta_printf(handle, "Filesystem inaccessible. Is an SD Card inserted?\r\n");
return SHELLMATTA_OK;
}
while (f_readdir(&dir, &fno) == FR_OK) {
if (fno.fname[0] == 0)
break;
shellmatta_printf(handle, "%c\t%s\r\n", (fno.fattrib & AM_DIR ? 'd' : 'f'), fno.fname);
}
f_closedir(&dir);
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
(void)handle;
(void)length;
(void)arguments;
NVIC_SystemReset();
return SHELLMATTA_BUSY;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@@ -298,7 +340,7 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[10] = {
static shellmatta_cmd_t cmd[12] = {
{
.cmd = "version",
.cmdAlias = "ver",
@@ -377,8 +419,25 @@ static shellmatta_cmd_t cmd[10] = {
.helpText = "Get current rotary encoder value",
.usageText = "",
.cmdFct = shell_cmd_rot,
.next = &cmd[10],
},
{
.cmd = "ls",
.cmdAlias = NULL,
.helpText = "List filesystem contents",
.usageText = "",
.cmdFct = shell_cmd_ls,
.next = &cmd[11],
},
{
.cmd = "reset",
.cmdAlias = NULL,
.helpText = "Reset controller",
.usageText = "Resets the controller",
.cmdFct = shell_cmd_reset,
.next = NULL,
}
};
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
@@ -394,6 +453,12 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
return handle;
}
void shell_print_motd(shellmatta_handle_t shell)
{
shellmatta_printf(shell, "\r\nShimatta 仕舞った Reflow Controller ready\r\n\r\n");
shell_cmd_ver(shell, NULL, 0UL);
shell_handle_input(shell, "\r\n", 2UL);
}
void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len)
{