Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { InternalClock bool // if true, this controller is the master. TransferRequest bool // if true, a transfer has been requested. AttachedDevice Device // the device that is attached to this controller. // contains filtered or unexported fields }
Controller is the serial controller. It is responsible for sending and receiving data to and from devices. Before a transfer, data holds the next byte to be sent. AKA types.SB During a transfer, it has a mix of the incoming data and the outgoing data. each cycle, the leftmost bit of data is sent to the attached device, and shifted out of data, and the incoming bit is shifted into data.
example:
Before : data = o7 o6 o5 o4 o3 o2 o1 o0 Cycle 1: data = o6 o5 o4 o3 o2 o1 o0 i0 Cycle 2: data = o5 o4 o3 o2 o1 o0 i0 i1 Cycle 3: data = o4 o3 o2 o1 o0 i0 i1 i2 Cycle 4: data = o3 o2 o1 o0 i0 i1 i2 i3 Cycle 5: data = o2 o1 o0 i0 i1 i2 i3 i4 Cycle 6: data = o1 o0 i0 i1 i2 i3 i4 i5 Cycle 7: data = o0 i0 i1 i2 i3 i4 i5 i6 Cycle 8: data = i0 i1 i2 i3 i4 i5 i6 i7
Where o0-o7 are the outgoing bits, and i0-i7 are the incoming bits.
func NewController ¶
func NewController(b *io.Bus, s *scheduler.Scheduler) *Controller
NewController creates a new Controller. A Controller is responsible for sending and receiving data to and from devices. It is also responsible for triggering serial interrupts.
By default, the Controller is attached to a nullDevice, which acts as if there is no device attached. This is the same as if the device is not plugged in. If you want to attach a device, use the Controller.Attach method.
func (*Controller) Attach ¶
func (c *Controller) Attach(d Device)
Attach attaches a Device to the Controller.
func (*Controller) Receive ¶
func (c *Controller) Receive(bit bool)
Receive receives a bit from the attached device, and shifts it into the data register. If the caller is the master, it does nothing.
func (*Controller) Send ¶
func (c *Controller) Send() bool
Send returns the leftmost bit of the data register, unless the caller is the master, in which case it always returns true. This is because the master is driving the clock, and thus should not be trying to read from its own data register.