diff --git a/examples/makefile b/examples/makefile
index 085d41f99..a08c0034e 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -4,7 +4,7 @@ SUBDIRS := \
custom_frequency_generator empty empty_c \
fft/split_radix_fft_4k_single_core fft/split_radix_fft_post_processing \
LCD_interface logic_scope pru_emif pru_eqep pru_i2s spi_loopback \
- fir multicore_scheduler rpmsg_echo_linux
+ fir multicore_scheduler rpmsg_echo_linux spi_driver
# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak
all: ARGUMENTS = all
diff --git a/examples/readme.md b/examples/readme.md
index 6bb74c6f3..f824ba642 100644
--- a/examples/readme.md
+++ b/examples/readme.md
@@ -51,6 +51,11 @@ spi_loopback
* Implement a loopback SPI connection between 2 PRU cores that act as SPI master
and SPI slave
+spi_driver
+* Bit-banged SPI master/slave driver on AM261x: PRU0 master writes config + trigger
+ to DMEM, PRU1 slave responds with fixed words; supports 5x16-bit back-to-back
+ bursts under one CS assertion with runtime-configurable mode/bit-order
+
fir
* Implements a 64-tap FIR filter on PRU with 32 bit fixed-point precision inputs(Q31).
@@ -97,6 +102,7 @@ For more information about the PRU features on each processor, refer to app note
| pru_emif | Y | Yport | Yport | Yport | N-sw | Yport |
| pru_i2s | Yport | Y | Yport | Y | N-sw | Yport |
| spi_loopback | Y | Yport | Yport | Yport | N-sw | Yport |
+| spi_driver | Yport | Y | Yport | Yport | N-hw | Yport |
| fir | Y | Yport | Yport | Yport | Yport | Yport |
| multicore_sheduler | Y | Npru | Npru | Npru | Npru | Yport |
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm
new file mode 100644
index 000000000..7056f3bd7
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm
@@ -0,0 +1,463 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
+
+;************************************************************************************
+; File: main.asm
+;
+; Brief: PRU0 SPI Master firmware for AM261x.
+; Reads SPI mode/bit order from PRU0 DMEM0 once at startup and
+; selects one of an 8-way branch table (MODE0-3 x MSB/LSB) since
+; the underlying macro resolves MODE/S_BIT at assemble time
+; (.if $symcmp) and cannot take a runtime register value. Then
+; enters a persistent loop: wait for cfg_trigger, run transfer(s),
+; store rx, clear cfg_trigger, repeat. Never halts.
+;
+; Phase 3, all 8 (MODE x bit-order) paths: on trigger, loads 5
+; independent 16-bit command words from DMEM and runs 5
+; back-to-back full-duplex transfers within one CS-low burst (no
+; inter-transfer delay), storing all 5 received words to DMEM
+; after the burst.
+;
+; Pin mapping (PRU0 r30/r31 bit numbers):
+; SCLK = GPO0 (r30.0, output)
+; SDO = GPO1 (r30.1, output)
+; CS = GPO2 (r30.2, output, active low)
+; SDI = GPI6 (r31.6, input)
+;
+; PRU0 DMEM0 config/data (R5F uses global address 0x48600000; PRU0 itself
+; uses c24, the constant-table entry for its own DMEM):
+; 0x00 mode 0=MODE0, 1=MODE1, 2=MODE2, 3=MODE3 (read once at startup)
+; 0x04 bitOrder 0=MSB first, 1=LSB first (read once at startup)
+; 0x10 cfg_trigger R5F sets to 1 to start a transaction; PRU0
+; clears to 0 when the 5 transfers complete
+; 0x14-0x24 cfg_cmd0..4 R5F writes 5 command words here before
+; setting cfg_trigger
+; 0x28-0x38 master_rx5_0..4 PRU0 writes 5 received words here after
+; the 5-transfer burst completes
+;************************************************************************************
+
+ .include "spi_master_macros.inc"
+
+ .retain
+ .retainrefs
+
+ .global main
+ .sect ".text:main"
+
+; PRU clock = 225 MHz on AM261x -> 4.44ns per cycle, use 5 (ceil) for safe timing
+ .asg 5, PRU_CLK_CYC_PRD_CONST
+
+; Pin assignments
+SCLK_PIN .set 0
+SDO_PIN .set 1
+CS_PIN .set 2
+SDI_PIN .set 6
+
+; Fixed for this driver's use case
+PACKET_SIZE .set 16
+; delay_comp1_reg .set 8
+; delay_comp2_reg .set 27 ; d1+d2=35 -> (10+35)*4.44ns = ~200ns period -> ~5 MHz SCLK
+
+; PRU0 DMEM0 offsets (base 0x48600000)
+DMEM_CFG_MODE .set 0x00
+DMEM_CFG_BITORDER .set 0x04
+DMEM_CFG_TRIGGER .set 0x10
+DMEM_CFG_DELAY_COMP1 .set 0x3C
+DMEM_CFG_DELAY_COMP2 .set 0x40
+
+; 5x16-bit command/response DMEM slots, all MODE x bit-order combinations
+DMEM_CFG_CMD0 .set 0x14
+DMEM_CFG_CMD1 .set 0x18
+DMEM_CFG_CMD2 .set 0x1C
+DMEM_CFG_CMD3 .set 0x20
+DMEM_CFG_CMD4 .set 0x24
+DMEM_MASTER_RX5_0 .set 0x28
+DMEM_MASTER_RX5_1 .set 0x2C
+DMEM_MASTER_RX5_2 .set 0x30
+DMEM_MASTER_RX5_3 .set 0x34
+DMEM_MASTER_RX5_4 .set 0x38
+
+ .asg R4.b0, bitId
+ .asg R20, delay_comp1_reg
+ .asg R21, delay_comp2_reg
+ .asg R6, cfgMode
+ .asg R7, cfgBitOrder
+ .asg R8, cfgTrigger
+ .asg R9, retAddr
+
+; 5x16-bit tx/rx registers for 5-transfer burst
+ .asg R10, tx0
+ .asg R11, tx1
+ .asg R12, tx2
+ .asg R13, tx3
+ .asg R14, tx4
+ .asg R15, rx0
+ .asg R16, rx1
+ .asg R17, rx2
+ .asg R18, rx3
+ .asg R19, rx4
+
+;********
+;* MAIN *
+;********
+
+main:
+ zero &r0, 120
+
+ ; Read runtime mode/bitOrder from PRU0's own DMEM0 once at startup, via the
+ ; constant table (c24 = own DMEM, default block index -> local 0x0000).
+ ; cfg_command/cfg_trigger are re-read every loop iteration below instead,
+ ; since they change per transaction.
+ lbco &cfgMode, c24, DMEM_CFG_MODE, 1
+ lbco &cfgBitOrder, c24, DMEM_CFG_BITORDER, 1
+ lbco &delay_comp1_reg, c24, DMEM_CFG_DELAY_COMP1, 4
+ lbco &delay_comp2_reg, c24, DMEM_CFG_DELAY_COMP2, 4
+ ; hardware loop takes N+1 cycles, so subtract to compensate with checks that it is not already zero
+ qbeq skip_sub_delay_1,delay_comp1_reg,0
+ sub delay_comp1_reg,delay_comp1_reg,1
+skip_sub_delay_1:
+ qbeq skip_sub_delay_2,delay_comp2_reg,0
+ sub delay_comp2_reg,delay_comp2_reg,1
+skip_sub_delay_2:
+
+ ; Branch to the (MODE x BITORDER) variant matching the runtime config
+ qbeq M0_MSB, cfgMode, 0
+ qbeq M1_MSB, cfgMode, 1
+ qbeq M2_MSB, cfgMode, 2
+ qbeq M3_MSB, cfgMode, 3
+ qba M3_MSB ; default: MODE3
+
+M0_MSB:
+ qbeq DO_M0_LSB, cfgBitOrder, 1
+ qba DO_M0_MSB
+M1_MSB:
+ qbeq DO_M1_LSB, cfgBitOrder, 1
+ qba DO_M1_MSB
+M2_MSB:
+ qbeq DO_M2_LSB, cfgBitOrder, 1
+ qba DO_M2_MSB
+M3_MSB:
+ qbeq DO_M3_LSB, cfgBitOrder, 1
+ qba DO_M3_MSB
+
+DO_M0_MSB:
+POLL_TRIGGER_MODE0_MSB:
+ m_pru_clr_pin SCLK_PIN ; MODE0 idle low
+ m_pru_set_pin CS_PIN
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE0_MSB, cfgTrigger, 0 ; wait for R5F to set cfg_trigger
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M0_MSB
+ qba TRANSFER_DONE_M0_MSB
+DO_M0_LSB:
+ m_pru_clr_pin SCLK_PIN
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE0_LSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE0_LSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M0_LSB
+ qba TRANSFER_DONE_M0_LSB
+
+DO_M1_MSB:
+ m_pru_clr_pin SCLK_PIN ; MODE1 idle low
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE1_MSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE1_MSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M1_MSB
+ qba TRANSFER_DONE_M1_MSB
+DO_M1_LSB:
+ m_pru_clr_pin SCLK_PIN
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE1_LSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE1_LSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M1_LSB
+ qba TRANSFER_DONE_M1_LSB
+
+DO_M2_MSB:
+ m_pru_set_pin SCLK_PIN ; MODE2 idle high
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE2_MSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE2_MSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M2_MSB
+ qba TRANSFER_DONE_M2_MSB
+DO_M2_LSB:
+ m_pru_set_pin SCLK_PIN
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE2_LSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE2_LSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M2_LSB
+ qba TRANSFER_DONE_M2_LSB
+
+DO_M3_MSB:
+ m_pru_set_pin SCLK_PIN ; MODE3 idle high
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE3_MSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE3_MSB, cfgTrigger, 0
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M3_MSB
+ qba TRANSFER_DONE_M3_MSB
+DO_M3_LSB:
+ m_pru_set_pin SCLK_PIN
+ m_pru_set_pin CS_PIN
+POLL_TRIGGER_MODE3_LSB:
+ lbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qbbc POLL_TRIGGER_MODE3_LSB, cfgTrigger, 0
+ ; Load all 5 command words up front - the burst below runs all 5
+ ; transfers back-to-back under one CS-low assertion.
+ lbco &tx0, c24, DMEM_CFG_CMD0, 4
+ lbco &tx1, c24, DMEM_CFG_CMD1, 4
+ lbco &tx2, c24, DMEM_CFG_CMD2, 4
+ lbco &tx3, c24, DMEM_CFG_CMD3, 4
+ lbco &tx4, c24, DMEM_CFG_CMD4, 4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+ m_pru_clr_pin CS_PIN
+ m_wait_nano_sec 35
+ jal retAddr, DO_5X_TRANSFER_M3_LSB
+ qba TRANSFER_DONE_M3_LSB
+
+TRANSFER_DONE_M0_MSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M0_MSB
+TRANSFER_DONE_M0_LSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M0_LSB
+TRANSFER_DONE_M1_MSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M1_MSB
+TRANSFER_DONE_M1_LSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M1_LSB
+TRANSFER_DONE_M2_MSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M2_MSB
+TRANSFER_DONE_M2_LSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M2_LSB
+TRANSFER_DONE_M3_MSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M3_MSB
+TRANSFER_DONE_M3_LSB:
+ m_wait_nano_sec 10
+ m_pru_set_pin CS_PIN
+ sbco &rx0, c24, DMEM_MASTER_RX5_0, 4
+ sbco &rx1, c24, DMEM_MASTER_RX5_1, 4
+ sbco &rx2, c24, DMEM_MASTER_RX5_2, 4
+ sbco &rx3, c24, DMEM_MASTER_RX5_3, 4
+ sbco &rx4, c24, DMEM_MASTER_RX5_4, 4
+ ldi32 cfgTrigger, 0x00000000
+ sbco &cfgTrigger, c24, DMEM_CFG_TRIGGER, 4
+ qba DO_M3_LSB
+
+; Out-of-line subroutines: 5 independent full-duplex transfers within one
+; CS-low burst, 16-bit each, one per (MODE x bit-order) combination. Reached
+; via jal (full-range jump) instead of being inlined in DO_M*_*, since 5
+; macro expansions inline pushed every qba in the file past the 10-bit
+; PC-relative offset limit. tx0..4 must already hold the 5 command words;
+; rx0..4 receive the 5 response words independently (each transfer uses its
+; own register pair). No inter-transfer delay - back-to-back at full rate.
+DO_5X_TRANSFER_M0_MSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "MSB"
+ jmp retAddr
+DO_5X_TRANSFER_M0_LSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE0", "LSB"
+ jmp retAddr
+
+DO_5X_TRANSFER_M1_MSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "MSB"
+ jmp retAddr
+DO_5X_TRANSFER_M1_LSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE1", "LSB"
+ jmp retAddr
+
+DO_5X_TRANSFER_M2_MSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "MSB"
+ jmp retAddr
+DO_5X_TRANSFER_M2_LSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE2", "LSB"
+ jmp retAddr
+
+DO_5X_TRANSFER_M3_MSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "MSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "MSB"
+ jmp retAddr
+DO_5X_TRANSFER_M3_LSB:
+ m_transfer_packet_spi_master_gpo_sclk_drv rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "LSB"
+ m_transfer_packet_spi_master_gpo_sclk_drv rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, delay_comp1_reg, delay_comp2_reg, "MODE3", "LSB"
+ jmp retAddr
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/example.projectspec b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/example.projectspec
new file mode 100644
index 000000000..155d5ca04
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/example.projectspec
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/linker.cmd b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/linker.cmd
new file mode 100644
index 000000000..13fdcb5e9
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/linker.cmd
@@ -0,0 +1,43 @@
+/*
+ * AM261x_PRU0.cmd
+ *
+ * Example Linker command file for linking assembly programs built with the TI-PRU-CGT
+ * on AM261x PRU0 cores
+ */
+
+/* Specify the System Memory Map */
+MEMORY
+{
+ PAGE 0:
+ /* 16 KB PRU Instruction RAM */
+ PRU_IMEM : org = 0x00000000 len = 0x00004000
+
+ PAGE 1:
+ /* Data RAMs */
+ /* 8 KB PRU Data RAM 0 */
+ PRU0_DMEM_0 : org = 0x00000000 len = 0x00002000
+ /* 8 KB PRU Data RAM 1 */
+ PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000
+
+ PAGE 2:
+ /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */
+ /* 32 KB PRU Shared RAM */
+ PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000
+}
+
+/* Specify the sections allocation into memory */
+SECTIONS {
+
+ .text > PRU_IMEM, PAGE 0
+ .stack > PRU0_DMEM_0, PAGE 1
+ .bss > PRU0_DMEM_0, PAGE 1
+ .cio > PRU0_DMEM_0, PAGE 1
+ .data > PRU0_DMEM_0, PAGE 1
+ .switch > PRU0_DMEM_0, PAGE 1
+ .sysmem > PRU0_DMEM_0, PAGE 1
+ .cinit > PRU0_DMEM_0, PAGE 1
+ .rodata > PRU0_DMEM_0, PAGE 1
+ .rofardata > PRU0_DMEM_0, PAGE 1
+ .farbss > PRU0_DMEM_0, PAGE 1
+ .fardata > PRU0_DMEM_0, PAGE 1
+}
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile
new file mode 100644
index 000000000..012b42073
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile
@@ -0,0 +1,49 @@
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+
+# Define build outputs
+OUTPUT_NAME := spi_driver_am261x-lp_icss_m1_pru0_fw
+
+# MCU+ projects: rename & move hex array output
+MCU_HEX_NAME := pru0_load_bin.h
+HEX_ARRAY_PREFIX := PRU0Firmware
+MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/spi_driver/firmware/am261x-lp/$(MCU_HEX_NAME)
+
+# which directories to search for assembly & C source files?
+FILES_PATH := .. ../../.. .
+
+# Linker command file
+COMMAND_FILES := linker.cmd
+
+# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG)
+PRU_VERSION := 3
+EXPECTED_DEVICE := am261x
+
+# Default values are defined in pru_rules.mak:
+# - include paths (INCLUDE)
+# - compiler flags (CFLAGS)
+# - linker flags (LFLAGS)
+
+# Optional:
+# Pre-define here to override default value
+# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT
+
+# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles
+include $(OPEN_PRU_PATH)/pru_rules.mak
+
+# Optional:
+# Append values to INCLUDE, CFLAGS, or LFLAGS here.
+# Values can be appended like this:
+# INCLUDE += --include_path=
+INCLUDE += --include_path=../../
+
+# Defines (pass instance specific definitions to the program)
+# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide'
+# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1:
+# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1
+DFLAGS :=
+
+# Libraries
+# see --library in 'PRU Optimizing C/C++ Compiler User's Guide'
+LIBS :=
+
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile_projectspec b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile_projectspec
new file mode 100644
index 000000000..2710c5b53
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile_projectspec
@@ -0,0 +1,16 @@
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+
+PROFILE?=Release
+
+PROJECT_NAME=spi_driver_am261x-lp_icss_m1_pru0_fw_ti-pru-cgt
+
+all:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE)
+
+clean:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean
+
+export:
+ $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/main.asm b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/main.asm
new file mode 100644
index 000000000..7546b72ec
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/main.asm
@@ -0,0 +1,135 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
+
+;************************************************************************************
+; File: main.asm
+;
+; Brief: PRU1 SPI Slave firmware for AM261x — encoder-emulation responder
+; (phase 3, MODE3/MSB only for now). Loops forever: waits for CS
+; low, then runs 5 independent full-duplex transfers back-to-back
+; within one CS-low burst via m_transfer_packet_spi_slave_gpi_sclk
+; (MODE3, MSB first, 16-bit each). Each transfer sends one of 5
+; fixed response words (0x1111/0x2222/0x3333/0x4444/0x5555) while
+; receiving one of the master's 5 command words; the 5 received
+; words are latched to DMEM1 after the burst for R5F visibility.
+; No decode logic — responses are fixed regardless of command
+; content. Never halts.
+;
+; Pin mapping (PRU1 GPO/GPI numbers):
+; SCLK = GPI4 (r31.4, input — driven by master)
+; CS = GPI6 (r31.6, input — driven by master, active low)
+; SDO = GPO5 (r30.5, output — slave transmits)
+; SDI = GPI11 (r31.11, input — slave receives)
+;************************************************************************************
+
+ .include "spi_slave_macros.inc"
+
+; CCS/makefile specific settings
+ .retain
+ .retainrefs
+
+ .global main
+ .sect ".text:main"
+
+; PRU clock = 225 MHz on AM261x -> 4.44ns per cycle, use 5 (ceil) for safe timing
+ .asg 5, PRU_CLK_CYC_PRD_CONST
+
+; Pin assignments
+SCLK_PIN .set 4
+CS_PIN .set 6
+SDO_PIN .set 5
+SDI_PIN .set 11
+
+PACKET_SIZE .set 16
+
+; Fixed responses for the 5x16-bit MODE3/MSB burst (independent of any
+; single-transfer decode path, which has been removed).
+RESP5_0 .set 0x1111
+RESP5_1 .set 0x2222
+RESP5_2 .set 0x3333
+RESP5_3 .set 0x4444
+RESP5_4 .set 0x5555
+
+; PRU1 DMEM1 offsets (base 0x48602000)
+DMEM_SLAVE_RX5_0 .set 0x00
+DMEM_SLAVE_RX5_1 .set 0x04
+DMEM_SLAVE_RX5_2 .set 0x08
+DMEM_SLAVE_RX5_3 .set 0x0C
+DMEM_SLAVE_RX5_4 .set 0x10
+
+; Register aliases
+ .asg R3, r_dataReg
+ .asg R4.b0, bitId
+ .asg R5, temp
+ .asg R6, retAddr
+
+; 5x16-bit tx/rx registers for the MODE3/MSB 5-transfer burst
+ .asg R10, tx0
+ .asg R11, tx1
+ .asg R12, tx2
+ .asg R13, tx3
+ .asg R14, tx4
+ .asg R15, rx0
+ .asg R16, rx1
+ .asg R17, rx2
+ .asg R18, rx3
+ .asg R19, rx4
+;********
+;* MAIN *
+;********
+
+main:
+ zero &r0, 120
+
+LOOP_BACK:
+ ; Load the 5 fixed responses to send, and clear the 5 rx registers,
+ ; before each 5-transfer burst.
+ ldi32 tx0, RESP5_0
+ ldi32 tx1, RESP5_1
+ ldi32 tx2, RESP5_2
+ ldi32 tx3, RESP5_3
+ ldi32 tx4, RESP5_4
+ ldi32 rx0, 0x00000000
+ ldi32 rx1, 0x00000000
+ ldi32 rx2, 0x00000000
+ ldi32 rx3, 0x00000000
+ ldi32 rx4, 0x00000000
+
+WAIT_CS_LOW:
+ ; Poll until CS goes low (master asserts)
+ qbbs WAIT_CS_LOW, r31, CS_PIN
+
+ ; Matches PRU0's DO_5X_TRANSFER_M3_MSB: master keeps CS low across 5
+ ; back-to-back transfers. Each transfer sends its own fixed response
+ ; while receiving the command word into its own register - not decoded,
+ ; just latched to DMEM1 afterward for R5F/debug visibility.
+ jal retAddr, DO_5X_TRANSFER
+
+ ldi32 temp, 0x00000000
+ sbbo &rx0, temp, DMEM_SLAVE_RX5_0, 4
+ sbbo &rx1, temp, DMEM_SLAVE_RX5_1, 4
+ sbbo &rx2, temp, DMEM_SLAVE_RX5_2, 4
+ sbbo &rx3, temp, DMEM_SLAVE_RX5_3, 4
+ sbbo &rx4, temp, DMEM_SLAVE_RX5_4, 4
+ qba LOOP_BACK
+
+; Out-of-line subroutine: 5 independent full-duplex transfers within one
+; CS-low burst, MODE3/MSB, 16-bit each, matching PRU0's DO_5X_TRANSFER_M3_MSB.
+; Reached via jal instead of inlined in LOOP_BACK for the same qba
+; 10-bit-offset reason as PRU0. tx0..4 must already hold the 5 fixed
+; responses; rx0..4 receive the 5 command words independently.
+DO_5X_TRANSFER:
+ qbbs ABORT_TRANSFER, r31, CS_PIN
+ m_transfer_packet_spi_slave_gpi_sclk rx0, tx0, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, "MODE3", "MSB"
+ qbbs ABORT_TRANSFER, r31, CS_PIN
+ m_transfer_packet_spi_slave_gpi_sclk rx1, tx1, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, "MODE3", "MSB"
+ qbbs ABORT_TRANSFER, r31, CS_PIN
+ m_transfer_packet_spi_slave_gpi_sclk rx2, tx2, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, "MODE3", "MSB"
+ qbbs ABORT_TRANSFER, r31, CS_PIN
+ m_transfer_packet_spi_slave_gpi_sclk rx3, tx3, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, "MODE3", "MSB"
+ qbbs ABORT_TRANSFER, r31, CS_PIN
+ m_transfer_packet_spi_slave_gpi_sclk rx4, tx4, PACKET_SIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, "MODE3", "MSB"
+ jmp retAddr
+
+ABORT_TRANSFER:
+ qba LOOP_BACK
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/example.projectspec b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/example.projectspec
new file mode 100644
index 000000000..2d8803d18
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/example.projectspec
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/linker.cmd b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/linker.cmd
new file mode 100644
index 000000000..774184ddf
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/linker.cmd
@@ -0,0 +1,43 @@
+/*
+ * AM261x_PRU1.cmd
+ *
+ * Example Linker command file for linking assembly programs built with the TI-PRU-CGT
+ * on AM261x PRU1 cores
+ */
+
+/* Specify the System Memory Map */
+MEMORY
+{
+ PAGE 0:
+ /* 16 KB PRU Instruction RAM */
+ PRU_IMEM : org = 0x00000000 len = 0x00004000
+
+ PAGE 1:
+ /* Data RAMs */
+ /* 8 KB PRU Data RAM 1 */
+ PRU1_DMEM_1 : org = 0x00000000 len = 0x00002000
+ /* 8 KB PRU Data RAM 0 */
+ PRU0_DMEM_0 : org = 0x00002000 len = 0x00002000
+
+ PAGE 2:
+ /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */
+ /* 32 KB PRU Shared RAM */
+ PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000
+}
+
+/* Specify the sections allocation into memory */
+SECTIONS {
+
+ .text > PRU_IMEM, PAGE 0
+ .stack > PRU1_DMEM_1, PAGE 1
+ .bss > PRU1_DMEM_1, PAGE 1
+ .cio > PRU1_DMEM_1, PAGE 1
+ .data > PRU1_DMEM_1, PAGE 1
+ .switch > PRU1_DMEM_1, PAGE 1
+ .sysmem > PRU1_DMEM_1, PAGE 1
+ .cinit > PRU1_DMEM_1, PAGE 1
+ .rodata > PRU1_DMEM_1, PAGE 1
+ .rofardata > PRU1_DMEM_1, PAGE 1
+ .farbss > PRU1_DMEM_1, PAGE 1
+ .fardata > PRU1_DMEM_1, PAGE 1
+}
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile
new file mode 100644
index 000000000..ecb35e07f
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile
@@ -0,0 +1,49 @@
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+
+# Define build outputs
+OUTPUT_NAME := spi_driver_am261x-lp_icss_m1_pru1_fw
+
+# MCU+ projects: rename & move hex array output
+MCU_HEX_NAME := pru1_load_bin.h
+HEX_ARRAY_PREFIX := PRU1Firmware
+MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/spi_driver/firmware/am261x-lp/$(MCU_HEX_NAME)
+
+# which directories to search for assembly & C source files?
+FILES_PATH := .. ../../.. .
+
+# Linker command file
+COMMAND_FILES := linker.cmd
+
+# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG)
+PRU_VERSION := 3
+EXPECTED_DEVICE := am261x
+
+# Default values are defined in pru_rules.mak:
+# - include paths (INCLUDE)
+# - compiler flags (CFLAGS)
+# - linker flags (LFLAGS)
+
+# Optional:
+# Pre-define here to override default value
+# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT
+
+# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles
+include $(OPEN_PRU_PATH)/pru_rules.mak
+
+# Optional:
+# Append values to INCLUDE, CFLAGS, or LFLAGS here.
+# Values can be appended like this:
+# INCLUDE += --include_path=
+INCLUDE += --include_path=../../
+
+# Defines (pass instance specific definitions to the program)
+# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide'
+# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1:
+# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1
+DFLAGS :=
+
+# Libraries
+# see --library in 'PRU Optimizing C/C++ Compiler User's Guide'
+LIBS :=
+
diff --git a/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile_projectspec b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile_projectspec
new file mode 100644
index 000000000..ba44df2b6
--- /dev/null
+++ b/examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile_projectspec
@@ -0,0 +1,16 @@
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+
+PROFILE?=Release
+
+PROJECT_NAME=spi_driver_am261x-lp_icss_m1_pru1_fw_ti-pru-cgt
+
+all:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE)
+
+clean:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean
+
+export:
+ $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full
diff --git a/examples/spi_driver/makefile b/examples/spi_driver/makefile
new file mode 100644
index 000000000..9268ea5fe
--- /dev/null
+++ b/examples/spi_driver/makefile
@@ -0,0 +1,106 @@
+include ../../imports.mak
+
+#######################
+# project information #
+#######################
+
+PROJECT_NAME := spi_driver
+SUPPORTED_PROCESSORS := am261x
+# Does the PRU code have dependencies outside of the open-pru repo?
+PRU_DEPENDENCIES :=
+# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores
+NON_PRU_DEPENDENCIES := mcuplus
+
+###################
+# Prebuild checks #
+###################
+BUILD_PROJECT := y
+DEVICE_NON_PRU :=
+
+# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS)
+ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS)))
+BUILD_PROJECT := n
+MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE)
+endif
+
+# Only build project if PRU dependencies exist
+ifneq (,$(PRU_DEPENDENCIES))
+# MCU+ SDK dependency?
+ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES)))
+ifneq ($(BUILD_MCUPLUS),y)
+BUILD_PROJECT := n
+MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y.
+endif
+endif
+# Additional PRU dependency checks go here. For example:
+#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES)))
+#if (dependency check fails)
+#BUILD_PROJECT := n
+#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist.
+#endif
+#endif
+endif
+
+# Only build non-PRU code if the non-PRU code is enabled in imports.mak
+ifeq ($(BUILD_MCUPLUS),y)
+ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES)))
+DEVICE_NON_PRU += $(DEVICE)_mcuplus
+endif
+endif
+ifeq ($(BUILD_LINUX),y)
+ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES)))
+DEVICE_NON_PRU += $(DEVICE)_linux
+endif
+endif
+
+###########################
+# Make and clean commands #
+###########################
+
+ifeq ($(BUILD_PROJECT),y)
+# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak
+# "make" builds PRU firmware first, then host (non-PRU) code
+all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)"
+all: pre_build_message
+ $(MAKE) pru
+ $(MAKE) host
+
+# "make pru" builds only PRU firmware for $(DEVICE)
+pru: ARGUMENTS_PRU = all
+pru: $(DEVICE)
+
+# "make host" builds only host (non-PRU) code for $(DEVICE)
+host: ARGUMENTS_MCUPLUS = all
+host: $(DEVICE_NON_PRU)
+
+# "make clean" cleans projects that match $(DEVICE) set in imports.mak
+clean: ARGUMENTS_PRU = clean
+clean: ARGUMENTS_MCUPLUS = scrub
+clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)"
+clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU)
+
+else
+# if a prebuild check failed, print message and exit
+all clean pru host: pre_build_message
+endif
+
+pre_build_message:
+ @echo $(MESSAGE)
+
+######################
+# Target definitions #
+######################
+
+# provide target definitions for each supported processor
+# PRU firmware should be built before any RTOS code that includes it
+am261x:
+# am261x-lp
+ $(MAKE) -C firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+ $(MAKE) -C firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+
+am261x_mcuplus:
+# am261x-lp
+ $(MAKE) -C mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS)
+
+.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS)
+
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/example.syscfg b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/example.syscfg
new file mode 100644
index 000000000..a536274e9
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/example.syscfg
@@ -0,0 +1,327 @@
+/**
+ * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
+ * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
+ * @cliArgs --device "AM261x_ZFG" --part "AM2612" --package "ZFG" --context "r5fss0-0" --product "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM261x@11.00.00"
+ * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --variant "500MHz" --context "r5fss0-0" --product "OPEN_PRU@2026.02.00" --product "MCU_PLUS_SDK_AM261x@11.00.00"
+ * @versions {"tool":"1.26.0+4407"}
+ */
+
+/**
+ * Import the modules used in this configuration.
+ */
+const ioexp = scripting.addModule("/board/ioexp/ioexp", {}, false);
+const ioexp1 = ioexp.addInstance();
+const i2c = scripting.addModule("/drivers/i2c/i2c", {}, false);
+const i2c1 = i2c.addInstance();
+const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false);
+const pruicss1 = pruicss.addInstance();
+const debug_log = scripting.addModule("/kernel/dpl/debug_log");
+const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg");
+const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
+const mpu_armv71 = mpu_armv7.addInstance();
+const mpu_armv72 = mpu_armv7.addInstance();
+const mpu_armv73 = mpu_armv7.addInstance();
+const mpu_armv74 = mpu_armv7.addInstance();
+const mpu_armv75 = mpu_armv7.addInstance();
+const mpu_armv76 = mpu_armv7.addInstance();
+const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false);
+const default_linker1 = default_linker.addInstance();
+const general = scripting.addModule("/memory_configurator/general", {}, false);
+const general1 = general.addInstance();
+const region = scripting.addModule("/memory_configurator/region", {}, false);
+const region1 = region.addInstance();
+const section = scripting.addModule("/memory_configurator/section", {}, false);
+const section1 = section.addInstance();
+const section2 = section.addInstance();
+const section3 = section.addInstance();
+const section4 = section.addInstance();
+const section5 = section.addInstance();
+const section6 = section.addInstance();
+const section7 = section.addInstance();
+const section8 = section.addInstance();
+const section9 = section.addInstance();
+const section10 = section.addInstance();
+const section11 = section.addInstance();
+const section12 = section.addInstance();
+
+/**
+ * Write custom configuration values to the imported modules.
+ */
+ioexp1.$name = "CONFIG_IOEXP0";
+ioexp1.TCA6408ARGTR_port0_pinBP_MUX_SW_S1_mode = 0;
+ioexp1.TCA6408ARGTR_port0_pinBP_BO_MUX_EN_N_mode = 0;
+ioexp1.TCA6408ARGTR_port0_pinBP_MUX_SW_SO_mode = 0;
+ioexp1.TCA6408ARGTR_port0_pinBP_MUX_SW_S1_state = 1;
+ioexp1.TCA6408ARGTR_port0_pinBP_BO_MUX_EN_mode = 0;
+
+ioexp1.peripheralDriver = i2c1;
+i2c1.$name = "CONFIG_I2C2";
+i2c1.I2C.$assign = "I2C0";
+i2c1.I2C.SCL.$assign = "GPIO135";
+i2c1.I2C.SDA.$assign = "GPIO134";
+i2c1.I2C_child.$name = "drivers_i2c_v1_i2c_v1_template1";
+
+pruicss1.$name = "CONFIG_PRU_ICSS0";
+pruicss1.instance = "ICSSM1";
+pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0";
+pruicss1.AdditionalICSSSettings[0].PruGPIO.create(1);
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].$assign = "PRU-ICSS1";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO5.$assign = "GPIO54";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO5.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO6.rx = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO6.$assign = "GPIO19";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO6.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO4.rx = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO4.$assign = "GPIO15";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO4.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO0.$assign = "GPIO81";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO0.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO1.$assign = "GPIO82";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO1.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO2.$assign = "GPIO83";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO2.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO9.$assign = "GPIO80";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO11.rx = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO11.$assign = "GPIO3";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO11.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO1.$assign = "GPIO72";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO1.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO2.rx = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO2.$assign = "GPIO73";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU1_GPIO2.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO7.$assign = "GPIO26";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO7.$used = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO6.rx = true;
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO6.$assign = "GPIO45";
+pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS1"].PR1_PRU0_GPIO6.$used = true;
+
+debug_log.enableUartLog = true;
+debug_log.enableCssLog = false;
+debug_log.uartLog.$name = "CONFIG_UART0";
+debug_log.uartLog.baudRate = 921600;
+debug_log.uartLog.UART.$assign = "UART0";
+debug_log.uartLog.UART.RXD.$assign = "GPIO27";
+debug_log.uartLog.UART.TXD.$assign = "GPIO28";
+debug_log.uartLog.child.$name = "drivers_uart_v2_uart_v2_template0";
+
+mpu_armv71.$name = "CONFIG_MPU_REGION0";
+mpu_armv71.size = 31;
+mpu_armv71.attributes = "Device";
+mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD";
+mpu_armv71.allowExecute = false;
+
+mpu_armv72.$name = "CONFIG_MPU_REGION1";
+mpu_armv72.size = 15;
+mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD";
+
+mpu_armv73.$name = "CONFIG_MPU_REGION2";
+mpu_armv73.baseAddr = 0x80000;
+mpu_armv73.size = 15;
+mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD";
+
+mpu_armv74.$name = "CONFIG_MPU_REGION3";
+mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD";
+mpu_armv74.baseAddr = 0x70000000;
+mpu_armv74.size = 21;
+
+mpu_armv75.$name = "CONFIG_MPU_REGION4";
+mpu_armv75.size = 14;
+mpu_armv75.baseAddr = 0x50D00000;
+mpu_armv75.allowExecute = false;
+mpu_armv75.attributes = "Device";
+
+mpu_armv76.$name = "CONFIG_MPU_REGION5";
+mpu_armv76.size = 14;
+mpu_armv76.allowExecute = false;
+mpu_armv76.attributes = "NonCached";
+mpu_armv76.baseAddr = 0x72000000;
+
+default_linker1.$name = "memory_configurator_default_linker0";
+
+general1.$name = "CONFIG_GENERAL0";
+general1.linker.$name = "TIARMCLANG0";
+
+region1.$name = "MEMORY_REGION_CONFIGURATION0";
+region1.memory_region.create(11);
+region1.memory_region[0].type = "TCMA";
+region1.memory_region[0].$name = "R5F_VECS";
+region1.memory_region[0].size = 0x40;
+region1.memory_region[0].auto = false;
+region1.memory_region[1].type = "TCMA";
+region1.memory_region[1].$name = "R5F_TCMA";
+region1.memory_region[1].size = 0x7FC0;
+region1.memory_region[2].type = "TCMB";
+region1.memory_region[2].size = 0x8000;
+region1.memory_region[2].$name = "R5F_TCMB";
+region1.memory_region[3].$name = "SBL";
+region1.memory_region[3].auto = false;
+region1.memory_region[3].size = 0x40000;
+region1.memory_region[4].$name = "OCRAM";
+region1.memory_region[4].auto = false;
+region1.memory_region[4].manualStartAddress = 0x70040000;
+region1.memory_region[4].size = 0x40000;
+region1.memory_region[5].type = "FLASH";
+region1.memory_region[5].auto = false;
+region1.memory_region[5].manualStartAddress = 0x60100000;
+region1.memory_region[5].size = 0x80000;
+region1.memory_region[5].$name = "FLASH";
+region1.memory_region[6].$name = "USER_SHM_MEM";
+region1.memory_region[6].auto = false;
+region1.memory_region[6].manualStartAddress = 0x70150000;
+region1.memory_region[6].size = 0x4000;
+region1.memory_region[6].isShared = true;
+region1.memory_region[6].shared_cores = ["r5fss0-1"];
+region1.memory_region[7].$name = "LOG_SHM_MEM";
+region1.memory_region[7].auto = false;
+region1.memory_region[7].manualStartAddress = 0x70154000;
+region1.memory_region[7].size = 0x4000;
+region1.memory_region[7].isShared = true;
+region1.memory_region[7].shared_cores = ["r5fss0-1"];
+region1.memory_region[8].type = "CUSTOM";
+region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM";
+region1.memory_region[8].auto = false;
+region1.memory_region[8].manualStartAddress = 0x72000000;
+region1.memory_region[8].size = 0x3E80;
+region1.memory_region[8].isShared = true;
+region1.memory_region[8].shared_cores = ["r5fss0-1"];
+region1.memory_region[9].type = "CUSTOM";
+region1.memory_region[9].$name = "MAILBOX_HSM";
+region1.memory_region[9].auto = false;
+region1.memory_region[9].manualStartAddress = 0x44000000;
+region1.memory_region[9].size = 0x3CE;
+region1.memory_region[9].isShared = true;
+region1.memory_region[9].shared_cores = ["r5fss0-1"];
+region1.memory_region[10].type = "CUSTOM";
+region1.memory_region[10].$name = "MAILBOX_R5F";
+region1.memory_region[10].auto = false;
+region1.memory_region[10].manualStartAddress = 0x44000400;
+region1.memory_region[10].size = 0x3CE;
+region1.memory_region[10].isShared = true;
+region1.memory_region[10].shared_cores = ["r5fss0-1"];
+
+section1.load_memory = "R5F_VECS";
+section1.group = false;
+section1.$name = "Vector Table";
+section1.output_section.create(1);
+section1.output_section[0].$name = ".vectors";
+section1.output_section[0].palignment = true;
+
+section2.load_memory = "OCRAM";
+section2.$name = "Text Segments";
+section2.output_section.create(5);
+section2.output_section[0].$name = ".text.hwi";
+section2.output_section[0].palignment = true;
+section2.output_section[1].$name = ".text.cache";
+section2.output_section[1].palignment = true;
+section2.output_section[2].$name = ".text.mpu";
+section2.output_section[2].palignment = true;
+section2.output_section[3].$name = ".text.boot";
+section2.output_section[3].palignment = true;
+section2.output_section[4].$name = ".text:abort";
+section2.output_section[4].palignment = true;
+
+section3.load_memory = "OCRAM";
+section3.$name = "Code and Read-Only Data";
+section3.output_section.create(2);
+section3.output_section[0].$name = ".text";
+section3.output_section[0].palignment = true;
+section3.output_section[1].$name = ".rodata";
+section3.output_section[1].palignment = true;
+
+section4.load_memory = "OCRAM";
+section4.$name = "Data Segment";
+section4.output_section.create(1);
+section4.output_section[0].$name = ".data";
+section4.output_section[0].palignment = true;
+
+section5.load_memory = "OCRAM";
+section5.$name = "Memory Segments";
+section5.output_section.create(3);
+section5.output_section[0].$name = ".bss";
+section5.output_section[0].output_sections_start = "__BSS_START";
+section5.output_section[0].output_sections_end = "__BSS_END";
+section5.output_section[0].palignment = true;
+section5.output_section[1].$name = ".sysmem";
+section5.output_section[1].palignment = true;
+section5.output_section[2].$name = ".stack";
+section5.output_section[2].palignment = true;
+
+section6.load_memory = "OCRAM";
+section6.$name = "Stack Segments";
+section6.output_section.create(5);
+section6.output_section[0].$name = ".irqstack";
+section6.output_section[0].output_sections_start = "__IRQ_STACK_START";
+section6.output_section[0].output_sections_end = "__IRQ_STACK_END";
+section6.output_section[0].input_section.create(1);
+section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;";
+section6.output_section[1].$name = ".fiqstack";
+section6.output_section[1].output_sections_start = "__FIQ_STACK_START";
+section6.output_section[1].output_sections_end = "__FIQ_STACK_END";
+section6.output_section[1].input_section.create(1);
+section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;";
+section6.output_section[2].$name = ".svcstack";
+section6.output_section[2].output_sections_start = "__SVC_STACK_START";
+section6.output_section[2].output_sections_end = "__SVC_STACK_END";
+section6.output_section[2].input_section.create(1);
+section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;";
+section6.output_section[3].$name = ".abortstack";
+section6.output_section[3].output_sections_start = "__ABORT_STACK_START";
+section6.output_section[3].output_sections_end = "__ABORT_STACK_END";
+section6.output_section[3].input_section.create(1);
+section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;";
+section6.output_section[4].$name = ".undefinedstack";
+section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START";
+section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END";
+section6.output_section[4].input_section.create(1);
+section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;";
+
+section7.load_memory = "OCRAM";
+section7.$name = "Initialization and Exception Handling";
+section7.output_section.create(3);
+section7.output_section[0].$name = ".ARM.exidx";
+section7.output_section[0].palignment = true;
+section7.output_section[1].$name = ".init_array";
+section7.output_section[1].palignment = true;
+section7.output_section[2].$name = ".fini_array";
+section7.output_section[2].palignment = true;
+
+section8.load_memory = "USER_SHM_MEM";
+section8.type = "NOLOAD";
+section8.$name = "User Shared Memory";
+section8.group = false;
+section8.output_section.create(1);
+section8.output_section[0].$name = ".bss.user_shared_mem";
+section8.output_section[0].alignment = 0;
+
+section9.load_memory = "LOG_SHM_MEM";
+section9.$name = "Log Shared Memory";
+section9.group = false;
+section9.type = "NOLOAD";
+section9.output_section.create(1);
+section9.output_section[0].$name = ".bss.log_shared_mem";
+section9.output_section[0].alignment = 0;
+
+section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM";
+section10.type = "NOLOAD";
+section10.$name = "IPC Shared Memory";
+section10.group = false;
+section10.output_section.create(1);
+section10.output_section[0].$name = ".bss.ipc_vring_mem";
+section10.output_section[0].alignment = 0;
+
+section11.load_memory = "MAILBOX_HSM";
+section11.type = "NOLOAD";
+section11.$name = "SIPC HSM Queue Memory";
+section11.group = false;
+section11.output_section.create(1);
+section11.output_section[0].$name = ".bss.sipc_hsm_queue_mem";
+section11.output_section[0].alignment = 0;
+
+section12.load_memory = "MAILBOX_R5F";
+section12.$name = "SIPC R5F Queue Memory";
+section12.group = false;
+section12.type = "NOLOAD";
+section12.output_section.create(1);
+section12.output_section[0].$name = ".bss.sipc_secure_host_queue_mem";
+section12.output_section[0].alignment = 0;
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/main.c b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/main.c
new file mode 100644
index 000000000..4bd3f9f5a
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/main.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2022-23 Texas Instruments Incorporated
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include "ti_drivers_config.h"
+#include "ti_board_config.h"
+#include "FreeRTOS.h"
+#include "task.h"
+
+#define MAIN_TASK_PRI (configMAX_PRIORITIES-1)
+
+#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE))
+StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));
+
+StaticTask_t gMainTaskObj;
+TaskHandle_t gMainTask;
+
+void empty_example_main(void *args);
+
+void freertos_main(void *args)
+{
+ empty_example_main(NULL);
+
+ vTaskDelete(NULL);
+}
+
+
+int main(void)
+{
+ /* init SOC specific modules */
+ System_init();
+ Board_init();
+
+ /* This task is created at highest priority, it should create more tasks and then delete itself */
+ gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */
+ "freertos_main", /* Text name for the task. This is to facilitate debugging only. */
+ MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
+ NULL, /* We are not using the task parameter. */
+ MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
+ gMainTaskStack, /* pointer to stack base */
+ &gMainTaskObj ); /* pointer to statically allocated task object memory */
+ configASSERT(gMainTask != NULL);
+
+ /* Start the scheduler to start the tasks executing. */
+ vTaskStartScheduler();
+
+ /* The following line should never be reached because vTaskStartScheduler()
+ will only return if there was not enough FreeRTOS heap memory available to
+ create the Idle and (if configured) Timer tasks. Heap management, and
+ techniques for trapping heap exhaustion, are described in the book text. */
+ DebugP_assertNoLog(0);
+
+ return 0;
+}
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec
new file mode 100644
index 000000000..5d7c5dfbe
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile
new file mode 100644
index 000000000..3c7ce497d
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile
@@ -0,0 +1,352 @@
+#
+# Auto generated makefile
+#
+
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak
+
+
+CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH)
+
+CC=$(CG_TOOL_ROOT)/bin/tiarmclang
+LNK=$(CG_TOOL_ROOT)/bin/tiarmclang
+STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip
+OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy
+COV=$(CG_TOOL_ROOT)/bin/tiarmcov
+PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata
+COVERAGE_PATH=$(abspath .)
+ifeq ($(OS), Windows_NT)
+ PYTHON=python
+else
+ PYTHON=python3
+endif
+
+PROFILE?=release
+ConfigName:=$(PROFILE)
+
+OUTNAME:=spi_driver.$(PROFILE).out
+
+BOOTIMAGE_PATH=$(abspath .)
+oeconfig?=None
+BOOTIMAGE_NAME:=spi_driver.$(PROFILE).appimage
+BOOTIMAGE_NAME_XIP:=spi_driver.$(PROFILE).appimage_xip
+BOOTIMAGE_NAME_SIGNED:=spi_driver.$(PROFILE).appimage.signed
+BOOTIMAGE_NAME_MCELF:=spi_driver.$(PROFILE).mcelf
+BOOTIMAGE_NAME_MCELF_HS:=spi_driver.$(PROFILE).mcelf.hs
+BOOTIMAGE_RPRC_NAME:=spi_driver.$(PROFILE).rprc
+BOOTIMAGE_RPRC_NAME_XIP:=spi_driver.$(PROFILE).rprc_xip
+BOOTIMAGE_RPRC_NAME_TMP:=spi_driver.$(PROFILE).rprc_tmp
+BOOTIMAGE_NAME_HS:=spi_driver.$(PROFILE).appimage.hs
+BOOTIMAGE_NAME_HS_FS:=spi_driver.$(PROFILE).appimage.hs_fs
+TARGETS := $(BOOTIMAGE_NAME_MCELF)
+
+ifeq ($(DEVICE_TYPE), HS)
+ TARGETS += $(BOOTIMAGE_NAME_MCELF_HS)
+endif
+
+FILES_common := \
+ main.c \
+ empty_example.c \
+ ti_drivers_config.c \
+ ti_drivers_open_close.c \
+ ti_board_config.c \
+ ti_board_open_close.c \
+ ti_dpl_config.c \
+ ti_pinmux_config.c \
+ ti_power_clock_config.c \
+
+FILES_PATH_common = \
+ .. \
+ ../../.. \
+ generated \
+
+INCLUDES_common := \
+ -I${CG_TOOL_ROOT}/include/c \
+ -I${MCU_PLUS_SDK_PATH}/source \
+ -I${OPEN_PRU_PATH}/source \
+ -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \
+ -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \
+ -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am261x/r5f \
+ -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \
+ -I${OPEN_PRU_PATH}/examples/spi_driver/firmware/am261x-lp \
+ -Igenerated \
+
+DEFINES_common := \
+ -DSOC_AM261X \
+ -DOS_FREERTOS \
+
+CFLAGS_common := \
+ -mcpu=cortex-r5 \
+ -mfloat-abi=hard \
+ -mfpu=vfpv3-d16 \
+ -mthumb \
+ -Wall \
+ -Werror \
+ -g \
+ -Wno-gnu-variable-sized-type-not-at-end \
+ -Wno-unused-function \
+
+CFLAGS_cpp_common := \
+ -Wno-c99-designator \
+ -Wno-extern-c-compat \
+ -Wno-c++11-narrowing \
+ -Wno-reorder-init-list \
+ -Wno-register \
+ -Wno-writable-strings \
+ -Wno-enum-compare \
+ -Wno-reserved-user-defined-literal \
+ -Wno-unused-const-variable \
+ -Wno-vla-cxx-extension \
+ -x c++ \
+
+CFLAGS_debug := \
+ -D_DEBUG_=1 \
+
+CFLAGS_release := \
+ -Os \
+
+LNK_FILES_common = \
+ generated/linker.cmd \
+
+LIBS_PATH_common = \
+ -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \
+ -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \
+ -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \
+ -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \
+ -Wl,-i${CG_TOOL_ROOT}/lib \
+
+LIBS_common = \
+ -lfreertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \
+ -ldrivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \
+ -lboard.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \
+ -llibc.a \
+ -llibsysbm.a \
+
+LFLAGS_common = \
+ -Wl,--diag_suppress=10063 \
+ -Wl,--ram_model \
+ -Wl,--reread_libs \
+ -Wl,--gen_xml_func_hash \
+
+
+LIBS_NAME = \
+ freertos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \
+ drivers.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \
+ board.am261x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \
+ libc.a \
+ libsysbm.a \
+
+LIBS_PATH_NAME = \
+ ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \
+ ${MCU_PLUS_SDK_PATH}/source/drivers/lib \
+ ${MCU_PLUS_SDK_PATH}/source/board/lib \
+ ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \
+ ${CG_TOOL_ROOT}/lib \
+
+FILES := $(FILES_common) $(FILES_$(PROFILE))
+ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE))
+FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE))
+CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE))
+ifeq ($(INSTRUMENTATION_MODE), yes)
+CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+endif
+DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE))
+INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE))
+LIBS := $(LIBS_common) $(LIBS_$(PROFILE))
+LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE))
+LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE))
+LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE))
+LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE))
+
+OBJDIR := obj/$(PROFILE)/
+OBJS := $(FILES:%.c=%.obj)
+OBJS += $(ASMFILES:%.S=%.obj)
+DEPS := $(FILES:%.c=%.d)
+
+vpath %.obj $(OBJDIR)
+vpath %.c $(FILES_PATH)
+vpath %.S $(FILES_PATH)
+vpath %.lib $(LIBS_PATH_NAME)
+vpath %.a $(LIBS_PATH_NAME)
+
+$(OBJDIR)/%.obj %.obj: %.c
+ @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $<
+ $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $<
+
+$(OBJDIR)/%.obj %.obj: %.S
+ @echo Compiling: am261x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $<
+ $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $<
+
+all: $(TARGETS)
+
+SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h
+SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h
+SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h
+SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c
+SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h
+SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h
+
+SYSTEM_FLAG ?= false
+
+ifeq ($(SYSTEM_FLAG), false)
+ SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME)
+else
+ SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME)
+endif
+
+$(OUTNAME): $(SYSTEM_COMMAND)
+ @echo .
+ @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ ...
+ $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml
+ @echo Linking: am261x:r5fss0-0:freertos:ti-arm-clang $@ Done !!!
+ @echo .
+
+clean:
+ @echo Cleaning: am261x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ...
+ $(RMDIR) $(OBJDIR)
+ $(RM) $(OUTNAME)
+ $(RM) $(BOOTIMAGE_NAME)
+ $(RM) $(BOOTIMAGE_NAME_XIP)
+ $(RM) $(BOOTIMAGE_NAME_SIGNED)
+ $(RM) $(BOOTIMAGE_RPRC_NAME)
+ $(RM) $(BOOTIMAGE_RPRC_NAME_XIP)
+ $(RM) $(BOOTIMAGE_NAME_MCELF)
+ $(RMDIR) generated/
+
+scrub:
+ @echo Scrubing: am261x:r5fss0-0:freertos:ti-arm-clang spi_driver ...
+ $(RMDIR) obj
+ifeq ($(OS),Windows_NT)
+ $(RM) \*.out
+ $(RM) \*.map
+ $(RM) \*.appimage*
+ $(RM) \*.rprc*
+ $(RM) \*.tiimage*
+ $(RM) \*.bin
+ $(RM) \*.lnkxml
+ $(RM) \*.mcelf
+ $(RM) \*.mcelf_xip
+ $(RM) \*.mcelf-enc
+ $(RM) \*.mcelf.hs
+else
+ $(RM) *.out
+ $(RM) *.map
+ $(RM) *.appimage*
+ $(RM) *.rprc*
+ $(RM) *.tiimage*
+ $(RM) *.bin
+ $(RM) *.lnkxml
+ $(RM) *.mcelf
+ $(RM) *.mcelf_xip
+ $(RM) *.mcelf-enc
+ $(RM) *.mcelf.hs
+endif
+ $(RMDIR) generated
+
+$(OBJS): | $(OBJDIR)
+
+$(OBJDIR):
+ $(MKDIR) $@
+
+
+.NOTPARALLEL:
+
+.INTERMEDIATE: syscfg
+$(SYSCFG_GEN_FILES): syscfg
+
+ifeq ($(SYSTEM_FLAG), false)
+syscfg: ../example.syscfg
+ @echo Generating SysConfig files ...
+ $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part AM2612 --package ZFG --output generated/ ../example.syscfg
+endif
+
+syscfg-gui:
+ $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM261x_ZFG --context r5fss0-0 --part AM2612 --package ZFG --output generated/ ../example.syscfg
+
+#
+# Generation of boot image which can be loaded by Secondary Boot Loader (SBL)
+#
+ifeq ($(OS),Windows_NT)
+EXE_EXT=.exe
+endif
+ifeq ($(OS),Windows_NT)
+ BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1
+else
+ BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh
+endif
+BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt
+
+
+BOOTIMAGE_CORE_ID_r5fss0-0 = 0
+BOOTIMAGE_CORE_ID_r5fss0-1 = 1
+BOOTIMAGE_CORE_ID_r5fss1-0 = 2
+BOOTIMAGE_CORE_ID_r5fss1-1 = 3
+SBL_RUN_ADDRESS=0x70002000
+SBL_DEV_ID=55
+
+APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py
+MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py
+
+ifeq ($(OS),Windows_NT)
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe
+else
+ UNAME_S = $(shell uname -s)
+ ifeq ($(UNAME_S), Darwin)
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac
+ else
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out
+endif
+endif
+
+MULTI_CORE_IMAGE_PARAMS = \
+ $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \
+
+MULTI_CORE_IMAGE_PARAMS_XIP = \
+ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \
+
+$(BOOTIMAGE_NAME_MCELF): $(OUTNAME)
+ @echo Boot MulticoreELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) ...
+ $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTNAME) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE) --otfaConfigFile=$(oeconfig)
+ @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!!
+ @echo .
+
+$(BOOTIMAGE_NAME_MCELF_HS): $(BOOTIMAGE_NAME_MCELF)
+ifeq ($(DEVICE_TYPE), HS)
+# Sign the appimage using appimage signing script
+ifeq ($(ENC_ENABLED),no)
+ifeq ($(RSASSAPSS_ENABLED),no)
+ @echo Boot image signing: Encryption is disabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS)
+else
+ @echo Boot image signing: Encryption is disabled. RSASSAPSS is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss
+endif
+else
+ifeq ($(RSASSAPSS_ENABLED),no)
+ @echo Boot image signing: Encryption is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS)
+ $(RM) $(BOOTIMAGE_NAME_MCELF)-enc
+else
+ @echo Boot image signing: Encryption is enabled. RSASSAPSS is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss
+ $(RM) $(BOOTIMAGE_NAME_MCELF)-enc
+endif
+endif
+ @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!!
+ @echo .
+endif
+
+
+
+.PHONY: coverage
+coverage:
+ @echo Creating Coverage Report for spi_driver.$(PROFILE) ...
+ $(MKDIR) coverage
+ $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spi_driver.$(PROFILE).profdata
+ $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spi_driver.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins
+ $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spi_driver.$(PROFILE).profdata > coverage/spi_driver.$(PROFILE).profdata.json
+ node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spi_driver.$(PROFILE).profdata.json --output-json=coverage/spi_driver.$(PROFILE).analysis.json --output=../spi_driver.annotations.$(PROFILE).S --top-function-count=500
+ @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!!
+
+-include $(addprefix $(OBJDIR)/, $(DEPS))
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen
new file mode 100644
index 000000000..15d7f2928
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen
@@ -0,0 +1,112 @@
+#
+# Auto generated makefile
+#
+
+# Below variables need to be defined outside this file or via command line
+# - OPEN_PRU_PATH
+# - MCU_PLUS_SDK_PATH
+# - PROFILE
+# - CG_TOOL_ROOT
+# - OUTNAME
+# - CCS_INSTALL_DIR
+# - CCS_IDE_MODE
+
+CCS_PATH=$(CCS_INSTALL_DIR)
+include $(OPEN_PRU_PATH)/imports.mak
+include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak
+
+STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip
+OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy
+ifeq ($(OS), Windows_NT)
+ PYTHON=python
+else
+ PYTHON=python3
+endif
+
+OUTFILE=$(PROFILE)/$(OUTNAME).out
+BOOTIMAGE_PATH=$(abspath ${PROFILE})
+BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf
+BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs
+TARGETS += $(BOOTIMAGE_NAME_MCELF)
+TARGETS += $(BOOTIMAGE_NAME_MCELF_HS)
+ifeq ($(DEVICE_TYPE), HS)
+ TARGETS += $(BOOTIMAGE_NAME_MCELF_HS)
+endif
+
+#
+# Generation of boot image which can be loaded by Secondary Boot Loader (SBL)
+#
+ifeq ($(OS),Windows_NT)
+EXE_EXT=.exe
+endif
+ifeq ($(OS),Windows_NT)
+ BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1
+else
+ BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh
+endif
+BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt
+
+BOOTIMAGE_CORE_ID_r5fss0-0 = 0
+BOOTIMAGE_CORE_ID_r5fss0-1 = 1
+BOOTIMAGE_CORE_ID_r5fss1-0 = 2
+BOOTIMAGE_CORE_ID_r5fss1-1 = 3
+SBL_RUN_ADDRESS=0x70002000
+SBL_DEV_ID=55
+
+APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/mcu_appimage_x509_cert_gen.py
+MCELF_IMAGE_GEN = $(MCU_PLUS_SDK_PATH)/tools/boot/multicore-elf/genimage.py
+
+ifeq ($(OS),Windows_NT)
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe
+else
+ UNAME_S = $(shell uname -s)
+ ifeq ($(UNAME_S), Darwin)
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac
+ else
+ XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out
+endif
+endif
+
+MULTI_CORE_IMAGE_PARAMS = \
+ $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \
+
+MULTI_CORE_IMAGE_PARAMS_XIP = \
+ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \
+
+all:
+ifeq ($(CCS_IDE_MODE),cloud)
+# No post build steps
+else
+
+ @echo Boot multi-core ELF image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ...
+
+ $(PYTHON) $(MCELF_IMAGE_GEN) --core-img=$(BOOTIMAGE_CORE_ID_r5fss0-0):$(OUTFILE) --output=$(BOOTIMAGE_NAME_MCELF) --merge-segments=$(MCELF_MERGE_SEGMENTS_FLAG) --tolerance-limit=$(MCELF_MERGE_SEGMENTS_TOLERANCE_LIMIT) --ignore-context=$(MCELF_IGNORE_CONTEXT_FLAG) --xip=$(MCELF_XIP_RANGE) --xlat=$(MCELF_ADDR_TRANSLATION_PATH) --max-segment-size=$(MCELF_MAX_SEGMENT_SIZE)
+
+ @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!!
+ @echo .
+
+ifeq ($(DEVICE_TYPE), HS)
+# Sign the appimage using appimage signing script
+ifeq ($(ENC_ENABLED),no)
+ifeq ($(RSASSAPSS_ENABLED),no)
+ @echo Boot image signing: Encryption is disabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS)
+else
+ @echo Boot image signing: Encryption is disabled. RSASSA-PSS is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss
+endif
+else
+ifeq ($(RSASSAPSS_ENABLED),no)
+ @echo Boot image signing: Encryption is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_MCELF_HS)
+ $(RM) $(BOOTIMAGE_NAME_MCELF)-enc
+else
+ @echo Boot image signing: Encryption is enabled. RSASSA-PSS is enabled.
+ $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME_MCELF) --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --kd-salt $(KD_SALT) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --enc_key_id $(APP_ENCRYPTION_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --pss_saltlen $(APP_SIGNING_SALT_LENGTH) --output $(BOOTIMAGE_NAME_MCELF_HS) --rsassa_pss
+ $(RM) $(BOOTIMAGE_NAME_MCELF)-enc
+endif
+endif
+ @echo Boot image: am261x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!!
+ @echo .
+endif
+endif
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec
new file mode 100644
index 000000000..2ce121511
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec
@@ -0,0 +1,16 @@
+export OPEN_PRU_PATH?=$(abspath ../../../../../..)
+include $(OPEN_PRU_PATH)/imports.mak
+
+PROFILE?=Release
+
+PROJECT_NAME=spi_driver_am261x-lp_r5fss0-0_freertos_ti-arm-clang
+
+all:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE)
+
+clean:
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean
+
+export:
+ $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects
+ $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full
diff --git a/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs
new file mode 100644
index 000000000..f716f8e9d
--- /dev/null
+++ b/examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs
@@ -0,0 +1,12 @@
+/*
+ * ======== syscfg_c.rov.xs ========
+ * This file contains the information needed by the Runtime Object
+ * View (ROV) tool.
+ */
+var crovFiles = [
+ "kernel/freertos/rov/FreeRTOS.rov.js",
+];
+
+var objectViewerFiles = [
+ "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js",
+];
diff --git a/examples/spi_driver/mcuplus/empty_example.c b/examples/spi_driver/mcuplus/empty_example.c
new file mode 100644
index 000000000..12fbc8096
--- /dev/null
+++ b/examples/spi_driver/mcuplus/empty_example.c
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 2025 Texas Instruments Incorporated
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * PRU-SPI encoder-emulation demo - R5F side (phase 3)
+ *
+ * Loads PRU1 (slave responder) then PRU0 (master), both persistent — neither
+ * halts after a burst. R5F sets SPI config once before loading, then
+ * repeatedly: prompts for 5 independent 16-bit command words, writes all 5 +
+ * sets cfg_trigger once, polls for PRU0 to clear cfg_trigger after running
+ * all 5 transfers back-to-back within one CS-low burst, and prints the 5
+ * responses. PRU0 supports all 8 (MODE x bit-order) combinations at runtime;
+ * PRU1 is hardcoded to MODE3/MSB/16-bit and always responds with 5 fixed
+ * words (0x1111/0x2222/0x3333/0x4444/0x5555) regardless of command content
+ * - no decode.
+ *
+ *
+ * PRU0 DMEM0 (ICSS_M1 absolute base 0x48600000):
+ * 0x00 cfg_mode R5F writes PRU_SPI_Mode before loading PRU0
+ * 0x04 cfg_bitorder R5F writes PRU_SPI_BitOrder before loading PRU0
+ * 0x10 cfg_trigger R5F sets to 1 to start; PRU0 clears to 0 when done
+ * 0x3C delay_comp_1 R5F sets delay comp 1 before loading PRU0
+ * 0x40 delay_comp_2 R5F sets delay comp 2 before loading PRU0
+ * 0x14-0x24 cfg_cmd0..4 5 command words (MODE3/MSB path only)
+ * 0x28-0x38 master_rx5_0..4 5 response words (MODE3/MSB path only)
+ *
+ *
+ * PRU1 is hardcoded to MODE3/MSB/16-bit and to 5 fixed responses -
+ * it is not part of the configurable driver API.
+ */
+
+#include
+#include
+#include
+#include
+#include "ti_drivers_config.h"
+#include "ti_drivers_open_close.h"
+#include "ti_board_open_close.h"
+#include
+
+#include
+#include
+
+#define DMEM_CFG_MODE (0x00U)
+#define DMEM_CFG_BITORDER (0x04U)
+#define DMEM_CFG_TRIGGER (0x10U)
+#define DMEM_CFG_DELAY_COMP1 (0x3CU)
+#define DMEM_CFG_DELAY_COMP2 (0x40U)
+
+/* 5x16-bit command/response DMEM slots */
+#define DMEM_CFG_CMD0 (0x14U)
+#define DMEM_CFG_CMD1 (0x18U)
+#define DMEM_CFG_CMD2 (0x1CU)
+#define DMEM_CFG_CMD3 (0x20U)
+#define DMEM_CFG_CMD4 (0x24U)
+#define DMEM_MASTER_RX5_0 (0x28U)
+#define DMEM_MASTER_RX5_1 (0x2CU)
+#define DMEM_MASTER_RX5_2 (0x30U)
+#define DMEM_MASTER_RX5_3 (0x34U)
+#define DMEM_MASTER_RX5_4 (0x38U)
+
+#define DMEM_SLAVE_RX (0x00U)
+
+/* Must match PRU1's CMD0-3 constants in main.asm (fixed at build time) */
+#define CMD_DATA_ID_0 (0x1U)
+#define CMD_DATA_ID_1 (0x2U)
+#define CMD_DATA_ID_2 (0x3U)
+#define CMD_DATA_ID_3 (0x4U)
+
+#define TRIGGER_POLL_SLEEP_US (10U)
+/* Worst-case burst: 80 bits x (10 overhead + 65535 + 65535) cycles
+ * = ~10.5M cycles = ~47 ms at 225 MHz. Use 100 ms so any legitimate burst
+ * (any legal delay_comp_1/delay_comp_2) completes before the timeout, while
+ * a genuinely stuck PRU is still detected and reloaded on the same order of
+ * magnitude (once stuck it stays stuck, so detection latency is not critical).
+ */
+#define TRIGGER_POLL_TIMEOUT_US (100000U)
+
+typedef enum
+{
+ PRU_SPI_MODE_0 = 0,
+ PRU_SPI_MODE_1,
+ PRU_SPI_MODE_2,
+ PRU_SPI_MODE_3
+} PRU_SPI_Mode;
+
+typedef enum
+{
+ PRU_SPI_MSB_FIRST = 0,
+ PRU_SPI_LSB_FIRST
+} PRU_SPI_BitOrder;
+
+typedef struct
+{
+ PRU_SPI_Mode mode;
+ PRU_SPI_BitOrder bitOrder;
+ uint32_t delay_comp_1;
+ uint32_t delay_comp_2;
+} PRU_SPI_Config;
+
+static PRUICSS_Handle gPruHandle;
+static uint32_t pru_dmem0 = 0U;
+static uint32_t pru_dmem1 = 0U;
+
+static inline void dmem_write32(uint32_t base, uint32_t offset, uint32_t value)
+{
+ volatile uint32_t *p = (volatile uint32_t *)(base + offset);
+ *p = value;
+}
+
+static inline uint32_t dmem_read32(uint32_t base, uint32_t offset)
+{
+ volatile uint32_t *p = (volatile uint32_t *)(base + offset);
+ return *p;
+}
+
+/* Valid delay-compensation range per the PRU firmware (main.asm:113-121):
+ * delay_comp_1/delay_comp_2 are full registers, valid 1-65535. A value of 0
+ * defeats the N-1 hardware-loop compensation and can wrap the hardware loop
+ * counter; values above 65535 exceed the .loop immediate limit. */
+#define DELAY_COMP_MIN (1U)
+#define DELAY_COMP_MAX (0xFFFFU)
+
+/* Must be called BEFORE PRUICSS_loadFirmware(PRU0) - loadFirmware resets and
+ * starts the core immediately, so config has to already be in DMEM0.
+ * Returns 0 on success, -1 if a delay-comp value is out of range. */
+static int PRU_SPI_setConfig(const PRU_SPI_Config *cfg)
+{
+ if (cfg->delay_comp_1 < DELAY_COMP_MIN || cfg->delay_comp_1 > DELAY_COMP_MAX)
+ {
+ DebugP_log("ERROR: delay_comp_1 %u out of range (1-65535)\r\n",
+ cfg->delay_comp_1);
+ DebugP_assert(0);
+ return -1;
+ }
+ if (cfg->delay_comp_2 < DELAY_COMP_MIN || cfg->delay_comp_2 > DELAY_COMP_MAX)
+ {
+ DebugP_log("ERROR: delay_comp_2 %u out of range (1-65535)\r\n",
+ cfg->delay_comp_2);
+ DebugP_assert(0);
+ return -1;
+ }
+
+ dmem_write32(pru_dmem0, DMEM_CFG_MODE, (uint32_t)cfg->mode);
+ dmem_write32(pru_dmem0, DMEM_CFG_BITORDER, (uint32_t)cfg->bitOrder);
+ dmem_write32(pru_dmem0, DMEM_CFG_DELAY_COMP1, cfg->delay_comp_1);
+ dmem_write32(pru_dmem0, DMEM_CFG_DELAY_COMP2, cfg->delay_comp_2);
+ return 0;
+}
+
+
+/* Writes 5 independent 16-bit command words, sets cfg_trigger once, polls
+ * until PRU0 clears it after running all 5 transfers back-to-back, then reads
+ * 5 independent response words. Works for any runtime mode/bit-order PRU0 is
+ * configured for. commandWords/responsesOut must each point to 5 uint32_t.
+ * Returns 1 on success, 0 on timeout. */
+static int PRU_SPI_runTransaction5(const uint32_t *commandWords, uint32_t *responsesOut)
+{
+ dmem_write32(pru_dmem0, DMEM_CFG_CMD0, commandWords[0]);
+ dmem_write32(pru_dmem0, DMEM_CFG_CMD1, commandWords[1]);
+ dmem_write32(pru_dmem0, DMEM_CFG_CMD2, commandWords[2]);
+ dmem_write32(pru_dmem0, DMEM_CFG_CMD3, commandWords[3]);
+ dmem_write32(pru_dmem0, DMEM_CFG_CMD4, commandWords[4]);
+ dmem_write32(pru_dmem0, DMEM_CFG_TRIGGER, 1U);
+
+ uint32_t elapsed = 0U;
+ while (dmem_read32(pru_dmem0, DMEM_CFG_TRIGGER) != 0U)
+ {
+ ClockP_usleep(TRIGGER_POLL_SLEEP_US);
+ elapsed += TRIGGER_POLL_SLEEP_US;
+ if (elapsed >= TRIGGER_POLL_TIMEOUT_US)
+ {
+ /* Clear the trigger if PRU has not cleared it after timeout */
+ dmem_write32(pru_dmem0, DMEM_CFG_TRIGGER, 0U);
+ return 0;
+ }
+ }
+
+ responsesOut[0] = dmem_read32(pru_dmem0, DMEM_MASTER_RX5_0);
+ responsesOut[1] = dmem_read32(pru_dmem0, DMEM_MASTER_RX5_1);
+ responsesOut[2] = dmem_read32(pru_dmem0, DMEM_MASTER_RX5_2);
+ responsesOut[3] = dmem_read32(pru_dmem0, DMEM_MASTER_RX5_3);
+ responsesOut[4] = dmem_read32(pru_dmem0, DMEM_MASTER_RX5_4);
+ return 1;
+}
+
+void empty_example_main(void *args)
+{
+ int32_t status;
+ int32_t scanf_status;
+ uint32_t input = 0U;
+
+ Drivers_open();
+ status = Board_driversOpen();
+ DebugP_assert(SystemP_SUCCESS == status);
+
+ gPruHandle = PRUICSS_open(CONFIG_PRU_ICSS0);
+ DebugP_assert(gPruHandle != NULL);
+
+ const PRUICSS_HwAttrs *pruAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS0);
+ DebugP_assert(pruAttrs != NULL);
+ pru_dmem0 = pruAttrs->pru0DramBase;
+ pru_dmem1 = pruAttrs->pru1DramBase;
+
+ status = PRUICSS_initMemory(gPruHandle, PRUICSS_DATARAM(PRUICSS_PRU0));
+ DebugP_assert(status != 0);
+ status = PRUICSS_initMemory(gPruHandle, PRUICSS_DATARAM(PRUICSS_PRU1));
+ DebugP_assert(status != 0);
+
+ /* PRU1 (slave responder) is hardcoded to MODE3/MSB - match it here.
+ * Must be written before PRU0 loads. Trigger starts cleared. */
+
+ /* Declare the configurations */
+ PRU_SPI_Config cfg = { .mode = PRU_SPI_MODE_3, .bitOrder = PRU_SPI_MSB_FIRST, .delay_comp_1 = 8, .delay_comp_2 = 27 };
+ /* For this example, SCLK ~ (225Mhz/ (10+d1+d2)) = 225/45 = 5Mhz, change the delay_comp_1 and delay_comp_2 values above according to use case */
+
+ /* Set the configurations. Reject out-of-range delay compensation before
+ * loading the PRUs - loadFirmware starts the core immediately. */
+ status = PRU_SPI_setConfig(&cfg);
+ DebugP_assert(SystemP_SUCCESS == status);
+ dmem_write32(pru_dmem0, DMEM_CFG_TRIGGER, 0U);
+
+ status = PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU1,
+ PRU1Firmware_0, sizeof(PRU1Firmware_0));
+ DebugP_assert(SystemP_SUCCESS == status);
+ DebugP_log("[PRU-SPI] PRU1 slave responder loaded\r\n");
+ status = PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU0,
+ PRU0Firmware_0, sizeof(PRU0Firmware_0));
+ DebugP_assert(SystemP_SUCCESS == status);
+ DebugP_log("[PRU-SPI] PRU0 master loaded (persistent, never halts)\r\n");
+
+ DebugP_log("Enter 5 16-bit command words per round; PRU1 always responds\r\n");
+ DebugP_log("with 0x1111, 0x2222, 0x3333, 0x4444, 0x5555 (in order).\r\n");
+ while (1)
+ {
+ uint32_t commandWords[5];
+ uint32_t responses[5];
+ uint32_t i;
+
+ DebugP_log("\r\nEnter 5 16-bit command words, one at a time:\r\n");
+ i = 0U;
+ while (i < 5U)
+ {
+ DebugP_log(" cmd[%u]: ", i);
+ input = 0xFFFFFFFFU;
+ scanf_status = DebugP_scanf("%x", &input);
+ if (scanf_status != SystemP_SUCCESS) {
+ DebugP_log("Invalid input (scan failed).\r\n");
+ input = 0U;
+ continue;
+ }
+
+ if (input > 0xFFFFU)
+ {
+ DebugP_log("Invalid input, must fit in 16 bits (0x0000-0xFFFF hex).\r\n");
+ continue;
+ }
+
+ commandWords[i] = input;
+ i++;
+ }
+
+ if (!PRU_SPI_runTransaction5(commandWords, responses))
+ {
+ DebugP_log("ERROR: PRU0 timeout waiting for trigger clear. Reloading PRUs...\r\n");
+ dmem_write32(pru_dmem0, DMEM_CFG_TRIGGER, 0U);
+ status = PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU1,
+ PRU1Firmware_0, sizeof(PRU1Firmware_0));
+ DebugP_assert(SystemP_SUCCESS == status);
+ status = PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU0,
+ PRU0Firmware_0, sizeof(PRU0Firmware_0));
+ DebugP_assert(SystemP_SUCCESS == status);
+ status = PRU_SPI_setConfig(&cfg);
+ DebugP_assert(SystemP_SUCCESS == status);
+ dmem_write32(pru_dmem0, DMEM_CFG_TRIGGER, 0U);
+ continue;
+ }
+
+ for (i = 0U; i < 5U; i++)
+ {
+ DebugP_log("[PRU-SPI] sent cmd[%u]=0x%04X response[%u]=0x%04X\r\n",
+ i, commandWords[i], i, responses[i]);
+ }
+ }
+
+ PRUICSS_disableCore(gPruHandle, PRUICSS_PRU0);
+ PRUICSS_disableCore(gPruHandle, PRUICSS_PRU1);
+
+ Board_driversClose();
+ Drivers_close();
+}
diff --git a/examples/spi_driver/readme.md b/examples/spi_driver/readme.md
new file mode 100644
index 000000000..2e507bd26
--- /dev/null
+++ b/examples/spi_driver/readme.md
@@ -0,0 +1,270 @@
+# spi_driver Project
+
+## Introduction
+
+This example implements a bit-banged SPI **master** driver on a PRU core,
+controlled from the R5F over a small runtime configuration API. There is no
+dedicated SPI peripheral involved — PRU0 toggles SCLK/SDO/CS and samples SDI
+directly using the `spi_master_macros.inc` bit-bang macros. PRU1 runs a
+matching SPI **slave** that emulates a simple fixed-response encoder, so the
+R5F demo can drive real command/response transactions on hardware; PRU1 is
+not part of the driver API and is not intended to be configurable.
+
+Both PRU0 and PRU1 are loaded **once** and run forever — there is no
+load-once-halt-once cycle per transfer. The R5F drives repeated SPI
+transactions against the already-running PRU0 via a DMEM-based
+trigger/poll mechanism (see "Driver Overview" below).
+
+Each triggered transaction is a **burst of 5 independent 16-bit transfers**
+run back-to-back under one CS-low assertion, with **no delay inserted
+between transfers** — SCLK runs continuously for all 80 bits. This is a
+deliberate design choice (minimum/no inter-transfer delay was the
+requirement), not an artifact — see "One-transaction response delay" below
+for the one real consequence of running transfers back-to-back like this.
+
+This is a first-version prototype driver, not a production-hardened one.
+
+## Supported Combinations
+
+Refer to open-pru/examples/readme.md > Supported processors per-project
+for the list of processors that support building this project, and information
+about porting this project to other processors.
+
+Currently only **AM261x LaunchPad** (ICSS_M1, PRU0 = master, PRU1 = slave) has
+been implemented and validated.
+
+## Validated HW & SW
+
+This project was tested on hardware with these software versions:
+
+| Processor | Hardware | Software |
+| --------- | ---------- | -------------------------- |
+| AM261x | AM261x LaunchPad | MCU PLUS SDK 11.0.0.29, OpenPRU 2026.02.00, TI PRU CGT 2.3.3, TI ARM Clang 4.0.0 |
+
+## Driver Overview
+
+The R5F application (`mcuplus/empty_example.c`) loads PRU1 (slave responder)
+then PRU0 (master), **once**. Neither PRU halts afterward — PRU0 sits in a
+persistent loop waiting for a trigger, and PRU1 sits in a persistent loop
+waiting for CS. `PRUICSS_loadFirmware()` internally does
+`disableCore -> writeMemory -> resetCore -> enableCore`, i.e. it starts the PRU
+running immediately, so mode/bitOrder configuration must be written before
+this call — but unlike the transfer itself, that only happens once at startup.
+
+Configuration and transfer data are exchanged through PRU0's own data RAM
+(DMEM0):
+
+| Offset | Name | Direction | Meaning |
+| ----------- | --------------------- | ------------- | ----------------------------------------------------------------- |
+| 0x00 | `cfg_mode` | R5F -> PRU0 | SPI mode, 0-3 (`PRU_SPI_Mode`), read once at startup |
+| 0x04 | `cfg_bitorder` | R5F -> PRU0 | 0 = MSB first, 1 = LSB first, read once at startup |
+| 0x10 | `cfg_trigger` | R5F <-> PRU0 | R5F sets to 1 to start a transaction; PRU0 clears to 0 when all 5 transfers complete |
+| 0x3C | `delay_comp_1` | R5F <-> PRU0 | PRU cycles between shifting edge and sampling edge (valid: 1-65535) |
+| 0x40 | `delay_comp_2` | R5F <-> PRU0 | PRU cycles between sampling edge and next shifting edge (valid: 1-65535) |
+| 0x14 - 0x24 | `cfg_cmd0` .. `cfg_cmd4` | R5F -> PRU0 | 5 independent 16-bit command words, written before setting `cfg_trigger` |
+| 0x28 - 0x38 | `master_rx5_0` .. `master_rx5_4` | PRU0 -> R5F | 5 independent 16-bit response words, written after the 5-transfer burst completes |
+
+SPI Modes and clock polarity :
+
+| SPI Mode | CPOL | CPHA | Idle State Clock Polarity | Clock Phase Used to Sample and/or Shift the Data|
+|----------|------|------|----------------------------|-------------------------------------------------|
+| 0 | 0 | 0 | Logic low | Data sampled on rising edge and shifted out on the falling edge |
+| 1 | 0 | 1 | Logic low | Data sampled on the falling edge and shifted out on the rising edge |
+| 2 | 1 | 0 | Logic high | Data sampled on the falling edge and shifted out on the rising edge |
+| 3 | 1 | 1 | Logic high | Data sampled on the rising edge and shifted out on the falling edge |
+### R5F driver API
+
+```c
+typedef enum { PRU_SPI_MODE_0=0, PRU_SPI_MODE_1, PRU_SPI_MODE_2, PRU_SPI_MODE_3 } PRU_SPI_Mode;
+typedef enum { PRU_SPI_MSB_FIRST=0, PRU_SPI_LSB_FIRST } PRU_SPI_BitOrder;
+typedef struct {
+ PRU_SPI_Mode mode;
+ PRU_SPI_BitOrder bitOrder;
+ uint8_t delay_comp_1;
+ uint8_t delay_comp_2;
+} PRU_SPI_Config;
+
+/* Must be called BEFORE PRUICSS_loadFirmware(PRU0) */
+static void PRU_SPI_setConfig(const PRU_SPI_Config *cfg);
+
+/* Writes 5 independent 16-bit command words + sets cfg_trigger, polls until
+ * PRU0 clears it (5ms timeout) after running all 5 transfers back-to-back
+ * under one CS-low assertion, then reads 5 independent response words into
+ * responsesOut. commandWords/responsesOut must each point to 5 uint32_t.
+ * Returns 0 on timeout. */
+static int PRU_SPI_runTransaction5(const uint32_t *commandWords, uint32_t *responsesOut);
+```
+
+Usage:
+
+```c
+PRU_SPI_Config cfg = { .mode = PRU_SPI_MODE_3, .bitOrder = PRU_SPI_MSB_FIRST, .delay_comp_1 = 8, .delay_comp_2 = 27 };
+PRU_SPI_setConfig(&cfg);
+PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU1, ...); /* slave responder first */
+PRUICSS_loadFirmware(gPruHandle, PRUICSS_PRU0, ...); /* master, auto-starts, never halts */
+
+uint32_t commandWords[5] = { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555 };
+uint32_t responses[5];
+if (PRU_SPI_runTransaction5(commandWords, responses)) {
+ /* responses[0..4] hold the 5 words received during this burst */
+}
+/* Call PRU_SPI_runTransaction5() again for the next burst — no reload needed. */
+```
+
+All 8 (MODE x bit-order) combinations run the same 5x16-bit burst — PRU0's
+runtime branch table (see "Configurable at runtime" below) now has a
+dedicated 5-transfer subroutine per combination. PRU1 (the slave responder)
+is still hardcoded to a single fixed mode/bit-order at build time — see
+"PRU1 (slave)" below — so only the one combination PRU1 is built for will
+produce a real round trip; the other 7 will still drive SCLK/SDO correctly
+on the wire, but PRU1 won't be sampling in a matching mode.
+
+**Load order matters.** PRU1 must load (and start polling CS) strictly before
+PRU0 loads (and auto-starts) — otherwise PRU0 can complete its first transfer
+before PRU1 is even watching for CS to go low.
+
+**No inter-transfer delay, by design.** Within a single triggered burst, all
+5 transfers run back-to-back with no gap — the last sampling edge of
+transfer N is immediately followed by the shifting edge of transfer N+1's
+first bit (a few cycles of `ldi`/branch overhead at most). SCLK toggles
+continuously for the full 80-bit burst; there is no idle period between the
+5 sub-transfers visible on a logic analyzer. This was an explicit
+requirement (minimum/no delay from the SPI side), not something left
+unoptimized.
+
+**Response content is fixed, not decoded.** PRU1 doesn't inspect the 5
+command words it receives — it always sends back the same 5 fixed response
+words regardless of content (see "PRU1 (slave)" below). This sidesteps the
+one-transaction pipeline delay that the earlier single-command version of
+this driver had (where PRU1 decoded command N only after already sending
+the response to command N-1) — since responses aren't decoded from input at
+all in the 5x burst version, there's nothing to be stale.
+
+### Configurable at runtime (via the driver API, no rebuild needed)
+
+- **SPI mode** (0-3, i.e. CPOL/CPHA combination) — read once at PRU0 startup
+- **Bit order** (MSB first / LSB first) — read once at PRU0 startup
+- **5 command words** (via `PRU_SPI_runTransaction5`, once per burst — not a
+ one-time config value like mode/bitOrder)
+- **Delay Compensation 1/2** - full register (R20/R21), valid 1–65535 (`loop` macro uses OP(256))
+
+**Note** - PRU clock = 225 MHz (ICSS_M1 SDK default; ICSS_M0 defaults to 200 MHz).
+`PRU_CLK_CYC_PRD_CONST` is set to `5` (ceil of 4.44 ns/cycle). This yields slightly
+fewer cycles than requested (e.g. 35 ns request -> ~31 ns effective); the
+35 ns `m_wait_nano_sec` values are safe upper bounds. SCLK = ~5 MHz for
+delay_comp_1=8, delay_comp_2=27.
+
+### Fixed at firmware build time (edit `firmware/am261x-lp/icss_m1_pru0_fw/main.asm` and rebuild)
+
+- **Packet size** — fixed at 16 bits (`PACKET_SIZE`). The underlying macros
+ (`spi_master_macros.inc`/`spi_slave_macros.inc`) enforce **1-32 bits** at
+ assemble time (`.if (PACKETSIZE > 32) | (PACKETSIZE < 1) .emsg ...`) since
+ data is shifted through a single 32-bit register — this is a hard ceiling
+ for this bit-bang approach, not just this driver's current choice.
+
+- **Pin assignments** (`SCLK_PIN`, `SDO_PIN`, `CS_PIN`, `SDI_PIN`)
+
+Both PRU0 (master, via `m_transfer_packet_spi_master_gpo_sclk_drv`) and PRU1
+(slave, via `m_transfer_packet_spi_slave_gpi_sclk`) use the combined
+full-duplex transfer macro, called 5 times per burst with no gap in between
+— see "PRU1 (slave)" below for the fixed responses PRU1 sends back.
+
+Mode, bit order and delay compensation can be selected at runtime because the underlying macro
+(`m_transfer_packet_spi_master_gpo_sclk_drv`) internally uses assembler directives
+(`.if $symcmp(...)`) that only resolve against string literals at assemble
+time — a runtime register value can't be passed in directly. The workaround
+is an 8-way branch table: all 8 MODE x bit-order combinations are pre-assembled
+as separate labeled blocks, and PRU0 reads `cfg_mode`/`cfg_bitorder` from its
+own DMEM0 at startup and uses plain runtime branches (`qbeq`/`qba`) to jump to
+the matching block. Packet size are not part of this table (would
+require a much larger branch table) and remain compile-time constants for this
+prototype.
+
+**NOTE**
+- Please refer to `open-pru\source\firmware\common\spi_master_macros.inc` for more details and implementation of the SPI macros used**
+**PRU0 accesses its own DMEM0 via the constant table (`c24`, `lbco`/`sbco`)**,
+whose default block index is already correctly pre-configured on this
+hardware — no `PRUICSS_setConstantTblEntry` call is required. The R5F accesses
+the same memory via its global/bus address (`0x48600000` for PRU0 DMEM0,
+`0x48602000` for PRU1 DMEM1). These are two different address spaces for the
+same physical memory — a PRU must never use the R5F's global address to access
+its own DMEM via `sbbo`/`lbbo`.
+
+### PRU1 (slave) — encoder-emulation responder
+
+PRU1 is hardcoded (build-time constant, not configurable via the driver API)
+to a single fixed mode/bit-order and emulates a simple fixed-response
+encoder: within a 5-transfer burst it sends back 5 fixed 16-bit response
+words, ignoring whatever command words it receives. It exists to give the
+R5F demo something realistic to exercise the trigger mechanism against.
+
+Currently built for **MODE3 / MSB first / 16-bit** (matches the R5F's
+`PRU_SPI_setConfig` call in the usage example above). To test a different
+mode/bit-order, rebuild PRU1's `main.asm` with a different mode/S_BIT string
+in its `DO_5X_TRANSFER` subroutine and update the R5F's `PRU_SPI_setConfig`
+call to match — PRU0 already supports all 8 combinations at runtime (see
+"Driver Overview" above), only PRU1 needs a rebuild.
+
+| Transfer # | Response word (fixed) |
+| ---------- | ---------------------- |
+| 1 | `0x1111` |
+| 2 | `0x2222` |
+| 3 | `0x3333` |
+| 4 | `0x4444` |
+| 5 | `0x5555` |
+
+PRU1 uses `m_transfer_packet_spi_slave_gpi_sclk` — the **combined**
+full-duplex slave macro, which sends and samples every bit concurrently
+within one CS-low burst.
+
+**Confirmed MODE3 behavior on this driver** (from `spi_master_macros.inc`'s
+own CPOL/CPHA table): SCLK idles **high**; data is **sampled** (received) on
+the **rising** edge and **shifted out** (transmitted) on the **falling**
+edge. Verified consistent on hardware with a logic analyzer.
+
+## Hardware Setup (AM261x LaunchPad)
+
+This demo needs PRU0 (master) wired to PRU1 (slave) on the LaunchPad header,
+since both firmware images run on the same board.
+
+**PRU0 (master) signals:**
+
+| Signal | PRU pin | SoC GPIO | LaunchPad header pin |
+| ------ | ------------- | -------------------------- | --------------------- |
+| SCLK | r30.0 (GPO0) | GPIO81 (PR1_PRU0_GPIO0) | J2.11 |
+| SDO | r30.1 (GPO1) | GPIO82 (PR1_PRU0_GPIO1) | J7.67 |
+| CS | r30.2 (GPO2) | GPIO83 (PR1_PRU0_GPIO2) | J7.68 |
+| SDI | r31.6 (GPI6) | GPIO45 (PR1_PRU0_GPIO6) | J7.69 |
+
+**PRU1 (slave, encoder-emulation responder) signals:**
+
+| Signal | PRU pin | SoC GPIO | LaunchPad header pin |
+| ------ | -------------- | --------------------------- | --------------------- |
+| SCLK | r31.4 (GPI4) | GPIO15 (PR1_PRU1_GPIO4) | J1.5 |
+| CS | r31.6 (GPI6) | GPIO19 (PR1_PRU1_GPIO6) | J5.48 |
+| SDO | r30.5 (GPO5) | GPIO54 (PR1_PRU1_GPIO5) | J2.13 |
+| SDI | r31.11 (GPI11) | GPIO3 (PR1_PRU1_GPIO11) | J1.8 |
+
+**Wiring for the demo** — connect master to slave with jumper wires:
+
+| Master pin | Slave pin | Signal |
+| ---------- | --------- | ------------- |
+| J2.11 (SCLK) | J1.5 (SCLK) | Clock, master-driven |
+| J7.68 (CS) | J5.48 (CS) | Chip select, master-driven, active low |
+| J7.67 (SDO) | J1.8 (SDI) | Master -> slave data (command) |
+| J7.69 (SDI) | J2.13 (SDO) | Slave -> master data (response) |
+
+All four wires are needed for this demo — unlike a simple loopback test, the
+R5F command/response loop depends on actually receiving PRU1's response on
+every transaction, not just verifying that a send occurred.
+
+## Overview
+
+For more information about using this example to write your own PRU firmware,
+refer to
+[Creating a New Project in the OpenPRU Repo](../../docs/open_pru_create_new_project.md).
+
+## Steps to Run the Example
+
+Refer to the **PRU Academy > PRU Getting Started Labs** for steps to build,
+load, and debug PRU firmware.
diff --git a/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec
index 290e3c451..4c94ca4d2 100644
--- a/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec
+++ b/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec
@@ -76,7 +76,5 @@
-
-
diff --git a/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec
index c514d4086..bf58fc436 100644
--- a/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec
+++ b/examples/spi_loopback/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec
@@ -76,7 +76,5 @@
-
-
diff --git a/examples/spi_loopback/readme.md b/examples/spi_loopback/readme.md
index 5d48e0bd8..879e145b5 100644
--- a/examples/spi_loopback/readme.md
+++ b/examples/spi_loopback/readme.md
@@ -4,6 +4,7 @@
This example provides a base for running loopback spi connection between a pair of master and slave PRU cores.
The example uses generic SPI macros introduced in files spi_master_macros.inc and spi_slave_macros.inc to emulate generic SPI master and slave interfaces over PRU GPIO pins.
+The macro files are located under `open-pru\source\firmware\common`.
## Overview
### Timing Parameters
diff --git a/examples/spi_loopback/firmware/am243x-lp/spi_master_macros.inc b/source/firmware/common/spi_master_macros.inc
similarity index 81%
rename from examples/spi_loopback/firmware/am243x-lp/spi_master_macros.inc
rename to source/firmware/common/spi_master_macros.inc
index fb48e528a..21e5a72fe 100644
--- a/examples/spi_loopback/firmware/am243x-lp/spi_master_macros.inc
+++ b/source/firmware/common/spi_master_macros.inc
@@ -91,8 +91,8 @@
; bitId - To track Bit index (8 bits wide)
; SCLK_PIN - PRU Pin number for SCLK
; SDI_PIN - PRU Pin number for SDI
-; DELAY_COMPEN_1 - PRU cycles to wait for while SCLK is high
-; DELAY_COMPEN_2 - PRU cycles to wait for while SCLK is low
+; DELAY_COMPEN_1 - PRU cycles to wait between shifting edge and sampling edge
+; DELAY_COMPEN_2 - PRU cycles to wait between sampling edge and next shifting edge
;
; Returns:
; - The received data packet is stored in the `dataReg` register.
@@ -170,8 +170,8 @@ SKIP_BIT_ENTRY_0?:
; bitId - To track Bit index (8 bits wide)
; SCLK_PIN - PRU Pin number for SCLK
; SDI_PIN - PRU Pin number for SDI
-; DELAY_COMPEN_1 - PRU cycles to wait for while SCLK is high
-; DELAY_COMPEN_2 - PRU cycles to wait for while SCLK is low
+; DELAY_COMPEN_1 - PRU cycles to wait between shifting edge and sampling edge
+; DELAY_COMPEN_2 - PRU cycles to wait between sampling edge and next shifting edge
;
; Returns:
; - The received data packet is stored in the `dataReg` register.
@@ -249,8 +249,8 @@ SKIP_BIT_ENTRY_0?:
; bitId - To track Bit index (8 bits wide)
; SCLK_PIN - PRU Pin number for SCLK
; SDO_PIN - PRU Pin number for SDO
-; DELAY_COMPEN_1 - PRU cycles to wait for while SCLK is high
-; DELAY_COMPEN_2 - PRU cycles to wait for while SCLK is low
+; DELAY_COMPEN_1 - PRU cycles to wait between shifting edge and sampling edge
+; DELAY_COMPEN_2 - PRU cycles to wait between sampling edge and next shifting edge
;
; Returns:
; - No return value
@@ -329,8 +329,8 @@ data_high?:
; bitId - To track Bit index (8 bits wide)
; SCLK_PIN - PRU Pin number for SCLK
; SDO_PIN - PRU Pin number for SDO
-; DELAY_COMPEN_1 - PRU cycles to wait for while SCLK is high
-; DELAY_COMPEN_2 - PRU cycles to wait for while SCLK is low
+; DELAY_COMPEN_1 - PRU cycles to wait between shifting edge and sampling edge
+; DELAY_COMPEN_2 - PRU cycles to wait between sampling edge and next shifting edge
;
; Returns:
; - No return value
@@ -371,6 +371,111 @@ data_high?:
.endm
+;************************************************************************************
+; Macro: m_transfer_packet_spi_master_gpo_sclk_drv
+;
+; Description:
+; - Reads 1 data packet and Writes 1 data packet concurrently through
+; the SPI slave interface. SPI master initiates SCLK.
+; - CS is to be pulled down before calling this macro.
+; - Theoretical max frequency at 333MHz PRU clock is 27.77MHz (d1=2, d2=0)
+; - Practical limitation upto 12.8 MHz SCLK (d1=9, d2=7) in combination with
+; m_transfer_packet_spi_slave_gpi_sclk macro
+;
+; PEAK cycles:
+; ~ (4+d1) + (6+d2) cycles
+;
+; Assumptions:
+; - CS must be pulled low before calling this macro.
+; - The SCLK_PIN, SDI_PIN and SDO_PIN must be configured correctly.
+; - PACKETSIZE should not be more than 32 (bits) or less than 1
+; - DELAY_COMPEN_1 and DELAY_COMPEN_2 are properly calculated
+; - r_dataReg should be cleared before calling this macro
+;
+; Pseudo code:
+; ========== C ==========
+; if(S_BIT == MSB)
+; bitId = PACKETSIZE - 1
+; elseif(S_BIT == LSB)
+; bitID = 0
+; loop: READ_PACKET
+; set SCLK shifting edge
+; set SDO bit
+; wait d1 cycles
+; set SCLK sampling edge
+; read SDI bit
+; wait d2 cycles
+; =======================
+;
+; Parameters:
+; s_dataReg - Contains data packet to send
+; r_dataReg - Register where received data packet is stored
+; PACKETSIZE - Size of data packet in bits
+; bitId - To track Bit index (8 bits wide)
+; SCLK_PIN - PRU Pin number for SCLK
+; SDO_PIN - PRU Pin number for SDO
+; SDI_PIN - PRU Pin number for SDI
+; DELAY_COMPEN_1 - PRU cycles to wait between shifting edge and sampling edge
+; DELAY_COMPEN_2 - PRU cycles to wait between sampling edge and next shifting edge
+; MODE - MODE0, MODE1, MODE2 or MODE3 mode of SPI operation
+; S_BIT - MSB or LSB
+;
+; Returns:
+; - The received data packet is stored in the `r_dataReg` register.
+;************************************************************************************
+m_transfer_packet_spi_master_gpo_sclk_drv .macro r_dataReg, s_dataReg, PACKETSIZE, bitId, SCLK_PIN, SDI_PIN, SDO_PIN, DELAY_COMPEN_1_REG, DELAY_COMPEN_2_REG, MODE, S_BIT
+ ; Validating packetsize parameter
+ .if (PACKETSIZE > 32) | (PACKETSIZE < 1)
+ .emsg "Error: Invalid parameter used in macro: PACKETSIZE"
+ .endif
+ .if $symcmp(S_BIT,"MSB") = 0
+ ldi bitId, PACKETSIZE - 1
+ .elseif $symcmp(S_BIT,"LSB") = 0
+ ldi bitId, 0
+ .else
+ .emsg "Error: Invalid parameter used in macro: S_BIT"
+ .endif
+READ_BIT_LOOP?:
+ ;shifting edge
+ m_handle_spi_mode "SHIFTING_EDGE", MODE, SCLK_PIN
+
+ qbbc data_low?, s_dataReg, bitId
+ m_pru_set_pin SDO_PIN
+ qba data_high?
+data_low?:
+ m_pru_clr_pin SDO_PIN
+ NOP
+data_high?:
+ loop endloop1?,DELAY_COMPEN_1_REG ; delay before sampling edge
+ NOP
+endloop1?:
+
+ ;sampling edge
+ m_handle_spi_mode "SAMPLING_EDGE", MODE, SCLK_PIN
+
+ qbbc BIT_ENTRY_0?, r31, SDI_PIN
+ set r_dataReg, r_dataReg, bitId ; store data in register
+ qba SKIP_BIT_ENTRY_0?
+BIT_ENTRY_0?:
+ clr r_dataReg, r_dataReg, bitId
+ nop
+SKIP_BIT_ENTRY_0?:
+ loop endloop?,DELAY_COMPEN_2_REG ; delay before shifting edge
+ NOP
+endloop?:
+
+ .if $symcmp(S_BIT,"MSB") = 0
+ sub bitId, bitId, 1
+ qbne READ_BIT_LOOP?, bitId, 0xFF
+ .elseif $symcmp(S_BIT,"LSB") = 0
+ add bitId, bitId, 1
+ qbne READ_BIT_LOOP?, bitId, PACKETSIZE
+ .endif
+
+ m_handle_spi_mode "END", MODE, SCLK_PIN
+
+ .endm
+
;************************************************************************************
; Macro: m_transfer_packet_spi_master_gpo_sclk
;
diff --git a/examples/spi_loopback/firmware/am243x-lp/spi_slave_macros.inc b/source/firmware/common/spi_slave_macros.inc
similarity index 100%
rename from examples/spi_loopback/firmware/am243x-lp/spi_slave_macros.inc
rename to source/firmware/common/spi_slave_macros.inc