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
21ce4632
Verified
Commit
21ce4632
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: added allow slave flag
parent
6294210a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!23
Support for serial data transfer 🔌
Pipeline
#2505
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/devices/printer.rs
+4
-0
4 additions, 0 deletions
src/devices/printer.rs
src/devices/stdout.rs
+4
-0
4 additions, 0 deletions
src/devices/stdout.rs
src/serial.rs
+17
-5
17 additions, 5 deletions
src/serial.rs
with
25 additions
and
5 deletions
src/devices/printer.rs
+
4
−
0
View file @
21ce4632
...
@@ -246,6 +246,10 @@ impl SerialDevice for PrinterDevice {
...
@@ -246,6 +246,10 @@ impl SerialDevice for PrinterDevice {
self
.state
=
PrinterState
::
from_u8
(
self
.state
as
u8
+
1
);
self
.state
=
PrinterState
::
from_u8
(
self
.state
as
u8
+
1
);
}
}
}
}
fn
allow_slave
(
&
self
)
->
bool
{
false
}
}
}
impl
Default
for
PrinterDevice
{
impl
Default
for
PrinterDevice
{
...
...
This diff is collapsed.
Click to expand it.
src/devices/stdout.rs
+
4
−
0
View file @
21ce4632
...
@@ -23,6 +23,10 @@ impl SerialDevice for StdoutDevice {
...
@@ -23,6 +23,10 @@ impl SerialDevice for StdoutDevice {
stdout
()
.flush
()
.unwrap
();
stdout
()
.flush
()
.unwrap
();
}
}
}
}
fn
allow_slave
(
&
self
)
->
bool
{
false
}
}
}
impl
Default
for
StdoutDevice
{
impl
Default
for
StdoutDevice
{
...
...
This diff is collapsed.
Click to expand it.
src/serial.rs
+
17
−
5
View file @
21ce4632
...
@@ -3,6 +3,11 @@ use crate::warnln;
...
@@ -3,6 +3,11 @@ use crate::warnln;
pub
trait
SerialDevice
{
pub
trait
SerialDevice
{
fn
send
(
&
mut
self
)
->
u8
;
fn
send
(
&
mut
self
)
->
u8
;
fn
receive
(
&
mut
self
,
byte
:
u8
);
fn
receive
(
&
mut
self
,
byte
:
u8
);
/// Whether the serial device "driver" supports slave mode
/// simulating an external clock source. Or if instead the
/// clock should always be generated by the running device.
fn
allow_slave
(
&
self
)
->
bool
;
}
}
pub
struct
Serial
{
pub
struct
Serial
{
...
@@ -89,15 +94,18 @@ impl Serial {
...
@@ -89,15 +94,18 @@ impl Serial {
self
.clock_speed
=
value
&
0x02
==
0x02
;
self
.clock_speed
=
value
&
0x02
==
0x02
;
self
.transferring
=
value
&
0x80
==
0x80
;
self
.transferring
=
value
&
0x80
==
0x80
;
// @TODO: THIS SEEMS LIKE A HACK, we'll need to check with
// in case the clock is meant to be set by the attached device
// the device driver how to handle no communication and receive
// and the current Game Boy is meant to be running in slave mode
// we must simulate no cable communication
// then checks if the attached device "driver" allows clock set
if
self
.transferring
&&
!
self
.shift_clock
{
// by external device and if not then ignores the transfer request
// by immediately disabling the transferring flag
if
!
self
.shift_clock
&&
!
self
.device
.allow_slave
()
{
self
.transferring
=
false
;
self
.transferring
=
false
;
}
}
// in case a transfer of byte has been requested and
// in case a transfer of byte has been requested and
// this is the then we need to start the transfer setup
// this is the then we need to start the transfer setup
else
if
self
.transferring
{
if
self
.transferring
{
// @TODO: if the GBC mode exists there should
// @TODO: if the GBC mode exists there should
// be special check logic here
// be special check logic here
//self.length = if self.gb.is_cgb() && self.clock_speed { 16 } else { 512 };
//self.length = if self.gb.is_cgb() && self.clock_speed { 16 } else { 512 };
...
@@ -189,6 +197,10 @@ impl SerialDevice for NullDevice {
...
@@ -189,6 +197,10 @@ impl SerialDevice for NullDevice {
}
}
fn
receive
(
&
mut
self
,
_
:
u8
)
{}
fn
receive
(
&
mut
self
,
_
:
u8
)
{}
fn
allow_slave
(
&
self
)
->
bool
{
false
}
}
}
impl
Default
for
NullDevice
{
impl
Default
for
NullDevice
{
...
...
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