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
a241a6ad
Commit
a241a6ad
authored
10 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Plain Diff
Transmission working
Merge branch 'transmission' into 'master' See merge request
!1
parents
2a1c0925
1cb73496
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cMIPS/serial.inp
+2
-1
2 additions, 1 deletion
cMIPS/serial.inp
cMIPS/tests/handlerUART.s
+19
-2
19 additions, 2 deletions
cMIPS/tests/handlerUART.s
cMIPS/tests/uart.c
+43
-37
43 additions, 37 deletions
cMIPS/tests/uart.c
with
64 additions
and
40 deletions
cMIPS/serial.inp
+
2
−
1
View file @
a241a6ad
0
00
11
ffffffff
7C2
This diff is collapsed.
Click to expand it.
cMIPS/tests/handlerUART.s
+
19
−
2
View file @
a241a6ad
...
...
@@ -35,6 +35,11 @@ RX:
#
ori
$a0
,
$a0
,
%
lo
(
x_IO_BASE_ADDR
)
#
sw
$k1
,
0
(
$a0
)
#
Print
for
debug
lw
$k1
,
0
(
$a1
)
j
RX
nop
TX
:
...
...
@@ -46,6 +51,10 @@ TX:
lw
$a1
,
52
(
$a0
)
#
Read
ntx
#
lui
$k1
,
%
hi
(
x_IO_BASE_ADDR
)
#
ori
$k1
,
$k1
,
%
lo
(
x_IO_BASE_ADDR
)
#
sw
$a1
,
0
(
$k1
)
#
Print
for
debug
addiu
$k1
,
$zero
,
16
slt
$k1
,
$a1
,
$k1
#
If
ntx
<
16
there
's something on the queue
beq
$k1
,
$zero
,
END
...
...
@@ -59,13 +68,21 @@ TX:
andi
$k1
,
$k1
,
15
#
It
's a circular queue so: (tx_hd+1)%16
sw
$k1
,
40
(
$a0
)
#
Save
tx_hd
addiu
$a1
,
$a1
,
24
#
tx_hd
position
on
tx_queue
#
addiu
$a1
,
$a1
,
24
#
tx_hd
position
on
tx_queue
add
$a0
,
$a1
,
$a0
#
tx_queue
head
address
lbu
$a1
,
0
(
$a0
)
#
Read
TX_queue
head
lbu
$a1
,
24
(
$a0
)
#
Read
TX_queue
head
lui
$a0
,
%
hi
(
HW_uart_addr
)
ori
$a0
,
$a0
,
%
lo
(
HW_uart_addr
)
sb
$a1
,
4
(
$a0
)
#
Put
data
on
UART
#
lui
$a0
,
%
hi
(
x_IO_BASE_ADDR
)
#
ori
$a0
,
$a0
,
%
lo
(
x_IO_BASE_ADDR
)
#
sw
$a1
,
0
(
$a0
)
#
Print
for
debug
lw
$k1
,
0
(
$a0
)
j
RX
nop
END
:
This diff is collapsed.
Click to expand it.
cMIPS/tests/uart.c
+
43
−
37
View file @
a241a6ad
...
...
@@ -56,7 +56,7 @@ int probetx(void); // returns ntx
int
iostat
(
void
);
// returns integer with status at lsb
void
ioctl
(
int
);
// write lsb in control register
char
getc
(
void
);
// returns char in queue, decrements nrx
int
Putc
(
char
);
// inserts char in queue, decrements ntx
void
Putc
(
char
);
// inserts char in queue, decrements ntx
int
ctoi
(
char
);
// converts a character to an integer
void
initUd
();
...
...
@@ -65,41 +65,51 @@ extern UARTDriver Ud;
volatile
Tserial
*
uart
;
int
main
(){
int
i
;
volatile
int
state
;
// tell GCC not to optimize away code
volatile
Tstatus
status
;
volatile
char
c
;
uart
=
(
void
*
)
IO_UART_ADDR
;
// bottom of UART address range
Tcontrol
ctrl
;
ctrl
.
ign
=
0
;
ctrl
.
intTX
=
0
;
ctrl
.
intTX
=
1
;
ctrl
.
intRX
=
1
;
ctrl
.
speed
=
2
;
// operate at 1/2 of the highest data rate
uart
->
cs
.
ctl
=
ctrl
;
initUd
();
volatile
char
c
;
c
=
getc
();
while
(
c
!=
'\0'
)
{
while
((
c
=
getc
())
!=
'\0'
)
{
if
(
c
!=
EOF
)
{
int
n
=
0
;
while
(
c
!=
'\n'
&&
c
!=
'\0'
)
{
int
h
=
ctoi
(
c
);
if
(
h
!=
EOF
)
{
n
=
n
*
16
+
h
;
Putc
(
c
);
}
c
=
getc
();
}
//If it's a negative hex make it a negative integer as well
n
=
0x8000
&
n
?
(
int
)(
0x7FFF
&
n
)
-
0x8000
:
n
;
print
(
n
)
;
//while(!Putc(c)); // Wait till there's space on queue
}
c
=
getc
();
if
(
Ud
.
ntx
<
16
){
disableInterr
()
;
uart
->
d
.
tx
=
Ud
.
tx_q
[
Ud
.
tx_hd
]
;
Ud
.
tx_hd
=
(
Ud
.
tx_hd
+
1
)
%
16
;
Ud
.
ntx
++
;
enableInterr
();
}
Putc
(
c
);
// Sends EOF
int
cont
;
for
(
cont
=
0
;
cont
<
1000
;
cont
++
);
//Wait for the remote uart
// while((c = getc()) != '\0') {
// if(c != EOF) {
// // while(!Putc(c)); // Wait till there's space on queue
// int n = 0;
// while(c != '\n' && c != '\0') {
// int h = ctoi(c);
// if(h != EOF) {
// n = n*16 + h;
// }
// c = getc();
// }
// //If it's a negative hex make it a negative integer as well
// n = 0x8000&n ? (int)(0x7FFF&n)-0x8000 : n;
// // print(n);
// }
// }
// Putc(c); // Sends EOF
return
0
;
}
...
...
@@ -114,37 +124,33 @@ void initUd(){
}
char
getc
(){
char
c
;
char
c
=
EOF
;
if
(
Ud
.
nrx
>
0
){
disableInterr
();
c
=
Ud
.
rx_q
[
Ud
.
rx_hd
];
Ud
.
rx_hd
=
(
Ud
.
rx_hd
+
1
)
%
16
;
Ud
.
nrx
--
;
enableInterr
();
}
else
{
c
=
EOF
;
}
return
c
;
}
int
Putc
(
char
c
){
int
sent
;
if
(
Ud
.
ntx
==
16
)
{
uart
->
d
.
tx
=
c
;
return
1
;
}
void
Putc
(
char
c
){
if
(
Ud
.
ntx
>
0
){
disableInterr
();
Ud
.
tx_q
[
Ud
.
tx_tl
]
=
c
;
Ud
.
tx_tl
=
(
Ud
.
tx_tl
+
1
)
%
16
;
Ud
.
ntx
--
;
enableInterr
();
sent
=
1
;
}
else
{
sent
=
0
;
while
(
!
(
TXempty
&
uart
->
cs
.
stat
.
s
));
disableInterr
();
uart
->
d
.
tx
=
Ud
.
tx_q
[
Ud
.
tx_hd
];
Ud
.
tx_hd
=
(
Ud
.
tx_hd
+
1
)
%
16
;
Ud
.
ntx
++
;
enableInterr
();
Putc
(
c
);
}
return
sent
;
}
int
proberx
(){
...
...
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