timer

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2020 License: GPL-3.0, GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package timer represents the timer part of the RIOT (the T in RIOT).

Index

Constants

This section is empty.

Variables

View Source
var IntervalList = []string{"TIM1T", "TIM8T", "TIM64T", "T1024T"}

IntervalList is a list of all possible string representations of the Interval type

Functions

This section is empty.

Types

type Interval

type Interval int

Interval indicates how often (in CPU cycles) the timer value decreases. the following rules apply

  • set to 1, 8, 64 or 1024 depending on which address has been written to by the CPU
  • is used to reset the cyclesRemaining
  • is changed to 1 once value reaches 0
  • is reset to its initial value of 1, 8, 64, or 1024 whenever INTIM is read by the CPU
const (
	TIM1T  Interval = 1
	TIM8T  Interval = 8
	TIM64T Interval = 64
	T1024T Interval = 1024
)

List of valid Interval values

func (Interval) String

func (in Interval) String() string

type Timer

type Timer struct {

	// the interval value most recently requested by the CPU
	Divider Interval

	// INTIMvalue is the current timer value and is a reflection of the INTIM
	// RIOT memory register. set with SetValue() function
	INTIMvalue uint8

	// TicksRemaining is the number of CPU cycles remaining before the
	// value is decreased. the following rules apply:
	//		* set to 0 when new timer is set
	//		* causes value to decrease whenever it reaches -1
	//		* is reset to divider whenever value is decreased
	//
	// with regards to the last point, note that divider changes to 1
	// once INTIMvalue reaches 0
	TicksRemaining int
	// contains filtered or unexported fields
}

Timer implements the timer part of the PIA 6532 (the T in RIOT)

func NewTimer

func NewTimer(mem bus.ChipBus) *Timer

NewTimer is the preferred method of initialisation of the Timer type

func (*Timer) SetInterval

func (tmr *Timer) SetInterval(interval string) bool

SetInterval sets the timer interval based on timer register name

func (*Timer) SetValue

func (tmr *Timer) SetValue(value uint8)

SetValue sets the timer value. Prefer this to setting INTIMvalue directly

func (*Timer) Step

func (tmr *Timer) Step()

Step timer forward one cycle

func (Timer) String

func (tmr Timer) String() string

func (*Timer) Update

func (tmr *Timer) Update(data bus.ChipData) bool

Update checks to see if ChipData applies to the Timer type and updates the internal timer state accordingly.

Returns true if ChipData requires more attention.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL