Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cMIPS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
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
Strozzi
cMIPS
Commits
ecb1da7c
Commit
ecb1da7c
authored
9 years ago
by
Jedian
Browse files
Options
Downloads
Patches
Plain Diff
Lindo e funcionando, mas instavel como sempre
Signed-off-by:
Jedian
<
jmb15@c3sl.ufpr.br
>
parent
d1782a3d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cMIPS/tests/jedidafu.c
+28
-34
28 additions, 34 deletions
cMIPS/tests/jedidafu.c
with
28 additions
and
34 deletions
cMIPS/tests/jedidafu.c
+
28
−
34
View file @
ecb1da7c
...
...
@@ -128,39 +128,29 @@ int int2hex (char *c, int i) {
return
j
-
1
;
}
int
main
(
void
)
{
// receive a string through the UART serial interface
int
i
,
j
;
// and responds with the i-eth hex-based fibonacci sequence number
volatile
int
state
=
0
;
volatile
Tstatus
status
;
char
filona
[
145
],
c
;
int
hdona
=
0
;
int
tlona
=
0
;
int
filonx
=
0
;
int
valfib
,
qt
,
rxz
,
q
;
int
fim
=
0
;
int
hdona
=
0
;
// head of the big queue
int
tlona
=
0
;
// tail of the big queue
int
filonx
=
0
;
// store the number of received integers to be processed
int
valfib
,
qt
,
rxz
,
q
;
// auxiliar variables
char
p
[
15
];
Tcontrol
ctrl
;
uart
=
(
void
*
)
IO_UART_ADDR
;
// bottom of UART address range
i
=
-
1
;
Ud
.
ntx
=
16
;
Ud
.
ntx
=
16
;
// initializing number of empty spaces in tx queue
ioctl
(
ctrl_util
(
2
,
1
,
1
,
1
));
// Speed = 2, intRX = 1, intTX = 1, rts = 1
do
{
state
++
;
// se tirar fode (b520 vira 15)
while
(
!
proberx
())
to_stdout
(
'-'
);
//i = 1 - i;
//to_stdout('\0');
// es
while
((
c
=
Getc
())
!=
-
1
){
state
++
;
// state is a volatile variable just for optimize blocking
while
(
!
proberx
())
to_stdout
(
'-'
);
// wait until first reception
while
((
c
=
Getc
())
!=
-
1
){
// dump the reception queue to the big queue
filona
[
tlona
]
=
c
;
// se tirar fode (b520 vira 15)
//to_stdout('*');
// cmips_delay(1);
//to_stdout('\0');
// es
tlona
++
;
tlona
%=
145
;
if
(
c
==
'\n'
){
...
...
@@ -168,11 +158,12 @@ int main(void) { // receive a string through the UART serial interface
filona
[
tlona
]
=
10
;
}
}
while
(
filonx
>
0
){
qt
=
Strlen
(
filona
+
hdona
);
valfib
=
hex2int
(
qt
,
(
filona
+
hdona
));
if
(
valfib
!=
-
1
)
valfib
=
buf
[
valfib
];
if
(
valfib
!=
-
1
)
// if is a valid value (lower than 2c and bigger or equal to 0)
valfib
=
buf
[
valfib
];
// if not valid, UART receives and prints ffffffff
hdona
+=
qt
+
1
;
hdona
%=
145
;
qt
=
int2hex
(
p
,
valfib
);
...
...
@@ -180,6 +171,7 @@ int main(void) { // receive a string through the UART serial interface
do
{
j
++
;
while
(((
rxz
=
proberx
())
<
10
)
&&
!
(
q
=
Putc
(
p
[
j
])));
while
((
c
=
Getc
())
!=
-
1
){
filona
[
tlona
]
=
c
;
tlona
++
;
...
...
@@ -189,15 +181,17 @@ int main(void) { // receive a string through the UART serial interface
filona
[
tlona
]
=
10
;
}
}
if
(
!
q
)
j
--
;
}
while
(
p
[
j
]
!=
0
);
filonx
--
;
if
(
!
filonx
)
return
state
;
}
}
while
(
state
);
}
while
(
state
<
200
);
return
state
;
...
...
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