pio

package module
v0.0.0-...-046cbfe Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

README

rp2040-pio

RP2040 PIO SDK based on @kenbell's PIO implementation.

Please use https://github.com/tinygo-org/pio instead. This version has been deprecated.

Documentation

Index

Constants

View Source
const (
	INSTR_BITS_JMP  = 0x0000
	INSTR_BITS_WAIT = 0x2000
	INSTR_BITS_IN   = 0x4000
	INSTR_BITS_OUT  = 0x6000
	INSTR_BITS_PUSH = 0x8000
	INSTR_BITS_PULL = 0x8080
	INSTR_BITS_MOV  = 0xa000
	INSTR_BITS_IRQ  = 0xc000
	INSTR_BITS_SET  = 0xe000

	// Bit mask for instruction code
	INSTR_BITS_Msk = 0xe000
)

This file contains the primitives for creating instructions dynamically

Variables

This section is empty.

Functions

func EncodeDelay

func EncodeDelay(cycles uint16) uint16

func EncodeIRQ

func EncodeIRQ(relative bool, irq uint16) uint16

func EncodeIRQClear

func EncodeIRQClear(relative bool, irq uint16) uint16

func EncodeIRQSet

func EncodeIRQSet(relative bool, irq uint16) uint16

func EncodeIn

func EncodeIn(src SrcDest, value uint16) uint16

func EncodeInstrAndArgs

func EncodeInstrAndArgs(instr uint16, arg1 uint16, arg2 uint16) uint16

func EncodeInstrAndSrcDest

func EncodeInstrAndSrcDest(instr uint16, dest SrcDest, value uint16) uint16

func EncodeJmp

func EncodeJmp(addr uint16) uint16

func EncodeMov

func EncodeMov(dest SrcDest, src SrcDest) uint16

func EncodeMovNot

func EncodeMovNot(dest SrcDest, src SrcDest) uint16

func EncodeMovReverse

func EncodeMovReverse(dest SrcDest, src SrcDest) uint16

func EncodeNOP

func EncodeNOP() uint16

func EncodeOut

func EncodeOut(dest SrcDest, value uint16) uint16

func EncodePull

func EncodePull(ifEmpty bool, block bool) uint16

func EncodePush

func EncodePush(ifFull bool, block bool) uint16

func EncodeSet

func EncodeSet(dest SrcDest, value uint16) uint16

func EncodeSetSetOpt

func EncodeSetSetOpt(bitCount uint16, value uint16) uint16

func EncodeSideSet

func EncodeSideSet(bitCount uint16, value uint16) uint16

func EncodeWaitGPIO

func EncodeWaitGPIO(polarity bool, pin uint16) uint16

func EncodeWaitIRQ

func EncodeWaitIRQ(polarity bool, relative bool, irq uint16) uint16

func EncodeWaitPin

func EncodeWaitPin(polarity bool, pin uint16) uint16

func MajorInstrBits

func MajorInstrBits(instr uint16) uint16

Types

type FifoJoin

type FifoJoin int
const (
	FIFO_JOIN_NONE FifoJoin = iota
	FIFO_JOIN_TX
	FIFO_JOIN_RX
)

type SrcDest

type SrcDest uint16
const (
	SrcDestPins    SrcDest = 0
	SrcDestX       SrcDest = 1
	SrcDestY       SrcDest = 2
	SrcDestNull    SrcDest = 3
	SrcDestPinDirs SrcDest = 4
	SrcDestExecMov SrcDest = 4
	SrcDestStatus  SrcDest = 5
	SrcDestPC      SrcDest = 5
	SrcDestISR     SrcDest = 6
	SrcDestOSR     SrcDest = 7
	SrcExecOut     SrcDest = 7
)

type StateMachineConfig

type StateMachineConfig struct {
	ClkDiv    uint32
	ExecCtrl  uint32
	ShiftCtrl uint32
	PinCtrl   uint32
}

StateMachineConfig holds the configuration for a PIO state machine.

This type is used by code generated by pioasm, in the RP2040 c-sdk - any changes should be backwards compatible.

func DefaultStateMachineConfig

func DefaultStateMachineConfig() StateMachineConfig

DefaultStateMachineConfig returns the default configuration for a PIO state machine.

The default configuration here, mirrors the state from pio_get_default_sm_config in the c-sdk.

This function is used by code generated by pioasm, in the RP2040 c-sdk - any changes should be backwards compatible.

func (*StateMachineConfig) SetClkDivIntFrac

func (cfg *StateMachineConfig) SetClkDivIntFrac(div uint16, frac uint8)

SetClkDivIntFrac sets the clock divider for the state machine from a whole and fractional part.

func (*StateMachineConfig) SetFIFOJoin

func (cfg *StateMachineConfig) SetFIFOJoin(join FifoJoin)
static inline void sm_config_set_fifo_join(pio_sm_config *c, enum pio_fifo_join join) {
    valid_params_if(PIO, join == PIO_FIFO_JOIN_NONE || join == PIO_FIFO_JOIN_TX || join == PIO_FIFO_JOIN_RX);
    c->shiftctrl = (c->shiftctrl & (uint)~(PIO_SM0_SHIFTCTRL_FJOIN_TX_BITS | PIO_SM0_SHIFTCTRL_FJOIN_RX_BITS)) |
                   (((uint)join) << PIO_SM0_SHIFTCTRL_FJOIN_TX_LSB);
}

func (*StateMachineConfig) SetInShift

func (cfg *StateMachineConfig) SetInShift(shiftRight bool, autoPush bool, pushThreshold uint16)

SetInShift sets the 'in' shifting parameters in a state machine configuration

func (*StateMachineConfig) SetOutShift

func (cfg *StateMachineConfig) SetOutShift(shiftRight bool, autoPush bool, pushThreshold uint16)

SetOutShift sets the 'out' shifting parameters in a state machine configuration

func (*StateMachineConfig) SetSetPins

func (cfg *StateMachineConfig) SetSetPins(base machine.Pin, count uint8)

SetSetPins sets the pins a PIO 'set' instruction modifies

func (*StateMachineConfig) SetSideSet

func (cfg *StateMachineConfig) SetSideSet(bitCount uint8, optional bool, pindirs bool)

SetSideSet sets the sideset parameters in a state machine configuration

This function is used by code generated by pioasm, in the RP2040 c-sdk - any changes should be backwards compatible.

func (*StateMachineConfig) SetWrap

func (cfg *StateMachineConfig) SetWrap(wrapTarget uint8, wrap uint8)

SetWrap sets the wrapping configuration for the state machine

This function is used by code generated by pioasm, in the RP2040 c-sdk - any changes should be backwards compatible.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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