Loading...
Searching...
No Matches
shell.h
Go to the documentation of this file.
1
5
6#ifndef _SHELL_H
7#define _SHELL_H
8
9#include "FreeRTOS.h"
10#include "stdbool.h"
11#include "stdint.h"
12#include "string.h"
13#include "task.h"
14
15#include "devices.h"
16#include "flash.h"
17#include "uart.h"
18
19#define SHELL_MAX_PROGRAMS 10
20#define SHELL_PROGRAM_NAME_LENGTH 20
21
22#define CMD_CLEAR "clear"
23
24extern uint32_t __shell_vector_start;
25extern uint32_t __shell_vector_end;
26extern Flash flash;
27extern UART usb;
28
29typedef struct ShellProgramHandle_t {
30 char name[SHELL_PROGRAM_NAME_LENGTH];
31 void (*exec)();
33
34typedef struct Shell {
35 UART usb;
36 Flash flash;
37 void (*help)(struct Shell *);
38 void (*run)(struct Shell *, uint8_t *);
39 void (*runTask)(struct Shell *, uint8_t *);
40 bool (*clear)(struct Shell *);
41 TaskHandle_t taskHandle;
42 ShellProgramHandle_t programHandles[SHELL_MAX_PROGRAMS];
43} Shell;
44
45typedef struct ShellTaskParams {
46 Shell *shell;
47 uint8_t *str;
49
50int Shell_init(Shell *);
51void Shell_help(Shell *);
52void Shell_runTask(Shell *, uint8_t *);
53void Shell_run(Shell *, uint8_t *);
54bool Shell_clear(Shell *);
55
56#endif
Struct definition for UART interface.
Definition uart.h:53
int Shell_init(Shell *)
Initializes the shell, registering programs from shell vector.
Definition shell.c:45
void Shell_help(Shell *)
Displays available shell commands.
Definition shell.c:80
bool Shell_clear(Shell *)
Send clear sequence to host terminal.
Definition shell.c:159
void Shell_runTask(Shell *, uint8_t *)
Creates a task to run a shell program.
Definition shell.c:134
void Shell_run(Shell *, uint8_t *)
Executes a shell program by name.
Definition shell.c:104
Definition shell.h:34
Definition flash.h:30