Add ACIA Reset()

This commit is contained in:
Ariejan de Vroom 2014-08-17 17:18:14 +02:00
parent 90e248e745
commit 856ff00573
2 changed files with 70 additions and 5 deletions

View File

@ -1,22 +1,62 @@
package i6502
const (
aciaData = iota
aciaStatus
aciaCommand
aciaControl
)
/*
ACIA 6551 Serial IO
*/
type Acia6551 struct {
rx chan byte // Reading (Acia Input) line
tx chan byte // Transmitting (Acia Output) line
Rx chan byte // Reading (Acia Input) 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) {
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 {
// We have a only 4 addresses, RX, TX, Command and Control
func (a *Acia6551) Size() uint16 {
// We have a only 4 addresses, Data, Status, Command and Control
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 {
return r.data[address]

View File

@ -5,6 +5,14 @@ import (
"testing"
)
func AciaSubject() *Acia6551 {
tx := make(chan byte)
rx := make(chan byte)
acia, _ := NewAcia6551(rx, tx)
return acia
}
func TestNewAcia6551(t *testing.T) {
tx := make(chan byte)
rx := make(chan byte)
@ -13,3 +21,20 @@ func TestNewAcia6551(t *testing.T) {
assert.Nil(t, err)
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) {
}