Documentation ¶
Overview ¶
Package pru manages access and control to the Programmable Real-time Units (PRU) of the TI AM335x (https://www.ti.com/processors/sitara-arm/applications/industrial-communications.html) The commonly available product with this part is the Beaglebone Black (https://beagleboard.org/black)
The PRU subsystem includes 2 cores that can be separately controlled, and an event/interrupt subsystem that allows the PRU cores and the host CPU to send and receive interrupt driven events.
This package is based on https://github.com/beagleboard/am335x_pru_package The repo mentioned above is required in order to build and install the PRU assembler, if custom PRU programs are to be loaded and executed. This repo also contains a number of useful reference documents.
Complete documentation is available via https://github.com/aamcrae/pru, and through godoc at https://pkg.go.dev/github.com/aamcrae/pru
Index ¶
- func Duration(ticks int) time.Duration
- func MicroSeconds2Ticks(m int) int
- func Ticks(d time.Duration) int
- type Config
- type Event
- type PRU
- type RamIO
- func (r *RamIO) Read(p []byte) (int, error)
- func (r *RamIO) ReadAt(p []byte, offs int64) (int, error)
- func (r *RamIO) ReadByte() (byte, error)
- func (r *RamIO) Seek(offs int64, whence int) (int64, error)
- func (r *RamIO) Write(p []byte) (int, error)
- func (r *RamIO) WriteAt(p []byte, offs int64) (int, error)
- func (r *RamIO) WriteByte(b byte) error
- type Unit
- func (u *Unit) Disable()
- func (u *Unit) IsRunning() bool
- func (u *Unit) LoadAndRun(code []uint32) error
- func (u *Unit) LoadAndRunAt(code []uint32, addr uint) error
- func (u *Unit) LoadAndRunFile(s string) error
- func (u *Unit) LoadAndRunFileAt(s string, addr uint) error
- func (u *Unit) LoadAt(code []uint32, addr uint) error
- func (u *Unit) LoadFile(s string) error
- func (u *Unit) LoadFileAt(s string, addr uint) error
- func (u *Unit) Reset()
- func (u *Unit) Run() error
- func (u *Unit) RunAt(addr uint) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MicroSeconds2Ticks ¶
Return the number of instruction cycles for the microseconds specified.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config contains the configuration mappings for the PRU. A configuration is initialised through config methods on this structure e.g:
ic := NewConfig() ic.EnableUnit(1) ic.Channel2Interrupt(2, 2).Event2Channel(16, 2) p := pru.Open(ic)
var DefaultConfig *Config
The default config. The default configuration is to enable both PRU cores, map all the channels to the corresponding host interrupts as 1:1, and map the first 10 of the PRU R31 interrupts to the corresponding channels. The first 2 of the PRU R31 are PRU-PRU interrupts, and the remaining 8 map to the 8 event devices.
Before the PRU is opened, this may be modified to overwrite the default configuration e.g DefaultConfig.Clear().EnableUnit(0).Event2Channel(16, 4).Channel2Interrupt(4, 4)
func (*Config) Channel2Interrupt ¶
Channel2Interrupt maps the channel to a host interrupt. It is recommended to map the channels to interrupts as 1:1 i.e channel 1 mapped to host interrupt 1 etc. Multiple channels should not be mapped to a single host interrupt. A channel to host interrupt mapping must be present for the host interrupt to be enabled.
func (*Config) EnableUnit ¶
EnableUnit enables the use of a PRU core unit in this process.
func (*Config) Event2Channel ¶
Event2Channel maps the system event to one of the 10 interrupt channels. Multiple system events may be mapped to a single channel, but the same system events should not be mapped to multiple channels. Adding the mapping will enable the system event.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event handles waiting on or receiving system events.
func (*Event) ClearHandler ¶
func (e *Event) ClearHandler()
ClearHandler removes any currently installed handler for this event
func (*Event) SetHandler ¶
func (e *Event) SetHandler(f func())
SetHandler installs an asynch handler that is invoked when events are read from the host interrupt device.
func (*Event) Wait ¶
Wait reads the event channel and returns the value once available. This cannot be used if a handler has been installed on this event.
func (*Event) WaitTimeout ¶
WaitTimeout reads the event, returning if the timeout expires. This cannot be used if a handler has been installed on this device e.g
ok, err := e.WaitTimeout(time.Second) if ok { // Event received else { // Timed out }
type PRU ¶
type PRU struct { Order binary.ByteOrder // encoding/binary Order for reading/writing. // contains filtered or unexported fields }
func (*PRU) ClearEvent ¶
ClearEvent resets the system event, and re-enables the associated host interrupt.
func (*PRU) Close ¶
func (p *PRU) Close()
Close deactivates the PRU subsystem, releasing all the resources associated with it.
func (*PRU) Description ¶
Description returns a human readable string describing the PRU
type RamIO ¶
type RamIO struct { Data []byte // contains filtered or unexported fields }
RamIO implements various io interfaces, using an underlying byte array.
type Unit ¶
type Unit struct { Ram ram // PRU unit data ram // contains filtered or unexported fields }
Unit represents one PRU (core) of the PRU-ICSS subsystem
func (*Unit) LoadAndRun ¶
Load and execute the program
func (*Unit) LoadAndRunAt ¶
Load and execute the program at the address specified.
func (*Unit) LoadAndRunFile ¶
Load and execute the program from the file specified.
func (*Unit) LoadAndRunFileAt ¶
Load and execute the program from a file at the address specified.
func (*Unit) LoadFileAt ¶
Load the program from a file to the address specified.