Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G4_mpu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC2
pro
G4_mpu
Commits
6fae3c24
Commit
6fae3c24
authored
1 year ago
by
brian
Browse files
Options
Downloads
Patches
Plain Diff
feat: full functionning UART
sudo minicom -D /dev/ttyUSB0 -b 9600 for local echo CTRL-A, e
parent
9efa67a8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mpu_user_console_etu.c
+5
-5
5 additions, 5 deletions
mpu_user_console_etu.c
user_cmd.c
+8
-9
8 additions, 9 deletions
user_cmd.c
user_cmd.h
+2
-1
2 additions, 1 deletion
user_cmd.h
with
15 additions
and
15 deletions
mpu_user_console_etu.c
+
5
−
5
View file @
6fae3c24
...
...
@@ -66,12 +66,12 @@ void ask_user_input(void) {
char
switch_cmd
[]
=
"switch"
;
char
status_cmd
[]
=
"status"
;
PRINT
(
"(%s) Would you like to `switch` or display `status` errors : "
,
is_supervisor_mode
?
"Supervisor"
:
"User"
)
;
PRINT
(
"
\r\n
(%s) Would you like to `switch` or display `status` errors : "
,
is_supervisor_mode
?
"Supervisor"
:
"User"
);
// fflush(stdin);
// fscanf(stdin, "%s", buff);
uart_scanf
(
buff
);
PRINT
(
"
\r\n
"
);
if
(
strncmp
(
buff
,
switch_cmd
,
strlen
(
switch_cmd
))
==
0
)
{
// permute through svc depending on flag
...
...
@@ -81,14 +81,14 @@ void ask_user_input(void) {
if
(
strncmp
(
buff
,
status_cmd
,
strlen
(
status_cmd
))
==
0
)
{
if
(
idx_error
==
0
)
{
PRINT
(
"No errors have occurred yet
\n
"
)
PRINT
(
"No errors have occurred yet
\
r\
n
"
)
;
return
;
}
for
(
int
i
=
0
;
i
<
idx_error
;
i
++
)
{
if
(
i
<
BUF_SIZE
)
{
PRINT
(
"Address that shat the bed : 0x%x
\t
Error code : 0x%x
\n
"
,
PRINT
(
"Address that shat the bed : 0x%x
\t
Error code : 0x%x
\
r\
n
"
,
arr_addr
[
i
],
arr_err_code
[
i
])
;
}
...
...
This diff is collapsed.
Click to expand it.
user_cmd.c
+
8
−
9
View file @
6fae3c24
...
...
@@ -31,15 +31,16 @@ void SVC_Handler() {
void
uart_scanf
(
char
*
buff
)
{
char
user_input
[
USER_INPUT_SIZE
]
=
{
0
};
size_t
idx
=
1
;
char
current
=
0
;
size_t
idx
=
0
;
while
(
user_input
[
idx
-
1
]
!=
'\
n
'
)
{
idx
--
;
user_input
[
idx
]
=
uart0_rec_byte_ref
()
;
while
(
current
!=
'\
r
'
)
{
current
=
uart0_rec_byte_ref
()
;
user_input
[
idx
]
=
current
;
idx
++
;
}
user_input
[
idx
-
1
]
=
'\0'
;
user_input
[
idx
-
1
]
=
'\0'
;
memcpy
(
buff
,
user_input
,
USER_INPUT_SIZE
);
}
...
...
@@ -49,10 +50,8 @@ void exec_user_read_write() {
int
i
=
0
,
coma_nb
=
0
,
value_idx
;
unsigned
addr
,
value
;
PRINT
(
"Write an hexadecimal address for reading <addr> or <addr>,<value> for writing (%s):
\n
"
,
is_supervisor_mode
?
"Supervisor"
:
"User"
)
;
PRINT
(
"Write an hexadecimal address for reading <addr> or <addr>,<value> for writing (%s):
\r\n
"
,
is_supervisor_mode
?
"Supervisor"
:
"User"
);
// fflush(stdin);
// fscanf(stdin, "%s", str);
...
...
This diff is collapsed.
Click to expand it.
user_cmd.h
+
2
−
1
View file @
6fae3c24
...
...
@@ -18,7 +18,8 @@ static char uart_stdout[UART_STDOUT_SIZE] = { 0 };
#define uart_printf(...) \
snprintf
(
uart_stdout
,
UART_STDOUT_SIZE
,
__VA_ARGS__
);
\
uart0_send_ref
((
uint8_t
*
)
uart_stdout
,
UART_STDOUT_SIZE
);
uart0_send_ref
((
uint8_t
*
)
uart_stdout
,
UART_STDOUT_SIZE
);
\
memset
(
uart_stdout
,
0
,
UART_STDOUT_SIZE
);
#if !UART_ENABLE
#define PRINT printf
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment