Skip to content

Commit ef019fc

Browse files
author
Maksymilian Wojczuk
committed
Changed mode to user command
1 parent ef08379 commit ef019fc

File tree

9 files changed

+713
-43
lines changed

9 files changed

+713
-43
lines changed

Inc/communication/ansi.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#ifndef ANSI_H
2+
#define ANSI_H
3+
4+
// ANSI/VT100 Terminal Control Escape Sequences
5+
// taken from http://www.termsys.demon.co.uk/vtansi.htm
6+
//
7+
#define ANSI_RESET "\033[2;37;0m"
8+
#define ANSI_CURSOR_OFF "\033[?25l"
9+
#define ANSI_CURSOR_ON "\033[?25h"
10+
11+
#define ANSI_CLEAR "\033[2J"
12+
#define ANSI_ERASE_EOL "\033[K"
13+
#define ANSI_ERASE_SOL "\033[1K"
14+
#define ANSI_ERASE_LINE "\033[2K"
15+
#define ANSI_ERASE_DOWN "\033[J"
16+
#define ANSI_ERASE_UP "\033[1J"
17+
18+
#define ANSI_DEL "\033[P"
19+
#define ANSI_DELn(n) "\033[" #n "P"
20+
21+
#define ANSI_HOME "\033[H"
22+
#define ANSI_SCROLL_UP "\033M"
23+
#define ANSI_FREEZE(top, btm) "\033[" #top ";" #btm "r"
24+
#define ANSI_UNFREEZE "\033[r"
25+
#define ANSI_GOTO(x, y) "\033[" #y ";" #x "H"
26+
27+
#define ANSI_UP "\033[A"
28+
#define ANSI_DOWN "\033[B"
29+
#define ANSI_RIGHT "\033[C"
30+
#define ANSI_LEFT "\033[D"
31+
32+
#define ANSI_UPn(n) "\033[" #n "A"
33+
#define ANSI_DOWNn(n) "\033[" #n "B"
34+
#define ANSI_RIGHTn(n) "\033[" #n "C"
35+
#define ANSI_LEFTn(n) "\033[" #n "D"
36+
37+
#define ANSI_SAVE_CURSOR "\033[s"
38+
#define ANSI_RESTORE_CURSOR "\033[u"
39+
#define ANSI_SAVE_ALL "\033[7"
40+
#define ANSI_RESTORE_ALL "\033[8"
41+
42+
#define ANSI_ENABLE_INSERT "\033[4h"
43+
#define ANSI_DISABLE_INSERT "\033[4l"
44+
45+
#define ANSI_ENABLE_ECHO "\033[12l"
46+
#define ANSI_DISABLE_ECHO "\033[12h"
47+
48+
#define ANSI_NORMAL "\033[0m"
49+
#define ANSI_BOLD "\033[1m"
50+
#define ANSI_ITALICS "\033[3m"
51+
#define ANSI_UNDERLINE "\033[4m"
52+
#define ANSI_BLINK "\033[5m"
53+
#define ANSI_INVERSE "\033[7m"
54+
#define ANSI_STRIKE "\033[9m"
55+
#define ANSI_BOLD_OFF "\033[22m"
56+
#define ANSI_ITALICS_OFF "\033[23m"
57+
#define ANSI_UNDERLINE_OFF "\033[24m"
58+
#define ANSI_BLINK_OFF "\033[25m"
59+
#define ANSI_INVERSE_OFF "\033[27m"
60+
#define ANSI_STRIKE_OFF "\033[29m"
61+
62+
#define ANSI_FG_BLACK "\033[0;30m"
63+
#define ANSI_FG_RED "\033[0;31m"
64+
#define ANSI_FG_GREEN "\033[0;32m"
65+
#define ANSI_FG_ORANGE "\033[0;33m"
66+
#define ANSI_FG_BLUE "\033[0;34m"
67+
#define ANSI_FG_MAGENTA "\033[0;35m"
68+
#define ANSI_FG_CYAN "\033[0;36m"
69+
#define ANSI_FG_GRAY "\033[0;37m"
70+
#define ANSI_FG_DEFAULT "\033[0;39m"
71+
72+
#define ANSI_FG_DKGRAY "\033[1;30m"
73+
#define ANSI_FG_LTRED "\033[1;31m"
74+
#define ANSI_FG_LTGREEN "\033[1;32m"
75+
#define ANSI_FG_YELLOW "\033[1;33m"
76+
#define ANSI_FG_LTBLUE "\033[1;34m"
77+
#define ANSI_FG_LTMAGENTA "\033[1;35m"
78+
#define ANSI_FG_LTCYAN "\033[1;36m"
79+
#define ANSI_FG_WHITE "\033[1;37m"
80+
81+
#define ANSI_BG_BLACK "\033[0;40m"
82+
#define ANSI_BG_RED "\033[0;41m"
83+
#define ANSI_BG_GREEN "\033[0;42m"
84+
#define ANSI_BG_ORANGE "\033[0;43m"
85+
#define ANSI_BG_BLUE "\033[0;44m"
86+
#define ANSI_BG_MAGENTA "\033[0;45m"
87+
#define ANSI_BG_CYAN "\033[0;46m"
88+
#define ANSI_BG_GRAY "\033[0;47m"
89+
#define ANSI_BG_DEFAULT "\033[0;49m"
90+
91+
#define ANSI_BG_DKGRAY "\033[1;40m"
92+
#define ANSI_BG_LTRED "\033[1;41m"
93+
#define ANSI_BG_LTGREEN "\033[1;42m"
94+
#define ANSI_BG_YELLOW "\033[1;43m"
95+
#define ANSI_BG_LTBLUE "\033[1;44m"
96+
#define ANSI_BG_LTMAGENTA "\033[1;45m"
97+
#define ANSI_BG_LTCYAN "\033[1;46m"
98+
#define ANSI_BG_WHITE "\033[1;47m"
99+
100+
#endif

Inc/communication/dbgu.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* The MIT License (MIT)
3+
* Copyright (c) 2016 Robert Brzoza-Woch
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be
12+
* included in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#ifndef __DBGU_H__
23+
#define __DBGU_H__
24+
25+
#include <inttypes.h>
26+
#include "stm32f4xx_hal.h"
27+
#include "stm32f4xx_hal_uart.h"
28+
#include "ansi.h"
29+
30+
void debug_init(UART_HandleTypeDef* handler);
31+
void debug_chr(char chr);
32+
int debug_test(void);
33+
char debug_inkey(void);
34+
char debug_waitkey(void);
35+
void debug_ascii(uint8_t b);
36+
void debug_msg(const char *str);
37+
void debug_txt(const char *str);
38+
void debug_txt_limit(const char *str, uint8_t len);
39+
void debug_dump(void *address, uint16_t len);
40+
void debug_shdn(uint32_t shdn_on);
41+
42+
#endif
43+
44+

Inc/communication/debug_leds.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef __debugLed_H
2+
#define __debugLed_H
3+
4+
void BlinkGreen() {
5+
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET);
6+
osDelay(500);
7+
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_RESET);
8+
osDelay(500);
9+
}
10+
11+
void BlinkRed() {
12+
HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET);
13+
osDelay(500);
14+
HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_RESET);
15+
osDelay(500);
16+
}
17+
18+
void BlinkBlue() {
19+
HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_SET);
20+
osDelay(500);
21+
HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_RESET);
22+
osDelay(500);
23+
}
24+
25+
#endif

Inc/communication/term_io.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef TERM_IO_H_
2+
#define TERM_IO_H_
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
#include <stdint.h>
9+
#include "dbgu.h"
10+
11+
#define xgetc() (char)debug_waitkey()
12+
#define xavail() debug_test()
13+
14+
int xatoi (char**, long*);
15+
void xputc (char);
16+
void xputs (const char*);
17+
void xitoa (long, int, int);
18+
void xprintf (const char*, ...) __attribute__ ((format (__printf__, 1, 2)));
19+
void put_dump (const uint8_t*, uint32_t ofs, int cnt);
20+
void get_line (char*, int len);
21+
int get_line_r (char*, int len, int *idx);
22+
23+
#ifdef __cplusplus
24+
}
25+
#endif
26+
27+
#endif /* TERM_IO_H_ */

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ Src/main.c \
158158
Src/lwip.c \
159159
Src/ethernetif.c \
160160
Src/stm32f4xx_it.c \
161-
Src/stm32f4xx_hal_msp.c
161+
Src/stm32f4xx_hal_msp.c \
162+
Src/communication/dbgu.c \
163+
Src/communication/term_io.c
162164

163165
# ASM sources
164166
ASM_SOURCES = \
@@ -237,7 +239,8 @@ C_INCLUDES = \
237239
-IMiddlewares/Third_Party/LwIP/src/include/posix \
238240
-IMiddlewares/Third_Party/LwIP/src/include/posix/sys \
239241
-IMiddlewares/Third_Party/LwIP/system/arch \
240-
-IDrivers/CMSIS/Include
242+
-IDrivers/CMSIS/Include \
243+
-IInc/communication
241244

242245

243246
# compile gcc flags

0 commit comments

Comments
 (0)