Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
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
Roberto Hexsel
cMIPS
Commits
968857b3
Commit
968857b3
authored
8 years ago
by
Roberto Hexsel
Browse files
Options
Downloads
Patches
Plain Diff
UART now has an independent register for clearing individual IRQs -- files missing
parent
460d2a4b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cMIPS/tests/uart_defs.c
+13
-7
13 additions, 7 deletions
cMIPS/tests/uart_defs.c
cMIPS/tests/uart_irx.c
+2
-2
2 additions, 2 deletions
cMIPS/tests/uart_irx.c
cMIPS/tests/uartrx.c
+9
-8
9 additions, 8 deletions
cMIPS/tests/uartrx.c
cMIPS/tests/uarttx.c
+2
-2
2 additions, 2 deletions
cMIPS/tests/uarttx.c
with
26 additions
and
19 deletions
cMIPS/tests/uart_defs.c
+
13
−
7
View file @
968857b3
...
...
@@ -8,6 +8,15 @@ typedef struct control { // control register fields (uses only ls byte)
speed
:
3
;
// 4,8,16... {tx,rx}clock data rates (bits 0..2)
}
Tcontrol
;
typedef
struct
interr
{
// interrupt clear bits (uses only ls byte)
unsigned
int
ign
:
24
,
// ignore uppermost 3 bytes
rts
:
1
,
// Request to Send output (bit 7)
ign2
:
2
,
// bits 6,5 ignored
clrTX
:
1
,
// interrupt on TX buffer empty (bit 4)
clrRX
:
1
,
// interrupt on RX buffer full (bit 3)
ign3
:
3
;
// bits 2..0 ignored
}
Tinterr
;
typedef
struct
status
{
// status register fields (uses only ls byte)
unsigned
int
ign
:
24
,
// ignore uppermost 3 bytes
cts
:
1
,
// Clear To Send input=1 (bit 7)
...
...
@@ -20,19 +29,16 @@ typedef struct status { // status register fields (uses only ls byte)
overun
:
1
;
// overun error (bit 0)
}
Tstatus
;
typedef
union
ctlStat
{
// control + status on same address
Tcontrol
ctl
;
// write-only
Tstatus
stat
;
// read-only
}
TctlStat
;
typedef
union
data
{
// data registers on same address
int
tx
;
// write-only
int
rx
;
// read-only
}
Tdata
;
typedef
struct
serial
{
TctlStat
cs
;
// address is (int *)IO_UART_ADDR
Tdata
d
;
// address is (int *)(IO_UART_ADDR+1)
Tcontrol
ctl
;
// read-writ, address is (int *)IO_UART_ADDR
Tstatus
stat
;
// read-only, address is (int *)(IO_UART_ADDR+1)
Tinterr
interr
;
// write-only, address is (int *)(IO_UART_ADDR+2)
Tdata
d
;
// read-write, address is (int *)(IO_UART_ADDR+3)
}
Tserial
;
...
...
This diff is collapsed.
Click to expand it.
cMIPS/tests/uart_irx.c
+
2
−
2
View file @
968857b3
...
...
@@ -39,7 +39,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
0
;
ctrl
.
speed
=
SPEED
;
uart
->
cs
.
ctl
=
ctrl
;
// initizlize UART
uart
->
ctl
=
ctrl
;
// initizlize UART
// handler sets flag=[U_FLAg] to 1 after new character is received;
// this program resets the flag on fetching a new character from buffer
...
...
@@ -50,7 +50,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
1
;
// do generate interrupts on RXbuffer full
ctrl
.
speed
=
SPEED
;
// operate at 1/4 of the highest data rate
uart
->
cs
.
ctl
=
ctrl
;
uart
->
ctl
=
ctrl
;
do
{
while
(
(
c
=
(
char
)
bfr
[
U_FLAG
])
==
0
)
// check flag in Ud[]
...
...
This diff is collapsed.
Click to expand it.
cMIPS/tests/uartrx.c
+
9
−
8
View file @
968857b3
...
...
@@ -35,7 +35,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
0
;
ctrl
.
speed
=
SPEED
;
// operate at the second highest data rate
uart
->
cs
.
ctl
=
ctrl
;
uart
->
ctl
=
ctrl
;
i
=
-
1
;
...
...
@@ -45,19 +45,20 @@ int main(void) { // receive a string through the UART serial interface
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
0
;
ctrl
.
speed
=
SPEED
;
// operate at the second highest data rate
uart
->
cs
.
ctl
=
ctrl
;
uart
->
ctl
=
ctrl
;
do
{
i
=
i
+
1
;
while
(
(
state
=
(
int
)
uart
->
cs
.
stat
.
rxFull
)
==
0
)
while
(
(
state
=
(
int
)
uart
->
stat
.
rxFull
)
==
0
)
delay_cycle
(
1
);
// just do something
s
[
i
]
=
(
char
)
uart
->
d
.
rx
;
if
(
s
[
i
]
!=
EOT
)
if
(
s
[
i
]
!=
EOT
)
{
to_stdout
(
s
[
i
]
);
// and print new char
else
to_stdout
(
'\n'
);
// and print new-line
}
else
{
to_stdout
(
'\n'
);
// print new-line
to_stdout
(
EOT
);
// and signal End Of Transmission
}
}
while
(
s
[
i
]
!=
EOT
);
return
(
state
);
...
...
This diff is collapsed.
Click to expand it.
cMIPS/tests/uarttx.c
+
2
−
2
View file @
968857b3
...
...
@@ -62,13 +62,13 @@ int main(void) { // send a string through the UART serial interface
ctrl
.
ign2
=
0
;
ctrl
.
ign
=
0
;
ctrl
.
rts
=
0
;
// make RTS=0 so RemoteUnit won't transmit, just receive
uart
->
cs
.
ctl
=
ctrl
;
uart
->
ctl
=
ctrl
;
i
=
-
1
;
do
{
i
=
i
+
1
;
while
(
(
state
=
(
int
)
uart
->
cs
.
stat
.
txEmpty
)
==
0
)
while
(
(
state
=
(
int
)
uart
->
stat
.
txEmpty
)
==
0
)
delay_cycle
(
1
);
// do something
uart
->
d
.
tx
=
(
int
)
s
[
i
];
...
...
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