procedure Ack_SM_IRQ
(This : Device;
Flag : SM_IRQ_Flag)
Acknolege a state-machine-level IRQ
procedure Clear_FIFO_Status
(This : Device;
SM : SM_Index;
Flags : SM_FIFO_Status := (others => True))
procedure Clear_FIFOs
(This : Device;
SM : SM_Index)
procedure Clear_Force_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
SM : SM_Index;
Flag : PIO_IRQ_Flag)
Clear force a system-level IRQ
procedure Clear_Force_SM_IRQ
(This : Device;
Flag : SM_IRQ_Flag)
Clear force a state-machine-level IRQ
function Current_Instruction_Address
(This : Device;
SM : SM_Index)
return PIO_Address
Current instruction address of the given state machine.
function Default_SM_Config
return SM_Config
type Device is range 0 .. RP.Device_Parameters.PIO_Count - 1;
procedure Disable
(This : Device)
procedure Disable_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
SM : SM_Index;
Flag : PIO_IRQ_Flag)
Disable a system-level IRQ
procedure Disable_SM_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
Flag : SM_IRQ_Flag)
Disable a system-level IRQ for SM IRQ flag 0..7. On RP2040, Flag must be in 0..3 or Constraint_Error is raised.
type Divider is delta Divider_Fraction
range 0.0 .. (2.0 ** 16 - Divider_Fraction);
Divider_Fraction : constant := 1.0 / 2.0 ** 8;
function DMA_RX_Trigger
(This : Device;
SM : SM_Index)
return RP.DMA.DMA_Request_Trigger
function DMA_TX_Trigger
(This : Device;
SM : SM_Index)
return RP.DMA.DMA_Request_Trigger
procedure Enable
(This : Device)
procedure Enable_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
SM : SM_Index;
Flag : PIO_IRQ_Flag)
Enable a system-level IRQ
procedure Enable_SM_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
Flag : SM_IRQ_Flag)
Enable a system-level IRQ for SM IRQ flag 0..7. On RP2040, Flag must be in 0..3 or Constraint_Error is raised.
function Enabled
(This : Device)
return SM_Mask
procedure Execute
(This : Device;
SM : SM_Index;
Instruction : PIO_Instruction)
function FIFO_Status
(This : Device;
SM : SM_Index)
return SM_FIFO_Status
procedure Force_IRQ_Flag
(This : Device;
IRQ : PIO_IRQ_ID;
SM : SM_Index;
Flag : PIO_IRQ_Flag)
Force a system-level IRQ
procedure Force_SM_IRQ
(This : Device;
Flag : SM_IRQ_Flag)
Force a state-machine-level IRQ
procedure Get
(This : Device;
SM : SM_Index;
Data : out UInt32)
Get one word from the RX FIFO of the given state machine. If the FIFO is empty, this call will run a busy loop until there's data available.
procedure Get
(This : Device;
SM : SM_Index;
Data : out UInt32_Array)
Get data from the RX FIFO of the given state machine. If the FIFO is empty, this call will run a busy loop until there's data available.
function GPIO_Function
(PIO : Device)
return RP.GPIO.GPIO_Function
function IRQ_Flag_Status
(This : Device;
IRQ : PIO_IRQ_ID;
SM : SM_Index;
Flag : PIO_IRQ_Flag)
return Boolean
Return True if a system-level IRQ is signaled (after masking and forcing)
procedure Load
(This : Device;
Prog : Program;
Offset : PIO_Address)
type MOV_Status_Type is (TX_Less_Than, RX_Less_Than, IRQ_Flag);
subtype Pin_Count is Natural range 0 .. 32;
type Pin_Direction is (Input, Output);
subtype PIO_Address is Natural range 0 .. 31;
subtype PIO_Device is Device;
type PIO_GPIO_Base is range 0 .. 16
with Static_Predicate => PIO_GPIO_Base = 0 or PIO_GPIO_Base = 16;
subtype PIO_Instruction is UInt16;
type PIO_IRQ_Flag is (RXNEMPTY, TXNFULL, SM_IRQ);
type PIO_IRQ_ID is range 0 .. 1;
subtype PIO_SM is SM_Index;
subtype PIO_SM_Config is SM_Config;
type Program is array (PIO_Address range <>) of PIO_Instruction;
procedure Put
(This : Device;
SM : SM_Index;
Data : UInt32)
Put one word in the TX FIFO of the given state machine. If the FIFO is full, this call will run a busy loop until there's room for the data.
procedure Put
(This : Device;
SM : SM_Index;
Data : UInt32_Array)
Put data in the TX FIFO of the given state machine. If the FIFO is full, this call will run a busy loop until there's room for the data.
function RX_FIFO_Address
(This : Device;
SM : SM_Index)
return System.Address
function RX_FIFO_Empty
(This : Device;
SM : SM_Index)
return Boolean
function RX_FIFO_Full
(This : Device;
SM : SM_Index)
return Boolean
procedure Set_Clkdiv_Int_Frac
(Config : in out SM_Config;
Div_Int : UInt16;
Div_Frac : UInt8)
procedure Set_Clock_Divider
(Config : in out SM_Config;
Div : Divider)
procedure Set_Clock_Frequency
(Config : in out SM_Config;
Frequency : Hertz)
procedure Set_Config
(This : Device;
SM : SM_Index;
Config : SM_Config)
procedure Set_Enabled
(This : Device;
SM : SM_Index;
Enabled : Boolean)
procedure Set_Enabled
(This : Device;
SM : SM_Mask)
procedure Set_FIFO_Join
(Config : in out SM_Config;
Join_TX : Boolean;
Join_RX : Boolean)
procedure Set_GPIO_Base
(This : Device;
Base : PIO_GPIO_Base)
PIO GPIO numbering can be offset by 0 or 16 pins on RP2350 On RP2040 this procedure raises an exception
procedure Set_In_Pins
(Config : in out SM_Config;
In_Base : RP.GPIO.GPIO_Pin)
procedure Set_In_Shift
(Config : in out SM_Config;
Shift_Right : Boolean;
Autopush : Boolean;
Push_Threshold : Shift_Threshold)
procedure Set_Jmp_Pin
(Config : in out SM_Config;
Pin : RP.GPIO.GPIO_Pin)
procedure Set_MOV_Status
(Config : in out SM_Config;
Status_Sel : MOV_Status_Type;
Status_N : UInt5)
Status_Sel = IRQ_Flag or Status_N > 15 not supported on RP2040
procedure Set_Out_Pins
(Config : in out SM_Config;
Out_Base : RP.GPIO.GPIO_Pin;
Out_Count : Pin_Count)
procedure Set_Out_Shift
(Config : in out SM_Config;
Shift_Right : Boolean;
Autopull : Boolean;
Pull_Threshold : Shift_Threshold)
procedure Set_Out_Special
(Config : in out SM_Config;
Sticky : Boolean;
Has_Enable_Pin : Boolean;
Enable_Pin_Index : RP.GPIO.GPIO_Pin)
procedure Set_Pin_Direction
(This : Device;
SM : SM_Index;
Pin : RP.GPIO.GPIO_Pin;
Direction : Pin_Direction)
procedure Set_Set_Pins
(Config : in out SM_Config;
Set_Base : RP.GPIO.GPIO_Pin;
Set_Count : Pin_Count)
procedure Set_Sideset
(Config : in out SM_Config;
Bit_Count : Sideset_Bit_Count;
Optional : Boolean;
Pindirs : Boolean)
procedure Set_Sideset_Pins
(Config : in out SM_Config;
Sideset_Base : RP.GPIO.GPIO_Pin)
procedure Set_Wrap
(Config : in out SM_Config;
Wrap_Target : PIO_Address;
Wrap : PIO_Address)
subtype Shift_Threshold is Natural range 1 .. 32;
subtype Sideset_Bit_Count is Natural range 0 .. 5;
type SM_Config is private;
type SM_FIFO_Status is record
TXSTALL : Boolean;
TXOVER : Boolean;
RXUNDER : Boolean;
RXSTALL : Boolean;
end record;
State machine has stalled on empty TX FIFO during a blocking PULL, or an OUT with autopull enabled.
TX FIFO overflow (i.e. write-on-full by the system) has occurred. Write-on-full does not alter the state or contents of the FIFO in any way, but the data that the system attempted to write is dropped, so if this flag is set, your software has quite likely dropped some data on the floor.
RX FIFO underflow (i.e. read-on-empty by the system) has occurred. Read-on-empty does not perturb the state of the FIFO in any way, but the data returned by reading from an empty FIFO is undefined, so this flag generally only becomes set due to some kind of software error.
State machine has stalled on full RX FIFO during a blocking PUSH, or an IN with autopush enabled. This flag is also set when a nonblocking PUSH to a full FIFO took place, in which case the state machine has dropped data.
type SM_Index is range 0 .. 3;
procedure SM_Initialize
(This : Device;
SM : SM_Index;
Initial_PC : PIO_Address;
Config : SM_Config)
type SM_IRQ_Flag is range 0 .. 7;
function SM_IRQ_Status
(This : Device;
Flag : SM_IRQ_Flag)
return Boolean
Return True if a state-machine-level IRQ is signaled
type SM_Mask is array (SM_Index) of Boolean
with Size => 4, Component_Size => 1;
procedure Try_Get
(This : Device;
SM : SM_Index;
Data : out UInt32;
Success : out Boolean)
Try to get one word from the RX FIFO of the given state machine. If the FIFO is empty, Success is set to False and Data is not set.
procedure Try_Put
(This : Device;
SM : SM_Index;
Data : UInt32;
Success : out Boolean)
Try to put one word in the TX FIFO of the given state machine. If the FIFO is full, Success is set to False and the data not transmitted.
function TX_FIFO_Address
(This : Device;
SM : SM_Index)
return System.Address
function TX_FIFO_Empty
(This : Device;
SM : SM_Index)
return Boolean
function TX_FIFO_Full
(This : Device;
SM : SM_Index)
return Boolean