Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
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
Container 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
João Magalhães
boytacean
Commits
c14ddd7c
Verified
Commit
c14ddd7c
authored
7 months ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: moved serial regs to constants
parent
7a06d01a
No related branches found
No related tags found
No related merge requests found
Pipeline
#4672
passed
7 months ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/consts.rs
+4
-0
4 additions, 0 deletions
src/consts.rs
src/serial.rs
+9
-5
9 additions, 5 deletions
src/serial.rs
with
13 additions
and
5 deletions
src/consts.rs
+
4
−
0
View file @
c14ddd7c
...
@@ -27,3 +27,7 @@ pub const HDMA2_ADDR: u16 = 0xff52;
...
@@ -27,3 +27,7 @@ pub const HDMA2_ADDR: u16 = 0xff52;
pub
const
HDMA3_ADDR
:
u16
=
0xff53
;
pub
const
HDMA3_ADDR
:
u16
=
0xff53
;
pub
const
HDMA4_ADDR
:
u16
=
0xff54
;
pub
const
HDMA4_ADDR
:
u16
=
0xff54
;
pub
const
HDMA5_ADDR
:
u16
=
0xff55
;
pub
const
HDMA5_ADDR
:
u16
=
0xff55
;
// Serial registers
pub
const
SB_ADDR
:
u16
=
0xff01
;
pub
const
SC_ADDR
:
u16
=
0xff02
;
This diff is collapsed.
Click to expand it.
src/serial.rs
+
9
−
5
View file @
c14ddd7c
//! Serial transfer (Link Cable) functions and structures.
//! Serial transfer (Link Cable) functions and structures.
use
crate
::{
mmu
::
BusComponent
,
warnln
};
use
crate
::{
consts
::{
SB_ADDR
,
SC_ADDR
},
mmu
::
BusComponent
,
warnln
,
};
pub
trait
SerialDevice
{
pub
trait
SerialDevice
{
/// Sends a byte (u8) to the attached serial connection.
/// Sends a byte (u8) to the attached serial connection.
...
@@ -89,9 +93,9 @@ impl Serial {
...
@@ -89,9 +93,9 @@ impl Serial {
pub
fn
read
(
&
mut
self
,
addr
:
u16
)
->
u8
{
pub
fn
read
(
&
mut
self
,
addr
:
u16
)
->
u8
{
match
addr
{
match
addr
{
// 0xFF01 — SB: Serial transfer data
// 0xFF01 — SB: Serial transfer data
0xff01
=>
self
.data
,
SB_ADDR
=>
self
.data
,
// 0xFF02 — SC: Serial transfer control
// 0xFF02 — SC: Serial transfer control
0xff02
=>
SC_ADDR
=>
{
{
#[allow(clippy::bool_to_int_with_if)]
#[allow(clippy::bool_to_int_with_if)]
(
if
self
.shift_clock
{
0x01
}
else
{
0x00
}
(
if
self
.shift_clock
{
0x01
}
else
{
0x00
}
...
@@ -108,9 +112,9 @@ impl Serial {
...
@@ -108,9 +112,9 @@ impl Serial {
pub
fn
write
(
&
mut
self
,
addr
:
u16
,
value
:
u8
)
{
pub
fn
write
(
&
mut
self
,
addr
:
u16
,
value
:
u8
)
{
match
addr
{
match
addr
{
// 0xFF01 — SB: Serial transfer data
// 0xFF01 — SB: Serial transfer data
0xff01
=>
self
.data
=
value
,
SB_ADDR
=>
self
.data
=
value
,
// 0xFF02 — SC: Serial transfer control
// 0xFF02 — SC: Serial transfer control
0xff02
=>
{
SC_ADDR
=>
{
self
.shift_clock
=
value
&
0x01
==
0x01
;
self
.shift_clock
=
value
&
0x01
==
0x01
;
self
.clock_speed
=
value
&
0x02
==
0x02
;
self
.clock_speed
=
value
&
0x02
==
0x02
;
self
.transferring
=
value
&
0x80
==
0x80
;
self
.transferring
=
value
&
0x80
==
0x80
;
...
...
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