mirror of
https://github.com/ariejan/i6502.git
synced 2024-06-24 00:29:26 +00:00
Add ACIA Reset()
This commit is contained in:
parent
90e248e745
commit
856ff00573
50
acia6551.go
50
acia6551.go
|
@ -1,22 +1,62 @@
|
||||||
package i6502
|
package i6502
|
||||||
|
|
||||||
|
const (
|
||||||
|
aciaData = iota
|
||||||
|
aciaStatus
|
||||||
|
aciaCommand
|
||||||
|
aciaControl
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ACIA 6551 Serial IO
|
ACIA 6551 Serial IO
|
||||||
*/
|
*/
|
||||||
type Acia6551 struct {
|
type Acia6551 struct {
|
||||||
rx chan byte // Reading (Acia Input) line
|
Rx chan byte // Reading (Acia Input) line
|
||||||
tx chan byte // Transmitting (Acia Output) line
|
Tx chan byte // Transmitting (Acia Output) line
|
||||||
|
|
||||||
|
rxData byte
|
||||||
|
txData byte
|
||||||
|
commandData byte
|
||||||
|
controlData byte
|
||||||
|
|
||||||
|
rxFull bool
|
||||||
|
txEmpty bool
|
||||||
|
|
||||||
|
rxIrqEnabled bool
|
||||||
|
txIrqEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAcia6551(rx chan byte, tx chan byte) (*Acia6551, error) {
|
func NewAcia6551(rx chan byte, tx chan byte) (*Acia6551, error) {
|
||||||
return &Acia6551{tx: tx, rx: rx}, nil
|
acia := &Acia6551{Tx: tx, Rx: rx}
|
||||||
|
acia.Reset()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// Handle rx data channel
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// Handle tx data channel
|
||||||
|
}()
|
||||||
|
|
||||||
|
return acia, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Acia6551) Size() uint16 {
|
func (a *Acia6551) Size() uint16 {
|
||||||
// We have a only 4 addresses, RX, TX, Command and Control
|
// We have a only 4 addresses, Data, Status, Command and Control
|
||||||
return 0x04
|
return 0x04
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Acia6551) Reset() {
|
||||||
|
a.rxData = 0
|
||||||
|
a.rxFull = false
|
||||||
|
|
||||||
|
a.txData = 0
|
||||||
|
a.txEmpty = true
|
||||||
|
|
||||||
|
a.rxIrqEnabled = false
|
||||||
|
a.txIrqEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func (r *Rom) Read(address uint16) byte {
|
func (r *Rom) Read(address uint16) byte {
|
||||||
return r.data[address]
|
return r.data[address]
|
||||||
|
|
|
@ -5,6 +5,14 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func AciaSubject() *Acia6551 {
|
||||||
|
tx := make(chan byte)
|
||||||
|
rx := make(chan byte)
|
||||||
|
acia, _ := NewAcia6551(rx, tx)
|
||||||
|
|
||||||
|
return acia
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewAcia6551(t *testing.T) {
|
func TestNewAcia6551(t *testing.T) {
|
||||||
tx := make(chan byte)
|
tx := make(chan byte)
|
||||||
rx := make(chan byte)
|
rx := make(chan byte)
|
||||||
|
@ -13,3 +21,20 @@ func TestNewAcia6551(t *testing.T) {
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, 0x4, acia.Size())
|
assert.Equal(t, 0x4, acia.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAciaReset(t *testing.T) {
|
||||||
|
a := AciaSubject()
|
||||||
|
a.Reset()
|
||||||
|
|
||||||
|
assert.Equal(t, a.txData, 0)
|
||||||
|
assert.True(t, a.txEmpty)
|
||||||
|
|
||||||
|
assert.Equal(t, a.rxData, 0)
|
||||||
|
assert.False(t, a.rxFull)
|
||||||
|
|
||||||
|
assert.False(t, a.txIrqEnabled)
|
||||||
|
assert.False(t, a.rxIrqEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAciaCommand(t *testing.T) {
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user