Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Killer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Vytor Calixto
Killer
Commits
ea9354ec
Commit
ea9354ec
authored
10 years ago
by
Israel Barreto Sant'Anna
Browse files
Options
Downloads
Patches
Plain Diff
Adicionada funções getc e putc (uart_putc)
Signed-off-by:
Israel B. Sant'Anna
<
ibsa14@inf.ufpr.br
>
parent
956daa5d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cMIPS/tests/handlerUART.s
+4
-2
4 additions, 2 deletions
cMIPS/tests/handlerUART.s
cMIPS/tests/uart.c
+74
-41
74 additions, 41 deletions
cMIPS/tests/uart.c
with
78 additions
and
43 deletions
cMIPS/tests/handlerUART.s
+
4
−
2
View file @
ea9354ec
#--------------------------------------------------------------------------
#
interrupt
handler
for
UART
#.
set
HW_uart_control
,(
x_IO_BASE_ADDR
+
?
*
x_IO_ADDR_RANGE
)
.
comm
uart_control
56
#
TODO
setar
endere
ç
o
no
MIPS
p
/
acessar
no
C
.
global
uart_control
.
comm
uart_control
56
#
TODO
setar
endere
ç
o
no
MIPS
p
/
acessar
no
C
(?)
#
uart_control
[
0
]=
rx_queue
,
[
16
]=
rx_hd
,
[
20
]=
rx_tl
,
[
24
]=
nrx
,
#
[
28
]=
tx_queue
,
[
44
]=
tx_hd
,
[
48
]=
tx_tl
,
[
52
]=
ntx
RX
:
andi
$a0
,
$k1
,
UART_rx_irq
#
Is
this
reception
?
...
...
This diff is collapsed.
Click to expand it.
cMIPS/tests/uart.c
+
74
−
41
View file @
ea9354ec
...
...
@@ -55,7 +55,7 @@ int probetx(void); // retorna ntx
int
iostat
(
void
);
// retorna inteiro com status no byte menos sign
void
ioctl
(
int
);
// escreve byte menos sign no reg de controle
char
getc
(
void
);
// retorna caractere na fila, decrementa nrx
//void
putc(char); // insere caractere na fila, decrementa ntx
int
uart_
putc
(
char
);
// insere caractere na fila, decrementa ntx
int
wrtc
(
char
);
// escreve caractere diretamente em txreg
extern
UartControl
uart_control
;
...
...
@@ -75,5 +75,38 @@ int main(void){
ctrl
.
speed
=
1
;
// operate at 1/2 of the highest data rate
uart
->
cs
.
ctl
=
ctrl
;
char
c
;
while
((
c
=
getc
())
!=
'\0'
)
uart_putc
(
c
);
return
0
;
}
char
getc
(){
char
c
;
if
(
uart_control
.
nrx
>
0
){
c
=
uart_control
.
rx_queue
[
uart_control
.
rx_hd
];
uart_control
.
rx_hd
=
(
uart_control
.
rx_hd
+
1
)
%
16
;
disableInterr
();
uart_control
.
nrx
--
;
enableInterr
();
}
else
{
c
=
-
1
;
}
return
c
;
}
int
uart_putc
(
char
c
){
int
sent
;
if
(
uart_control
.
ntx
>
0
){
uart_control
.
tx_queue
[
uart_control
.
tx_tl
]
=
c
;
uart_control
.
tx_tl
=
(
uart_control
.
tx_tl
+
1
)
%
16
;
disableInterr
();
uart_control
.
ntx
--
;
enableInterr
();
sent
=
1
;
}
else
{
sent
=
0
;
}
return
sent
;
}
\ No newline at end of file
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