From 9a16e0053ee48bdc37d4cf32708b2063af6c09bd Mon Sep 17 00:00:00 2001 From: Achala Ram Date: Mon, 4 May 2026 17:52:47 +0530 Subject: [PATCH 01/29] am261x: pru i2c: Add PRU I2C Master firmware and R5F example - Add I2C firmware - Create PRU0/PRU1 build projects for ICSS_M0 - Configure makefiles and projectspec for open-pru structure Signed-off-by: Achala Ram --- .../ti-pru-cgt/example.projectspec | 81 + .../icss_m0_pru0_fw/ti-pru-cgt/linker.cmd | 43 + .../icss_m0_pru0_fw/ti-pru-cgt/makefile | 48 + .../ti-pru-cgt/example.projectspec | 81 + .../icss_m0_pru1_fw/ti-pru-cgt/linker.cmd | 43 + .../icss_m0_pru1_fw/ti-pru-cgt/makefile | 48 + .../firmware/am261x-lp/pru0_load_bin.h | 956 ++++++++++++ .../firmware/am261x-lp/pru1_load_bin.h | 956 ++++++++++++ .../firmware/pru_i2c_firmware_version.h | 54 + examples/pru_i2c/firmware/pru_i2c_interface.h | 214 +++ examples/pru_i2c/firmware/pru_i2c_macro.h | 1000 ++++++++++++ examples/pru_i2c/firmware/pru_i2c_main.asm | 1389 +++++++++++++++++ 12 files changed, 4913 insertions(+) create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile create mode 100644 examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h create mode 100644 examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h create mode 100644 examples/pru_i2c/firmware/pru_i2c_firmware_version.h create mode 100644 examples/pru_i2c/firmware/pru_i2c_interface.h create mode 100644 examples/pru_i2c/firmware/pru_i2c_macro.h create mode 100644 examples/pru_i2c/firmware/pru_i2c_main.asm diff --git a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..bc4cac089 --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..13fdcb5e9 --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_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/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..3395c098c --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_i2c_am261x-lp_icss_m0_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/pru_i2c/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= + +# 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/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..afbcb22bd --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..2c780dcff --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_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 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 > 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/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..dc9d20d19 --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := pru_i2c_am261x-lp_icss_m0_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/pru_i2c/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= + +# 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/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h new file mode 100644 index 000000000..b40c2f3dd --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -0,0 +1,956 @@ +/* + * Copyright (C) 2025 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. + */ + +const uint32_t PRU0Firmware_0[] = { +0x2effbb80, +0x91342481, +0x13020101, +0x81342481, +0x2401008a, +0x240000ca, +0x2402008b, +0x240000cb, +0x2403008c, +0x240000cc, +0x2400788d, +0x240000cd, +0x240000ce, +0x2400008e, +0x240000cf, +0x2400008f, +0x240000d0, +0x24000090, +0x240000d1, +0x24000091, +0x240000d2, +0x24000092, +0x240000d3, +0x24000093, +0x24000000, +0x2f05138a, +0x2effbd80, +0x24000081, +0x010c8181, +0x90813996, +0x91003a81, +0xd100e110, +0x91107a81, +0x24ffffc1, +0x24ffff81, +0x24ffffc2, +0x24ffff82, +0x81107a81, +0x91043a81, +0x1f00e1e1, +0x81043a81, +0x91743a81, +0x24ffff81, +0x81743a81, +0x91003a81, +0x1f00e1e1, +0x81003a81, +0x24000083, +0x90837994, +0x91107a82, +0x2409c3f4, +0x240000f5, +0x00d6f4f4, +0x0300f5f5, +0x81787a94, +0x5103960b, +0x5102961c, +0x5101962d, +0x91003a81, +0x1d00e1e1, +0x81003a81, +0x24020085, +0x240040c6, +0x24000086, +0x80852086, +0x7f0000f9, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21004200, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21005400, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21006600, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0xf1a42a84, +0xc90fe402, +0x24007c8d, +0x20830000, +0xf1082a84, +0x5100c408, +0x6911c403, +0x2400868d, +0x20830000, +0x2400c48d, +0x24050c84, +0xe1080a84, +0x20830000, +0x20830000, +0xf1d82a8e, +0x2400006e, +0x24008a8d, +0x20830000, +0xf1e40a6e, +0x24008d8d, +0x20830000, +0x1e0efefe, +0x1e2efefe, +0x2400918d, +0x20830000, +0xf1940a50, +0x2400948d, +0x20830000, +0xf1950a70, +0x2400978d, +0x20830000, +0xf1a42a84, +0xc90ae403, +0x24009f8d, +0x20830000, +0x2400c48d, +0x24050a84, +0xe1080a84, +0x20830000, +0xf1a42a84, +0xd108e403, +0x1d08f0f0, +0x2100a400, +0x1f08f0f0, +0x2400a68d, +0x20830000, +0xf1a42a84, +0xc900e403, +0x1f00f0f0, +0x2100ab00, +0x1d00f0f0, +0x2400ad8d, +0x20830000, +0xf1a42a84, +0xc901e403, +0x1f01f0f0, +0x2100b200, +0x1d01f0f0, +0x2400b48d, +0x20830000, +0xf1a42a84, +0xc905e403, +0x1f05f0f0, +0x2100b900, +0x1d05f0f0, +0x2400bb8d, +0x20830000, +0xf1a42a84, +0xc904e403, +0x1f04f0f0, +0x2100c000, +0x1d04f0f0, +0x2400dc8d, +0x24050084, +0xe1080a84, +0x20830000, +0x24000084, +0xe10a0a84, +0x24000085, +0x01088585, +0x90851984, +0x1e6e8484, +0x80851984, +0x2400cd8d, +0x20830000, +0x24020085, +0x240020c6, +0x24000086, +0x80852086, +0x2400d38d, +0x20830000, +0x24000085, +0x01088585, +0x90851984, +0xc86e8402, +0x2100da00, +0x2400788d, +0x20830000, +0x2400cd8d, +0x20830000, +0x24000084, +0xe10a0a84, +0x24000085, +0x01088585, +0x90851984, +0x1e6e8484, +0x80851984, +0x2400e58d, +0x20830000, +0x24020085, +0x240020c6, +0x24000086, +0x80852086, +0x2400eb8d, +0x20830000, +0x24000085, +0x01088585, +0x90851984, +0xc86e8402, +0x2100f200, +0x2400f48d, +0x20830000, +0x2400e58d, +0x20830000, +0xf1082a84, +0x5100c402, +0x2400f88d, +0x20830000, +0xf1082a84, +0x6910c405, +0x2401008d, +0x24050084, +0xe1080a84, +0x20830000, +0x2401048d, +0x20830000, +0x1e2efefe, +0x1e0efefe, +0x2400c48d, +0x20830000, +0xf1082a84, +0x6911c403, +0x2400788d, +0x20830000, +0x24010a8d, +0x20830000, +0xf1082a84, +0x6912c403, +0x2401578d, +0x20830000, +0x2401108d, +0x20830000, +0xf1082a84, +0x6913c403, +0x2401538d, +0x20830000, +0x2401168d, +0x20830000, +0xf1082a84, +0x6914c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6915c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6916c402, +0x20830000, +0x2401238d, +0x20830000, +0xf1082a84, +0x6917c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6918c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6919c402, +0x20830000, +0x20830000, +0xf1082a84, +0x691ac402, +0x20830000, +0x20830000, +0xf1082a84, +0x691bc402, +0x20830000, +0x2401388d, +0x20830000, +0xf1082a84, +0x691cc402, +0x20830000, +0x24013d8d, +0x20830000, +0xf1082a84, +0x691dc403, +0x24035c8d, +0x20830000, +0x2401438d, +0x20830000, +0xf1082a84, +0x691ec403, +0x24036f8d, +0x20830000, +0x2401498d, +0x20830000, +0xf1082a84, +0x691fc403, +0x2403858d, +0x20830000, +0x24014f8d, +0x20830000, +0x2400dc8d, +0x24050c84, +0xe1080a84, +0x20830000, +0x1d02f0f0, +0x2401c991, +0x24015b8d, +0x20830000, +0x1f02f0f0, +0x24021791, +0x24015b8d, +0x20830000, +0x1e2efefe, +0x1e0efefe, +0x24015f8d, +0x20830000, +0xd108f003, +0x24007f84, +0x21016300, +0x2403ff84, +0xf1ac0acd, +0x1084cdcd, +0x2401678d, +0x20830000, +0xd108f007, +0x0909cdcd, +0xc902f003, +0x1f08cdcd, +0x21016d00, +0x1d08cdcd, +0x21017500, +0x09016d6d, +0xc902f003, +0x1f006d6d, +0x21017300, +0x1d006d6d, +0x11076d6d, +0x13f06d6d, +0x11000f0f, +0x11004f4f, +0x2401798d, +0x20830000, +0xf1980a84, +0x49ff8407, +0x61018406, +0x11ff046f, +0x11004f4f, +0xf04f0b2f, +0x2401858d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xc900f002, +0x1c2efefe, +0x2401898d, +0x20830000, +0xc900f002, +0x1c0efefe, +0x24018d8d, +0x20830000, +0x0d0f0f05, +0xc805cd03, +0x1e2efefe, +0x21019200, +0x1c2efefe, +0x01010f0f, +0x2401958d, +0x20830000, +0x1e0efefe, +0x2401988d, +0x20830000, +0x24019a8d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2401a08d, +0x20830000, +0x24018d8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2401a78d, +0x20830000, +0x1e0efefe, +0x11000f0f, +0x2401ab8d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x2101af00, +0x1f03f0f0, +0x2401b18d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f009, +0xc908f005, +0x51014f04, +0x01014f4f, +0x24018d8d, +0x20830000, +0x11004f4f, +0x1091918d, +0x20830000, +0x2401c48d, +0x20830000, +0x1e0efefe, +0x24050884, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xc9072f03, +0x1e2efefe, +0x2101cd00, +0x1c2efefe, +0x09012f2f, +0x01010f0f, +0x2401d18d, +0x20830000, +0x1e0efefe, +0x2401d48d, +0x20830000, +0x2401d68d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2401dc8d, +0x20830000, +0x2401c98d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2401e38d, +0x20830000, +0x1e0efefe, +0x2401e68d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x2101ea00, +0x1f03f0f0, +0xd105f003, +0x2401ef8d, +0x20830000, +0x2402018d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f019, +0x01014f4f, +0x11000f0f, +0x606f4f04, +0x11004f4f, +0x2403468d, +0x20830000, +0xf04f0b2f, +0x2401c98d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f007, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0xf04f0b2f, +0x2403468d, +0x20830000, +0x2402128d, +0x20830000, +0x1e0efefe, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x24021e8d, +0x20830000, +0x1e0efefe, +0x09012f2f, +0x2402228d, +0x20830000, +0xd02eff03, +0x11fe2f2f, +0x21022600, +0x13012f2f, +0x01010f0f, +0x2402298d, +0x20830000, +0x1c0efefe, +0x61080f17, +0x01014f4f, +0xd105f00c, +0x606f4f0b, +0xc904f00a, +0x2402468d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402438d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x24021c8d, +0x20830000, +0x1e2efefe, +0x2402498d, +0x20830000, +0x1e2efefe, +0x2402498d, +0x20830000, +0x1e0efefe, +0xe1980a6f, +0x24024d8d, +0x20830000, +0xd105f003, +0x2402528d, +0x20830000, +0x24025a8d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x05014f04, +0xe0040c2f, +0x606f4f0a, +0x11004f4f, +0x2403468d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0x2403468d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x24021c8d, +0x20830000, +0xc9075103, +0x1e2efefe, +0x21026b00, +0x1c2efefe, +0x09015151, +0x01010f0f, +0x24026f8d, +0x20830000, +0x1e0efefe, +0x2402728d, +0x20830000, +0x2402748d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x24027a8d, +0x20830000, +0x2402678d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402818d, +0x20830000, +0x1e0efefe, +0x2402848d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x21028800, +0x1f03f0f0, +0xd105f003, +0x24028d8d, +0x20830000, +0x24029f8d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f019, +0x01014f4f, +0x11000f0f, +0x606f4f04, +0x11004f4f, +0x2401c98d, +0x20830000, +0xf04f0b51, +0x2402678d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f007, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0xf04f0b51, +0x2401c98d, +0x20830000, +0x2402b08d, +0x20830000, +0x1e0efefe, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402bc8d, +0x20830000, +0x1e0efefe, +0x09016f6f, +0x2402c08d, +0x20830000, +0xd02eff03, +0x11fe6f6f, +0x2102c400, +0x13016f6f, +0x01010f0f, +0x2402c78d, +0x20830000, +0x1c0efefe, +0x61080f17, +0x01014f4f, +0xd105f00c, +0x606f4f0b, +0xc904f00a, +0x2402e48d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402e18d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402ba8d, +0x20830000, +0x1e2efefe, +0x2402e78d, +0x20830000, +0x1e2efefe, +0x2402e78d, +0x20830000, +0x1e0efefe, +0xe1980a6f, +0x2402eb8d, +0x20830000, +0xd105f003, +0x2402f08d, +0x20830000, +0x2402f88d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x05014f04, +0xe0040c6f, +0x606f4f0a, +0x11004f4f, +0x2402178d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0x2402178d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402ba8d, +0x20830000, +0xc9072f03, +0x1e2efefe, +0x21030900, +0x1c2efefe, +0x09012f2f, +0x01010f0f, +0x24030d8d, +0x20830000, +0x1e0efefe, +0x2403108d, +0x20830000, +0x2403128d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2403188d, +0x20830000, +0x2403058d, +0x20830000, +0x1e2efefe, +0x1f00cdcd, +0x24031c8d, +0x20830000, +0x1e0efefe, +0x24031f8d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x21032300, +0x1f03f0f0, +0xd105f003, +0x2403288d, +0x20830000, +0x2403348d, +0x20830000, +0x1c0efefe, +0xd103f017, +0x11004f4f, +0x11000f0f, +0xd102f004, +0xf04f0b2f, +0x2401c98d, +0x20830000, +0x2401858d, +0x1f08cdcd, +0x24021791, +0x20830000, +0x1c0efefe, +0xd103f00b, +0x11004f4f, +0x11000f0f, +0xd102f004, +0xf04f0b2f, +0x2402678d, +0x20830000, +0x2401858d, +0x1f08cdcd, +0x2402b591, +0x20830000, +0x2403428d, +0x20830000, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x1c2efefe, +0xc901f003, +0x24034c8d, +0x20830000, +0x2403548d, +0x20830000, +0x1e0efefe, +0x24034f8d, +0x20830000, +0x1e2efefe, +0x24050084, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x1e2efefe, +0x2403578d, +0x20830000, +0x1e0efefe, +0x24050084, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2400008f, +0x240a00cf, +0x2403608d, +0x20830000, +0x01010f0f, +0xd00eff02, +0x01014f4f, +0x606f0f02, +0x2403668d, +0x20830000, +0x2400dc8d, +0x504f0f03, +0x24050584, +0x21036b00, +0x24050684, +0x2400008f, +0x240000cf, +0xe1080a84, +0x20830000, +0x2400008f, +0x240900cf, +0x2403738d, +0x20830000, +0x1e0efefe, +0x2403768d, +0x20830000, +0x2403788d, +0x20830000, +0x1c0efefe, +0x01010f0f, +0x24037c8d, +0x20830000, +0x606f0f03, +0x2403818d, +0x20830000, +0x2403738d, +0x20830000, +0x2400dc8d, +0x24050784, +0xe1080a84, +0x20830000, +0xf1980a84, +0x49ff8406, +0x61018405, +0x11ff046f, +0x11004f4f, +0x2403908d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xf04f0b2f, +0xe04f0c2f, +0x01014f4f, +0x704f6f02, +0x20830000, +0x2400dc8d, +0x24050084, +0xe1080a84, +0x20830000, +0x2a000000}; + diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h new file mode 100644 index 000000000..63424ecc8 --- /dev/null +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -0,0 +1,956 @@ +/* + * Copyright (C) 2025 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. + */ + +const uint32_t PRU1Firmware_0[] = { +0x2effbb80, +0x91342481, +0x13020101, +0x81342481, +0x2401008a, +0x240000ca, +0x2402008b, +0x240000cb, +0x2403008c, +0x240000cc, +0x2400788d, +0x240000cd, +0x240000ce, +0x2400008e, +0x240000cf, +0x2400008f, +0x240000d0, +0x24000090, +0x240000d1, +0x24000091, +0x240000d2, +0x24000092, +0x240000d3, +0x24000093, +0x24000000, +0x2f05138a, +0x2effbd80, +0x24000081, +0x010c8181, +0x90813996, +0x91003a81, +0xd100e110, +0x91107a81, +0x24ffffc1, +0x24ffff81, +0x24ffffc2, +0x24ffff82, +0x81107a81, +0x91043a81, +0x1f00e1e1, +0x81043a81, +0x91743a81, +0x24ffff81, +0x81743a81, +0x91003a81, +0x1f00e1e1, +0x81003a81, +0x24000083, +0x90837994, +0x91107a82, +0x2409c3f4, +0x240000f5, +0x00d6f4f4, +0x0300f5f5, +0x81787a94, +0x5103960b, +0x5102961c, +0x5101962d, +0x91003a81, +0x1d00e1e1, +0x81003a81, +0x24020085, +0x240040c6, +0x24000086, +0x80852086, +0x7f0000f9, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21004200, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21005400, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0x91743a81, +0xcf00e1ff, +0x91743a81, +0xd101e102, +0x21006600, +0x1f01e1e1, +0x81743a81, +0x00d6f4f4, +0x0300f5f5, +0x24008081, +0x24028082, +0x80822081, +0x24000000, +0x2e85138a, +0x228d0083, +0x24000000, +0x2f05138a, +0x7f0000ef, +0xf1a42a84, +0xc90fe402, +0x24007c8d, +0x20830000, +0xf1082a84, +0x5100c408, +0x6911c403, +0x2400868d, +0x20830000, +0x2400c48d, +0x24050c84, +0xe1080a84, +0x20830000, +0x20830000, +0xf1d82a8e, +0x2400006e, +0x24008a8d, +0x20830000, +0xf1e40a6e, +0x24008d8d, +0x20830000, +0x1e0efefe, +0x1e2efefe, +0x2400918d, +0x20830000, +0xf1940a50, +0x2400948d, +0x20830000, +0xf1950a70, +0x2400978d, +0x20830000, +0xf1a42a84, +0xc90ae403, +0x24009f8d, +0x20830000, +0x2400c48d, +0x24050a84, +0xe1080a84, +0x20830000, +0xf1a42a84, +0xd108e403, +0x1d08f0f0, +0x2100a400, +0x1f08f0f0, +0x2400a68d, +0x20830000, +0xf1a42a84, +0xc900e403, +0x1f00f0f0, +0x2100ab00, +0x1d00f0f0, +0x2400ad8d, +0x20830000, +0xf1a42a84, +0xc901e403, +0x1f01f0f0, +0x2100b200, +0x1d01f0f0, +0x2400b48d, +0x20830000, +0xf1a42a84, +0xc905e403, +0x1f05f0f0, +0x2100b900, +0x1d05f0f0, +0x2400bb8d, +0x20830000, +0xf1a42a84, +0xc904e403, +0x1f04f0f0, +0x2100c000, +0x1d04f0f0, +0x2400dc8d, +0x24050084, +0xe1080a84, +0x20830000, +0x24000084, +0xe10a0a84, +0x24000085, +0x01088585, +0x90851984, +0x1e6e8484, +0x80851984, +0x2400cd8d, +0x20830000, +0x24020085, +0x240020c6, +0x24000086, +0x80852086, +0x2400d38d, +0x20830000, +0x24000085, +0x01088585, +0x90851984, +0xc86e8402, +0x2100da00, +0x2400788d, +0x20830000, +0x2400cd8d, +0x20830000, +0x24000084, +0xe10a0a84, +0x24000085, +0x01088585, +0x90851984, +0x1e6e8484, +0x80851984, +0x2400e58d, +0x20830000, +0x24020085, +0x240020c6, +0x24000086, +0x80852086, +0x2400eb8d, +0x20830000, +0x24000085, +0x01088585, +0x90851984, +0xc86e8402, +0x2100f200, +0x2400f48d, +0x20830000, +0x2400e58d, +0x20830000, +0xf1082a84, +0x5100c402, +0x2400f88d, +0x20830000, +0xf1082a84, +0x6910c405, +0x2401008d, +0x24050084, +0xe1080a84, +0x20830000, +0x2401048d, +0x20830000, +0x1e2efefe, +0x1e0efefe, +0x2400c48d, +0x20830000, +0xf1082a84, +0x6911c403, +0x2400788d, +0x20830000, +0x24010a8d, +0x20830000, +0xf1082a84, +0x6912c403, +0x2401578d, +0x20830000, +0x2401108d, +0x20830000, +0xf1082a84, +0x6913c403, +0x2401538d, +0x20830000, +0x2401168d, +0x20830000, +0xf1082a84, +0x6914c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6915c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6916c402, +0x20830000, +0x2401238d, +0x20830000, +0xf1082a84, +0x6917c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6918c402, +0x20830000, +0x20830000, +0xf1082a84, +0x6919c402, +0x20830000, +0x20830000, +0xf1082a84, +0x691ac402, +0x20830000, +0x20830000, +0xf1082a84, +0x691bc402, +0x20830000, +0x2401388d, +0x20830000, +0xf1082a84, +0x691cc402, +0x20830000, +0x24013d8d, +0x20830000, +0xf1082a84, +0x691dc403, +0x24035c8d, +0x20830000, +0x2401438d, +0x20830000, +0xf1082a84, +0x691ec403, +0x24036f8d, +0x20830000, +0x2401498d, +0x20830000, +0xf1082a84, +0x691fc403, +0x2403858d, +0x20830000, +0x24014f8d, +0x20830000, +0x2400dc8d, +0x24050c84, +0xe1080a84, +0x20830000, +0x1d02f0f0, +0x2401c991, +0x24015b8d, +0x20830000, +0x1f02f0f0, +0x24021791, +0x24015b8d, +0x20830000, +0x1e2efefe, +0x1e0efefe, +0x24015f8d, +0x20830000, +0xd108f003, +0x24007f84, +0x21016300, +0x2403ff84, +0xf1ac0acd, +0x1084cdcd, +0x2401678d, +0x20830000, +0xd108f007, +0x0909cdcd, +0xc902f003, +0x1f08cdcd, +0x21016d00, +0x1d08cdcd, +0x21017500, +0x09016d6d, +0xc902f003, +0x1f006d6d, +0x21017300, +0x1d006d6d, +0x11076d6d, +0x13f06d6d, +0x11000f0f, +0x11004f4f, +0x2401798d, +0x20830000, +0xf1980a84, +0x49ff8407, +0x61018406, +0x11ff046f, +0x11004f4f, +0xf04f0b2f, +0x2401858d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xc900f002, +0x1c2efefe, +0x2401898d, +0x20830000, +0xc900f002, +0x1c0efefe, +0x24018d8d, +0x20830000, +0x0d0f0f05, +0xc805cd03, +0x1e2efefe, +0x21019200, +0x1c2efefe, +0x01010f0f, +0x2401958d, +0x20830000, +0x1e0efefe, +0x2401988d, +0x20830000, +0x24019a8d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2401a08d, +0x20830000, +0x24018d8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2401a78d, +0x20830000, +0x1e0efefe, +0x11000f0f, +0x2401ab8d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x2101af00, +0x1f03f0f0, +0x2401b18d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f009, +0xc908f005, +0x51014f04, +0x01014f4f, +0x24018d8d, +0x20830000, +0x11004f4f, +0x1091918d, +0x20830000, +0x2401c48d, +0x20830000, +0x1e0efefe, +0x24050884, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xc9072f03, +0x1e2efefe, +0x2101cd00, +0x1c2efefe, +0x09012f2f, +0x01010f0f, +0x2401d18d, +0x20830000, +0x1e0efefe, +0x2401d48d, +0x20830000, +0x2401d68d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2401dc8d, +0x20830000, +0x2401c98d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2401e38d, +0x20830000, +0x1e0efefe, +0x2401e68d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x2101ea00, +0x1f03f0f0, +0xd105f003, +0x2401ef8d, +0x20830000, +0x2402018d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f019, +0x01014f4f, +0x11000f0f, +0x606f4f04, +0x11004f4f, +0x2403468d, +0x20830000, +0xf04f0b2f, +0x2401c98d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f007, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0xf04f0b2f, +0x2403468d, +0x20830000, +0x2402128d, +0x20830000, +0x1e0efefe, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x24021e8d, +0x20830000, +0x1e0efefe, +0x09012f2f, +0x2402228d, +0x20830000, +0xd02eff03, +0x11fe2f2f, +0x21022600, +0x13012f2f, +0x01010f0f, +0x2402298d, +0x20830000, +0x1c0efefe, +0x61080f17, +0x01014f4f, +0xd105f00c, +0x606f4f0b, +0xc904f00a, +0x2402468d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402438d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x24021c8d, +0x20830000, +0x1e2efefe, +0x2402498d, +0x20830000, +0x1e2efefe, +0x2402498d, +0x20830000, +0x1e0efefe, +0xe1980a6f, +0x24024d8d, +0x20830000, +0xd105f003, +0x2402528d, +0x20830000, +0x24025a8d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x05014f04, +0xe0040c2f, +0x606f4f0a, +0x11004f4f, +0x2403468d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0x2403468d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x24021c8d, +0x20830000, +0xc9075103, +0x1e2efefe, +0x21026b00, +0x1c2efefe, +0x09015151, +0x01010f0f, +0x24026f8d, +0x20830000, +0x1e0efefe, +0x2402728d, +0x20830000, +0x2402748d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x24027a8d, +0x20830000, +0x2402678d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402818d, +0x20830000, +0x1e0efefe, +0x2402848d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x21028800, +0x1f03f0f0, +0xd105f003, +0x24028d8d, +0x20830000, +0x24029f8d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f019, +0x01014f4f, +0x11000f0f, +0x606f4f04, +0x11004f4f, +0x2401c98d, +0x20830000, +0xf04f0b51, +0x2402678d, +0x20830000, +0x1c0efefe, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0xd103f007, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0xf04f0b51, +0x2401c98d, +0x20830000, +0x2402b08d, +0x20830000, +0x1e0efefe, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402bc8d, +0x20830000, +0x1e0efefe, +0x09016f6f, +0x2402c08d, +0x20830000, +0xd02eff03, +0x11fe6f6f, +0x2102c400, +0x13016f6f, +0x01010f0f, +0x2402c78d, +0x20830000, +0x1c0efefe, +0x61080f17, +0x01014f4f, +0xd105f00c, +0x606f4f0b, +0xc904f00a, +0x2402e48d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402e18d, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x24ffffdb, +0x24fdff9b, +0x10fbfcfc, +0xe1003d9c, +0x20830000, +0x2402ba8d, +0x20830000, +0x1e2efefe, +0x2402e78d, +0x20830000, +0x1e2efefe, +0x2402e78d, +0x20830000, +0x1e0efefe, +0xe1980a6f, +0x2402eb8d, +0x20830000, +0xd105f003, +0x2402f08d, +0x20830000, +0x2402f88d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x05014f04, +0xe0040c6f, +0x606f4f0a, +0x11004f4f, +0x2402178d, +0x20830000, +0x1c0efefe, +0x11000f0f, +0x11004f4f, +0x1d05f0f0, +0x2402178d, +0x20830000, +0x2450d0dd, +0x2408189d, +0xf1003d9c, +0x1f09fcfc, +0xe1003d9c, +0x2402ba8d, +0x20830000, +0xc9072f03, +0x1e2efefe, +0x21030900, +0x1c2efefe, +0x09012f2f, +0x01010f0f, +0x24030d8d, +0x20830000, +0x1e0efefe, +0x2403108d, +0x20830000, +0x2403128d, +0x20830000, +0x1c0efefe, +0x61080f03, +0x2403188d, +0x20830000, +0x2403058d, +0x20830000, +0x1e2efefe, +0x1f00cdcd, +0x24031c8d, +0x20830000, +0x1e0efefe, +0x24031f8d, +0x20830000, +0xd02eff03, +0x1d03f0f0, +0x21032300, +0x1f03f0f0, +0xd105f003, +0x2403288d, +0x20830000, +0x2403348d, +0x20830000, +0x1c0efefe, +0xd103f017, +0x11004f4f, +0x11000f0f, +0xd102f004, +0xf04f0b2f, +0x2401c98d, +0x20830000, +0x2401858d, +0x1f08cdcd, +0x24021791, +0x20830000, +0x1c0efefe, +0xd103f00b, +0x11004f4f, +0x11000f0f, +0xd102f004, +0xf04f0b2f, +0x2402678d, +0x20830000, +0x2401858d, +0x1f08cdcd, +0x2402b591, +0x20830000, +0x2403428d, +0x20830000, +0x24050984, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x1c2efefe, +0xc901f003, +0x24034c8d, +0x20830000, +0x2403548d, +0x20830000, +0x1e0efefe, +0x24034f8d, +0x20830000, +0x1e2efefe, +0x24050084, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x1e2efefe, +0x2403578d, +0x20830000, +0x1e0efefe, +0x24050084, +0xe1080a84, +0x2400dc8d, +0x20830000, +0x2400008f, +0x240a00cf, +0x2403608d, +0x20830000, +0x01010f0f, +0xd00eff02, +0x01014f4f, +0x606f0f02, +0x2403668d, +0x20830000, +0x2400dc8d, +0x504f0f03, +0x24050584, +0x21036b00, +0x24050684, +0x2400008f, +0x240000cf, +0xe1080a84, +0x20830000, +0x2400008f, +0x240900cf, +0x2403738d, +0x20830000, +0x1e0efefe, +0x2403768d, +0x20830000, +0x2403788d, +0x20830000, +0x1c0efefe, +0x01010f0f, +0x24037c8d, +0x20830000, +0x606f0f03, +0x2403818d, +0x20830000, +0x2403738d, +0x20830000, +0x2400dc8d, +0x24050784, +0xe1080a84, +0x20830000, +0xf1980a84, +0x49ff8406, +0x61018405, +0x11ff046f, +0x11004f4f, +0x2403908d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400dc8d, +0x20830000, +0xf04f0b2f, +0xe04f0c2f, +0x01014f4f, +0x704f6f02, +0x20830000, +0x2400dc8d, +0x24050084, +0xe1080a84, +0x20830000, +0x2a000000}; + diff --git a/examples/pru_i2c/firmware/pru_i2c_firmware_version.h b/examples/pru_i2c/firmware/pru_i2c_firmware_version.h new file mode 100644 index 000000000..211e6ea5c --- /dev/null +++ b/examples/pru_i2c/firmware/pru_i2c_firmware_version.h @@ -0,0 +1,54 @@ +; Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ +; +; 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. + +;************************************************************************************ +; File: firmware_version.h +; +; Brief: ICSS I2C Firmware version control file +;************************************************************************************ + + .if !$defined("__firmware_version_h") +__firmware_version_h .set 1 + +; bit31 release or internal version +FIRMWARE_VERSION_INTERNAL .set 1 +FIRMWARE_VERSION_RELEASE .set 1 +; bit30..24 major version number ;For major IP changes. +FIRMWARE_VERSION_MAJOR .set 0x00 +; bit23..16 minor version number ;For feature additions to firmware. +FIRMWARE_VERSION_MINOR .set 0x00 +; bit15..0 build number ;For all other minor changes. +FIRMWARE_VERSION_BUILD .set 0x00 + +; macro for indicating version of firmware +I2C_FIRMWARE_VERSION .set ((FIRMWARE_VERSION_RELEASE << 31) | (FIRMWARE_VERSION_MAJOR << 24) | (FIRMWARE_VERSION_MINOR << 16) | (FIRMWARE_VERSION_BUILD << 0)) + + + .endif ;__firmware_version_h \ No newline at end of file diff --git a/examples/pru_i2c/firmware/pru_i2c_interface.h b/examples/pru_i2c/firmware/pru_i2c_interface.h new file mode 100644 index 000000000..0e5d7cfec --- /dev/null +++ b/examples/pru_i2c/firmware/pru_i2c_interface.h @@ -0,0 +1,214 @@ +/* Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ +* +* 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. + +************************************************************************************* +* File: icss_i2c.h +* +* Brief: This is a common header file with all memory map configuration. +************************************************************************************* +*/ +#ifndef ICSS_I2C_H +#define ICSS_I2C_H + +#define PRUICSS_MAX_INSTANCE (2U) + +typedef enum PRUICSS_PruCores_e +{ + PRUICCSS_PRU0, + PRUICCSS_PRU1 +}PRUICSS_PruCores; + +/* The Memory Size of I2C Instance */ +#define ICSS_I2C_INSTANCE_SIZE (0x0300) +/* The Memory offset of I2C Tx Buffer */ +#define ICSS_I2C_INSTANCE_TX_OFFSET (0x0100) +/* The Memory offset of I2C Rx Buffer */ +#define ICSS_I2C_INSTANCE_RX_OFFSET (0x0200) + +#define ICSS_I2C_CONFIG_MEMORY (0x0000) + +/* The Memory region of I2C INSTANCE0 MMap */ +#define ICSS_I2C_INSTANCE0_ADDR (ICSS_I2C_CONFIG_MEMORY + 0x100 ) + +/* The Memory region of I2C INSTANCE0 Tx buffer */ +#define ICSS_I2C_INSTANCE0_TX_MEM (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_INSTANCE_TX_OFFSET) + +/* The Memory region of I2C INSTANCE0 Rx buffer */ +#define ICSS_I2C_INSTANCE0_RX_MEM (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_INSTANCE_RX_OFFSET) + +/* The Memory offset of I2C Revision Register low value */ +#define ICSS_I2C_REVNB_LO_OFFSET (0x00) +/* The Memory offset of I2C Revision Register high value */ +#define ICSS_I2C_REVNB_HI_OFFSET (0x04) +/* The Memory offset of I2C command value register */ +#define ICSS_I2C_COMMAND_OFFSET (0x08) +/* The Memory offset of I2C IRQ status register */ +#define ICSS_I2C_IRQSTATUS_OFFSET (0x28) +/* The Memory offset of I2C Fifo size register */ +#define ICSS_I2C_BUF_OFFSET (0x94) +/* The Memory offset of I2C data count register */ +#define ICSS_I2C_CNT_OFFSET (0x98) +/* The Memory offset of I2C configuration register */ +#define ICSS_I2C_CON_OFFSET (0xA4) +/* The Memory offset of I2C slave address register */ +#define ICSS_I2C_SA_OFFSET (0xAC) +/* The Memory offset of I2C input output pin value */ +#define ICSS_I2C_PRU_PIN_OFFSET (0xD8) +/* The Memory offset of I2C clock value register */ +#define ICSS_I2C_PRU_CLK_VAL_OFFSET (0xDC) +/* The Memory offset of I2C smbus command code register */ +#define ICSS_I2C_PRU_CMD_CODE_OFFSET (0xE0) +/* The Memory offset of I2C instance id register */ +#define ICSS_I2C_PRU_INST_ID_OFFSET (0xE4) + +/* The register bit for enabling i2c instance */ +#define ICSS_I2C_MODULE_ENABLE_BIT (15) +/* The register bit for selecting master or slave */ +#define ICSS_I2C_MASTER_SLAVE_MODE_BIT (10) +/* The register bit for selecting address mode */ +#define ICSS_I2C_ADDRESSING_MODE_BIT (8) +/* The register bit for enabling i2c burst mode */ +#define ICSS_I2C_SMBUS_BURST_BIT (5) +/* The register bit for deciding NACK recieve */ +#define ICSS_I2C_RECIEVE_NACK_BIT (4) +/* The register bit for deciding ACK recieve */ +#define ICSS_I2C_ACK_RECIEVED_BIT (3) +/* The register bit for selecting between read/write */ +#define ICSS_I2C_READ_WRITE_BIT (2) +/* The register bit for enabling start bit */ +#define ICSS_I2C_START_BIT (0) +/* The register bit for enabling stop bit */ +#define ICSS_I2C_STOP_BIT (1) + +/* The command value for resetting I2C instance */ +#define ICSS_I2C_RESET_CMD (0x10U) +/* The command value for setting up I2C instance */ +#define ICSS_I2C_SETUP_CMD (0x11U) +/* The command value for start Rx for I2C instance */ +#define ICSS_I2C_RX_CMD (0x12U) +/* The command value for start Tx for I2C instance */ +#define ICSS_I2C_TX_CMD (0x13U) +/* The command value for start quick cmd for I2C instance */ +#define ICSS_SMBUS_QUICK_CMD (0x14U) +/* The command value for start send byte cmd for I2C instance */ +#define ICSS_SMBUS_SEND_BYTE_CMD (0x15U) +/* The command value for start recieve byte cmd for I2C instance */ +#define ICSS_SMBUS_RECEIVE_BYTE_CMD (0x16U) +/* The command value for start write byte cmd for I2C instance */ +#define ICSS_SMBUS_WRITE_BYTE_CMD (0x17U) +/* The command value for start read byte cmd for I2C instance */ +#define ICSS_SMBUS_READ_BYTE_CMD (0x18U) +/* The command value for start write word cmd for I2C instance */ +#define ICSS_SMBUS_WRITE_WORD_CMD (0x19U) +/* The command value for start read word for I2C instance */ +#define ICSS_SMBUS_READ_WORD_CMD (0x1AU) +/* The command value for start block write for I2C instance */ +#define ICSS_SMBUS_BLOCK_WRITE_CMD (0x1BU) +/* The command value for start block read for I2C instance */ +#define ICSS_SMBUS_BLOCK_READ_CMD (0x1CU) +/* The command value for start read scl cmd for I2C instance */ +#define ICSS_I2C_READ_SCL_CMD (0x1DU) +/* The command value for start reset slave cmd for I2C instance */ +#define ICSS_I2C_RESET_SLAVE_CMD (0x1EU) +/* The command value for loopback mode */ +#define ICSS_I2C_LOOPBACK_CMD (0x1FU) + +/* The response for command successful */ +#define COMMAND_SUCCESS (0x0500U) +/* The response for reset command failure */ +#define RESET_COMMAND_FAILED (0x0501U) +/* The response for setup command failure */ +#define SETUP_COMMAND_FAILED (0x0502U) +/* The response for tx command failure */ +#define TX_COMMAND_FAILED (0x0503U) +/* The response for rx command failure */ +#define RX_COMMAND_FAILED (0x0504U) +/* The response for if SCL value high */ +#define SCL_VALUE_HIGH (0x0505U) +/* The response for if SCL value low */ +#define SCL_VALUE_LOW (0x0506U) +/* The response for sucessfull reset command */ +#define RESET_SLAVE_DONE (0x0507U) +/* The response for NACK for address transmission */ +#define ADDRESS_ACKNOWLDEGE_FAILED (0x0508U) +/* The response for NACK for data transmission */ +#define DATA_ACKNOWLDEGE_FAILED (0x0509U) +/* The response for wrong master slave configuration */ +#define MASTER_SLAVE_MODE_FAILED (0x050AU) +/* The response for wrong addressing mode configuration */ +#define ADDRESSING_MODE_FAILED (0x050BU) +/* The response for invalid command passed configuration */ +#define INVALID_COMMAND (0x050CU) +/* The response for incorrect data count configuration */ +#define INVALID_DATA_COUNT (0x050DU) +/* The time out for the response to come */ +#define TIME_OUT_ERROR (0x050EU) + + +/* The iep counter increment value for 400KHz value */ +// 1 I2C instance, time-slice 125 (625/5) cycles. +// => bus clock time is 125*4/200e6 = 2.5 usec. +// => bus clock speed is 1/2.5e-6 = 400 kHz +#define IEP_CMP_INCREMENT_VAL_400KHZ (0x00000270U) // 400 kHz +#define IEP_CMP_INCREMENT_HALF_VAL_400KHZ (0x00000138U) + +/* The iep counter increment value for 100KHz value */ +// 4 I2C instances, time-slice 125 (625/5) cycles. +// => bus clock time is 125*4*4/200e6 = 10 usec. +// => bus clock speed is 1/10e-6 = 100 kHz +#define IEP_CMP_INCREMENT_VAL_100KHZ (0x000009c3U) // 100 kHz, 1x instances +#define IEP_CMP_INCREMENT_HALF_VAL_100KHZ (0x000004e1U) // + +// 1 I2C instance, time-slice 64 (320/5) cycles. +// => bus clock time is 64*4/200e6 = 1.28 usec. +// => bus clock speed is 1/1.28e-6 = 781.25 kHz +#define IEP_CMP_INCREMENT_VAL_1MHZ (0x00000140U) // 781.25 kHz, 1x instance +#define IEP_CMP_INCREMENT_HALF_VAL_1MHZ (0x000000A0U) + +/* The register offset of IRQ status for host to read */ +#define IRQ_COMMON_REGISTER_OFFSET (0x0008U) +/* The register offset of global frequency set */ +#define I2C_BUS_FREQUENCY_OFFSET (0x000CU) + +/* The frequency configuration for I2C FW */ +#define ICSS_I2C_NO_FREQ (0x00U) +/* The frequency configuration for I2C FW @ 1MHZ */ +#define ICSS_I2C_1MHZ_FREQ (0x01U) +/* The frequency configuration for I2C FW @ 400KHZ */ +#define ICSS_I2C_400KHZ_FREQ (0x02U) +/* The frequency configuration for I2C FW @ 100KHZ */ +#define ICSS_I2C_100KHZ_FREQ (0x03U) + +/* The interrupt line used for host for PRU0*/ +#define ICSS_I2C_INTC_PRU0_BIT_VAL (0x00100000U) +/* The interrupt line used for host for PRU1*/ +#define ICSS_I2C_INTC_PRU1_BIT_VAL (0x00200000U) + +#endif diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h new file mode 100644 index 000000000..e1f31ff75 --- /dev/null +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -0,0 +1,1000 @@ +; Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ +; +; 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. + +;************************************************************************************ +; File: icss_i2c_macro.h +; +; Brief: This file contains ICSS I2C macros definations +;************************************************************************************ + + .if !$defined("__icss_i2c_macros_h") +__icss_i2c_macros_h .set 1 + +;************************************* includes ************************************* + + ;;.include "icss_constant_defines.inc" + ;;.include "icss_cfg_regs.h" + ;;.include "icss_iep_regs.h" + ;;.include "icss_intc_regs.inc" + ;;;.include "endat_icss_reg_defs.h" + .cdecls C,NOLIST +%{ +#include "pru_i2c_interface.h" +%} + +;--------------------------------------------------------------------------------------- + +;************************************************************************************ +; +; Macro: ENABLE_XIN_XOUT_SHITFTING +; +; Enable support of shifting during XIN/XOUT operation +; +; PEAK cycles: +; 3 cycles +; Pseudo code: +; ICSS_CFG_SPPC[0-7] |= 0x02 +; +; Parameters: +; None +; +; Returns: +; None +; +ENABLE_XIN_XOUT_SHITFTING .macro + LBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4 + OR TEMP_REG1.b0, TEMP_REG1.b0, 0x02 + SBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4 + .endm + + +;************************************************************************************ +; +; Macro: I2C_WAIT_FOR_IEP_CMP +; +; wait until the IEP CMP Event triggers and interrupt +; +; PEAK cycles: +; NA +; Pseudo code: +; while(r31.t31==0) +; +; Parameters: +; None +; +; Returns: +; None +; +;************************************************************************************ +I2C_WAIT_FOR_IEP_CMP .macro + +WAIT_FOR_INT?: + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 + QBBC WAIT_FOR_INT?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT + ;;;;QBBC WAIT_FOR_INT?, R31, 31 + + .endm + + +;************************************************************************************ +; +; Macro: I2C_IEP_INTC_CLEAR_EVENT +; +; Clear the iep cmp event and intc event +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; +; Returns: +; None +; +;************************************************************************************ +I2C_IEP_INTC_CLEAR_EVENT .macro arg1 + + ; clear the IEP compare event happened + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 + .if $defined("PRU0") + QBBS IEP_INTC_CLEAR?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT + JMP arg1 + .else + QBBS IEP_INTC_CLEAR?, TEMP_REG1, PRU1_IEP_CMP_STATUS_BIT + JMP arg1 + .endif +IEP_INTC_CLEAR?: + + .if $defined("PRU0") + SET TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT + .else + SET TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_STATUS_BIT + .endif + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 + + ;Set compare values + ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 + ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 + .if $defined("PRU0") + SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8 + .endif ;PRU0 + + .if $defined("PRU1") + SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU1_IEP_CMP_REG, 8 + .endif ;PRU1 + + ; Clear the intc interrupt event flag + LDI TEMP_REG1.w0, 0x0080 + LDI TEMP_REG2.w0, ICSS_INTC_SECR1 + SBCO &TEMP_REG1, ICSS_INTC_CONST, TEMP_REG2.w0, 4 + + .endm + +;************************************************************************************ +; +; Macro: I2C_WAVE_FUNCTION0 +; +; jump to the next state of i2c function +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; +; Returns: +; None +; +;************************************************************************************ +I2C_WAVE_FUNCTION0 .macro + + ;Restore I2C instance context + LDI R0.b0, 0x00 + XIN BANK0, &R10, 40 + + ;Jump and link to the next task function + JAL TEMP_REG3.w0, R13.w0 ;R13 store RESET MODE + + ;Save context to SPAD + LDI R0.b0, 0x00 + XOUT BANK0, &R10, 40 + + .endm + + +;************************************************************************************ +; +; Macro: UPDATE_NEXT_LOCAL_STATE +; +; update next state in state keep register +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label of next state +; +; Returns: +; None +; +;************************************************************************************ +UPDATE_NEXT_LOCAL_STATE .macro arg1 + LDI R13.w0, $CODE(arg1) + .endm + + +;************************************************************************************ +; +; Macro: STATE_TASK_OVER +; +; Return to the scheduler as state task is over. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label of next state +; +; Returns: +; None +; +;************************************************************************************ +STATE_TASK_OVER .macro + JMP TEMP_REG3.w0 + .endm + +;************************************************************************************ +; +; Macro: SET_SCL_PIN_HIGH +; +; Set high value on SCL pin +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; +; Returns: +; None +; +;************************************************************************************ +SET_SCL_PIN_HIGH .macro + SET R30, R30, R14.b0 + .endm + +;************************************************************************************ +; +; Macro: SET_SDA_PIN_HIGH +; +; Set high value on SDA pin +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None: +; +; Returns: +; None +; +;************************************************************************************ +SET_SDA_PIN_HIGH .macro + SET R30, R30, R14.b1 + .endm + + + +;---------------------------------------------------------------------- +; Macro Name: SET_SCL_PIN_LOW +; Description: Set low value on SCL pin +; Input Parameters: none +; Output Parameters: none +;---------------------------------------------------------------------- +SET_SCL_PIN_LOW .macro + CLR R30, R30, R14.b0 + .endm + +;---------------------------------------------------------------------- +; Macro Name: SET_SDA_PIN_LOW +; Description: Set low value on SDA pin +; Input Parameters: Label on new memory location +; Output Parameters: none +;---------------------------------------------------------------------- +SET_SDA_PIN_LOW .macro + CLR R30, R30, R14.b1 + .endm + +;---------------------------------------------------------------------- +; Macro Name: READ_SDA_PIN_ACK +; Description: Set high value on SCL pin +; Input Parameters: none +; Output Parameters: none +;---------------------------------------------------------------------- +READ_SDA_PIN_ACK .macro + QBBS ACK_RECIEVED?, R31, R14.b1 + CLR R16, R16, ICSS_I2C_ACK_RECIEVED_BIT + JMP NO_ACK_RECIEVED? +ACK_RECIEVED?: + SET R16, R16, ICSS_I2C_ACK_RECIEVED_BIT +NO_ACK_RECIEVED?: + .endm + +;---------------------------------------------------------------------- +; Macro Name: COPY_LOCAL_TO_GLOBAL_STATE +; Description: copy next state from global state register. +; Input Parameters: none +; Output Parameters: none +;---------------------------------------------------------------------- +COPY_LOCAL_TO_GLOBAL_STATE .macro + AND R13.w0, R17.w0, R17.w0 + .endm + + +;************************************************************************************ +; +; Macro: RAISE_INTERRUPT_MEM_FOR_HOST +; +; raise the interrupt memory for telling host which instance raise the interrupt. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None: +; +; Returns: +; None +; +;************************************************************************************ +RAISE_INTERRUPT_MEM_FOR_HOST .macro arg1 + LDI TEMP_REG4.w0, 0x0000 + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET+2, 2 + + LDI TEMP_REG5.w0, ICSS_I2C_CONFIG_MEMORY + ADD TEMP_REG5.w0, TEMP_REG5.w0, IRQ_COMMON_REGISTER_OFFSET + LBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 + SET TEMP_REG4.w0, TEMP_REG4.w0, R14.b3 + SBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + .endm + + +;************************************************************************************ +; +; Macro: RAISE_INTERRUPT_FOR_HOST +; +; raise the interrupt memory for telling host which instance raise the interrupt. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None: +; +; Returns: +; None +; +;************************************************************************************ +RAISE_INTERRUPT_FOR_HOST .macro arg1 + LDI TEMP_REG5.w0, ICSS_INTC_SRSR1 + .if $defined("PRU0") + LDI32 TEMP_REG6, ICSS_I2C_INTC_PRU0_BIT_VAL + .else + LDI32 TEMP_REG6, ICSS_I2C_INTC_PRU1_BIT_VAL + .endif + SBCO &TEMP_REG6, ICSS_INTC_CONST, TEMP_REG5.w0, 4 + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + .endm + +;************************************************************************************ +; +; Macro: CHECK_INTERRUPT_RECEIVED +; +; raise the interrupt memory for telling host which instance raise the interrupt. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label on new memory location if interrupt is ACKed +; arg2: Label on new memory location if interrupt is not ACKed +; +; Returns: +; None +; +;************************************************************************************ +CHECK_INTERRUPT_RECEIVED .macro arg1, arg2 + LDI TEMP_REG5.w0, ICSS_I2C_CONFIG_MEMORY + ADD TEMP_REG5.w0, TEMP_REG5.w0, IRQ_COMMON_REGISTER_OFFSET + LBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 + QBBC INTERRUPT_RECEIVED_JMP_STATE?, TEMP_REG4.w0, R14.b3 + JMP INTERRUPT_RECEIVED_REPEAT_STATE? + +INTERRUPT_RECEIVED_JMP_STATE?: + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + +INTERRUPT_RECEIVED_REPEAT_STATE?: + UPDATE_NEXT_LOCAL_STATE arg2 + STATE_TASK_OVER + .endm + + +;************************************************************************************ +; +; Macro: SET_OUTPUT_PIN_VALUE_HIGH +; +; Set high value on SCL and SDA pin +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label on next memory location +; +; +; Returns: +; None +; +;************************************************************************************ +SET_OUTPUT_PIN_VALUE_HIGH .macro arg1 + SET_SDA_PIN_HIGH + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + .endm + +;************************************************************************************ +; +; Macro: UPDATE_NEXT_GLOBAL_STATE +; +; update next state in state keep register +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label on next memory location +; +; +; Returns: +; None +; +;************************************************************************************ +UPDATE_NEXT_GLOBAL_STATE .macro arg1 + LDI R17.w0, $CODE(arg1) + .endm + +;************************************************************************************ +; +; Macro: READ_ADDRESS_REGISTER +; +; Read the address register for slave address +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label on next memory location +; +; +; Returns: +; None +; +;************************************************************************************ +READ_ADDRESS_REGISTER .macro arg1 + QBBS read_address_register_10bits?, R16, ICSS_I2C_ADDRESSING_MODE_BIT + LDI TEMP_REG4.w0, 0x007F + JMP read_address_register_done? + +read_address_register_10bits?: + LDI TEMP_REG4.w0, 0x03FF + +read_address_register_done?: + LBBO &R13.w2, R10, ICSS_I2C_SA_OFFSET, 2 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R13.w2, 0x53 + .endif + + AND R13.w2, R13.w2, TEMP_REG4.w0 + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + .endm + +;************************************************************************************ +; +; Macro: READ_RW_REGISTER_BIT +; +; Read the RW bit to find read or write operation +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1: Label on new memory location +; +; +; Returns: +; None +; +;************************************************************************************ +READ_RW_REGISTER_BIT .macro arg1 + QBBS read_rw_register_bit_10bits?, R16, ICSS_I2C_ADDRESSING_MODE_BIT + LSL R13.w2, R13.w2, 9 + QBBC slave_address_w_setup?, R16, ICSS_I2C_READ_WRITE_BIT + SET R13.w2, R13.w2, 8 + JMP slave_address_rw_setup_return? +slave_address_w_setup?: + CLR R13.w2, R13.w2, 8 +slave_address_rw_setup_return?: + JMP read_rw_register_bit_done? + +read_rw_register_bit_10bits?: + LSL R13.b3, R13.b3, 1 + QBBC slave_address_w_setup_10bits?, R16, ICSS_I2C_READ_WRITE_BIT + SET R13.b3, R13.b3, 0 + JMP slave_address_rw_setup_return_10bits? +slave_address_w_setup_10bits?: + CLR R13.b3, R13.b3, 0 +slave_address_rw_setup_return_10bits?: + AND R13.b3, R13.b3, 0x07 + OR R13.b3, R13.b3, 0xF0 + +read_rw_register_bit_done?: + AND R15.b0, R15.b0, 0x00 + AND R15.b2, R15.b2, 0x00 + UPDATE_NEXT_LOCAL_STATE arg1 + STATE_TASK_OVER + .endm + + +;************************************************************************************ +; +; Macro: SEND_TX_DATA_CHECK_FOR_ACK +; +; Description: send 8 bits of Tx data +; check if ACK is recieved from slave or not. +; keep on sending until all data is sent. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; arg1 is register to be used for reading that data. +; arg2 is Label on new memory location for TX DATA complete +; arg3 is Label on new memory location for No ACK +; Returns: +; None +; +;************************************************************************************ +SEND_TX_DATA_CHECK_FOR_ACK .macro arg1, arg2, arg3 +; +; modify the SDA pin value based on the most significant bit of DATA value +; +tx_data_sda_begin?: + QBBC tx_data_sda_low?, arg1, 7 + SET_SDA_PIN_HIGH + JMP tx_data_sda_continue? +tx_data_sda_low?: + SET_SDA_PIN_LOW +tx_data_sda_continue?: + LSL arg1, arg1, 1 + ADD R15.b0, R15.b0, 0x01 + LDI R13.w0, $CODE(tx_data_scl_begin?) + STATE_TASK_OVER + +; +; make SCL high for sending SDA bit +; +tx_data_scl_begin?: + SET_SCL_PIN_HIGH + LDI R13.w0, $CODE(tx_data_sda_read?) + STATE_TASK_OVER + +; +; Jump to next state as this is tx mode, done for matching timing parameter. +; +tx_data_sda_read?: + LDI R13.w0, $CODE(tx_data_scl_end?) + STATE_TASK_OVER + +; +; make SCL low for stop sending SDA bit +; make decision for sending next data bit or check for ACK +; +tx_data_scl_end?: + SET_SCL_PIN_LOW + QBGT tx_sda_next_bit?, R15.b0, 0x08 + LDI R13.w0, $CODE(tx_data_ack_begin?) + STATE_TASK_OVER + +tx_sda_next_bit?: + LDI R13.w0, $CODE(tx_data_sda_begin?) + STATE_TASK_OVER + +; +; Change direction of GPIO +; +tx_data_ack_begin?: + SET_SDA_PIN_INPUT_DIRECTION + LDI R13.w0, $CODE(tx_data_ack_scl_begin?) + STATE_TASK_OVER + +; +; make SCL high for reading ACK bit +; +tx_data_ack_scl_begin?: + SET_SCL_PIN_HIGH + LDI R13.w0, $CODE(tx_data_ack_read?) + STATE_TASK_OVER + +; +; make SDA line for reading ACK bit +; +tx_data_ack_read?: + READ_SDA_PIN_ACK + QBBS tx_data_ack_read_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT + LDI R13.w0, $CODE(tx_data_ack_scl_end?) + STATE_TASK_OVER + +tx_data_ack_read_next_state?: + LDI R13.w0, $CODE(tx_data_ack_scl_end_v2?) + STATE_TASK_OVER + +; +; make SCL low +; read if ACK bit is set then check if data is still left to be sent +; +tx_data_ack_scl_end?: + SET_SCL_PIN_LOW + SET_SDA_PIN_OUTPUT_DIRECTION + QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT + ADD R15.b2, R15.b2, 0x01 + AND R15.b0, R15.b0, 0x00 + QBGT tx_mode_continue?, R15.b2, R15.b3 + AND R15.b2, R15.b2, 0x00 + LDI R13.w0, $CODE(arg2) + STATE_TASK_OVER +tx_mode_continue?: + LBBO &arg1, R11, R15.b2, 1 + LDI R13.w0, $CODE(tx_data_sda_begin?) + + STATE_TASK_OVER + +; +; make SCL low +; read if ACK bit is set then check if data is still left to be sent +; + +tx_data_ack_scl_end_v2?: + SET_SCL_PIN_LOW + SET_SDA_PIN_OUTPUT_DIRECTION + QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT + AND R15.b0, R15.b0, 0x00 + AND R15.b2, R15.b2, 0x00 + CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT + LBBO &arg1, R11, R15.b2, 1 + LDI R13.w0, $CODE(arg2) + STATE_TASK_OVER + + +tx_data_ack_not_recieved?: + LDI R13.w0, $CODE(no_tx_data_ack_recieved?) + STATE_TASK_OVER + +; +; if no data ack is recieved, response with no ack in response command +; raise an interrupt +; +no_tx_data_ack_recieved?: + SET_SCL_PIN_HIGH + LDI TEMP_REG4.w0, DATA_ACKNOWLDEGE_FAILED + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + LDI R13.w0, $CODE(arg3) + STATE_TASK_OVER + + .endm + + + + + +;************************************************************************************ +; +; Macro: I2C_SETUP_IEP_COUNTER +; +; Description: Setup the IEP timer counter for periodic interrupt. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; Returns: +; None +; +;************************************************************************************ + +I2C_SETUP_IEP_COUNTER .macro + ;read IEP Timer enabled or not + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 + QBBS iep_counter_setup_done?, TEMP_REG1 , 0 + + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8 + LDI32 TEMP_REG1 , 0xFFFFFFFF + LDI32 TEMP_REG2 , 0xFFFFFFFF + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8 + + ;Clear overflow status register + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_STATUS_REG, 4 + SET TEMP_REG1 , TEMP_REG1 , 0 + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_STATUS_REG, 4 + + ;Clear compare status + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 + LDI TEMP_REG1.w0 , 0xFFFF + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 + + ;Enable IEP counter + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 + SET TEMP_REG1 , TEMP_REG1 , 0 + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 + +iep_counter_setup_done?: + ;Set compare values + + LDI TEMP_REG3.w0, ICSS_I2C_CONFIG_MEMORY + LBCO &IEP_COUNTER_NEXT_VAL1, ICSS_DMEM0_CONST, TEMP_REG3.w0, 8 + LBCO &TEMP_REG2, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8 + + ;;;debug code + ;;.if $defined("DEBUG_CODE") + LDI IEP_COUNTER_NEXT_VAL1, 0x9c3 + LDI IEP_COUNTER_NEXT_VAL2, 0x0 + ;;.endif + +loop3?: + ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 + ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 + ;;QBGT loop3?, IEP_COUNTER_NEXT_VAL2, TEMP_REG3 + ;;QBLT loop4?, IEP_COUNTER_NEXT_VAL2, TEMP_REG3 + ;;QBGT loop3?, IEP_COUNTER_NEXT_VAL1, TEMP_REG2 +loop4?: + ;;ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 + ;;ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 + SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8 + + ;Enable compare events + .if $defined("PRU0") + ZERO &TEMP_REG1, 4 + SET TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_ENABLE_BIT + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4 + .endif ;PRU0 + + .if $defined("PRU1") + ZERO &TEMP_REG1, 4 + SET TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_ENABLE_BIT + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4 + .endif ;PRU1 + + .endm + + + +;------------------------------------------------------------------------------------------------------------------------------- +; Macro Name: READ_RX_DATA_AND_SEND_ACK +; Description: read 8 bits of Rx data then send ack +; keep on sending until all data is read. +; Input Parameters: arg1 is register to be used for reading data. +; Input Parameters: arg2 is Label on new memory location for DATA complete +; Output Parameters: none +;---------------------------------------------------------------------------------------------------------------------------- +READ_RX_DATA_AND_SEND_ACK .macro arg1, arg2 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; release SDA line so slave can drive it. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + SET_SDA_PIN_INPUT_DIRECTION +rx_data_sda_begin?: + LDI R13.w0, $CODE(rx_data_scl_begin?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for reading data value +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_scl_begin?: + SET_SCL_PIN_HIGH + LSL arg1, arg1, 1 + LDI R13.w0, $CODE(rx_data_sda_read?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Read the SDA pin value and store it in the MSB of receive register +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_sda_read?: + QBBS rx_data_sda_high?, R31, R14.b1 + AND arg1, arg1, 0xFE + JMP rx_data_sda_read_continue? +rx_data_sda_high?: + OR arg1, arg1, 0x01 +rx_data_sda_read_continue?: + ADD R15.b0, R15.b0, 0x01 + LDI R13.w0, $CODE(rx_data_scl_end?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for finishing data read +; also check if all the data needed to read is over then send ACK +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_scl_end?: + SET_SCL_PIN_LOW + QBGT rx_sda_next_bit?, R15.b0, 0x08 + ADD R15.b2, R15.b2, 0x01 + QBBS rx_data_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT + QBGT rx_data_next_state?, R15.b2, R15.b3 + QBBC rx_data_next_state?, R16, ICSS_I2C_RECIEVE_NACK_BIT + LDI R13.w0, $CODE(rx_data_nack_begin?) + SET_SDA_PIN_OUTPUT_DIRECTION + STATE_TASK_OVER + +rx_data_next_state?: + LDI R13.w0, $CODE(rx_data_ack_begin?) + SET_SDA_PIN_OUTPUT_DIRECTION + STATE_TASK_OVER + +rx_sda_next_bit?: + LDI R13.w0, $CODE(rx_data_sda_begin?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SDA line low to send an ACK. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_ack_begin?: + ;SET_SDA_PIN_OUTPUT_DIRECTION + SET_SDA_PIN_HIGH + LDI R13.w0, $CODE(rx_data_ack_scl_begin?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SDA line low to send an NACK. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_nack_begin?: + SET_SDA_PIN_HIGH + LDI R13.w0, $CODE(rx_data_ack_scl_begin?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for reading ACK bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_ack_scl_begin?: + SET_SCL_PIN_HIGH + SBBO &R15.b3, R10, ICSS_I2C_CNT_OFFSET, 1 + LDI R13.w0, $CODE(rx_data_ack_read?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; jump to next state, done to match the timing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_ack_read?: + QBBS rx_data_ack_read_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT + LDI R13.w0, $CODE(rx_data_ack_scl_end?) + STATE_TASK_OVER + +rx_data_ack_read_next_state?: + LDI R13.w0, $CODE(rx_data_ack_scl_end_v2?) + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for finishing data read +; also check if all the data needed to read is over then finish read +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_ack_scl_end?: + SET_SCL_PIN_LOW + AND R15.b0, R15.b0, 0x00 + SUB TEMP_REG4.b0, R15.b2, 1 + SBBO &arg1, R12, TEMP_REG4.b0, 1 + QBGT rx_mode_continue?, R15.b2, R15.b3 + AND R15.b2, R15.b2, 0x00 + LDI R13.w0, $CODE(arg2) + ; SET_SDA_PIN_INPUT_DIRECTION + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for finishing data read +; also check if all the data needed to read is over then finish read +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +rx_data_ack_scl_end_v2?: + SET_SCL_PIN_LOW + AND R15.b0, R15.b0, 0x00 + AND R15.b2, R15.b2, 0x00 + CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT + LDI R13.w0, $CODE(arg2) + STATE_TASK_OVER + +rx_mode_continue?: + SET_SDA_PIN_INPUT_DIRECTION + LDI R13.w0, $CODE(rx_data_sda_begin?) + STATE_TASK_OVER + + .endm + + +;************************************************************************************ +; +; Macro: SET_SDA_PIN_INPUT_DIRECTION +; +; Description: Setup the Control register for SDA pin input +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; Returns: +; None +; +;************************************************************************************ +SET_SDA_PIN_INPUT_DIRECTION .macro + + ;; For Am263x LDI32 r29, 0x50D00824 + ;for Am261x + LDI32 r29, 0x50D00818 + LBBO &r28, r29, 0, 4 + SET r28, r28, 9 + SBBO &r28, r29, 0, 4 + + .endm + +;************************************************************************************ +; +; Macro: SET_SDA_PIN_OUTPUT_DIRECTION +; +; Description: Clear the Control register for SDA pin output. +; +; PEAK cycles: +; +; Pseudo code: +; +; +; Parameters: +; None +; Returns: +; None +; +;************************************************************************************ + +SET_SDA_PIN_OUTPUT_DIRECTION .macro + + ;; For Am263x LDI32 r29, 0x50D00824 + ;for Am261x + LDI32 r29, 0x50D00818 + LBBO &r28, r29, 0, 4 + LDI32 R27, 0xFFFFFDFF + AND r28, r28, r27 + SBBO &r28, r29, 0, 4 + + .endm +.endif ; __icss_i2c_macros_h \ No newline at end of file diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm new file mode 100644 index 000000000..63808fe7b --- /dev/null +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -0,0 +1,1389 @@ +; Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ +; +; 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. + +;-------------------------------------------------------------------------------------- +; File: pru_i2c_main.asm +; +; Brief: Firmware for ICSS PRU +;-------------------------------------------------------------------------------------- + +; CCS/makefile specific settings + .retain ; Required for building .out with assembly file + .retainrefs ; Required for building .out with assembly file + + .global main + .sect ".text" + +;----------------------------------Includes---------------------------------------------------- + + .include "pru_i2c_firmware_version.h" + .include "pru_i2c_macro.h" + .include "icss_constant_defines.inc" + .include "icss_cfg_regs.inc" + .include "icss_iep_regs.inc" + .include "icss_intc_regs.inc" +;-------------------------------------------------------------------------------------- + +; +; symbols +; + + .asg R1, TEMP_REG1 ; temporary register 1 + .asg R2, TEMP_REG2 ; temporary register 2 + .asg R3, TEMP_REG3 ; temporary register 3 + .asg R4, TEMP_REG4 ; temporary register 4 + .asg R5, TEMP_REG5 ; temporary register 5 + .asg R6, TEMP_REG6 ; temporary register 6 + .asg R7, TEMP_REG7 ; temporary register 7 + .asg R8, TEMP_REG8 ; temporary register 8 + + .asg R20, IEP_COUNTER_NEXT_VAL1 + .asg R21, IEP_COUNTER_NEXT_VAL2 + .asg R22, I2C_GLOBAL_FREQ_REG + + + + +PRU0_IEP_CMP_REG .set ICSS_IEP_CMP0_REG +PRU1_IEP_CMP_REG .set ICSS_IEP_CMP1_REG +PRU0_IEP_CMP_ENABLE_BIT .set 1 +PRU1_IEP_CMP_ENABLE_BIT .set 2 +PRU0_IEP_CMP_STATUS_BIT .set 0 +PRU1_IEP_CMP_STATUS_BIT .set 1 + + +; Bank ids for Xfer instructions +BANK0 .set 10 +BANK1 .set 11 +BANK2 .set 12 +;-------------------------------------------------------------------------------------- + +;******** +;* MAIN * +;******** + +main: + +init: +;---------------------------------------------------------------------------- +; Clear the register space +; Before begining with the application, make sure all the registers are set +; to 0. PRU has 32 - 4 byte registers: R0 to R31, with R30 and R31 being special +; registers for output and input respectively. +;---------------------------------------------------------------------------- + +; Give the starting address and number of bytes to clear. + ZERO &R0, 120 + + + ;need to add section to store firmware version in memory' + ;///// + + ; Enable support of shifting during XIN/XOUT operation + ENABLE_XIN_XOUT_SHITFTING + + ;Initialize I2C instance 0 registers + LDI R10.w0 , ICSS_I2C_INSTANCE0_ADDR + LDI R10.w2 , 0x0000 + LDI R11.w0 , ICSS_I2C_INSTANCE0_TX_MEM + LDI R11.w2 , 0x0000 + LDI R12.w0 , ICSS_I2C_INSTANCE0_RX_MEM + LDI R12.w2 , 0x0000 + LDI R13.w0 , $CODE(RESET_MODE) + LDI R13.w2 , 0x0000 + LDI32 R14 , 0x00000000 + LDI32 R15 , 0x00000000 + LDI32 R16 , 0x00000000 + LDI32 R17 , 0x00000000 + LDI32 R18 , 0x00000000 + LDI32 R19 , 0x00000000 + + LDI R0.b0, 0x00 + XOUT BANK0, &R10, 40 + + ;add a variable delay for N cyles to avoid contention + ;between PRU0 and PRU1 if both out of reset at the same time. + ;;DELAY DELAY_CYCLE + + ZERO &R0, 124 ;Zero all registers + + ;decide the global working frequency for I2C FW + ;Load frequency from DMEM + LDI TEMP_REG1.w0, ICSS_I2C_CONFIG_MEMORY + ADD TEMP_REG1.w0, TEMP_REG1.w0, I2C_BUS_FREQUENCY_OFFSET + LBCO &I2C_GLOBAL_FREQ_REG.w0, ICSS_DMEM0_CONST, TEMP_REG1.w0, 4 + + ;Debug code for testing + .if $defined("DEBUG_CODE") + LDI TEMP_REG1.w0, ICSS_I2C_400KHZ_FREQ + LDI TEMP_REG1.w2, IEP_CMP_INCREMENT_VAL_400KHZ + MOV I2C_GLOBAL_FREQ_REG, TEMP_REG1 + .endif + + ; Setup the IEP Timer Counter + I2C_SETUP_IEP_COUNTER + + ; jump to task_loop based on global frequency + QBEQ TASK_LOOP_100Khz, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_100KHZ_FREQ + QBEQ TASK_LOOP_400Khz, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_400KHZ_FREQ + QBEQ TASK_LOOP_1Mhz, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_1MHZ_FREQ + +ERROR_LOOP: + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 + CLR TEMP_REG1 , TEMP_REG1 , 0 + SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 + LDI TEMP_REG5.w0, ICSS_INTC_SRSR1 + LDI32 TEMP_REG6, 0x00400000 + SBCO &TEMP_REG6, ICSS_INTC_CONST, TEMP_REG5.w0, 4 + QBA ERROR_LOOP + + +;---------------------------------------------------------- +; Task for 100Khz mode +; 1) Waiting for cmp event +; 2) Clear the event +; 3) Perform the i2c wave transition +;---------------------------------------------------------- +TASK_LOOP_100Khz: + ;wait for the IEP CMP event 1 to happen +IEP_CHECK_EVENT0: + I2C_WAIT_FOR_IEP_CMP + + ; clear IEP CMP event and interrupt associated with it. + I2C_IEP_INTC_CLEAR_EVENT IEP_CHECK_EVENT0 + + ;perform the i2c wave transition + I2C_WAVE_FUNCTION0 + + QBA TASK_LOOP_100Khz + + +;---------------------------------------------------------- +; Task for 400Khz mode +; 1) Waiting for cmp event +; 2) Clear the event +; 3) Perform the i2c wave transition +;---------------------------------------------------------- +TASK_LOOP_400Khz: + ;wait for the IEP CMP event 1 to happen +IEP_CHECK_EVENT1: + I2C_WAIT_FOR_IEP_CMP + + ; clear IEP CMP event and interrupt associated with it. + I2C_IEP_INTC_CLEAR_EVENT IEP_CHECK_EVENT1 + + ;perform the i2c wave transition + I2C_WAVE_FUNCTION0 + + QBA TASK_LOOP_400Khz + + +;---------------------------------------------------------- +; Task for 1MHz mode +; 1) Waiting for cmp event +; 2) Clear the event +; 3) Perform the i2c wave transition +;---------------------------------------------------------- + +TASK_LOOP_1Mhz: + ;wait for the IEP CMP event 1 to happen +IEP_CHECK_EVENT2: + I2C_WAIT_FOR_IEP_CMP + + ; clear IEP CMP event and interrupt associated with it. + I2C_IEP_INTC_CLEAR_EVENT IEP_CHECK_EVENT2 + + ;perform the i2c wave transition + I2C_WAVE_FUNCTION0 + + QBA TASK_LOOP_1Mhz + + + + +;-----------------------------------------------------------I2C states---------------------------------------------------------------------------------- +; +; +; In all state, the processing is broken into multiple state we have a tight budget of +; 20 cycles per state. +; +;----------------------------------------------------------- + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This is the initial mode in which comes out of reset +; It checks if the enabled bit is set or not. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_MODE: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + + ;Debug Code + .if $defined("DEBUG_CODE") + SET TEMP_REG4, TEMP_REG4, ICSS_I2C_MODULE_ENABLE_BIT + .endif + + QBBC RESET_MODE_RETURN, TEMP_REG4, ICSS_I2C_MODULE_ENABLE_BIT + UPDATE_NEXT_LOCAL_STATE CHECK_SETUP_COMMAND + +RESET_MODE_RETURN: + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; In this state, firmware is only out of reset +; The only command it can accept in the state is setup command. +; if any other command is passed it will send invalid command response back +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CHECK_SETUP_COMMAND: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + LDI TEMP_REG4, 0 + LDI TEMP_REG4.w2, ICSS_I2C_SETUP_CMD + .endif + + QBEQ CHECK_SETUP_COMMAND_RETURN, TEMP_REG4.w2, 0x00 + QBNE CHECK_SETUP_COMMAND_ERROR, TEMP_REG4.w2, ICSS_I2C_SETUP_CMD + + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_PRU_PIN_NUM + STATE_TASK_OVER + +CHECK_SETUP_COMMAND_ERROR: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_ERROR + LDI TEMP_REG4.w0, INVALID_COMMAND + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +CHECK_SETUP_COMMAND_RETURN: + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This state load the PRU pins no. for the instance. +; SCL -> PRU GPO and SDA -> PRU GPI pins numbers +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_PRU_PIN_NUM: + LBBO &R14, R10, ICSS_I2C_PRU_PIN_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R14.b0, 1 + LDI R14.b1, 2 + .endif + + LDI R14.b3, 0x00 + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_INST_ID + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This instance id of the FW is being loaded into the register. +; This id helps the FW to decide which bit to raise high when raising an interrupt. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_INST_ID: + LBBO &R14.b3, R10, ICSS_I2C_PRU_INST_ID_OFFSET, 1 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R14.b3, 0 + .endif + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_SCL_SDA_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This set the SCL clk line and SDA data line high. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_SCL_SDA_HIGH: + SET_SCL_PIN_HIGH + SET_SDA_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_TX_FIFO_SIZE + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the Tx fifo size of the firmware +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_TX_FIFO_SIZE: + LBBO &R16.b2, R10, ICSS_I2C_BUF_OFFSET, 1 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R16.b2, 12 + .endif + + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_RX_FIFO_SIZE + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the Rx fifo size of the firmware +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_RX_FIFO_SIZE: + LBBO &R16.b3, R10, ICSS_I2C_BUF_OFFSET+1, 1 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R16.b3, 12 + .endif + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_MASTER_SLAVE_MODE + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware into master or slave mode +; currently only master mode is supported. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_MASTER_SLAVE_MODE: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + SET TEMP_REG4, TEMP_REG4, ICSS_I2C_MASTER_SLAVE_MODE_BIT + .endif + + QBBC SETUP_I2C_MASTER_SLAVE_ERROR, TEMP_REG4, ICSS_I2C_MASTER_SLAVE_MODE_BIT + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_ADDRESSING_MODE + STATE_TASK_OVER + +SETUP_I2C_MASTER_SLAVE_ERROR: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_ERROR + LDI TEMP_REG4.w0, MASTER_SLAVE_MODE_FAILED + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware for 10 bits or 8 bits addressing mode +; currently only 7 bits mode is supported. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_ADDRESSING_MODE: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + QBBS SETUP_I2C_ADDRESSING_10BIT, TEMP_REG4, ICSS_I2C_ADDRESSING_MODE_BIT + CLR R16, R16, ICSS_I2C_ADDRESSING_MODE_BIT + JMP SETUP_I2C_ADDRESSING_DONE + +SETUP_I2C_ADDRESSING_10BIT: + SET R16, R16, ICSS_I2C_ADDRESSING_MODE_BIT + +SETUP_I2C_ADDRESSING_DONE: + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_START_CTRL + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware for sending start bit at beginning or not +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_START_CTRL: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + SET TEMP_REG4, TEMP_REG4, ICSS_I2C_START_BIT + .endif + + QBBC SETUP_I2C_NO_START_CTRL, TEMP_REG4, ICSS_I2C_START_BIT + SET R16, R16, ICSS_I2C_START_BIT + JMP SETUP_I2C_START_DONE + +SETUP_I2C_NO_START_CTRL: + CLR R16, R16, ICSS_I2C_START_BIT + +SETUP_I2C_START_DONE: + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_STOP_CTRL + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware for sending stop bit at end of data transfer +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_STOP_CTRL: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + SET TEMP_REG4, TEMP_REG4, ICSS_I2C_STOP_BIT + .endif + + QBBC SETUP_I2C_NO_STOP_CTRL, TEMP_REG4, ICSS_I2C_STOP_BIT + SET R16, R16, ICSS_I2C_STOP_BIT + JMP SETUP_I2C_STOP_DONE + +SETUP_I2C_NO_STOP_CTRL: + CLR R16, R16, ICSS_I2C_STOP_BIT + +SETUP_I2C_STOP_DONE: + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_SMBUS_BURST_CTRL + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware for sending start bit at beginning or not +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_SMBUS_BURST_CTRL: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + QBBC SETUP_I2C_NO_SMBUS_BURST_CTRL, TEMP_REG4, ICSS_I2C_SMBUS_BURST_BIT + SET R16, R16, ICSS_I2C_SMBUS_BURST_BIT + JMP SETUP_I2C_SMBUS_BURST_DONE + +SETUP_I2C_NO_SMBUS_BURST_CTRL: + CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT + +SETUP_I2C_SMBUS_BURST_DONE: + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_NACK_CTRL + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; This configures the firmware for ending the read operation with NACK or not +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_NACK_CTRL: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + SET TEMP_REG4, TEMP_REG4, ICSS_I2C_RECIEVE_NACK_BIT + .endif + + QBBC SETUP_I2C_NO_NACK_CTRL, TEMP_REG4, ICSS_I2C_RECIEVE_NACK_BIT + SET R16, R16, ICSS_I2C_RECIEVE_NACK_BIT + JMP SETUP_I2C_NACK_DONE + + + +SETUP_I2C_NO_NACK_CTRL: + CLR R16, R16, ICSS_I2C_RECIEVE_NACK_BIT + +SETUP_I2C_NACK_DONE: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + + ;debug code + .if $defined("DEBUG_CODE") + UPDATE_NEXT_LOCAL_STATE FIRMWARE_READY + .endif + + LDI TEMP_REG4.w0, COMMAND_SUCCESS + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Set the MMap for host to find out which instance raised the interrupt. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RAISE_HOST_INTERRUPT_MEM_FOR_ERROR: + RAISE_INTERRUPT_MEM_FOR_HOST RAISE_HOST_INTERRUPT_FOR_ERROR + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Raise interrupt for Host while the firmware was trying to configure +; setup procedures. +; after raising the interrupt wait for host to respond. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RAISE_HOST_INTERRUPT_FOR_ERROR: + RAISE_INTERRUPT_FOR_HOST CHECK_HOST_INTERRUPT_ERROR_RECEIVED + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; check for host to receive the command response +; then jump to "reset" mode again for reconfiguration +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CHECK_HOST_INTERRUPT_ERROR_RECEIVED: + CHECK_INTERRUPT_RECEIVED RESET_MODE, RAISE_HOST_INTERRUPT_FOR_ERROR + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Set the MMap for host to find out which instance raised the interrupt. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RAISE_HOST_INTERRUPT_MEM_FOR_READY: + RAISE_INTERRUPT_MEM_FOR_HOST RAISE_HOST_INTERRUPT_FOR_READY + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Raise interrupt for Host while the firmware succesfully does setup configuration +; but fails to any transaction i.e. read or write. +; after raising the interrupt wait for host to respond. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RAISE_HOST_INTERRUPT_FOR_READY: + RAISE_INTERRUPT_FOR_HOST CHECK_HOST_INTERRUPT_READY_RECEIVED + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; check for host to receive the command response +; then jump to "firmware ready" mode again to do a transaction again +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CHECK_HOST_INTERRUPT_READY_RECEIVED: + CHECK_INTERRUPT_RECEIVED FIRMWARE_READY, RAISE_HOST_INTERRUPT_FOR_READY + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; In this state, firmware is out of reset succesfully +; firmware is ready to accept any command and check if the command word is not "0x0000" +; then start to check which command is passed. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +FIRMWARE_READY: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + LDI TEMP_REG4.w2, ICSS_I2C_TX_CMD + .endif + + QBEQ FIRMWARE_READY_RETURN, TEMP_REG4.w2, 0x00 + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_RESET_CMD_CHECK + +FIRMWARE_READY_RETURN: + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the reset command has been passed. +; if reset command is passed then resets the firmware else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_RESET_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + ;;LDI TEMP_REG4.w2, ICSS_I2C_TX_CMD + LDI TEMP_REG4.w2, ICSS_I2C_RX_CMD + .endif + + QBNE ICSS_I2C_RESET_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_RESET_CMD + UPDATE_NEXT_LOCAL_STATE RESET_SCL_SDA_HIGH + LDI TEMP_REG4.w0, COMMAND_SUCCESS + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +ICSS_I2C_RESET_CMD_CHECK_RETURN: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_SETUP_CMD_CHECK + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; set the value on iep gpo enable register to high value +; this will pull the line to high impedence and open drain will keep the line high +; set the value on iep gpo to low value for pulling the line +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SCL_SDA_HIGH: + SET_OUTPUT_PIN_VALUE_HIGH RAISE_HOST_INTERRUPT_MEM_FOR_ERROR + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the setup command has been passed. +; if setup command is passed then redo the firmware setup procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_SETUP_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + ;;LDI TEMP_REG4.w2, ICSS_I2C_TX_CMD + LDI TEMP_REG4.w2, ICSS_I2C_RX_CMD + .endif + + QBNE ICSS_I2C_SETUP_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_SETUP_CMD + UPDATE_NEXT_LOCAL_STATE RESET_MODE + STATE_TASK_OVER + +ICSS_I2C_SETUP_CMD_CHECK_RETURN: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_RX_CMD_CHECK + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the Rx command has been passed. +; if Rx command is passed then start receive data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_RX_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + ;;LDI TEMP_REG4.w2, ICSS_I2C_TX_CMD + LDI TEMP_REG4.w2, ICSS_I2C_RX_CMD + .endif + + QBNE ICSS_I2C_RX_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_RX_CMD + UPDATE_NEXT_LOCAL_STATE RX_MODE + STATE_TASK_OVER + +ICSS_I2C_RX_CMD_CHECK_RETURN: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_TX_CMD_CHECK + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the Tx command has been passed. +; if Tx command is passed then start transmit data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_TX_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + + ;debug code + .if $defined("DEBUG_CODE") + LDI TEMP_REG4.w2, ICSS_I2C_TX_CMD + .endif + + QBNE ICSS_I2C_TX_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_TX_CMD + UPDATE_NEXT_LOCAL_STATE TX_MODE + STATE_TASK_OVER + +ICSS_I2C_TX_CMD_CHECK_RETURN: + UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_QUICK_CHECK + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus Quick command has been passed. +; if Quick command is passed then start Quick data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_QUICK_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_QUICK_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE QUICK_CMD_MODE + STATE_TASK_OVER + +ICSS_SMBUS_QUICK_CMD_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_SEND_BYTE + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus send byte command has been passed. +; if send byte command is passed then start send byte data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_SEND_BYTE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_SEND_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_SEND_BYTE_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE SEND_BYTE_MODE + STATE_TASK_OVER + +ICSS_SMBUS_SEND_BYTE_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_RECEIVE_BYTE + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus receive byte command has been passed. +; if receive byte command is passed then start receive byte data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_RECEIVE_BYTE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_RECEIVE_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_RECEIVE_BYTE_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE RECEIVE_BYTE_MODE + STATE_TASK_OVER + +ICSS_SMBUS_RECEIVE_BYTE_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_WRITE_BYTE + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus write byte command has been passed. +; if write byte command is passed then start write byte data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_WRITE_BYTE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_WRITE_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_WRITE_BYTE_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE WRITE_BYTE_MODE + STATE_TASK_OVER + +ICSS_SMBUS_WRITE_BYTE_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_READ_BYTE + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus read byte command has been passed. +; if read byte command is passed then start read byte data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +ICSS_SMBUS_READ_BYTE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_READ_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_READ_BYTE_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE READ_BYTE_MODE + STATE_TASK_OVER + +ICSS_SMBUS_READ_BYTE_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_WRITE_WORD + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus write word command has been passed. +; if write word command is passed then start write word data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_WRITE_WORD: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_WRITE_WORD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_WRITE_WORD_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE WRITE_WORD_MODE + STATE_TASK_OVER + +ICSS_SMBUS_WRITE_WORD_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_READ_WORD + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus read word command has been passed. +; if read word command is passed then start read word data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_READ_WORD: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_READ_WORD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_READ_WORD_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE READ_WORD_MODE + STATE_TASK_OVER + +ICSS_SMBUS_READ_WORD_CHECK_NEXT: + ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_BLOCK_WRITE + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus block write command has been passed. +; if block write command is passed then start block write data procedure +; else check for another command +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_SMBUS_BLOCK_WRITE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_BLOCK_WRITE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_WRITE_CMD + ;;;; UPDATE_NEXT_LOCAL_STATE BLOCK_WRITE_MODE + STATE_TASK_OVER + +ICSS_SMBUS_BLOCK_WRITE_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_BLOCK_READ + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the smbus block read command has been passed. +; if block read command is passed then start block read data procedure +; else no matching command has been found +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +ICSS_SMBUS_BLOCK_READ: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_SMBUS_BLOCK_READ_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_READ_CMD + ;;; UPDATE_NEXT_LOCAL_STATE BLOCK_READ_MODE + STATE_TASK_OVER + +ICSS_SMBUS_BLOCK_READ_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_READ_SCL_CMD_CHECK + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the I2C read SCL command has been passed. +; if this command requires the host to change the pinmux to input for SCL pin +; else no matching command has been found +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_READ_SCL_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_I2C_READ_SCL_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_I2C_READ_SCL_CMD + UPDATE_NEXT_LOCAL_STATE READ_SCL_PIN_SETUP + STATE_TASK_OVER + +ICSS_I2C_READ_SCL_CMD_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_RESET_SLAVE_CMD_CHECK + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the I2C reset slave command has been passed. +; if this command will send 9 clock pulse to device for reseting it. +; else no matching command has been found +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_RESET_SLAVE_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_I2C_RESET_SLAVE_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_I2C_RESET_SLAVE_CMD + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_BEGIN + STATE_TASK_OVER + +ICSS_I2C_RESET_SLAVE_CMD_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE ICSS_I2C_LOOPBACK_CMD_CHECK + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; checks if the I2C reset slave command has been passed. +; if this command will send 9 clock pulse to device for reseting it. +; else no matching command has been found +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ICSS_I2C_LOOPBACK_CMD_CHECK: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBNE ICSS_I2C_LOOPBACK_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_I2C_LOOPBACK_CMD + UPDATE_NEXT_LOCAL_STATE LOOPBACK_DATA_COUNT + STATE_TASK_OVER + +ICSS_I2C_LOOPBACK_CMD_CHECK_NEXT: + UPDATE_NEXT_LOCAL_STATE FIRMWARE_READY_COMMAND_ERROR + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; no known command has been matched with passed cmd +; raise an interrupt and respond with error reponse word +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +FIRMWARE_READY_COMMAND_ERROR: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + LDI TEMP_REG4.w0, INVALID_COMMAND + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; set the local register to indicate tx mode +; set the value on iep gpo to low value for pulling the line +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +TX_MODE: + CLR R16, R16, ICSS_I2C_READ_WRITE_BIT + UPDATE_NEXT_GLOBAL_STATE TX_DATA_SDA_BEGIN + UPDATE_NEXT_LOCAL_STATE SET_SCL_SDA_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; set the local register to indicate rx mode +; set the value on iep gpo to low value for pulling the line +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RX_MODE: + SET R16, R16, ICSS_I2C_READ_WRITE_BIT + UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN + UPDATE_NEXT_LOCAL_STATE SET_SCL_SDA_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; set the value on iep gpo enable register to high value +; this will pull the line to high impedence and open drain will keep the line high +; set the value on iep gpo to low value for pulling the line +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SET_SCL_SDA_HIGH: + SET_OUTPUT_PIN_VALUE_HIGH SLAVE_ADDRESS_SETUP + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; read the slave address from configuration registers. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SLAVE_ADDRESS_SETUP: + READ_ADDRESS_REGISTER SLAVE_ADDRESS_RW_SETUP + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; configure the read/write bit in the slave address register for transmission +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SLAVE_ADDRESS_RW_SETUP: + READ_RW_REGISTER_BIT DATA_COUNT + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Read the number of 8 bits data need to be read or writen +; also initialize the data count and bit count register to 0 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +DATA_COUNT: + LBBO &TEMP_REG4.w0, R10, ICSS_I2C_CNT_OFFSET, 2 + + ;debug code + .if $defined("DEBUG_CODE") + ; fif count + LDI TEMP_REG4.w0, 1 + .endif + + QBLT DATA_COUNT_ERROR, TEMP_REG4.w0, 0xFF + QBGT DATA_COUNT_ERROR, TEMP_REG4.w0, 0x01 + + ;debug code + .if $defined("DEBUG_CODE") + LDI R24.b0, 0x53 + LDI r24.b1, 0xFF + LDI r24.b2, 0x00 + ldi r24.b3, 0x00 + ldi r25.b0, 0x33 + SBBO &r24, R11, 0, 1 + .endif + + AND R15.b3, TEMP_REG4.b0, 0xFF + AND R15.b2, R15.b2, 0x00 + LBBO &R15.b1, R11, R15.b2, 1 + + UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW + STATE_TASK_OVER + +DATA_COUNT_ERROR: + LDI TEMP_REG4.w0, INVALID_DATA_COUNT + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SDA low for start condition +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +START_CONDITION_SDA_LOW: + QBBC START_CONDITION_SDA_LOW_RETURN, R16, ICSS_I2C_START_BIT + SET_SDA_PIN_LOW +START_CONDITION_SDA_LOW_RETURN: + UPDATE_NEXT_LOCAL_STATE START_CONDITION_SCL_LOW + + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for start condition +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +START_CONDITION_SCL_LOW: + QBBC START_CONDITION_SCL_LOW_RETURN, R16, ICSS_I2C_START_BIT + SET_SCL_PIN_LOW +START_CONDITION_SCL_LOW_RETURN: + UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; modify the SDA pin value based on the most significant bit of Address register +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_SDA_BEGIN: + RSB TEMP_REG5.b0, R15.b0, 15 + QBBC ADDRESS_SDA_LOW, R13.w2, TEMP_REG5.b0 + SET_SDA_PIN_HIGH + JMP ADDRESS_SDA_CONTINUE +ADDRESS_SDA_LOW: + SET_SDA_PIN_LOW +ADDRESS_SDA_CONTINUE: + ADD R15.b0, R15.b0, 0x01 + UPDATE_NEXT_LOCAL_STATE ADDRESS_SCL_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for sending SDA bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_SCL_BEGIN: + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_READ + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; nothing to be read in address tx mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_SDA_READ: + UPDATE_NEXT_LOCAL_STATE ADDRESS_SCL_END + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for ending the transmission of bit +; also decide the next state based on all the bits have been sent or not. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_SCL_END: + SET_SCL_PIN_LOW + QBGT SDA_NEXT_BIT, R15.b0, 0x08 + UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_BEGIN + STATE_TASK_OVER + +SDA_NEXT_BIT: + UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; change the direction of PIN as INPUT. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_ACK_BEGIN: + SET_SDA_PIN_INPUT_DIRECTION + UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for reading ACK bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_ACK_SCL_BEGIN: + SET_SCL_PIN_HIGH + AND R15.b0, R15.b0, 0x00 + UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_READ + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SDA line for reading ACK bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_ACK_READ: + READ_SDA_PIN_ACK + UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_END + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low +; read if ACK bit is set then start sending or receiving data else indicate no ack +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +ADDRESS_ACK_SCL_END: + SET_SCL_PIN_LOW + ;SET the dirction for GPIO + SET_SDA_PIN_OUTPUT_DIRECTION + QBBS ADDRESS_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT + QBBC ADDRESS_ACK_SCL_END_DONE, R16, ICSS_I2C_ADDRESSING_MODE_BIT + QBEQ ADDRESS_ACK_SCL_END_DONE, R15.b2, 0x01 + ADD R15.b2, R15.b2, 0x01 + UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN + STATE_TASK_OVER + +ADDRESS_ACK_SCL_END_DONE: + AND R15.b2, R15.b2, 0x00 + COPY_LOCAL_TO_GLOBAL_STATE + STATE_TASK_OVER + +ADDRESS_ACK_NOT_RECIEVED: + UPDATE_NEXT_LOCAL_STATE NO_ADDRESS_ACK_RECIEVED + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; if no address ack is recieved, response with no ack in response command +; raise an interrupt +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +NO_ADDRESS_ACK_RECIEVED: + SET_SCL_PIN_HIGH + LDI TEMP_REG4.w0, ADDRESS_ACKNOWLDEGE_FAILED + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; start sending TX data and wait for ACK receive +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +TX_DATA_SDA_BEGIN: + SEND_TX_DATA_CHECK_FOR_ACK R15.b1, DATA_PROCESSING_COMPLETE, RAISE_HOST_INTERRUPT_MEM_FOR_READY + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; start sending RX data and send ACK to device +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RX_DATA_SDA_BEGIN: + READ_RX_DATA_AND_SEND_ACK R15.b1, DATA_PROCESSING_COMPLETE + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; start sending TX data and wait for ACK receive for smbus Burst Mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +TX_DATA_SDA_BEGIN_BURST: + SEND_TX_DATA_CHECK_FOR_ACK R17.b2, TX_DATA_SDA_BEGIN, RAISE_HOST_INTERRUPT_MEM_FOR_READY + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; start sending RX data and send ACK to device for smbus Burst Mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RX_DATA_SDA_BEGIN_BURST: + READ_RX_DATA_AND_SEND_ACK R15.b3, RX_DATA_SDA_BEGIN + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; modify the SDA pin value based on the most significant bit of DATA value +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_SDA_BEGIN: + QBBC CMD_CODE_SDA_LOW, R15.b1, 7 + SET_SDA_PIN_HIGH + JMP CMD_CODE_SDA_CONTINUE +CMD_CODE_SDA_LOW: + SET_SDA_PIN_LOW +CMD_CODE_SDA_CONTINUE: + LSL R15.b1, R15.b1, 1 + ADD R15.b0, R15.b0, 0x01 + UPDATE_NEXT_LOCAL_STATE CMD_CODE_SCL_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for sending SDA bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_SCL_BEGIN: + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE CMD_CODE_SDA_READ + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Jump to next state as this is tx mode, done for matching timing parameter. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_SDA_READ: + UPDATE_NEXT_LOCAL_STATE CMD_CODE_SCL_END + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low for stop sending SDA bit +; make decision for sending next data bit or check for ACK +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_SCL_END: + SET_SCL_PIN_LOW + QBGT CMD_CODE_SDA_NEXT_BIT, R15.b0, 0x08 + UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_BEGIN + STATE_TASK_OVER + +CMD_CODE_SDA_NEXT_BIT: + UPDATE_NEXT_LOCAL_STATE CMD_CODE_SDA_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; release SDA line so slave can drive it. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_ACK_BEGIN: + SET_SDA_PIN_HIGH + SET R13.w2, R13.w2, 0 + UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high for reading ACK bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_ACK_SCL_BEGIN: + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_READ + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SDA line for reading ACK bit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_ACK_READ: + READ_SDA_PIN_ACK + QBBS CMD_CODE_ACK_READ_NEXT_STATE, R16, ICSS_I2C_SMBUS_BURST_BIT + UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_END + STATE_TASK_OVER + +CMD_CODE_ACK_READ_NEXT_STATE: + UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_END_V2 + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low +; read if ACK bit is set then check if data is still left to be sent +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_ACK_SCL_END: + SET_SCL_PIN_LOW + QBBS CMD_CODE_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT + AND R15.b2, R15.b2, 0x00 + AND R15.b0, R15.b0, 0x00 + QBBS CMD_CODE_RX, R16, ICSS_I2C_READ_WRITE_BIT + LBBO &R15.b1, R11, R15.b2, 1 + UPDATE_NEXT_LOCAL_STATE TX_DATA_SDA_BEGIN + STATE_TASK_OVER + +CMD_CODE_RX: + UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW + SET R13.w2, R13.w2, 8 + UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low +; read if ACK bit is set then check if data is still left to be sent +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +CMD_CODE_ACK_SCL_END_V2: + SET_SCL_PIN_LOW + QBBS CMD_CODE_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT + AND R15.b2, R15.b2, 0x00 + AND R15.b0, R15.b0, 0x00 + QBBS CMD_CODE_RX_V2, R16, ICSS_I2C_READ_WRITE_BIT + LBBO &R15.b1, R11, R15.b2, 1 + UPDATE_NEXT_LOCAL_STATE TX_DATA_SDA_BEGIN_BURST + STATE_TASK_OVER + +CMD_CODE_RX_V2: + UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW + SET R13.w2, R13.w2, 8 + UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN_BURST + STATE_TASK_OVER + + +CMD_CODE_ACK_NOT_RECIEVED: + UPDATE_NEXT_LOCAL_STATE NO_CMD_CODE_ACK_RECIEVED + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; if no data ack is received, response with no ack in response command +; raise an interrupt +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +NO_CMD_CODE_ACK_RECIEVED: + LDI TEMP_REG4.w0, DATA_ACKNOWLDEGE_FAILED + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; data transmit or receive is over +; check whether to sent stop bit or not +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +DATA_PROCESSING_COMPLETE: + SET_SDA_PIN_LOW + QBBC COMPLETE_WITH_NO_STOP, R16, ICSS_I2C_STOP_BIT + UPDATE_NEXT_LOCAL_STATE STOP_CONDITION_SCL_HIGH + STATE_TASK_OVER + +COMPLETE_WITH_NO_STOP: + UPDATE_NEXT_LOCAL_STATE NO_STOP_CONDITION_SDA_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; send stop condition by making SCL high first +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +STOP_CONDITION_SCL_HIGH: + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE STOP_CONDITION_SDA_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; send stop condition by making SDA high next +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +STOP_CONDITION_SDA_HIGH: + SET_SDA_PIN_HIGH + LDI TEMP_REG4.w0, COMMAND_SUCCESS + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; do not send stop condition by making SDA high first +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +NO_STOP_CONDITION_SDA_HIGH: + SET_SDA_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE NO_STOP_CONDITION_SCL_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; do not send stop condition by making SCL high next +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +NO_STOP_CONDITION_SCL_HIGH: + SET_SCL_PIN_HIGH + LDI TEMP_REG4.w0, COMMAND_SUCCESS + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; prepare to read clk value for 10 clk cycles +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +READ_SCL_PIN_SETUP: + LDI R15.w0, 0x0000 + LDI R15.w2, 0x0A00 + UPDATE_NEXT_LOCAL_STATE READ_SCL_PIN_VALUE + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; read the scl clk value for 10 clk cycles +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +READ_SCL_PIN_VALUE: + ADD R15.b0, R15.b0, 0x01 + QBBS SCL_PIN_VALUE_HIGH, R31, R14.b0 + ADD R15.b2, R15.b2, 0x01 + +SCL_PIN_VALUE_HIGH: + QBGT READ_SCL_PIN_VALUE_REPEAT, R15.b0, R15.b3 + UPDATE_NEXT_LOCAL_STATE READ_SCL_PIN_DONE + +READ_SCL_PIN_VALUE_REPEAT: + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; read scl pins for 10 cycles is done. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +READ_SCL_PIN_DONE: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + QBEQ SCL_PIN_READ_VALUE_LOW, R15.b0, R15.b2 + LDI TEMP_REG4.w0, SCL_VALUE_HIGH + JMP READ_SCL_PIN_DONE_RETURN + +SCL_PIN_READ_VALUE_LOW: + LDI TEMP_REG4.w0, SCL_VALUE_LOW + +READ_SCL_PIN_DONE_RETURN: + LDI R15.w0, 0x0000 + LDI R15.w2, 0x0000 + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; setup for reseting the slave +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_SCL_BEGIN: + LDI R15.w0, 0x0000 + LDI R15.w2, 0x0900 + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL high +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_SCL_HIGH: + SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT1 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; wait to match the timing parameters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_SCL_WAIT1: + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_LOW + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; make SCL low +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_SCL_LOW: + SET_SCL_PIN_LOW + ADD R15.b0, R15.b0, 0x01 + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; wait to match the timing parameters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_SCL_WAIT2: + QBGT RESET_SLAVE_SCL_RETURN, R15.b0, R15.b3 + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_RETURN + STATE_TASK_OVER + +RESET_SLAVE_SCL_RETURN: + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_HIGH + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Finish reseting slave +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +RESET_SLAVE_RETURN: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + LDI TEMP_REG4.w0, RESET_SLAVE_DONE + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Read the number of 8 bits data need to be copied over +; also initialize the data count and bit count register to 0 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +LOOPBACK_DATA_COUNT: + LBBO &TEMP_REG4.w0, R10, ICSS_I2C_CNT_OFFSET, 2 + QBLT LOOPBACK_DATA_COUNT_ERROR, TEMP_REG4.w0, 0xFF + QBGT LOOPBACK_DATA_COUNT_ERROR, TEMP_REG4.w0, 0x01 + AND R15.b3, TEMP_REG4.b0, 0xFF + AND R15.b2, R15.b2, 0x00 + UPDATE_NEXT_LOCAL_STATE LOOPBACK_COPY_DATA + STATE_TASK_OVER + +LOOPBACK_DATA_COUNT_ERROR: + LDI TEMP_REG4.w0, INVALID_DATA_COUNT + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; copy data from Tx to Rx buffer. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +LOOPBACK_COPY_DATA: + LBBO &R15.b1, R11, R15.b2, 1 + SBBO &R15.b1, R12, R15.b2, 1 + ADD R15.b2, R15.b2, 1 + QBGE LOOPBACK_COPY_DATA_RETURN, R15.b3, R15.b2 + STATE_TASK_OVER + +LOOPBACK_COPY_DATA_RETURN: + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + LDI TEMP_REG4.w0, COMMAND_SUCCESS + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + STATE_TASK_OVER + + + halt ; end of program From d3795004aeaa5f2cf64ba6874864ab0f8d8ac361 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Wed, 17 Jun 2026 14:13:50 +0530 Subject: [PATCH 02/29] examples: pru_i2c: wire firmware into top-level build (fixes am261x CI) The am261x "Verify all makefiles were built" CI step failed with "makefile never built" for the two pru_i2c PRU firmware makefiles, because nothing in the top-level make recursed into them. - Add examples/pru_i2c/makefile aggregator (modeled on examples/empty), scoped to am261x with an am261x target that builds the pru0/pru1 ti-pru-cgt firmware. Non-am261x devices hit the SUPPORTED_PROCESSORS prebuild check and skip cleanly, so other device builds are unaffected. - Add pru_i2c to examples/makefile SUBDIRS so the top-level make recurses into it. Verified with GNU Make dry-runs: am261x recurses into both firmware leaf makefiles (each producing a .out, satisfying the verify step); am263x prints "does not have a build option" and builds nothing. Co-Authored-By: Claude Opus 4.8 --- examples/makefile | 2 +- examples/pru_i2c/makefile | 94 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 examples/pru_i2c/makefile diff --git a/examples/makefile b/examples/makefile index 0087eedbe..43e67eed0 100644 --- a/examples/makefile +++ b/examples/makefile @@ -3,7 +3,7 @@ include ../imports.mak 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 spi_loopback \ + LCD_interface logic_scope pru_emif pru_i2c spi_loopback \ fir multicore_scheduler rpmsg_echo_linux # "make" or "make all" builds projects that match $(DEVICE) set in imports.mak diff --git a/examples/pru_i2c/makefile b/examples/pru_i2c/makefile new file mode 100644 index 000000000..f7afc7331 --- /dev/null +++ b/examples/pru_i2c/makefile @@ -0,0 +1,94 @@ +include ../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := pru_i2c +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 := + +################### +# 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 +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_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) From 8801d3c76cd0c8ec15ff12d281f090019aae7ede Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 12:47:57 +0530 Subject: [PATCH 03/29] examples: pru_i2c: add R5F NORTOS host example for am261x-lp Add the R5F side of the PRU I2C master example. The host code loads the PRU I2C firmware on ICSSM0 PRU1, configures it through the PRU data RAM (400 kHz, SCL/SDA = PR0_PRU1_GPIO18/19 on BoosterPack J1.4/J1.3), writes a few bytes to an EEPROM-style target at 0x50, reads them back and logs PASS or FAIL with the firmware response codes. It polls the IRQ bit in the data RAM instead of using the PRU interrupt. - mcuplus/pru_i2c_example.c: common host logic, uses pru_i2c_interface.h - mcuplus/am261x-lp/r5fss0-0_nortos: main.c, example.syscfg and the ti-arm-clang makefile/projectspec, derived from the empty example - makefile: NON_PRU_DEPENDENCIES := mcuplus and am261x_mcuplus target - readme.md: memory interface, pins, build/run, known limitations Build-tested only (MCU+ SDK AM261x 10.02.00.15), not run on hardware. Co-Authored-By: Claude Opus 5.5 --- examples/pru_i2c/makefile | 6 +- .../am261x-lp/r5fss0-0_nortos/example.syscfg | 293 +++++++++++ .../mcuplus/am261x-lp/r5fss0-0_nortos/main.c | 50 ++ .../ti-arm-clang/example.projectspec | 113 +++++ .../r5fss0-0_nortos/ti-arm-clang/makefile | 367 ++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 141 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + examples/pru_i2c/mcuplus/pru_i2c_example.c | 474 ++++++++++++++++++ examples/pru_i2c/readme.md | 223 ++++++++ 10 files changed, 1694 insertions(+), 1 deletion(-) create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec create mode 100644 examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 examples/pru_i2c/mcuplus/pru_i2c_example.c create mode 100644 examples/pru_i2c/readme.md diff --git a/examples/pru_i2c/makefile b/examples/pru_i2c/makefile index f7afc7331..800821250 100644 --- a/examples/pru_i2c/makefile +++ b/examples/pru_i2c/makefile @@ -9,7 +9,7 @@ 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 := +NON_PRU_DEPENDENCIES := mcuplus ################### # Prebuild checks # @@ -91,4 +91,8 @@ am261x: $(MAKE) -C firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) $(MAKE) -C firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +am261x_mcuplus: +# am261x-lp + $(MAKE) -C mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + .PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg new file mode 100644 index 000000000..e9bca5832 --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg @@ -0,0 +1,293 @@ +/** + * 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 "MCU_PLUS_SDK@07.03.01" + * @v2CliArgs --device "AM2612" --package "NFBGA (ZFG)" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01" + * @versions {"tool":"1.22.0+3893"} + */ + +/** + * Import the modules used in this configuration. + */ +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. + */ +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.instance = "ICSSM0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO.create(1); +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; +/* I2C SCL: PR0_PRU1_GPIO18, output only (BoosterPack J1.4) */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.$assign = "GPIO120"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.$used = true; +/* I2C SDA: PR0_PRU1_GPIO19, input and output, internal pull-up (BoosterPack J1.3) */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.$assign = "GPIO119"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.rx = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.pu_pd = "pu"; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +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; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].$suggestSolution = "PRU-ICSS0"; diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c new file mode 100644 index 000000000..ad9984816 --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2026 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 "ti_drivers_config.h" +#include "ti_board_config.h" + +void pru_i2c_example_main(void *args); + +int main(void) +{ + System_init(); + Board_init(); + + pru_i2c_example_main(NULL); + + Board_deinit(); + System_deinit(); + + return 0; +} diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..cd2771cac --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile new file mode 100644 index 000000000..228c3c314 --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile @@ -0,0 +1,367 @@ +# +# 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:=pru_i2c.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=pru_i2c.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=pru_i2c.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=pru_i2c.$(PROFILE).appimage.signed +BOOTIMAGE_NAME_MCELF:=pru_i2c.$(PROFILE).mcelf +BOOTIMAGE_NAME_MCELF_HS:=pru_i2c.$(PROFILE).mcelf.hs +BOOTIMAGE_RPRC_NAME:=pru_i2c.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=pru_i2c.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=pru_i2c.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=pru_i2c.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=pru_i2c.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_HS) +endif + +FILES_common := \ + main.c \ + pru_i2c_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/pru_io/driver \ + -I${OPEN_PRU_PATH}/examples/pru_i2c/firmware/am261x-lp \ + -I${OPEN_PRU_PATH}/examples/pru_i2c/firmware \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM261X \ + +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/nortos/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 = \ + -lnortos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + nortos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/nortos/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:nortos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am261x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -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:nortos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am261x:r5fss0-0:nortos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am261x:r5fss0-0:nortos: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:nortos:ti-arm-clang pru_i2c ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(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) *.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 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +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): $(OUTNAME) + @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @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) + @echo Boot MulticoreELF ELF image: $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF) Done !!! + @echo . + +$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +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) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) + $(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) --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_HS) --rsassa_pss + $(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) --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_HS) + $(RM) $(BOOTIMAGE_NAME)-enc + $(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) --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_HS) --rsassa_pss + $(RM) $(BOOTIMAGE_NAME)-enc + $(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:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for pru_i2c.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o pru_i2c.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=pru_i2c.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=pru_i2c.$(PROFILE).profdata > coverage/pru_i2c.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/pru_i2c.$(PROFILE).profdata.json --output-json=coverage/pru_i2c.$(PROFILE).analysis.json --output=../pru_i2c.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..d1e3c1dd8 --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,141 @@ +# +# 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:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp +BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf +BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs +BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_i2c.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_i2c.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) +TARGETS += $(BOOTIMAGE_NAME_MCELF) +TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_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 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +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 image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + + @echo Boot multi-core ELF image: am261x:r5fss0-0:nortos: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 . + + @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) 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) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) + $(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) --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_HS) --rsassa_pss + $(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) --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_HS) + $(RM) $(BOOTIMAGE_NAME)-enc + $(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) --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_HS) --rsassa_pss + $(RM) $(BOOTIMAGE_NAME)-enc + $(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:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! + @echo . +endif +endif diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..a483afd8d --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=pru_i2c_am261x-lp_r5fss0-0_nortos_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/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/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/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c new file mode 100644 index 000000000..5011f3a04 --- /dev/null +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -0,0 +1,474 @@ +/* + * Copyright (C) 2026 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 +#include +#include +#include "ti_drivers_config.h" +#include "ti_drivers_open_close.h" +#include "ti_board_config.h" +#include "ti_board_open_close.h" +#include +#include +#include + +/* PRU <-> host memory map and command/response codes (shared with the PRU + * firmware, do not duplicate the values here) */ +#include "pru_i2c_interface.h" + +/* + * This example shows an R5F core (NORTOS) using the PRU I2C master firmware + * from examples/pru_i2c/firmware to talk to an I2C target: + * 1. the I2C configuration is written into the PRU data RAM + * 2. the PRU firmware is loaded and started + * 3. the R5F sends commands to the PRU through the data RAM and waits for + * the PRU to report completion + * + * The demo transfers are written for a generic EEPROM-style target (for + * example an AT24C02 / 24LC02) that takes a one byte register pointer + * followed by data bytes: + * - write: [pointer, data0 ... dataN-1] + * - read back: write [pointer], then read N bytes + */ + +/* ========================================================================== */ +/* User configurable settings */ +/* ========================================================================== */ + +/* PRU core that runs the I2C firmware: 0 = ICSSM0 PRU0, 1 = ICSSM0 PRU1. + * + * AM261x-LP: the BoosterPack headers carry PR0_PRU1_GPIO17..19 but none of the + * PR0_PRU0_GPIOx signals (those are used by the on-board Ethernet PHY), so + * the default is PRU1. If you change this, update the pinmux in example.syscfg + * to the matching PR0_PRUx_GPIOy pins as well. */ +#define PRU_I2C_PRU_CORE (1U) + +/* PRU GPIO numbers used for the bus. The firmware uses one number per signal + * for both the output (R30[n]) and the input (R31[n]) register bit, so the + * pad has to be PR0_PRUx_GPIO in example.syscfg. You can change these two + * numbers, but keep them in sync with example.syscfg. + * SCL: PR0_PRU1_GPIO18 (pad GPIO120, BoosterPack J1.4) + * SDA: PR0_PRU1_GPIO19 (pad GPIO119, BoosterPack J1.3) */ +#define PRU_I2C_SCL_PIN (18U) +#define PRU_I2C_SDA_PIN (19U) + +/* I2C bus frequency selection, one of ICSS_I2C_100KHZ_FREQ, + * ICSS_I2C_400KHZ_FREQ or ICSS_I2C_1MHZ_FREQ. The IEP compare increment + * (time between state machine ticks) has to match the selected frequency. */ +#define PRU_I2C_BUS_FREQ (ICSS_I2C_400KHZ_FREQ) +#define PRU_I2C_IEP_INCREMENT (IEP_CMP_INCREMENT_VAL_400KHZ) + +/* 7-bit address of the I2C target used for the demo transfers */ +#define PRU_I2C_TARGET_ADDR (0x50U) +/* Register pointer (first byte of every demo transfer) */ +#define PRU_I2C_TARGET_REG (0x00U) +/* Number of data bytes written and read back */ +#define PRU_I2C_TEST_LEN (4U) +/* Time to wait after a write before the target responds again. EEPROMs hold + * off for the internal write cycle (typically 5 ms max). */ +#define PRU_I2C_WRITE_CYCLE_US (10000U) + +/* How long the R5F waits for the PRU to report a response */ +#define PRU_I2C_TIMEOUT_US (100000U) + +/* ========================================================================== */ +/* Local macros */ +/* ========================================================================== */ + +/* PRU firmware image array. The header is generated by the PRU firmware build + * into examples/pru_i2c/firmware/am261x-lp/ */ +#if (PRU_I2C_PRU_CORE == 0U) +#include +#define PRU_I2C_FIRMWARE PRU0Firmware_0 +#define PRU_I2C_OUT_CTRL_REG (CSL_MSS_CTRL_U_BASE + CSL_MSS_CTRL_ICSSM0_PRU0_GPIO_OUT_CTRL) +#else +#include +#define PRU_I2C_FIRMWARE PRU1Firmware_0 +#define PRU_I2C_OUT_CTRL_REG (CSL_MSS_CTRL_U_BASE + CSL_MSS_CTRL_ICSSM0_PRU1_GPIO_OUT_CTRL) +#endif + +/* Offsets inside the PRU data RAM of the selected core (PRU0 -> DMEM0, + * PRU1 -> DMEM1; the firmware accesses it at local address 0). + * The layout is defined by pru_i2c_interface.h. */ +#define PRU_I2C_IRQ_REG (IRQ_COMMON_REGISTER_OFFSET) /* u16: bit n set by PRU, cleared by R5F */ +#define PRU_I2C_FREQ_REG (I2C_BUS_FREQUENCY_OFFSET) /* u16: frequency selection */ +#define PRU_I2C_IEP_INC_REG (I2C_BUS_FREQUENCY_OFFSET + 2U) /* u16: IEP compare increment */ + +/* Instance 0 registers. ICSS_I2C_COMMAND_OFFSET is a 32-bit word: the low + * half is the response of the PRU, the high half is the command from the R5F. */ +#define PRU_I2C_RESPONSE_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_COMMAND_OFFSET) +#define PRU_I2C_COMMAND_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_COMMAND_OFFSET + 2U) +#define PRU_I2C_TX_FIFO_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_BUF_OFFSET) /* u8 */ +#define PRU_I2C_RX_FIFO_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_BUF_OFFSET + 1U) /* u8 */ +#define PRU_I2C_COUNT_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_CNT_OFFSET) /* u16 */ +#define PRU_I2C_CON_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_CON_OFFSET) /* u32 */ +#define PRU_I2C_SA_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_SA_OFFSET) /* u16 */ +#define PRU_I2C_SCL_PIN_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_PIN_OFFSET) /* u8 */ +#define PRU_I2C_SDA_PIN_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_PIN_OFFSET + 1U) /* u8 */ +#define PRU_I2C_INST_ID_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_INST_ID_OFFSET) /* u8 */ + +/* Bit of the IRQ register that belongs to instance 0 */ +#define PRU_I2C_INST_ID (0U) + +/* The firmware accepts a data count of 1..255 */ +#define PRU_I2C_MAX_COUNT (255U) + +/* ========================================================================== */ +/* Global variables */ +/* ========================================================================== */ + +PRUICSS_Handle gPruIcss0Handle; + +/* Base address of the data RAM of the PRU that runs the I2C firmware */ +static uintptr_t gPruDmemBase; + +/* ========================================================================== */ +/* Local function definitions */ +/* ========================================================================== */ + +static const char *PruI2c_responseToString(uint16_t response) +{ + const char *str; + + switch (response) + { + case COMMAND_SUCCESS: str = "COMMAND_SUCCESS"; break; + case RESET_COMMAND_FAILED: str = "RESET_COMMAND_FAILED"; break; + case SETUP_COMMAND_FAILED: str = "SETUP_COMMAND_FAILED"; break; + case TX_COMMAND_FAILED: str = "TX_COMMAND_FAILED"; break; + case RX_COMMAND_FAILED: str = "RX_COMMAND_FAILED"; break; + case ADDRESS_ACKNOWLDEGE_FAILED: str = "ADDRESS_ACKNOWLDEGE_FAILED (no ACK from target)"; break; + case DATA_ACKNOWLDEGE_FAILED: str = "DATA_ACKNOWLDEGE_FAILED"; break; + case MASTER_SLAVE_MODE_FAILED: str = "MASTER_SLAVE_MODE_FAILED"; break; + case ADDRESSING_MODE_FAILED: str = "ADDRESSING_MODE_FAILED"; break; + case INVALID_COMMAND: str = "INVALID_COMMAND"; break; + case INVALID_DATA_COUNT: str = "INVALID_DATA_COUNT"; break; + case TIME_OUT_ERROR: str = "TIME_OUT_ERROR (no response from PRU)"; break; + default: str = "unknown response"; break; + } + return str; +} + +/* Wait until the PRU sets this instance's bit in the IRQ register. + * The PRU also raises INTC system event SRSR1 bit 20 (PRU0) / 21 (PRU1) at + * the same time (ICSS_I2C_INTC_PRU0_BIT_VAL / ICSS_I2C_INTC_PRU1_BIT_VAL). + * This example does not use the interrupt, it polls the data RAM flag. */ +static int32_t PruI2c_waitForPru(uint32_t timeoutUs) +{ + uint64_t start = ClockP_getTimeUsec(); + + while ((HW_RD_REG16(gPruDmemBase + PRU_I2C_IRQ_REG) & (1U << PRU_I2C_INST_ID)) == 0U) + { + if ((ClockP_getTimeUsec() - start) > timeoutUs) + { + return SystemP_TIMEOUT; + } + } + return SystemP_SUCCESS; +} + +/* Acknowledge the PRU response. The PRU waits for the bit to be cleared + * before it accepts the next command. */ +static void PruI2c_ackPru(void) +{ + uint16_t irq = HW_RD_REG16(gPruDmemBase + PRU_I2C_IRQ_REG); + + irq &= (uint16_t)~(1U << PRU_I2C_INST_ID); + HW_WR_REG16(gPruDmemBase + PRU_I2C_IRQ_REG, irq); +} + +/* Send a command to the PRU, wait for its response and acknowledge it. */ +static int32_t PruI2c_sendCommand(uint16_t command, uint16_t *response) +{ + int32_t status; + + HW_WR_REG16(gPruDmemBase + PRU_I2C_COMMAND_REG, command); + + status = PruI2c_waitForPru(PRU_I2C_TIMEOUT_US); + if (status == SystemP_SUCCESS) + { + *response = HW_RD_REG16(gPruDmemBase + PRU_I2C_RESPONSE_REG); + PruI2c_ackPru(); + } + else + { + *response = TIME_OUT_ERROR; + } + return status; +} + +/* Write the I2C configuration into the PRU data RAM, load the firmware and + * run the setup command. */ +static int32_t PruI2c_init(void) +{ + const PRUICSS_HwAttrs *hwAttrs; + uint16_t response = 0U; + uint32_t reg; + int32_t status; + + hwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS0); + DebugP_assert(hwAttrs != NULL); + gPruDmemBase = (PRU_I2C_PRU_CORE == 0U) ? hwAttrs->pru0DramBase : hwAttrs->pru1DramBase; + + /* PRUICSS_loadFirmware() enables the PRU core right away, and the + * firmware reads the frequency settings once while it boots. So stop the + * core, clear the data RAM and write the whole configuration before the + * firmware is loaded. */ + status = PRUICSS_disableCore(gPruIcss0Handle, PRU_I2C_PRU_CORE); + if (status != SystemP_SUCCESS) + { + return status; + } + if (PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRU_I2C_PRU_CORE)) == 0U) + { + return SystemP_FAILURE; + } + + /* Bus frequency (u16) and IEP compare increment (u16) */ + HW_WR_REG16(gPruDmemBase + PRU_I2C_FREQ_REG, PRU_I2C_BUS_FREQ); + HW_WR_REG16(gPruDmemBase + PRU_I2C_IEP_INC_REG, PRU_I2C_IEP_INCREMENT); + + /* Instance 0 configuration */ + /* TX and RX buffers are 256 bytes each */ + HW_WR_REG8(gPruDmemBase + PRU_I2C_TX_FIFO_REG, 0xFFU); + HW_WR_REG8(gPruDmemBase + PRU_I2C_RX_FIFO_REG, 0xFFU); + HW_WR_REG8(gPruDmemBase + PRU_I2C_SCL_PIN_REG, PRU_I2C_SCL_PIN); + HW_WR_REG8(gPruDmemBase + PRU_I2C_SDA_PIN_REG, PRU_I2C_SDA_PIN); + HW_WR_REG8(gPruDmemBase + PRU_I2C_INST_ID_REG, PRU_I2C_INST_ID); + /* Module enabled, master mode, 7-bit addressing, START and STOP around + * every transfer, NACK the last byte of a read */ + reg = (1U << ICSS_I2C_MODULE_ENABLE_BIT) | + (1U << ICSS_I2C_MASTER_SLAVE_MODE_BIT) | + (1U << ICSS_I2C_START_BIT) | + (1U << ICSS_I2C_STOP_BIT) | + (1U << ICSS_I2C_RECIEVE_NACK_BIT); + HW_WR_REG32(gPruDmemBase + PRU_I2C_CON_REG, reg); + + /* The firmware switches SDA between output and input with the matching + * bit of the ICSSM0_PRUx_GPIO_OUT_CTRL register (1 = output disabled). + * SysConfig sets that bit for pins configured with "rx", so make sure the + * SDA bit starts at 0 (output enabled) before the PRU runs. */ + reg = HW_RD_REG32(PRU_I2C_OUT_CTRL_REG); + reg &= ~(1U << PRU_I2C_SDA_PIN); + HW_WR_REG32(PRU_I2C_OUT_CTRL_REG, reg); + + /* Load the firmware, this also starts the PRU core */ + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRU_I2C_PRU_CORE, + PRU_I2C_FIRMWARE, sizeof(PRU_I2C_FIRMWARE)); + if (status != SystemP_SUCCESS) + { + return status; + } + + /* Latch the configuration inside the firmware */ + status = PruI2c_sendCommand(ICSS_I2C_SETUP_CMD, &response); + if ((status != SystemP_SUCCESS) || (response != COMMAND_SUCCESS)) + { + DebugP_log("PRU I2C setup failed, response 0x%04X (%s)\r\n", + response, PruI2c_responseToString(response)); + return SystemP_FAILURE; + } + return SystemP_SUCCESS; +} + +/* Write tx[0..len-1] to the target. */ +static int32_t PruI2c_write(uint8_t targetAddr, const uint8_t *tx, uint32_t len, uint16_t *response) +{ + uint32_t i; + int32_t status; + + if ((len == 0U) || (len > PRU_I2C_MAX_COUNT)) + { + *response = INVALID_DATA_COUNT; + return SystemP_FAILURE; + } + + HW_WR_REG16(gPruDmemBase + PRU_I2C_SA_REG, targetAddr); + HW_WR_REG16(gPruDmemBase + PRU_I2C_COUNT_REG, len); + for (i = 0U; i < len; i++) + { + HW_WR_REG8(gPruDmemBase + ICSS_I2C_INSTANCE0_TX_MEM + i, tx[i]); + } + + status = PruI2c_sendCommand(ICSS_I2C_TX_CMD, response); + if ((status == SystemP_SUCCESS) && (*response != COMMAND_SUCCESS)) + { + status = SystemP_FAILURE; + } + return status; +} + +/* Read len bytes from the target into rx. */ +static int32_t PruI2c_read(uint8_t targetAddr, uint8_t *rx, uint32_t len, uint16_t *response) +{ + uint32_t i; + int32_t status; + + if ((len == 0U) || (len > PRU_I2C_MAX_COUNT)) + { + *response = INVALID_DATA_COUNT; + return SystemP_FAILURE; + } + + HW_WR_REG16(gPruDmemBase + PRU_I2C_SA_REG, targetAddr); + HW_WR_REG16(gPruDmemBase + PRU_I2C_COUNT_REG, len); + + status = PruI2c_sendCommand(ICSS_I2C_RX_CMD, response); + if (status == SystemP_SUCCESS) + { + if (*response == COMMAND_SUCCESS) + { + for (i = 0U; i < len; i++) + { + rx[i] = HW_RD_REG8(gPruDmemBase + ICSS_I2C_INSTANCE0_RX_MEM + i); + } + } + else + { + status = SystemP_FAILURE; + } + } + return status; +} + +/* ========================================================================== */ +/* Example */ +/* ========================================================================== */ + +void pru_i2c_example_main(void *args) +{ + uint8_t txBuf[PRU_I2C_TEST_LEN + 1U]; + uint8_t rxBuf[PRU_I2C_TEST_LEN]; + uint16_t response; + uint32_t i; + int32_t status; + int32_t testStatus = SystemP_SUCCESS; + + Drivers_open(); // check return status + + status = Board_driversOpen(); + DebugP_assert(SystemP_SUCCESS == status); + + gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + DebugP_assert(gPruIcss0Handle != NULL); + + DebugP_log("PRU I2C master example started\r\n"); + DebugP_log("PRU core %u, SCL = PR0_PRU%u_GPIO%u, SDA = PR0_PRU%u_GPIO%u, target 0x%02X\r\n", + PRU_I2C_PRU_CORE, PRU_I2C_PRU_CORE, PRU_I2C_SCL_PIN, + PRU_I2C_PRU_CORE, PRU_I2C_SDA_PIN, PRU_I2C_TARGET_ADDR); + + status = PruI2c_init(); + if (status != SystemP_SUCCESS) + { + DebugP_log("FAIL: PRU I2C init (status %d)\r\n", status); + testStatus = SystemP_FAILURE; + } + + if (testStatus == SystemP_SUCCESS) + { + /* 1. write pointer + data bytes */ + txBuf[0] = PRU_I2C_TARGET_REG; + for (i = 0U; i < PRU_I2C_TEST_LEN; i++) + { + txBuf[1U + i] = (uint8_t)(0xA5U ^ (i * 0x11U)); + } + status = PruI2c_write(PRU_I2C_TARGET_ADDR, txBuf, PRU_I2C_TEST_LEN + 1U, &response); + DebugP_log("Write %u bytes at pointer 0x%02X: response 0x%04X (%s)\r\n", + PRU_I2C_TEST_LEN, PRU_I2C_TARGET_REG, response, PruI2c_responseToString(response)); + if (status != SystemP_SUCCESS) + { + testStatus = SystemP_FAILURE; + } + } + + if (testStatus == SystemP_SUCCESS) + { + /* wait for the internal write cycle of the target */ + ClockP_usleep(PRU_I2C_WRITE_CYCLE_US); + + /* 2. set the pointer ... */ + status = PruI2c_write(PRU_I2C_TARGET_ADDR, txBuf, 1U, &response); + DebugP_log("Write pointer 0x%02X: response 0x%04X (%s)\r\n", + PRU_I2C_TARGET_REG, response, PruI2c_responseToString(response)); + if (status != SystemP_SUCCESS) + { + testStatus = SystemP_FAILURE; + } + } + + if (testStatus == SystemP_SUCCESS) + { + /* 3. ... and read the data back */ + memset(rxBuf, 0, sizeof(rxBuf)); + status = PruI2c_read(PRU_I2C_TARGET_ADDR, rxBuf, PRU_I2C_TEST_LEN, &response); + DebugP_log("Read %u bytes: response 0x%04X (%s)\r\n", + PRU_I2C_TEST_LEN, response, PruI2c_responseToString(response)); + if (status != SystemP_SUCCESS) + { + testStatus = SystemP_FAILURE; + } + } + + if (testStatus == SystemP_SUCCESS) + { + /* 4. compare */ + for (i = 0U; i < PRU_I2C_TEST_LEN; i++) + { + DebugP_log(" byte %u: wrote 0x%02X, read 0x%02X\r\n", i, txBuf[1U + i], rxBuf[i]); + if (txBuf[1U + i] != rxBuf[i]) + { + testStatus = SystemP_FAILURE; + } + } + if (testStatus != SystemP_SUCCESS) + { + DebugP_log("FAIL: read back data does not match\r\n"); + } + } + + if (testStatus == SystemP_SUCCESS) + { + DebugP_log("PASS: PRU I2C write/read back\r\n"); + DebugP_log("All tests have passed!!\r\n"); + } + else + { + DebugP_log("Some tests have failed!!\r\n"); + } + + PRUICSS_disableCore(gPruIcss0Handle, PRU_I2C_PRU_CORE); + PRUICSS_close(gPruIcss0Handle); + Board_driversClose(); + Drivers_close(); +} diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md new file mode 100644 index 000000000..2049e9e7c --- /dev/null +++ b/examples/pru_i2c/readme.md @@ -0,0 +1,223 @@ +# PRU I2C Master + +## Introduction + +This project implements an I2C master (controller) in PRU firmware. A PRU core +bit-bangs SCL and SDA with an IEP-timed state machine, and a host core (here an +R5F core running NORTOS) controls the bus through commands and data buffers in +the PRU data RAM. The R5F example in `mcuplus/` loads the firmware, writes a +few bytes to an I2C target, reads them back and prints PASS or FAIL together +with the response code of the PRU firmware for every transfer. + +The project contains: + +* `firmware/`: PRU assembly firmware (`pru_i2c_main.asm`), the memory interface + header (`pru_i2c_interface.h`) and a CCS/makefile project for PRU0 and PRU1 + of ICSSM0. +* `mcuplus/`: R5F host code. `pru_i2c_example.c` is the common host logic, + `mcuplus/am261x-lp/r5fss0-0_nortos/` holds `main.c`, `example.syscfg` and + the CCS/makefile project. + +# Supported Combinations + + Parameter | Value + ---------------|----------- + ICSSM | ICSSM0 - PRU0, PRU1 (firmware). The R5F example runs the firmware on ICSSM0 PRU1 + Toolchain | pru-cgt (PRU firmware), ti-arm-clang (R5F) + Board | am261x-lp + Example folder | examples/pru_i2c/ + +For all other devices and boards see the section "Supported processors +per-project" in the [examples readme](../readme.md). Only the AM261x-LP has +build infrastructure for this project; building for any other device prints +"does not have a build option" and builds nothing. + +# Validated HW & SW + +This example has **not been validated on hardware**. It has only been built. + + Item | Version + ---------------------------|----------- + Build: MCU+ SDK | AM261x MCU+ SDK 10.02.00.15 (the version used by the OpenPRU CI) + Build: PRU compiler | ti-cgt-pru 2.3.3 + Build: R5F compiler | ti-cgt-armllvm 4.0.3.LTS + Build: SysConfig | 1.26.2 + Hardware run | not done (no board revision, I2C target or scope capture to report) + +# How it works + +## PRU <-> host memory interface + +The host core talks to the firmware through the data RAM of the PRU core that +runs the firmware (PRU0 -> DMEM0, PRU1 -> DMEM1). The firmware reads and writes +this memory at local address 0. All offsets and bit definitions are in +[firmware/pru_i2c_interface.h](firmware/pru_i2c_interface.h), the host code +includes that header instead of repeating the values. + + Offset (DMEM) | Size | Name | Description + ------------------|------|----------------------------------------|------------- + 0x0008 | u16 | `IRQ_COMMON_REGISTER_OFFSET` | Bit `` is **set by the PRU** when a response is ready and **cleared by the host** to acknowledge it. The PRU does not accept the next command until the bit is cleared. + 0x000C | u16 | `I2C_BUS_FREQUENCY_OFFSET` | Bus frequency: `ICSS_I2C_100KHZ_FREQ` (3), `ICSS_I2C_400KHZ_FREQ` (2), `ICSS_I2C_1MHZ_FREQ` (1). Any other value sends the firmware into an error loop. + 0x000E | u16 | `I2C_BUS_FREQUENCY_OFFSET` + 2 | IEP compare increment for the selected frequency (`IEP_CMP_INCREMENT_VAL_400KHZ`, ...) + 0x0100 | | `ICSS_I2C_INSTANCE0_ADDR` | Start of the instance 0 block (offsets below are relative to it) + + 0x08 | u16 | `ICSS_I2C_COMMAND_OFFSET` | Response of the PRU (`COMMAND_SUCCESS` 0x0500, `ADDRESS_ACKNOWLDEGE_FAILED`, `DATA_ACKNOWLDEGE_FAILED`, `INVALID_COMMAND`, ...) + + 0x0A | u16 | `ICSS_I2C_COMMAND_OFFSET` + 2 | Command from the host (`ICSS_I2C_SETUP_CMD`, `ICSS_I2C_TX_CMD`, `ICSS_I2C_RX_CMD`, ...). The PRU clears it when it raises the response. + + 0x94 / + 0x95 | u8 | `ICSS_I2C_BUF_OFFSET` | TX / RX FIFO size + + 0x98 | u16 | `ICSS_I2C_CNT_OFFSET` | Number of bytes to transfer, 1..255 + + 0xA4 | u32 | `ICSS_I2C_CON_OFFSET` | Configuration: bit 15 module enable, bit 10 master (must be 1), bit 8 10-bit addressing, bit 5 SMBus burst, bit 4 NACK the last read byte, bit 1 send STOP, bit 0 send START + + 0xAC | u16 | `ICSS_I2C_SA_OFFSET` | 7-bit target address + + 0xD8 / + 0xD9 | u8 | `ICSS_I2C_PRU_PIN_OFFSET` | SCL / SDA pin: the bit number in R30 (output) and R31 (input) + + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the bit used in the IRQ register (use 0) + + 0x100 (0x0200) | 256 B| `ICSS_I2C_INSTANCE0_TX_MEM` | TX buffer + + 0x200 (0x0300) | 256 B| `ICSS_I2C_INSTANCE0_RX_MEM` | RX buffer + +The PRU also raises INTC system event SRSR1 bit 20 (PRU0) or bit 21 (PRU1) +(`ICSS_I2C_INTC_PRU0_BIT_VAL`, `ICSS_I2C_INTC_PRU1_BIT_VAL`) when it sets the +IRQ bit. The R5F example does not use this interrupt, it polls the IRQ bit +in the data RAM with a timeout. An interrupt can be added with the +`PRUICSS_intcInit()` / `PRUICSS_registerIrqHandler()` APIs. + +## Sequence + +1. **Configure, then start the PRU.** The firmware reads the frequency words + (0x0C) once while it boots, and `PRUICSS_loadFirmware()` starts the core. + So the host stops the core, clears the data RAM, writes the frequency words + and the instance 0 block (pins, instance id, FIFO sizes, `CON` with module + enable, master, START, STOP and NACK), and only then loads the firmware. +2. **Setup.** Write `ICSS_I2C_SETUP_CMD`, wait for the IRQ bit, check that the + response is `COMMAND_SUCCESS`, clear the IRQ bit. +3. **Transfers.** For each transfer write the target address and the byte + count (and the data into the TX buffer for a write), then write + `ICSS_I2C_TX_CMD` or `ICSS_I2C_RX_CMD`. Wait for the IRQ bit, read the + response (and the RX buffer for a read), clear the IRQ bit. + +The demo uses a generic EEPROM-style target (default address 0x50) that +takes a one byte pointer followed by data: + +1. write `[pointer, d0, d1, d2, d3]` +2. wait 10 ms for the internal write cycle of the target +3. write `[pointer]` (STOP is sent, the target keeps its pointer) +4. read 4 bytes and compare them with what was written + +## SDA direction + +The firmware turns SDA into an input (to read the ACK bit or read data) by +setting the bit of the SDA pin in the `ICSSM0_PRUx_GPIO_OUT_CTRL` register of +MSS_CTRL (1 = output disabled; PRU0 at 0x50D00810, PRU1 at 0x50D00814) and +back to an output by clearing it. SysConfig sets that bit for every PRU GPIO +configured with "rx", which includes SDA. The R5F example therefore clears the +SDA bit of this register before it starts the PRU, so that the PRU can drive +the START condition. The example assumes the firmware uses the register of the +PRU core it runs on. + +# Pin assignment (AM261x-LP) + + Signal | PRU GPIO (R30/R31 bit) | SoC pad | BoosterPack | Direction + -------|------------------------|--------------------|-------------|---------- + SCL | PR0_PRU1_GPIO18 (18) | GPIO120 (ball C19) | J1.4 | output (push-pull) + SDA | PR0_PRU1_GPIO19 (19) | GPIO119 (ball C18) | J1.3 | input and output, internal pull-up enabled + +The bit numbers are set with `PRU_I2C_SCL_PIN` and `PRU_I2C_SDA_PIN` in +`mcuplus/pru_i2c_example.c`. The pads are configured in +`mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg`. The firmware uses one +number per signal for both the R30 output bit and the R31 input bit, so the +GPO and GPI have to be the same `PR0_PRU1_GPIO` pin. If you change a pin, +change it in both files. + +Why PRU1: on the AM261x-LP none of the `PR0_PRU0_GPIOx` (ICSSM0 PRU0) signals +is routed to the BoosterPack headers, they are used by the on-board Ethernet +PHY 0 (RGMII2). `PR0_PRU1_GPIO17`, `GPIO18` and `GPIO19` are routed to +J2.17, J1.4 and J1.3. The firmware itself is built for both PRU0 and PRU1. +To run it on PRU0 set `PRU_I2C_PRU_CORE` to 0 and change the pinmux to pins +that are available on your board. + +How the routing was checked: in the *AM261x LaunchPad User's Guide* +(SPRUJF1D, section 2.12 "Pinmux Mapping", table "Pinmux Options for J1"), +`PR0_PRU1_GPIO19` is the mode 0 function of J1.3 and `PR0_PRU1_GPIO18` the mode +0 function of J1.4. SysConfig 1.26.2 resolves them to GPIO119 and GPIO120. The +SDK Ethernet pinmux for the LP (`icss_dual_emac/am261x-lp/pruicss_pinmux.h`) +does not use these two PRU GPIOs. This was a document and tool check only. It +was **not** checked against the LP schematic or on a board. In the standard +BoosterPack mux mode (BP_MUX_SW_S1:S0 = 00) J1.3 and J1.4 are the BoosterPack +UART3 RX and TX lines, so do not plug in a BoosterPack that drives them. + +# Steps to run the example + +Generic build, load and run steps are not repeated here, see the +[Getting Started](../../docs/getting_started.md) documents. The project +specific steps are: + +1. **Wire the target.** Connect an I2C target to J1.4 (SCL), J1.3 (SDA) and + GND, and power it from 3.3 V. SDA needs a pull-up resistor (for example + 2.2 k to 4.7 k to 3.3 V). The example also enables the internal pull-up of + the SDA pad, but that one is weak, use an external resistor. SCL is driven + push-pull and needs no pull-up. The default target is an EEPROM-style device (for example a 24C02) + at address 0x50. Change `PRU_I2C_TARGET_ADDR` (and, if needed, + `PRU_I2C_TARGET_REG`, `PRU_I2C_TEST_LEN`) in `mcuplus/pru_i2c_example.c` + for another device. +2. **Build.** From the repository root (with `DEVICE`, `BUILD_MCUPLUS` and the + tool paths set in `imports.mak`) run + `make DEVICE=am261x BUILD_MCUPLUS=y`, or build only this project with + `make -C examples/pru_i2c all DEVICE=am261x BUILD_MCUPLUS=y`. The PRU + firmware is built first, the R5F build includes the generated + `pru1_load_bin.h`. The R5F image is + `mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/pru_i2c.release.out` + (`.mcelf` and `.appimage` are generated next to it). With CCS, import the + PRU0/PRU1 firmware projects and the R5F project from `examples/pru_i2c`, + build the PRU projects first. +3. **Run on the R5F core** (r5fss0-0) and open the UART0 console (the log + output of the example goes to UART0, like in the other AM261x examples). + +## Expected output + +With a responding target: + +``` +PRU I2C master example started +PRU core 1, SCL = PR0_PRU1_GPIO18, SDA = PR0_PRU1_GPIO19, target 0x50 +Write 4 bytes at pointer 0x00: response 0x0500 (COMMAND_SUCCESS) +Write pointer 0x00: response 0x0500 (COMMAND_SUCCESS) +Read 4 bytes: response 0x0500 (COMMAND_SUCCESS) + byte 0: wrote 0xA5, read 0xA5 + byte 1: wrote 0xB4, read 0xB4 + byte 2: wrote 0x87, read 0x87 + byte 3: wrote 0x96, read 0x96 +PASS: PRU I2C write/read back +All tests have passed!! +``` + +With no target on the bus the first transfer fails with +`response 0x0508 (ADDRESS_ACKNOWLDEGE_FAILED (no ACK from target))` and the +example prints `Some tests have failed!!`. +A `TIME_OUT_ERROR (no response from PRU)` means the PRU did not answer within +100 ms, for example because the firmware is not running or the setup command +was not accepted. + +# Known limitations + +* **SCL is push-pull.** The firmware drives SCL high and low; it does not + release it. Clock stretching by a target is not supported, and SCL must not + be shared with other bus masters or driven by another device. +* **Only plain I2C read and write are implemented.** The commands for + `ICSS_I2C_TX_CMD` (write) and `ICSS_I2C_RX_CMD` (read) work on a data + count of 1..255 bytes. The SMBus commands (`ICSS_SMBUS_*`: quick command, + send/receive byte, read/write byte/word, block read/write) are stubs in the + firmware and must not be used. +* Master mode only, one instance (instance 0) per PRU core, no multi-master + arbitration, 7-bit addressing in the example (the `CON` bit for 10-bit + addressing exists in the firmware interface but is not used here). +* The START and STOP bits of `CON` are latched by the setup command. The + example sets both, so each transfer is a complete START ... STOP transaction. + The pointer-then-read sequence of the demo therefore uses two separate + transactions and works only with targets that keep their pointer across a + STOP (EEPROM-like). Targets that need a repeated START are not covered. +* **Bus frequency is nominal.** The timing constants in + `pru_i2c_interface.h` are calculated for a 200 MHz ICSS clock. The + SysConfig configuration of this example sets the ICSSM0 core clock to 225 MHz + and the IEP clock to 250 MHz (`CONFIG_PRU_ICSS0_CORE_CLK_FREQ_HZ`, + `CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ` in the generated `ti_drivers_config.h`), so + the real SCL frequency can differ from the selected 100 kHz / 400 kHz / + 1 MHz. Measure SCL on the bus before relying on the timing. +* The example polls the IRQ bit instead of using the PRU interrupt. +* The example is built for NORTOS on the r5fss0-0 core of the AM261x-LP only. +* Build-tested only, see "Validated HW & SW". From 999b5fdab55f1b1e5295de3cc39aeeb5192129a5 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 12:50:50 +0530 Subject: [PATCH 04/29] examples: pru_i2c: R5F: global words in DMEM0, IEP increment from IEP clock - The firmware reads the IRQ register (0x08) and the frequency word (0x0C) through ICSS_DMEM0_CONST, which is DMEM0 on both cores. The example runs on PRU1 and wrote them to DMEM1, so the firmware would read a zero frequency selector and the host would poll the wrong IRQ word. Write them in DMEM0, and only clear this instance's IRQ bit. - Use the core number as the instance id, so a PRU0 and a PRU1 instance can share the IRQ register. - The IEP_CMP_INCREMENT_VAL_* constants assume a 200 MHz IEP clock; this SysConfig runs it at 250 MHz (200 MHz needs the R5F at 400 MHz). Derive the increment from CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ, rounding up to a whole IEP clock per tick so SCL never exceeds PRU_I2C_BUS_HZ (785 counts, ~398 kHz at 250 MHz). Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/mcuplus/pru_i2c_example.c | 51 +++++++++++++++------- examples/pru_i2c/readme.md | 40 +++++++++-------- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index 5011f3a04..57672657b 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -83,11 +83,22 @@ #define PRU_I2C_SCL_PIN (18U) #define PRU_I2C_SDA_PIN (19U) -/* I2C bus frequency selection, one of ICSS_I2C_100KHZ_FREQ, - * ICSS_I2C_400KHZ_FREQ or ICSS_I2C_1MHZ_FREQ. The IEP compare increment - * (time between state machine ticks) has to match the selected frequency. */ +/* I2C bus frequency. PRU_I2C_BUS_FREQ is the firmware's frequency selector + * (ICSS_I2C_100KHZ_FREQ, ICSS_I2C_400KHZ_FREQ or ICSS_I2C_1MHZ_FREQ). The + * actual SCL rate is set by the IEP compare increment below. */ #define PRU_I2C_BUS_FREQ (ICSS_I2C_400KHZ_FREQ) -#define PRU_I2C_IEP_INCREMENT (IEP_CMP_INCREMENT_VAL_400KHZ) +#define PRU_I2C_BUS_HZ (400000U) + +/* The firmware advances its state machine once per IEP compare event and + * needs 4 ticks per SCL period. The IEP counts PRU_I2C_IEP_DEFAULT_INC per + * IEP clock, and its clock comes from SysConfig (250 MHz by default on + * AM261x, while the IEP_CMP_INCREMENT_VAL_* constants in + * pru_i2c_interface.h assume 200 MHz). So derive the increment from the + * configured IEP clock, rounding the tick up to a whole IEP clock so that + * SCL never runs faster than PRU_I2C_BUS_HZ. */ +#define PRU_I2C_IEP_DEFAULT_INC (5U) +#define PRU_I2C_IEP_CLKS_PER_TICK ((CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ + (4U * PRU_I2C_BUS_HZ) - 1U) / (4U * PRU_I2C_BUS_HZ)) +#define PRU_I2C_IEP_INCREMENT (PRU_I2C_IEP_CLKS_PER_TICK * PRU_I2C_IEP_DEFAULT_INC) /* 7-bit address of the I2C target used for the demo transfers */ #define PRU_I2C_TARGET_ADDR (0x50U) @@ -118,14 +129,15 @@ #define PRU_I2C_OUT_CTRL_REG (CSL_MSS_CTRL_U_BASE + CSL_MSS_CTRL_ICSSM0_PRU1_GPIO_OUT_CTRL) #endif -/* Offsets inside the PRU data RAM of the selected core (PRU0 -> DMEM0, - * PRU1 -> DMEM1; the firmware accesses it at local address 0). - * The layout is defined by pru_i2c_interface.h. */ +/* Global words, shared by both PRU cores. The firmware reads them through + * ICSS_DMEM0_CONST, which is DMEM0 on PRU0 and on PRU1 alike, so they always + * live in PRU0's data RAM. The layout is defined by pru_i2c_interface.h. */ #define PRU_I2C_IRQ_REG (IRQ_COMMON_REGISTER_OFFSET) /* u16: bit n set by PRU, cleared by R5F */ #define PRU_I2C_FREQ_REG (I2C_BUS_FREQUENCY_OFFSET) /* u16: frequency selection */ #define PRU_I2C_IEP_INC_REG (I2C_BUS_FREQUENCY_OFFSET + 2U) /* u16: IEP compare increment */ -/* Instance 0 registers. ICSS_I2C_COMMAND_OFFSET is a 32-bit word: the low +/* Instance 0 registers, in the data RAM of the core that runs the firmware + * (PRU0 -> DMEM0, PRU1 -> DMEM1). ICSS_I2C_COMMAND_OFFSET is a 32-bit word: the low * half is the response of the PRU, the high half is the command from the R5F. */ #define PRU_I2C_RESPONSE_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_COMMAND_OFFSET) #define PRU_I2C_COMMAND_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_COMMAND_OFFSET + 2U) @@ -138,8 +150,9 @@ #define PRU_I2C_SDA_PIN_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_PIN_OFFSET + 1U) /* u8 */ #define PRU_I2C_INST_ID_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_INST_ID_OFFSET) /* u8 */ -/* Bit of the IRQ register that belongs to instance 0 */ -#define PRU_I2C_INST_ID (0U) +/* Bit of the shared IRQ register that belongs to this instance. Use the core + * number so a PRU0 and a PRU1 instance can run side by side. */ +#define PRU_I2C_INST_ID (PRU_I2C_PRU_CORE) /* The firmware accepts a data count of 1..255 */ #define PRU_I2C_MAX_COUNT (255U) @@ -152,6 +165,8 @@ PRUICSS_Handle gPruIcss0Handle; /* Base address of the data RAM of the PRU that runs the I2C firmware */ static uintptr_t gPruDmemBase; +/* Base address of DMEM0, which holds the global IRQ and frequency words */ +static uintptr_t gPruGlobalBase; /* ========================================================================== */ /* Local function definitions */ @@ -188,7 +203,7 @@ static int32_t PruI2c_waitForPru(uint32_t timeoutUs) { uint64_t start = ClockP_getTimeUsec(); - while ((HW_RD_REG16(gPruDmemBase + PRU_I2C_IRQ_REG) & (1U << PRU_I2C_INST_ID)) == 0U) + while ((HW_RD_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG) & (1U << PRU_I2C_INST_ID)) == 0U) { if ((ClockP_getTimeUsec() - start) > timeoutUs) { @@ -202,10 +217,10 @@ static int32_t PruI2c_waitForPru(uint32_t timeoutUs) * before it accepts the next command. */ static void PruI2c_ackPru(void) { - uint16_t irq = HW_RD_REG16(gPruDmemBase + PRU_I2C_IRQ_REG); + uint16_t irq = HW_RD_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG); irq &= (uint16_t)~(1U << PRU_I2C_INST_ID); - HW_WR_REG16(gPruDmemBase + PRU_I2C_IRQ_REG, irq); + HW_WR_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG, irq); } /* Send a command to the PRU, wait for its response and acknowledge it. */ @@ -240,6 +255,7 @@ static int32_t PruI2c_init(void) hwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS0); DebugP_assert(hwAttrs != NULL); gPruDmemBase = (PRU_I2C_PRU_CORE == 0U) ? hwAttrs->pru0DramBase : hwAttrs->pru1DramBase; + gPruGlobalBase = hwAttrs->pru0DramBase; /* PRUICSS_loadFirmware() enables the PRU core right away, and the * firmware reads the frequency settings once while it boots. So stop the @@ -255,9 +271,12 @@ static int32_t PruI2c_init(void) return SystemP_FAILURE; } - /* Bus frequency (u16) and IEP compare increment (u16) */ - HW_WR_REG16(gPruDmemBase + PRU_I2C_FREQ_REG, PRU_I2C_BUS_FREQ); - HW_WR_REG16(gPruDmemBase + PRU_I2C_IEP_INC_REG, PRU_I2C_IEP_INCREMENT); + /* Bus frequency (u16) and IEP compare increment (u16), shared by both + * cores. Clear only this instance's IRQ bit: the other core's instance + * may be using the same register. */ + HW_WR_REG16(gPruGlobalBase + PRU_I2C_FREQ_REG, PRU_I2C_BUS_FREQ); + HW_WR_REG16(gPruGlobalBase + PRU_I2C_IEP_INC_REG, PRU_I2C_IEP_INCREMENT); + PruI2c_ackPru(); /* Instance 0 configuration */ /* TX and RX buffers are 256 bytes each */ diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md index 2049e9e7c..0389d7944 100644 --- a/examples/pru_i2c/readme.md +++ b/examples/pru_i2c/readme.md @@ -48,18 +48,21 @@ This example has **not been validated on hardware**. It has only been built. ## PRU <-> host memory interface -The host core talks to the firmware through the data RAM of the PRU core that -runs the firmware (PRU0 -> DMEM0, PRU1 -> DMEM1). The firmware reads and writes -this memory at local address 0. All offsets and bit definitions are in +The host core talks to the firmware through PRU data RAM. The two global +words (IRQ register and frequency) are always in DMEM0, for PRU0 and PRU1 +alike: the firmware reads them through `ICSS_DMEM0_CONST`. The instance block +and the TX/RX buffers are in the data RAM of the core that runs the firmware +(PRU0 -> DMEM0, PRU1 -> DMEM1), at local address 0x100. All offsets and bit +definitions are in [firmware/pru_i2c_interface.h](firmware/pru_i2c_interface.h), the host code includes that header instead of repeating the values. - Offset (DMEM) | Size | Name | Description + Offset | Size | Name | Description ------------------|------|----------------------------------------|------------- - 0x0008 | u16 | `IRQ_COMMON_REGISTER_OFFSET` | Bit `` is **set by the PRU** when a response is ready and **cleared by the host** to acknowledge it. The PRU does not accept the next command until the bit is cleared. - 0x000C | u16 | `I2C_BUS_FREQUENCY_OFFSET` | Bus frequency: `ICSS_I2C_100KHZ_FREQ` (3), `ICSS_I2C_400KHZ_FREQ` (2), `ICSS_I2C_1MHZ_FREQ` (1). Any other value sends the firmware into an error loop. - 0x000E | u16 | `I2C_BUS_FREQUENCY_OFFSET` + 2 | IEP compare increment for the selected frequency (`IEP_CMP_INCREMENT_VAL_400KHZ`, ...) - 0x0100 | | `ICSS_I2C_INSTANCE0_ADDR` | Start of the instance 0 block (offsets below are relative to it) + DMEM0 0x0008 | u16 | `IRQ_COMMON_REGISTER_OFFSET` | Shared by both cores. Bit `` is **set by the PRU** when a response is ready and **cleared by the host** to acknowledge it. The PRU does not accept the next command until the bit is cleared. + DMEM0 0x000C | u16 | `I2C_BUS_FREQUENCY_OFFSET` | Shared by both cores. Bus frequency selector: `ICSS_I2C_100KHZ_FREQ` (3), `ICSS_I2C_400KHZ_FREQ` (2), `ICSS_I2C_1MHZ_FREQ` (1). Any other value sends the firmware into an error loop. + DMEM0 0x000E | u16 | `I2C_BUS_FREQUENCY_OFFSET` + 2 | IEP compare increment per state tick (4 ticks per SCL period), a multiple of the IEP DEFAULT_INC (5). See "Bus frequency" below. + own DMEM 0x0100 | | `ICSS_I2C_INSTANCE0_ADDR` | Start of the instance 0 block (offsets below are relative to it) + 0x08 | u16 | `ICSS_I2C_COMMAND_OFFSET` | Response of the PRU (`COMMAND_SUCCESS` 0x0500, `ADDRESS_ACKNOWLDEGE_FAILED`, `DATA_ACKNOWLDEGE_FAILED`, `INVALID_COMMAND`, ...) + 0x0A | u16 | `ICSS_I2C_COMMAND_OFFSET` + 2 | Command from the host (`ICSS_I2C_SETUP_CMD`, `ICSS_I2C_TX_CMD`, `ICSS_I2C_RX_CMD`, ...). The PRU clears it when it raises the response. + 0x94 / + 0x95 | u8 | `ICSS_I2C_BUF_OFFSET` | TX / RX FIFO size @@ -67,7 +70,7 @@ includes that header instead of repeating the values. + 0xA4 | u32 | `ICSS_I2C_CON_OFFSET` | Configuration: bit 15 module enable, bit 10 master (must be 1), bit 8 10-bit addressing, bit 5 SMBus burst, bit 4 NACK the last read byte, bit 1 send STOP, bit 0 send START + 0xAC | u16 | `ICSS_I2C_SA_OFFSET` | 7-bit target address + 0xD8 / + 0xD9 | u8 | `ICSS_I2C_PRU_PIN_OFFSET` | SCL / SDA pin: the bit number in R30 (output) and R31 (input) - + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the bit used in the IRQ register (use 0) + + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the bit used in the shared IRQ register. The example uses the core number, so a PRU0 and a PRU1 instance do not collide. + 0x100 (0x0200) | 256 B| `ICSS_I2C_INSTANCE0_TX_MEM` | TX buffer + 0x200 (0x0300) | 256 B| `ICSS_I2C_INSTANCE0_RX_MEM` | RX buffer @@ -107,8 +110,8 @@ MSS_CTRL (1 = output disabled; PRU0 at 0x50D00810, PRU1 at 0x50D00814) and back to an output by clearing it. SysConfig sets that bit for every PRU GPIO configured with "rx", which includes SDA. The R5F example therefore clears the SDA bit of this register before it starts the PRU, so that the PRU can drive -the START condition. The example assumes the firmware uses the register of the -PRU core it runs on. +the START condition. The firmware selects the register of the core it is built +for (`-DPRU0` / `-DPRU1`, and `-DICSSM1` for ICSSM1). # Pin assignment (AM261x-LP) @@ -211,13 +214,14 @@ was not accepted. The pointer-then-read sequence of the demo therefore uses two separate transactions and works only with targets that keep their pointer across a STOP (EEPROM-like). Targets that need a repeated START are not covered. -* **Bus frequency is nominal.** The timing constants in - `pru_i2c_interface.h` are calculated for a 200 MHz ICSS clock. The - SysConfig configuration of this example sets the ICSSM0 core clock to 225 MHz - and the IEP clock to 250 MHz (`CONFIG_PRU_ICSS0_CORE_CLK_FREQ_HZ`, - `CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ` in the generated `ti_drivers_config.h`), so - the real SCL frequency can differ from the selected 100 kHz / 400 kHz / - 1 MHz. Measure SCL on the bus before relying on the timing. +* **Bus frequency.** The `IEP_CMP_INCREMENT_VAL_*` constants in + `pru_i2c_interface.h` assume a 200 MHz IEP clock. With the default SysConfig + settings of this example the IEP clock is 250 MHz + (`CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ` in the generated `ti_drivers_config.h`; + 200 MHz needs the R5F at 400 MHz), so the example derives the increment from + that define instead (`PRU_I2C_IEP_INCREMENT`), rounding up so SCL never runs + faster than `PRU_I2C_BUS_HZ`. At 250 MHz and 400 kHz that is 157 IEP clocks + per tick, about 398 kHz. Not yet measured on a board. * The example polls the IRQ bit instead of using the PRU interrupt. * The example is built for NORTOS on the r5fss0-0 core of the AM261x-LP only. * Build-tested only, see "Validated HW & SW". From 2feaaf1c33f6f2dcd55e890b901013f24054ca85 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 12:48:22 +0530 Subject: [PATCH 05/29] examples: pru_i2c: fix per-core IEP/scratchpad use, read ACK and SDA control Found by running the firmware ELFs on TI pru-simulator against an I2C target model (see the PR description for the harness and results). Per-core resources (both PRUs share the IEP and the scratchpad banks): - The makefile build defined neither PRU0 nor PRU1 (DFLAGS was empty), so icss_constant_defines.inc treated both cores as PRU1: the firmware read its frequency word from the other core's DMEM, got 0 and went to ERROR_LOOP. Neither IEP compare was enabled either. The committed pru0/pru1_load_bin.h were built this way and are identical apart from the array name. Add -DPRU0/-DPRU1 (as the projectspecs already do) and fail the build with .emsg if neither is defined. - I2C_WAIT_FOR_IEP_CMP polled the PRU0 status bit and I2C_SETUP_IEP_COUNTER programmed CMP0 on both cores, so PRU1 never saw a tick. Select CMP register, status bit and enable bit once per core. - I2C_SETUP_IEP_COUNTER wrote CMP_CFG with only its own enable bit set, disabling the other core's compare. Read-modify-write it instead. - The first compare value was a hardcoded 0x9C3 (debug guard commented out). Use the live IEP count + one tick, so a core can join a counter the other core already started. - I2C_IEP_INTC_CLEAR_EVENT wrote back the whole CMP_STATUS value, which (write-1-to-clear) also clears the other core's pending event. Clear only this core's bit. - Both cores saved their context to scratchpad bank 10. Use bank 10 for PRU0 and bank 11 for PRU1. - ERROR_LOOP stopped the shared IEP counter. Leave it running. I2C protocol: - Read: the master drove SDA high in the ACK slot after every byte (rx_data_ack_begin used SET_SDA_PIN_HIGH), so it NACKed each byte and multi-byte reads returned 0xFF after the first byte. Drive it low. - SET_SDA_PIN_INPUT/OUTPUT_DIRECTION wrote 0x50D00818 (ICSSM1_PRU0_GPIO_OUT_CTRL) with a hardcoded bit 9. These projects run on ICSSM0, so SDA was never released: ACKs were read back from the master's own drive (a write to an absent address reported success). Use this core's ICSSM0 register (ICSSM1 with -DICSSM1) and the configured SDA pin. - Release SDA on the SCL falling edge after the 8th bit instead of one tick later, and keep it released after the address ACK of a read, so the push-pull master does not drive SDA high while the target drives ACK or read data. Housekeeping: file header names, register usage map, wait macro docs, and a missing newline/indent on the final .endif (assembler warning W0004 "Open block(s) at EOF"). Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- .../icss_m0_pru0_fw/ti-pru-cgt/makefile | 2 +- .../icss_m0_pru1_fw/ti-pru-cgt/makefile | 2 +- .../firmware/pru_i2c_firmware_version.h | 2 +- examples/pru_i2c/firmware/pru_i2c_macro.h | 123 +++++++----------- examples/pru_i2c/firmware/pru_i2c_main.asm | 79 +++++++++-- 5 files changed, 120 insertions(+), 88 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile index 3395c098c..00993d53b 100644 --- a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile @@ -40,7 +40,7 @@ include $(OPEN_PRU_PATH)/pru_rules.mak # 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 := +DFLAGS := -DPRU0 -DSLICE0 -DSOC_AM261X # Libraries # see --library in 'PRU Optimizing C/C++ Compiler User's Guide' diff --git a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile index dc9d20d19..35f940ca4 100644 --- a/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile +++ b/examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile @@ -40,7 +40,7 @@ include $(OPEN_PRU_PATH)/pru_rules.mak # 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 := +DFLAGS := -DPRU1 -DSLICE1 -DSOC_AM261X # Libraries # see --library in 'PRU Optimizing C/C++ Compiler User's Guide' diff --git a/examples/pru_i2c/firmware/pru_i2c_firmware_version.h b/examples/pru_i2c/firmware/pru_i2c_firmware_version.h index 211e6ea5c..652ff8867 100644 --- a/examples/pru_i2c/firmware/pru_i2c_firmware_version.h +++ b/examples/pru_i2c/firmware/pru_i2c_firmware_version.h @@ -29,7 +29,7 @@ ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;************************************************************************************ -; File: firmware_version.h +; File: pru_i2c_firmware_version.h ; ; Brief: ICSS I2C Firmware version control file ;************************************************************************************ diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index e1f31ff75..393b9c001 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -29,7 +29,7 @@ ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;************************************************************************************ -; File: icss_i2c_macro.h +; File: pru_i2c_macro.h ; ; Brief: This file contains ICSS I2C macros definations ;************************************************************************************ @@ -79,26 +79,32 @@ ENABLE_XIN_XOUT_SHITFTING .macro ; ; Macro: I2C_WAIT_FOR_IEP_CMP ; -; wait until the IEP CMP Event triggers and interrupt -; +; wait until this core's IEP compare event (I2C_IEP_CMP_STATUS_BIT) is set +; ; PEAK cycles: -; NA +; Unbounded by design: this is the scheduler tick. It returns at most +; one IEP compare period after the previous tick. The compare is armed +; by I2C_SETUP_IEP_COUNTER and re-armed by I2C_IEP_INTC_CLEAR_EVENT, and +; the shared IEP counter is never stopped by this firmware, so the wait +; always terminates. There is no other time base to time it out against. ; Pseudo code: -; while(r31.t31==0) +; while(IEP_CMP_STATUS_REG.I2C_IEP_CMP_STATUS_BIT == 0) ; ; Parameters: -; None +; None ; ; Returns: ; None ; +; Registers modified: +; TEMP_REG1 +; ;************************************************************************************ I2C_WAIT_FOR_IEP_CMP .macro WAIT_FOR_INT?: LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 - QBBC WAIT_FOR_INT?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT - ;;;;QBBC WAIT_FOR_INT?, R31, 31 + QBBC WAIT_FOR_INT?, TEMP_REG1, I2C_IEP_CMP_STATUS_BIT .endm @@ -125,33 +131,20 @@ I2C_IEP_INTC_CLEAR_EVENT .macro arg1 ; clear the IEP compare event happened LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 - .if $defined("PRU0") - QBBS IEP_INTC_CLEAR?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT - JMP arg1 - .else - QBBS IEP_INTC_CLEAR?, TEMP_REG1, PRU1_IEP_CMP_STATUS_BIT + QBBS IEP_INTC_CLEAR?, TEMP_REG1, I2C_IEP_CMP_STATUS_BIT JMP arg1 - .endif IEP_INTC_CLEAR?: - - .if $defined("PRU0") - SET TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT - .else - SET TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_STATUS_BIT - .endif + + ; write-1-to-clear only this core's bit: the other PRU shares the register + LDI TEMP_REG1, 0 + SET TEMP_REG1, TEMP_REG1, I2C_IEP_CMP_STATUS_BIT SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 ;Set compare values ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 - .if $defined("PRU0") - SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8 - .endif ;PRU0 + SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, I2C_IEP_CMP_REG, 8 - .if $defined("PRU1") - SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU1_IEP_CMP_REG, 8 - .endif ;PRU1 - ; Clear the intc interrupt event flag LDI TEMP_REG1.w0, 0x0080 LDI TEMP_REG2.w0, ICSS_INTC_SECR1 @@ -181,14 +174,14 @@ I2C_WAVE_FUNCTION0 .macro ;Restore I2C instance context LDI R0.b0, 0x00 - XIN BANK0, &R10, 40 + XIN I2C_CONTEXT_BANK, &R10, 40 ;Jump and link to the next task function JAL TEMP_REG3.w0, R13.w0 ;R13 store RESET MODE ;Save context to SPAD LDI R0.b0, 0x00 - XOUT BANK0, &R10, 40 + XOUT I2C_CONTEXT_BANK, &R10, 40 .endm @@ -625,6 +618,10 @@ tx_data_sda_read?: tx_data_scl_end?: SET_SCL_PIN_LOW QBGT tx_sda_next_bit?, R15.b0, 0x08 + ; The target may drive ACK as soon as SCL falls after the 8th bit, so + ; release SDA on this edge rather than one tick later. SCL is already low, + ; so the release cannot be seen as a STOP. + SET_SDA_PIN_INPUT_DIRECTION LDI R13.w0, $CODE(tx_data_ack_begin?) STATE_TASK_OVER @@ -633,10 +630,9 @@ tx_sda_next_bit?: STATE_TASK_OVER ; -; Change direction of GPIO +; SDA was released in tx_data_scl_end; this tick keeps the 4-tick bit timing ; tx_data_ack_begin?: - SET_SDA_PIN_INPUT_DIRECTION LDI R13.w0, $CODE(tx_data_ack_scl_begin?) STATE_TASK_OVER @@ -763,41 +759,18 @@ I2C_SETUP_IEP_COUNTER .macro SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 iep_counter_setup_done?: - ;Set compare values - - LDI TEMP_REG3.w0, ICSS_I2C_CONFIG_MEMORY - LBCO &IEP_COUNTER_NEXT_VAL1, ICSS_DMEM0_CONST, TEMP_REG3.w0, 8 - LBCO &TEMP_REG2, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8 - - ;;;debug code - ;;.if $defined("DEBUG_CODE") - LDI IEP_COUNTER_NEXT_VAL1, 0x9c3 - LDI IEP_COUNTER_NEXT_VAL2, 0x0 - ;;.endif - -loop3?: + ; First compare = current count + one tick. Starting from the live count + ; (rather than a constant) is what lets the second PRU join a counter the + ; first PRU already started. + LBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8 ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 - ;;QBGT loop3?, IEP_COUNTER_NEXT_VAL2, TEMP_REG3 - ;;QBLT loop4?, IEP_COUNTER_NEXT_VAL2, TEMP_REG3 - ;;QBGT loop3?, IEP_COUNTER_NEXT_VAL1, TEMP_REG2 -loop4?: - ;;ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2 - ;;ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00 - SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8 - - ;Enable compare events - .if $defined("PRU0") - ZERO &TEMP_REG1, 4 - SET TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_ENABLE_BIT - SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4 - .endif ;PRU0 + SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, I2C_IEP_CMP_REG, 8 - .if $defined("PRU1") - ZERO &TEMP_REG1, 4 - SET TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_ENABLE_BIT + ; Enable this core's compare event without disabling the other core's + LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4 + SET TEMP_REG1, TEMP_REG1, I2C_IEP_CMP_ENABLE_BIT SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4 - .endif ;PRU1 .endm @@ -871,8 +844,7 @@ rx_sda_next_bit?: ; make SDA line low to send an ACK. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; rx_data_ack_begin?: - ;SET_SDA_PIN_OUTPUT_DIRECTION - SET_SDA_PIN_HIGH + SET_SDA_PIN_LOW LDI R13.w0, $CODE(rx_data_ack_scl_begin?) STATE_TASK_OVER @@ -957,13 +929,13 @@ rx_mode_continue?: ; None ; ;************************************************************************************ -SET_SDA_PIN_INPUT_DIRECTION .macro - - ;; For Am263x LDI32 r29, 0x50D00824 - ;for Am261x - LDI32 r29, 0x50D00818 +SET_SDA_PIN_INPUT_DIRECTION .macro + + ; AM261x: set the SDA pin's OUTDISABLE bit in this core's + ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) + LDI32 r29, I2C_GPIO_OUT_CTRL LBBO &r28, r29, 0, 4 - SET r28, r28, 9 + SET r28, r28, R14.b1 SBBO &r28, r29, 0, 4 .endm @@ -988,13 +960,12 @@ SET_SDA_PIN_INPUT_DIRECTION .macro SET_SDA_PIN_OUTPUT_DIRECTION .macro - ;; For Am263x LDI32 r29, 0x50D00824 - ;for Am261x - LDI32 r29, 0x50D00818 + ; AM261x: clear the SDA pin's OUTDISABLE bit in this core's + ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) + LDI32 r29, I2C_GPIO_OUT_CTRL LBBO &r28, r29, 0, 4 - LDI32 R27, 0xFFFFFDFF - AND r28, r28, r27 + CLR r28, r28, R14.b1 SBBO &r28, r29, 0, 4 .endm -.endif ; __icss_i2c_macros_h \ No newline at end of file + .endif ; __icss_i2c_macros_h diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 63808fe7b..9f304a23d 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -78,11 +78,62 @@ PRU1_IEP_CMP_ENABLE_BIT .set 2 PRU0_IEP_CMP_STATUS_BIT .set 0 PRU1_IEP_CMP_STATUS_BIT .set 1 - ; Bank ids for Xfer instructions BANK0 .set 10 BANK1 .set 11 BANK2 .set 12 + +; MSS_CTRL ICSSMx_PRUy_GPIO_OUT_CTRL (AM261x, cslr_mss_ctrl.h). Setting a bit +; disables the output driver of that PRU GPO pin, which releases the line to +; the external pull-up. Used to hand SDA to the target for ACK and read data. +ICSSM0_PRU0_GPIO_OUT_CTRL .set 0x50D00810 +ICSSM0_PRU1_GPIO_OUT_CTRL .set 0x50D00814 +ICSSM1_PRU0_GPIO_OUT_CTRL .set 0x50D00818 +ICSSM1_PRU1_GPIO_OUT_CTRL .set 0x50D0081C + +; Per-core resources. The IEP and the scratchpad banks are shared by both +; PRUs, so each core must use its own compare register, status bit, enable +; bit and context bank. The build must define exactly one of PRU0 / PRU1 +; (projectspec -DPRU0/-DPRU1, makefile DFLAGS); icss_constant_defines.inc +; also relies on it to select the DMEM constants. + .if $defined("PRU0") +I2C_IEP_CMP_REG .set PRU0_IEP_CMP_REG +I2C_IEP_CMP_ENABLE_BIT .set PRU0_IEP_CMP_ENABLE_BIT +I2C_IEP_CMP_STATUS_BIT .set PRU0_IEP_CMP_STATUS_BIT +I2C_CONTEXT_BANK .set BANK0 + .if $defined("ICSSM1") +I2C_GPIO_OUT_CTRL .set ICSSM1_PRU0_GPIO_OUT_CTRL + .else +I2C_GPIO_OUT_CTRL .set ICSSM0_PRU0_GPIO_OUT_CTRL + .endif + .elseif $defined("PRU1") +I2C_IEP_CMP_REG .set PRU1_IEP_CMP_REG +I2C_IEP_CMP_ENABLE_BIT .set PRU1_IEP_CMP_ENABLE_BIT +I2C_IEP_CMP_STATUS_BIT .set PRU1_IEP_CMP_STATUS_BIT +I2C_CONTEXT_BANK .set BANK1 + .if $defined("ICSSM1") +I2C_GPIO_OUT_CTRL .set ICSSM1_PRU1_GPIO_OUT_CTRL + .else +I2C_GPIO_OUT_CTRL .set ICSSM0_PRU1_GPIO_OUT_CTRL + .endif + .else + .emsg "pru_i2c: define PRU0 or PRU1 for the core this firmware runs on" + .endif + +; Register usage: +; R1-R8 TEMP_REG1..8, scratch. TEMP_REG3.w0 holds the state return +; address while a state runs (JAL in I2C_WAVE_FUNCTION0). +; R10-R19 I2C instance context, saved/restored with XIN/XOUT on +; I2C_CONTEXT_BANK: +; R10 instance base, R11 Tx buffer, R12 Rx buffer, +; R13.w0 next state, R13.w2 slave address shift register, +; R14 b0 SCL pin, b1 SDA pin, b3 instance id, +; R15 b0 bit count, b1 data byte, b2 byte index, b3 byte count, +; R16 control flags (ICSS_I2C_*_BIT), R17.w0 post-address state. +; R20-R21 next IEP compare value (64-bit), R22 frequency word. +; R27-R29 scratch for SET_SDA_PIN_*_DIRECTION. + + ;-------------------------------------------------------------------------------------- ;******** @@ -126,7 +177,7 @@ init: LDI32 R19 , 0x00000000 LDI R0.b0, 0x00 - XOUT BANK0, &R10, 40 + XOUT I2C_CONTEXT_BANK, &R10, 40 ;add a variable delay for N cyles to avoid contention ;between PRU0 and PRU1 if both out of reset at the same time. @@ -155,10 +206,9 @@ init: QBEQ TASK_LOOP_400Khz, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_400KHZ_FREQ QBEQ TASK_LOOP_1Mhz, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_1MHZ_FREQ +; Unsupported frequency selector. Do not stop the IEP counter here: it is +; shared with the other PRU, whose I2C instance may already be running. ERROR_LOOP: - LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 - CLR TEMP_REG1 , TEMP_REG1 , 0 - SBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_GLOBAL_CFG_REG, 4 LDI TEMP_REG5.w0, ICSS_INTC_SRSR1 LDI32 TEMP_REG6, 0x00400000 SBCO &TEMP_REG6, ICSS_INTC_CONST, TEMP_REG5.w0, 4 @@ -976,6 +1026,9 @@ ADDRESS_SDA_READ: ADDRESS_SCL_END: SET_SCL_PIN_LOW QBGT SDA_NEXT_BIT, R15.b0, 0x08 + ; release SDA on the falling edge after the 8th bit: the target may drive + ; ACK from here on (SCL is already low, so this is not a STOP) + SET_SDA_PIN_INPUT_DIRECTION UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_BEGIN STATE_TASK_OVER @@ -984,10 +1037,9 @@ SDA_NEXT_BIT: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; change the direction of PIN as INPUT. +; SDA was released in ADDRESS_SCL_END; this tick keeps the 4-tick bit timing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_ACK_BEGIN: - SET_SDA_PIN_INPUT_DIRECTION UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_BEGIN STATE_TASK_OVER @@ -1014,9 +1066,17 @@ ADDRESS_ACK_READ: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_ACK_SCL_END: SET_SCL_PIN_LOW - ;SET the dirction for GPIO - SET_SDA_PIN_OUTPUT_DIRECTION QBBS ADDRESS_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT + ; In a read, the target starts driving the first data bit as soon as SCL + ; falls after its ACK, so SDA must stay released. Only take SDA back when + ; the master transmits next: a write, or the second byte of a 10-bit + ; address. + QBBC ADDRESS_ACK_SDA_OUTPUT, R16, ICSS_I2C_READ_WRITE_BIT + QBBC ADDRESS_ACK_SDA_DONE, R16, ICSS_I2C_ADDRESSING_MODE_BIT + QBEQ ADDRESS_ACK_SDA_DONE, R15.b2, 0x01 +ADDRESS_ACK_SDA_OUTPUT: + SET_SDA_PIN_OUTPUT_DIRECTION +ADDRESS_ACK_SDA_DONE: QBBC ADDRESS_ACK_SCL_END_DONE, R16, ICSS_I2C_ADDRESSING_MODE_BIT QBEQ ADDRESS_ACK_SCL_END_DONE, R15.b2, 0x01 ADD R15.b2, R15.b2, 0x01 @@ -1037,6 +1097,7 @@ ADDRESS_ACK_NOT_RECIEVED: ; raise an interrupt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NO_ADDRESS_ACK_RECIEVED: + SET_SDA_PIN_OUTPUT_DIRECTION SET_SCL_PIN_HIGH LDI TEMP_REG4.w0, ADDRESS_ACKNOWLDEGE_FAILED SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 From 56aa65492c8fd75f718b600a526e8a0915ffb37e Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 12:48:22 +0530 Subject: [PATCH 06/29] examples: pru_i2c: make IEP increments multiples of DEFAULT_INC The IEP counts in steps of DEFAULT_INC = 5. 0x270 (624) and 0x9C3 (2499) are not multiples of 5, so a compare that fires only when the counter equals the compare value is never hit at 400 kHz or 100 kHz. Use 0x271 (625, i.e. the 125 cycles the comment already describes) and 0x9C4 (2500). 1 MHz (0x140 = 320) was already a multiple of 5. SPRUJB6B does not say whether an IEP compare is an equality match or a crossing match. With these values the tick is exact under either. Also fix the file header name. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/firmware/pru_i2c_interface.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_interface.h b/examples/pru_i2c/firmware/pru_i2c_interface.h index 0e5d7cfec..8ad7e1e7b 100644 --- a/examples/pru_i2c/firmware/pru_i2c_interface.h +++ b/examples/pru_i2c/firmware/pru_i2c_interface.h @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ************************************************************************************* -* File: icss_i2c.h +* File: pru_i2c_interface.h * * Brief: This is a common header file with all memory map configuration. ************************************************************************************* @@ -173,17 +173,19 @@ typedef enum PRUICSS_PruCores_e /* The iep counter increment value for 400KHz value */ +// The IEP counts DEFAULT_INC = 5 per 200 MHz clock, so every increment +// must be a multiple of 5 to land exactly on a counter value. // 1 I2C instance, time-slice 125 (625/5) cycles. // => bus clock time is 125*4/200e6 = 2.5 usec. // => bus clock speed is 1/2.5e-6 = 400 kHz -#define IEP_CMP_INCREMENT_VAL_400KHZ (0x00000270U) // 400 kHz +#define IEP_CMP_INCREMENT_VAL_400KHZ (0x00000271U) // 400 kHz #define IEP_CMP_INCREMENT_HALF_VAL_400KHZ (0x00000138U) /* The iep counter increment value for 100KHz value */ // 4 I2C instances, time-slice 125 (625/5) cycles. // => bus clock time is 125*4*4/200e6 = 10 usec. // => bus clock speed is 1/10e-6 = 100 kHz -#define IEP_CMP_INCREMENT_VAL_100KHZ (0x000009c3U) // 100 kHz, 1x instances +#define IEP_CMP_INCREMENT_VAL_100KHZ (0x000009C4U) // 100 kHz, 1x instances #define IEP_CMP_INCREMENT_HALF_VAL_100KHZ (0x000004e1U) // // 1 I2C instance, time-slice 64 (320/5) cycles. From 1a0ad13c90be8e1a1720f6db62c1f1ba5676013a Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 13:01:28 +0530 Subject: [PATCH 07/29] examples: pru_i2c: regenerate pru0/pru1_load_bin.h Rebuilt with the makefile flow (make -C examples/pru_i2c pru DEVICE=am261x BUILD_MCUPLUS=y), which now passes -DPRU0 / -DPRU1. The previous arrays were built with neither define and were identical for both cores apart from the array name. These arrays are byte-identical to the ELFs exercised on pru-simulator. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- .../firmware/am261x-lp/pru0_load_bin.h | 524 +++++++++--------- .../firmware/am261x-lp/pru1_load_bin.h | 516 +++++++++-------- 2 files changed, 512 insertions(+), 528 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index b40c2f3dd..aa8be4906 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -41,7 +41,7 @@ const uint32_t PRU0Firmware_0[] = { 0x240000cb, 0x2403008c, 0x240000cc, -0x2400788d, +0x24007a8d, 0x240000cd, 0x240000ce, 0x2400008e, @@ -60,7 +60,7 @@ const uint32_t PRU0Firmware_0[] = { 0x2effbd80, 0x24000081, 0x010c8181, -0x90813996, +0x90813896, 0x91003a81, 0xd100e110, 0x91107a81, @@ -78,34 +78,32 @@ const uint32_t PRU0Firmware_0[] = { 0x91003a81, 0x1f00e1e1, 0x81003a81, -0x24000083, -0x90837994, -0x91107a82, -0x2409c3f4, -0x240000f5, +0x91107a94, 0x00d6f4f4, 0x0300f5f5, 0x81787a94, -0x5103960b, -0x5102961c, -0x5101962d, -0x91003a81, -0x1d00e1e1, -0x81003a81, +0x91703a81, +0x1f01e1e1, +0x81703a81, +0x51039608, +0x5102961b, +0x5101962e, 0x24020085, 0x240040c6, 0x24000086, 0x80852086, -0x7f0000f9, +0x7f0000fc, 0x91743a81, 0xcf00e1ff, 0x91743a81, -0xd101e102, -0x21004200, -0x1f01e1e1, +0xd100e102, +0x21003e00, +0x240000e1, +0x1f00e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81787a94, 0x24008081, 0x24028082, 0x80822081, @@ -114,16 +112,18 @@ const uint32_t PRU0Firmware_0[] = { 0x228d0083, 0x24000000, 0x2f05138a, -0x7f0000ef, +0x7f0000ed, 0x91743a81, 0xcf00e1ff, 0x91743a81, -0xd101e102, -0x21005400, -0x1f01e1e1, +0xd100e102, +0x21005200, +0x240000e1, +0x1f00e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81787a94, 0x24008081, 0x24028082, 0x80822081, @@ -132,16 +132,18 @@ const uint32_t PRU0Firmware_0[] = { 0x228d0083, 0x24000000, 0x2f05138a, -0x7f0000ef, +0x7f0000ed, 0x91743a81, 0xcf00e1ff, 0x91743a81, -0xd101e102, +0xd100e102, 0x21006600, -0x1f01e1e1, +0x240000e1, +0x1f00e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81787a94, 0x24008081, 0x24028082, 0x80822081, @@ -150,80 +152,80 @@ const uint32_t PRU0Firmware_0[] = { 0x228d0083, 0x24000000, 0x2f05138a, -0x7f0000ef, +0x7f0000ed, 0xf1a42a84, 0xc90fe402, -0x24007c8d, +0x24007e8d, 0x20830000, 0xf1082a84, 0x5100c408, 0x6911c403, -0x2400868d, +0x2400888d, 0x20830000, -0x2400c48d, +0x2400c68d, 0x24050c84, 0xe1080a84, 0x20830000, 0x20830000, 0xf1d82a8e, 0x2400006e, -0x24008a8d, +0x24008c8d, 0x20830000, 0xf1e40a6e, -0x24008d8d, +0x24008f8d, 0x20830000, 0x1e0efefe, 0x1e2efefe, -0x2400918d, +0x2400938d, 0x20830000, 0xf1940a50, -0x2400948d, +0x2400968d, 0x20830000, 0xf1950a70, -0x2400978d, +0x2400998d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x24009f8d, +0x2400a18d, 0x20830000, -0x2400c48d, +0x2400c68d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100a400, +0x2100a600, 0x1f08f0f0, -0x2400a68d, +0x2400a88d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100ab00, +0x2100ad00, 0x1d00f0f0, -0x2400ad8d, +0x2400af8d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b200, +0x2100b400, 0x1d01f0f0, -0x2400b48d, +0x2400b68d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100b900, +0x2100bb00, 0x1d05f0f0, -0x2400bb8d, +0x2400bd8d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c000, +0x2100c200, 0x1d04f0f0, -0x2400dc8d, +0x2400de8d, 0x24050084, 0xe1080a84, 0x20830000, @@ -231,83 +233,83 @@ const uint32_t PRU0Firmware_0[] = { 0xe10a0a84, 0x24000085, 0x01088585, -0x90851984, +0x90851884, 0x1e6e8484, -0x80851984, -0x2400cd8d, +0x80851884, +0x2400cf8d, 0x20830000, 0x24020085, -0x240020c6, +0x240010c6, 0x24000086, 0x80852086, -0x2400d38d, +0x2400d58d, 0x20830000, 0x24000085, 0x01088585, -0x90851984, +0x90851884, 0xc86e8402, -0x2100da00, -0x2400788d, +0x2100dc00, +0x24007a8d, 0x20830000, -0x2400cd8d, +0x2400cf8d, 0x20830000, 0x24000084, 0xe10a0a84, 0x24000085, 0x01088585, -0x90851984, +0x90851884, 0x1e6e8484, -0x80851984, -0x2400e58d, +0x80851884, +0x2400e78d, 0x20830000, 0x24020085, -0x240020c6, +0x240010c6, 0x24000086, 0x80852086, -0x2400eb8d, +0x2400ed8d, 0x20830000, 0x24000085, 0x01088585, -0x90851984, +0x90851884, 0xc86e8402, -0x2100f200, -0x2400f48d, +0x2100f400, +0x2400f68d, 0x20830000, -0x2400e58d, +0x2400e78d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400f88d, +0x2400fa8d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401008d, +0x2401028d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401048d, +0x2401068d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2400c48d, +0x2400c68d, 0x20830000, 0xf1082a84, 0x6911c403, -0x2400788d, +0x24007a8d, 0x20830000, -0x24010a8d, +0x24010c8d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401578d, +0x2401598d, 0x20830000, -0x2401108d, +0x2401128d, 0x20830000, 0xf1082a84, 0x6913c403, -0x2401538d, +0x2401558d, 0x20830000, -0x2401168d, +0x2401188d, 0x20830000, 0xf1082a84, 0x6914c402, @@ -320,7 +322,7 @@ const uint32_t PRU0Firmware_0[] = { 0xf1082a84, 0x6916c402, 0x20830000, -0x2401238d, +0x2401258d, 0x20830000, 0xf1082a84, 0x6917c402, @@ -341,72 +343,72 @@ const uint32_t PRU0Firmware_0[] = { 0xf1082a84, 0x691bc402, 0x20830000, -0x2401388d, +0x24013a8d, 0x20830000, 0xf1082a84, 0x691cc402, 0x20830000, -0x24013d8d, +0x24013f8d, 0x20830000, 0xf1082a84, 0x691dc403, -0x24035c8d, +0x2403548d, 0x20830000, -0x2401438d, +0x2401458d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24036f8d, +0x2403678d, 0x20830000, -0x2401498d, +0x24014b8d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403858d, +0x24037d8d, 0x20830000, -0x24014f8d, +0x2401518d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c991, -0x24015b8d, +0x2401d191, +0x24015d8d, 0x20830000, 0x1f02f0f0, -0x24021791, -0x24015b8d, +0x24021b91, +0x24015d8d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x24015f8d, +0x2401618d, 0x20830000, 0xd108f003, 0x24007f84, -0x21016300, +0x21016500, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401678d, +0x2401698d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21016d00, +0x21016f00, 0x1d08cdcd, -0x21017500, +0x21017700, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21017300, +0x21017500, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x2401798d, +0x24017b8d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -414,203 +416,201 @@ const uint32_t PRU0Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401858d, +0x2401878d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x2401898d, +0x24018b8d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24018d8d, +0x24018f8d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21019200, +0x21019400, 0x1c2efefe, 0x01010f0f, -0x2401958d, +0x2401978d, 0x20830000, 0x1e0efefe, -0x2401988d, -0x20830000, 0x24019a8d, 0x20830000, -0x1c0efefe, -0x61080f03, -0x2401a08d, -0x20830000, -0x24018d8d, +0x24019c8d, 0x20830000, +0x1c0efefe, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, 0x2401a78d, 0x20830000, +0x24018f8d, +0x20830000, +0x2401a98d, +0x20830000, 0x1e0efefe, 0x11000f0f, -0x2401ab8d, +0x2401ad8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101af00, +0x2101b100, 0x1f03f0f0, -0x2401b18d, +0x2401b38d, 0x20830000, 0x1c0efefe, +0xd103f011, +0xc902f003, +0xc908f007, +0x51014f06, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f009, 0xc908f005, 0x51014f04, 0x01014f4f, -0x24018d8d, +0x24018f8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401c48d, +0x2401c78d, 0x20830000, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1c2efcfc, +0xe1003d9c, 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101cd00, +0x2101d500, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401d18d, +0x2401d98d, 0x20830000, 0x1e0efefe, -0x2401d48d, -0x20830000, -0x2401d68d, -0x20830000, -0x1c0efefe, -0x61080f03, 0x2401dc8d, 0x20830000, -0x2401c98d, +0x2401de8d, 0x20830000, +0x1c0efefe, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2401e38d, +0x2401e98d, +0x20830000, +0x2401d18d, +0x20830000, +0x2401eb8d, 0x20830000, 0x1e0efefe, -0x2401e68d, +0x2401ee8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101ea00, +0x2101f200, 0x1f03f0f0, 0xd105f003, -0x2401ef8d, +0x2401f78d, 0x20830000, -0x2402018d, +0x2402078d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f019, +0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2403468d, +0x24033e8d, 0x20830000, 0xf04f0b2f, -0x2401c98d, +0x2401d18d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x2403468d, +0x24033e8d, 0x20830000, -0x2402128d, +0x2402168d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x24021e8d, +0x2402228d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402228d, +0x2402268d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21022600, +0x21022a00, 0x13012f2f, 0x01010f0f, -0x2402298d, +0x24022d8d, 0x20830000, 0x1c0efefe, -0x61080f17, +0x61080f13, 0x01014f4f, -0xd105f00c, -0x606f4f0b, -0xc904f00a, +0xd105f00a, +0x606f4f09, +0xc904f008, 0x2402468d, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, 0x2402438d, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x24021c8d, +0x2402208d, 0x20830000, -0x1e2efefe, +0x1c2efefe, 0x2402498d, 0x20830000, 0x1e2efefe, @@ -631,20 +631,20 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x2403468d, +0x24033e8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x2403468d, +0x24033e8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x24021c8d, +0x2402208d, 0x20830000, 0xc9075103, 0x1e2efefe, @@ -660,16 +660,16 @@ const uint32_t PRU0Firmware_0[] = { 0x2402748d, 0x20830000, 0x1c0efefe, -0x61080f03, -0x24027a8d, -0x20830000, -0x2402678d, -0x20830000, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, +0x24027f8d, +0x20830000, +0x2402678d, +0x20830000, 0x2402818d, 0x20830000, 0x1e0efefe, @@ -682,106 +682,98 @@ const uint32_t PRU0Firmware_0[] = { 0xd105f003, 0x24028d8d, 0x20830000, -0x24029f8d, +0x24029d8d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f019, +0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401c98d, +0x2401d18d, 0x20830000, 0xf04f0b51, 0x2402678d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401c98d, +0x2401d18d, 0x20830000, -0x2402b08d, +0x2402ac8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2402bc8d, +0x2402b88d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402c08d, +0x2402bc8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102c400, +0x2102c000, 0x13016f6f, 0x01010f0f, -0x2402c78d, +0x2402c38d, 0x20830000, 0x1c0efefe, -0x61080f17, +0x61080f13, 0x01014f4f, -0xd105f00c, -0x606f4f0b, -0xc904f00a, -0x2402e48d, +0xd105f00a, +0x606f4f09, +0xc904f008, +0x2402dc8d, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402e18d, +0x2402d98d, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402ba8d, +0x2402b68d, 0x20830000, -0x1e2efefe, -0x2402e78d, +0x1c2efefe, +0x2402df8d, 0x20830000, 0x1e2efefe, -0x2402e78d, +0x2402df8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402eb8d, +0x2402e38d, 0x20830000, 0xd105f003, -0x2402f08d, +0x2402e88d, 0x20830000, -0x2402f88d, +0x2402f08d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -789,55 +781,55 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x2402178d, +0x24021b8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x2402178d, +0x24021b8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408109d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2402ba8d, +0x2402b68d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x21030900, +0x21030100, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x24030d8d, +0x2403058d, 0x20830000, 0x1e0efefe, -0x2403108d, +0x2403088d, 0x20830000, -0x2403128d, +0x24030a8d, 0x20830000, 0x1c0efefe, 0x61080f03, -0x2403188d, +0x2403108d, 0x20830000, -0x2403058d, +0x2402fd8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x24031c8d, +0x2403148d, 0x20830000, 0x1e0efefe, -0x24031f8d, +0x2403178d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21032300, +0x21031b00, 0x1f03f0f0, 0xd105f003, -0x2403288d, +0x2403208d, 0x20830000, -0x2403348d, +0x24032c8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -845,11 +837,11 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401c98d, +0x2401d18d, 0x20830000, -0x2401858d, +0x2401878d, 0x1f08cdcd, -0x24021791, +0x24021b91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -859,52 +851,52 @@ const uint32_t PRU0Firmware_0[] = { 0xf04f0b2f, 0x2402678d, 0x20830000, -0x2401858d, +0x2401878d, 0x1f08cdcd, -0x2402b591, +0x2402b191, 0x20830000, -0x2403428d, +0x24033a8d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x24034c8d, +0x2403448d, 0x20830000, -0x2403548d, +0x24034c8d, 0x20830000, 0x1e0efefe, -0x24034f8d, +0x2403478d, 0x20830000, 0x1e2efefe, 0x24050084, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x1e2efefe, -0x2403578d, +0x24034f8d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2400008f, 0x240a00cf, -0x2403608d, +0x2403588d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403668d, +0x24035e8d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x504f0f03, 0x24050584, -0x21036b00, +0x21036300, 0x24050684, 0x2400008f, 0x240000cf, @@ -912,23 +904,23 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, -0x2403738d, +0x24036b8d, 0x20830000, 0x1e0efefe, -0x2403768d, +0x24036e8d, 0x20830000, -0x2403788d, +0x2403708d, 0x20830000, 0x1c0efefe, 0x01010f0f, -0x24037c8d, +0x2403748d, 0x20830000, 0x606f0f03, -0x2403818d, +0x2403798d, 0x20830000, -0x2403738d, +0x24036b8d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050784, 0xe1080a84, 0x20830000, @@ -937,18 +929,18 @@ const uint32_t PRU0Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403908d, +0x2403888d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index 63424ecc8..8cb346c46 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -41,7 +41,7 @@ const uint32_t PRU1Firmware_0[] = { 0x240000cb, 0x2403008c, 0x240000cc, -0x2400788d, +0x24007a8d, 0x240000cd, 0x240000ce, 0x2400008e, @@ -56,7 +56,7 @@ const uint32_t PRU1Firmware_0[] = { 0x240000d3, 0x24000093, 0x24000000, -0x2f05138a, +0x2f05938a, 0x2effbd80, 0x24000081, 0x010c8181, @@ -78,152 +78,154 @@ const uint32_t PRU1Firmware_0[] = { 0x91003a81, 0x1f00e1e1, 0x81003a81, -0x24000083, -0x90837994, -0x91107a82, -0x2409c3f4, -0x240000f5, +0x91107a94, 0x00d6f4f4, 0x0300f5f5, -0x81787a94, -0x5103960b, -0x5102961c, -0x5101962d, -0x91003a81, -0x1d00e1e1, -0x81003a81, +0x81807a94, +0x91703a81, +0x1f02e1e1, +0x81703a81, +0x51039608, +0x5102961b, +0x5101962e, 0x24020085, 0x240040c6, 0x24000086, 0x80852086, -0x7f0000f9, +0x7f0000fc, 0x91743a81, -0xcf00e1ff, +0xcf01e1ff, 0x91743a81, 0xd101e102, -0x21004200, +0x21003e00, +0x240000e1, 0x1f01e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81807a94, 0x24008081, 0x24028082, 0x80822081, 0x24000000, -0x2e85138a, +0x2e85938a, 0x228d0083, 0x24000000, -0x2f05138a, -0x7f0000ef, +0x2f05938a, +0x7f0000ed, 0x91743a81, -0xcf00e1ff, +0xcf01e1ff, 0x91743a81, 0xd101e102, -0x21005400, +0x21005200, +0x240000e1, 0x1f01e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81807a94, 0x24008081, 0x24028082, 0x80822081, 0x24000000, -0x2e85138a, +0x2e85938a, 0x228d0083, 0x24000000, -0x2f05138a, -0x7f0000ef, +0x2f05938a, +0x7f0000ed, 0x91743a81, -0xcf00e1ff, +0xcf01e1ff, 0x91743a81, 0xd101e102, 0x21006600, +0x240000e1, 0x1f01e1e1, 0x81743a81, 0x00d6f4f4, 0x0300f5f5, +0x81807a94, 0x24008081, 0x24028082, 0x80822081, 0x24000000, -0x2e85138a, +0x2e85938a, 0x228d0083, 0x24000000, -0x2f05138a, -0x7f0000ef, +0x2f05938a, +0x7f0000ed, 0xf1a42a84, 0xc90fe402, -0x24007c8d, +0x24007e8d, 0x20830000, 0xf1082a84, 0x5100c408, 0x6911c403, -0x2400868d, +0x2400888d, 0x20830000, -0x2400c48d, +0x2400c68d, 0x24050c84, 0xe1080a84, 0x20830000, 0x20830000, 0xf1d82a8e, 0x2400006e, -0x24008a8d, +0x24008c8d, 0x20830000, 0xf1e40a6e, -0x24008d8d, +0x24008f8d, 0x20830000, 0x1e0efefe, 0x1e2efefe, -0x2400918d, +0x2400938d, 0x20830000, 0xf1940a50, -0x2400948d, +0x2400968d, 0x20830000, 0xf1950a70, -0x2400978d, +0x2400998d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x24009f8d, +0x2400a18d, 0x20830000, -0x2400c48d, +0x2400c68d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100a400, +0x2100a600, 0x1f08f0f0, -0x2400a68d, +0x2400a88d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100ab00, +0x2100ad00, 0x1d00f0f0, -0x2400ad8d, +0x2400af8d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b200, +0x2100b400, 0x1d01f0f0, -0x2400b48d, +0x2400b68d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100b900, +0x2100bb00, 0x1d05f0f0, -0x2400bb8d, +0x2400bd8d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c000, +0x2100c200, 0x1d04f0f0, -0x2400dc8d, +0x2400de8d, 0x24050084, 0xe1080a84, 0x20830000, @@ -234,22 +236,22 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400cd8d, +0x2400cf8d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400d38d, +0x2400d58d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100da00, -0x2400788d, +0x2100dc00, +0x24007a8d, 0x20830000, -0x2400cd8d, +0x2400cf8d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -258,56 +260,56 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400e58d, +0x2400e78d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400eb8d, +0x2400ed8d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100f200, -0x2400f48d, +0x2100f400, +0x2400f68d, 0x20830000, -0x2400e58d, +0x2400e78d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400f88d, +0x2400fa8d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401008d, +0x2401028d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401048d, +0x2401068d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2400c48d, +0x2400c68d, 0x20830000, 0xf1082a84, 0x6911c403, -0x2400788d, +0x24007a8d, 0x20830000, -0x24010a8d, +0x24010c8d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401578d, +0x2401598d, 0x20830000, -0x2401108d, +0x2401128d, 0x20830000, 0xf1082a84, 0x6913c403, -0x2401538d, +0x2401558d, 0x20830000, -0x2401168d, +0x2401188d, 0x20830000, 0xf1082a84, 0x6914c402, @@ -320,7 +322,7 @@ const uint32_t PRU1Firmware_0[] = { 0xf1082a84, 0x6916c402, 0x20830000, -0x2401238d, +0x2401258d, 0x20830000, 0xf1082a84, 0x6917c402, @@ -341,72 +343,72 @@ const uint32_t PRU1Firmware_0[] = { 0xf1082a84, 0x691bc402, 0x20830000, -0x2401388d, +0x24013a8d, 0x20830000, 0xf1082a84, 0x691cc402, 0x20830000, -0x24013d8d, +0x24013f8d, 0x20830000, 0xf1082a84, 0x691dc403, -0x24035c8d, +0x2403548d, 0x20830000, -0x2401438d, +0x2401458d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24036f8d, +0x2403678d, 0x20830000, -0x2401498d, +0x24014b8d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403858d, +0x24037d8d, 0x20830000, -0x24014f8d, +0x2401518d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c991, -0x24015b8d, +0x2401d191, +0x24015d8d, 0x20830000, 0x1f02f0f0, -0x24021791, -0x24015b8d, +0x24021b91, +0x24015d8d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x24015f8d, +0x2401618d, 0x20830000, 0xd108f003, 0x24007f84, -0x21016300, +0x21016500, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401678d, +0x2401698d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21016d00, +0x21016f00, 0x1d08cdcd, -0x21017500, +0x21017700, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21017300, +0x21017500, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x2401798d, +0x24017b8d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -414,203 +416,201 @@ const uint32_t PRU1Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401858d, +0x2401878d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x2401898d, +0x24018b8d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24018d8d, +0x24018f8d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21019200, +0x21019400, 0x1c2efefe, 0x01010f0f, -0x2401958d, +0x2401978d, 0x20830000, 0x1e0efefe, -0x2401988d, -0x20830000, 0x24019a8d, 0x20830000, -0x1c0efefe, -0x61080f03, -0x2401a08d, -0x20830000, -0x24018d8d, +0x24019c8d, 0x20830000, +0x1c0efefe, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, 0x2401a78d, 0x20830000, +0x24018f8d, +0x20830000, +0x2401a98d, +0x20830000, 0x1e0efefe, 0x11000f0f, -0x2401ab8d, +0x2401ad8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101af00, +0x2101b100, 0x1f03f0f0, -0x2401b18d, +0x2401b38d, 0x20830000, 0x1c0efefe, +0xd103f011, +0xc902f003, +0xc908f007, +0x51014f06, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f009, 0xc908f005, 0x51014f04, 0x01014f4f, -0x24018d8d, +0x24018f8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401c48d, +0x2401c78d, 0x20830000, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1c2efcfc, +0xe1003d9c, 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101cd00, +0x2101d500, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401d18d, +0x2401d98d, 0x20830000, 0x1e0efefe, -0x2401d48d, -0x20830000, -0x2401d68d, -0x20830000, -0x1c0efefe, -0x61080f03, 0x2401dc8d, 0x20830000, -0x2401c98d, +0x2401de8d, 0x20830000, +0x1c0efefe, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2401e38d, +0x2401e98d, +0x20830000, +0x2401d18d, +0x20830000, +0x2401eb8d, 0x20830000, 0x1e0efefe, -0x2401e68d, +0x2401ee8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101ea00, +0x2101f200, 0x1f03f0f0, 0xd105f003, -0x2401ef8d, +0x2401f78d, 0x20830000, -0x2402018d, +0x2402078d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f019, +0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2403468d, +0x24033e8d, 0x20830000, 0xf04f0b2f, -0x2401c98d, +0x2401d18d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x2403468d, +0x24033e8d, 0x20830000, -0x2402128d, +0x2402168d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x24021e8d, +0x2402228d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402228d, +0x2402268d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21022600, +0x21022a00, 0x13012f2f, 0x01010f0f, -0x2402298d, +0x24022d8d, 0x20830000, 0x1c0efefe, -0x61080f17, +0x61080f13, 0x01014f4f, -0xd105f00c, -0x606f4f0b, -0xc904f00a, +0xd105f00a, +0x606f4f09, +0xc904f008, 0x2402468d, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, 0x2402438d, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x24021c8d, +0x2402208d, 0x20830000, -0x1e2efefe, +0x1c2efefe, 0x2402498d, 0x20830000, 0x1e2efefe, @@ -631,20 +631,20 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x2403468d, +0x24033e8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x2403468d, +0x24033e8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x24021c8d, +0x2402208d, 0x20830000, 0xc9075103, 0x1e2efefe, @@ -660,16 +660,16 @@ const uint32_t PRU1Firmware_0[] = { 0x2402748d, 0x20830000, 0x1c0efefe, -0x61080f03, -0x24027a8d, -0x20830000, -0x2402678d, -0x20830000, +0x61080f08, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, +0x24027f8d, +0x20830000, +0x2402678d, +0x20830000, 0x2402818d, 0x20830000, 0x1e0efefe, @@ -682,106 +682,98 @@ const uint32_t PRU1Firmware_0[] = { 0xd105f003, 0x24028d8d, 0x20830000, -0x24029f8d, +0x24029d8d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, -0xd103f019, +0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401c98d, +0x2401d18d, 0x20830000, 0xf04f0b51, 0x2402678d, 0x20830000, 0x1c0efefe, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401c98d, +0x2401d18d, 0x20830000, -0x2402b08d, +0x2402ac8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2402bc8d, +0x2402b88d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402c08d, +0x2402bc8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102c400, +0x2102c000, 0x13016f6f, 0x01010f0f, -0x2402c78d, +0x2402c38d, 0x20830000, 0x1c0efefe, -0x61080f17, +0x61080f13, 0x01014f4f, -0xd105f00c, -0x606f4f0b, -0xc904f00a, -0x2402e48d, +0xd105f00a, +0x606f4f09, +0xc904f008, +0x2402dc8d, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402e18d, +0x2402d98d, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x24ffffdb, -0x24fdff9b, -0x10fbfcfc, +0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402ba8d, +0x2402b68d, 0x20830000, -0x1e2efefe, -0x2402e78d, +0x1c2efefe, +0x2402df8d, 0x20830000, 0x1e2efefe, -0x2402e78d, +0x2402df8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402eb8d, +0x2402e38d, 0x20830000, 0xd105f003, -0x2402f08d, +0x2402e88d, 0x20830000, -0x2402f88d, +0x2402f08d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -789,55 +781,55 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x2402178d, +0x24021b8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x2402178d, +0x24021b8d, 0x20830000, 0x2450d0dd, -0x2408189d, +0x2408149d, 0xf1003d9c, -0x1f09fcfc, +0x1e2efcfc, 0xe1003d9c, -0x2402ba8d, +0x2402b68d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x21030900, +0x21030100, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x24030d8d, +0x2403058d, 0x20830000, 0x1e0efefe, -0x2403108d, +0x2403088d, 0x20830000, -0x2403128d, +0x24030a8d, 0x20830000, 0x1c0efefe, 0x61080f03, -0x2403188d, +0x2403108d, 0x20830000, -0x2403058d, +0x2402fd8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x24031c8d, +0x2403148d, 0x20830000, 0x1e0efefe, -0x24031f8d, +0x2403178d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21032300, +0x21031b00, 0x1f03f0f0, 0xd105f003, -0x2403288d, +0x2403208d, 0x20830000, -0x2403348d, +0x24032c8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -845,11 +837,11 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401c98d, +0x2401d18d, 0x20830000, -0x2401858d, +0x2401878d, 0x1f08cdcd, -0x24021791, +0x24021b91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -859,52 +851,52 @@ const uint32_t PRU1Firmware_0[] = { 0xf04f0b2f, 0x2402678d, 0x20830000, -0x2401858d, +0x2401878d, 0x1f08cdcd, -0x2402b591, +0x2402b191, 0x20830000, -0x2403428d, +0x24033a8d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x24034c8d, +0x2403448d, 0x20830000, -0x2403548d, +0x24034c8d, 0x20830000, 0x1e0efefe, -0x24034f8d, +0x2403478d, 0x20830000, 0x1e2efefe, 0x24050084, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x1e2efefe, -0x2403578d, +0x24034f8d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0x2400008f, 0x240a00cf, -0x2403608d, +0x2403588d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403668d, +0x24035e8d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x504f0f03, 0x24050584, -0x21036b00, +0x21036300, 0x24050684, 0x2400008f, 0x240000cf, @@ -912,23 +904,23 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, -0x2403738d, +0x24036b8d, 0x20830000, 0x1e0efefe, -0x2403768d, +0x24036e8d, 0x20830000, -0x2403788d, +0x2403708d, 0x20830000, 0x1c0efefe, 0x01010f0f, -0x24037c8d, +0x2403748d, 0x20830000, 0x606f0f03, -0x2403818d, +0x2403798d, 0x20830000, -0x2403738d, +0x24036b8d, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050784, 0xe1080a84, 0x20830000, @@ -937,18 +929,18 @@ const uint32_t PRU1Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403908d, +0x2403888d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400dc8d, +0x2400de8d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400dc8d, +0x2400de8d, 0x24050084, 0xe1080a84, 0x20830000, From b65a54e6436c9c58fa4de8b99afb33f4e4fdb374 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 13:48:28 +0530 Subject: [PATCH 08/29] examples: pru_i2c: answer every command, fix bus recovery, release idle SDA Found on pru-simulator while checking the commands beyond TX. - Dispatcher: the SMBus stub checks (QUICK .. BLOCK_READ) only advanced to the next check from some stubs, so dispatch stopped at ICSS_SMBUS_QUICK_CHECK for every command after TX. READ_SCL, RESET_SLAVE and LOOPBACK were unreachable, and any SMBus or unknown command left the firmware spinning there until reset. Replace the stub chain with one range check: SMBus commands (not implemented) get INVALID_COMMAND, everything else goes on to READ_SCL / RESET_SLAVE / LOOPBACK and then INVALID_COMMAND. - RESET_SLAVE counted falling edges and ended with SCL low: 8 full SCL pulses and a bus left low. It also kept driving SDA high, fighting the stuck target it is meant to free. Release SDA, give 9 full pulses and end with SCL high. - SDA is now released whenever the bus is idle (after setup, after STOP, after RESET) and taken back at the start of each transfer, so an idle master never drives SDA high against a target holding it low. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/firmware/pru_i2c_main.asm | 187 +++++---------------- 1 file changed, 39 insertions(+), 148 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 9f304a23d..5d2401259 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -370,6 +370,10 @@ SETUP_I2C_INST_ID: SETUP_I2C_SCL_SDA_HIGH: SET_SCL_PIN_HIGH SET_SDA_PIN_HIGH + ; SDA is released whenever the bus is idle and taken back at the start of + ; each transfer (SET_SCL_SDA_HIGH), so the master never drives SDA high + ; against a target that holds it low (e.g. a stuck bus before RESET_SLAVE). + SET_SDA_PIN_INPUT_DIRECTION UPDATE_NEXT_LOCAL_STATE SETUP_I2C_TX_FIFO_SIZE STATE_TASK_OVER @@ -621,7 +625,11 @@ ICSS_I2C_RESET_CMD_CHECK_RETURN: ; set the value on iep gpo to low value for pulling the line ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RESET_SCL_SDA_HIGH: - SET_OUTPUT_PIN_VALUE_HIGH RAISE_HOST_INTERRUPT_MEM_FOR_ERROR + SET_SDA_PIN_HIGH + SET_SCL_PIN_HIGH + SET_SDA_PIN_INPUT_DIRECTION ; bus idle: release SDA + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_ERROR + STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; checks if the setup command has been passed. @@ -685,151 +693,24 @@ ICSS_I2C_TX_CMD_CHECK: STATE_TASK_OVER ICSS_I2C_TX_CMD_CHECK_RETURN: - UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_QUICK_CHECK + UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_CMD_CHECK STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus Quick command has been passed. -; if Quick command is passed then start Quick data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_QUICK_CHECK: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_QUICK_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE QUICK_CMD_MODE - STATE_TASK_OVER - -ICSS_SMBUS_QUICK_CMD_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_SEND_BYTE - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus send byte command has been passed. -; if send byte command is passed then start send byte data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_SEND_BYTE: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_SEND_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_SEND_BYTE_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE SEND_BYTE_MODE - STATE_TASK_OVER - -ICSS_SMBUS_SEND_BYTE_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_RECEIVE_BYTE - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus receive byte command has been passed. -; if receive byte command is passed then start receive byte data procedure -; else check for another command ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_RECEIVE_BYTE: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_RECEIVE_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_RECEIVE_BYTE_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE RECEIVE_BYTE_MODE - STATE_TASK_OVER - -ICSS_SMBUS_RECEIVE_BYTE_CHECK_NEXT: - UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_WRITE_BYTE - STATE_TASK_OVER - +; The SMBus commands (ICSS_SMBUS_QUICK_CMD .. ICSS_SMBUS_BLOCK_READ_CMD) are +; not implemented yet: answer them with INVALID_COMMAND. Every other command +; is passed on to the next check, so READ_SCL, RESET_SLAVE and LOOPBACK stay +; reachable and an unknown command is answered instead of stalling the +; dispatcher. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus write byte command has been passed. -; if write byte command is passed then start write byte data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_WRITE_BYTE: +ICSS_SMBUS_CMD_CHECK: LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_WRITE_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_WRITE_BYTE_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE WRITE_BYTE_MODE - STATE_TASK_OVER - -ICSS_SMBUS_WRITE_BYTE_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_READ_BYTE - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus read byte command has been passed. -; if read byte command is passed then start read byte data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -ICSS_SMBUS_READ_BYTE: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_READ_BYTE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_READ_BYTE_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE READ_BYTE_MODE - STATE_TASK_OVER - -ICSS_SMBUS_READ_BYTE_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_WRITE_WORD - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus write word command has been passed. -; if write word command is passed then start write word data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_WRITE_WORD: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_WRITE_WORD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_WRITE_WORD_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE WRITE_WORD_MODE - STATE_TASK_OVER - -ICSS_SMBUS_WRITE_WORD_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_READ_WORD - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus read word command has been passed. -; if read word command is passed then start read word data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_READ_WORD: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_READ_WORD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_READ_WORD_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE READ_WORD_MODE - STATE_TASK_OVER - -ICSS_SMBUS_READ_WORD_CHECK_NEXT: - ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_BLOCK_WRITE - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus block write command has been passed. -; if block write command is passed then start block write data procedure -; else check for another command -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -ICSS_SMBUS_BLOCK_WRITE: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_BLOCK_WRITE_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_WRITE_CMD - ;;;; UPDATE_NEXT_LOCAL_STATE BLOCK_WRITE_MODE + QBLT ICSS_SMBUS_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_READ_CMD + QBGT ICSS_SMBUS_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD + UPDATE_NEXT_LOCAL_STATE FIRMWARE_READY_COMMAND_ERROR STATE_TASK_OVER -ICSS_SMBUS_BLOCK_WRITE_CHECK_NEXT: - UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_BLOCK_READ - STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; checks if the smbus block read command has been passed. -; if block read command is passed then start block read data procedure -; else no matching command has been found -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -ICSS_SMBUS_BLOCK_READ: - LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 - QBNE ICSS_SMBUS_BLOCK_READ_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_READ_CMD - ;;; UPDATE_NEXT_LOCAL_STATE BLOCK_READ_MODE - STATE_TASK_OVER - -ICSS_SMBUS_BLOCK_READ_CHECK_NEXT: +ICSS_SMBUS_CMD_CHECK_NEXT: UPDATE_NEXT_LOCAL_STATE ICSS_I2C_READ_SCL_CMD_CHECK STATE_TASK_OVER @@ -915,7 +796,11 @@ RX_MODE: ; set the value on iep gpo to low value for pulling the line ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SET_SCL_SDA_HIGH: - SET_OUTPUT_PIN_VALUE_HIGH SLAVE_ADDRESS_SETUP + SET_SDA_PIN_HIGH + SET_SCL_PIN_HIGH + SET_SDA_PIN_OUTPUT_DIRECTION ; take SDA back for this transfer + UPDATE_NEXT_LOCAL_STATE SLAVE_ADDRESS_SETUP + STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; read the slave address from configuration registers. @@ -1292,6 +1177,7 @@ STOP_CONDITION_SCL_HIGH: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STOP_CONDITION_SDA_HIGH: SET_SDA_PIN_HIGH + SET_SDA_PIN_INPUT_DIRECTION ; bus idle: release SDA (line stays high) LDI TEMP_REG4.w0, COMMAND_SUCCESS SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY @@ -1363,22 +1249,28 @@ READ_SCL_PIN_DONE_RETURN: RESET_SLAVE_SCL_BEGIN: LDI R15.w0, 0x0000 LDI R15.w2, 0x0900 - UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_HIGH + ; Bus recovery: make sure SDA is released so a target that holds it low + ; can let go, then clock SCL until it does. SDA stays released afterwards, + ; as on an idle bus. + SET_SDA_PIN_INPUT_DIRECTION + SET_SDA_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_LOW STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high +; make SCL high, counting one clock pulse per rising edge ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RESET_SLAVE_SCL_HIGH: SET_SCL_PIN_HIGH - UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT1 + ADD R15.b0, R15.b0, 0x01 + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT2 STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; wait to match the timing parameters ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RESET_SLAVE_SCL_WAIT1: - UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_LOW + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_HIGH STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1386,12 +1278,11 @@ RESET_SLAVE_SCL_WAIT1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RESET_SLAVE_SCL_LOW: SET_SCL_PIN_LOW - ADD R15.b0, R15.b0, 0x01 - UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT2 + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_WAIT1 STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; wait to match the timing parameters +; wait to match the timing parameters; after 9 pulses SCL is left high ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RESET_SLAVE_SCL_WAIT2: QBGT RESET_SLAVE_SCL_RETURN, R15.b0, R15.b3 @@ -1399,7 +1290,7 @@ RESET_SLAVE_SCL_WAIT2: STATE_TASK_OVER RESET_SLAVE_SCL_RETURN: - UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_HIGH + UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_LOW STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From 227de73faf104161afeea1925ddb187ba7a64d53 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 13:48:35 +0530 Subject: [PATCH 09/29] examples: pru_i2c: regenerate pru0/pru1_load_bin.h Byte-identical to the ELFs exercised on pru-simulator. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- .../firmware/am261x-lp/pru0_load_bin.h | 402 +++++++++--------- .../firmware/am261x-lp/pru1_load_bin.h | 402 +++++++++--------- 2 files changed, 396 insertions(+), 408 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index aa8be4906..5c914bca9 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -162,7 +162,7 @@ const uint32_t PRU0Firmware_0[] = { 0x6911c403, 0x2400888d, 0x20830000, -0x2400c68d, +0x2400cb8d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -176,56 +176,61 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x1e0efefe, 0x1e2efefe, -0x2400938d, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x2400988d, 0x20830000, 0xf1940a50, -0x2400968d, +0x24009b8d, 0x20830000, 0xf1950a70, -0x2400998d, +0x24009e8d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a18d, +0x2400a68d, 0x20830000, -0x2400c68d, +0x2400cb8d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100a600, +0x2100ab00, 0x1f08f0f0, -0x2400a88d, +0x2400ad8d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100ad00, +0x2100b200, 0x1d00f0f0, -0x2400af8d, +0x2400b48d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b400, +0x2100b900, 0x1d01f0f0, -0x2400b68d, +0x2400bb8d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100bb00, +0x2100c000, 0x1d05f0f0, -0x2400bd8d, +0x2400c28d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c200, +0x2100c700, 0x1d04f0f0, -0x2400de8d, +0x2400e38d, 0x24050084, 0xe1080a84, 0x20830000, @@ -236,22 +241,22 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400cf8d, +0x2400d48d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400d58d, +0x2400da8d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100dc00, +0x2100e100, 0x24007a8d, 0x20830000, -0x2400cf8d, +0x2400d48d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -260,155 +265,133 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400e78d, +0x2400ec8d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400ed8d, +0x2400f28d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100f400, -0x2400f68d, +0x2100f900, +0x2400fb8d, 0x20830000, -0x2400e78d, +0x2400ec8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400fa8d, +0x2400ff8d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401028d, +0x2401078d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401068d, +0x2401108d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2400c68d, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x2400cb8d, 0x20830000, 0xf1082a84, 0x6911c403, 0x24007a8d, 0x20830000, -0x24010c8d, +0x2401168d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401598d, +0x2401438d, 0x20830000, -0x2401128d, +0x24011c8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x2401558d, -0x20830000, -0x2401188d, -0x20830000, -0xf1082a84, -0x6914c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6915c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6916c402, -0x20830000, -0x2401258d, -0x20830000, -0xf1082a84, -0x6917c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6918c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6919c402, -0x20830000, -0x20830000, -0xf1082a84, -0x691ac402, -0x20830000, -0x20830000, -0xf1082a84, -0x691bc402, +0x24013f8d, 0x20830000, -0x24013a8d, +0x2401228d, 0x20830000, 0xf1082a84, -0x691cc402, +0x491cc404, +0x6114c403, +0x24013b8d, 0x20830000, -0x24013f8d, +0x2401298d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403548d, +0x2403488d, 0x20830000, -0x2401458d, +0x24012f8d, 0x20830000, 0xf1082a84, 0x691ec403, -0x2403678d, +0x24035b8d, 0x20830000, -0x24014b8d, +0x2401358d, 0x20830000, 0xf1082a84, 0x691fc403, -0x24037d8d, +0x2403778d, 0x20830000, -0x2401518d, +0x24013b8d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401d191, -0x24015d8d, +0x2401c091, +0x2401478d, 0x20830000, 0x1f02f0f0, -0x24021b91, -0x24015d8d, +0x24020a91, +0x2401478d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2401618d, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1c2efcfc, +0xe1003d9c, +0x2401508d, 0x20830000, 0xd108f003, 0x24007f84, -0x21016500, +0x21015400, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401698d, +0x2401588d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21016f00, +0x21015e00, 0x1d08cdcd, -0x21017700, +0x21016600, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21017500, +0x21016400, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24017b8d, +0x24016a8d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -416,32 +399,32 @@ const uint32_t PRU0Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401878d, +0x2401768d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x24018b8d, +0x24017a8d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24018f8d, +0x24017e8d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21019400, +0x21018300, 0x1c2efefe, 0x01010f0f, -0x2401978d, +0x2401868d, 0x20830000, 0x1e0efefe, -0x24019a8d, +0x2401898d, 0x20830000, -0x24019c8d, +0x24018b8d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -450,21 +433,21 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401a78d, +0x2401968d, 0x20830000, -0x24018f8d, +0x24017e8d, 0x20830000, -0x2401a98d, +0x2401988d, 0x20830000, 0x1e0efefe, 0x11000f0f, -0x2401ad8d, +0x24019c8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101b100, +0x2101a000, 0x1f03f0f0, -0x2401b38d, +0x2401a28d, 0x20830000, 0x1c0efefe, 0xd103f011, @@ -479,12 +462,12 @@ const uint32_t PRU0Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x24018f8d, +0x24017e8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401c78d, +0x2401b68d, 0x20830000, 0x2450d0dd, 0x2408109d, @@ -494,20 +477,20 @@ const uint32_t PRU0Firmware_0[] = { 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101d500, +0x2101c400, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401d98d, +0x2401c88d, 0x20830000, 0x1e0efefe, -0x2401dc8d, +0x2401cb8d, 0x20830000, -0x2401de8d, +0x2401cd8d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -516,23 +499,23 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401e98d, +0x2401d88d, 0x20830000, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2401eb8d, +0x2401da8d, 0x20830000, 0x1e0efefe, -0x2401ee8d, +0x2401dd8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101f200, +0x2101e100, 0x1f03f0f0, 0xd105f003, -0x2401f78d, +0x2401e68d, 0x20830000, -0x2402078d, +0x2401f68d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -545,10 +528,10 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x24033e8d, +0x24032d8d, 0x20830000, 0xf04f0b2f, -0x2401d18d, +0x2401c08d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -561,32 +544,32 @@ const uint32_t PRU0Firmware_0[] = { 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x24033e8d, +0x24032d8d, 0x20830000, -0x2402168d, +0x2402058d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402228d, +0x2402118d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402268d, +0x2402158d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21022a00, +0x21021900, 0x13012f2f, 0x01010f0f, -0x24022d8d, +0x24021c8d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -594,36 +577,36 @@ const uint32_t PRU0Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402468d, +0x2402358d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402438d, +0x2402328d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402208d, +0x24020f8d, 0x20830000, 0x1c2efefe, -0x2402498d, +0x2402388d, 0x20830000, 0x1e2efefe, -0x2402498d, +0x2402388d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x24024d8d, +0x24023c8d, 0x20830000, 0xd105f003, -0x2402528d, +0x2402418d, 0x20830000, -0x24025a8d, +0x2402498d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -631,33 +614,33 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x24033e8d, +0x24032d8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24033e8d, +0x24032d8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402208d, +0x24020f8d, 0x20830000, 0xc9075103, 0x1e2efefe, -0x21026b00, +0x21025a00, 0x1c2efefe, 0x09015151, 0x01010f0f, -0x24026f8d, +0x24025e8d, 0x20830000, 0x1e0efefe, -0x2402728d, +0x2402618d, 0x20830000, -0x2402748d, +0x2402638d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -666,23 +649,23 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24027f8d, +0x24026e8d, 0x20830000, -0x2402678d, +0x2402568d, 0x20830000, -0x2402818d, +0x2402708d, 0x20830000, 0x1e0efefe, -0x2402848d, +0x2402738d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21028800, +0x21027700, 0x1f03f0f0, 0xd105f003, -0x24028d8d, +0x24027c8d, 0x20830000, -0x24029d8d, +0x24028c8d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -695,10 +678,10 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401d18d, +0x2401c08d, 0x20830000, 0xf04f0b51, -0x2402678d, +0x2402568d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -711,32 +694,32 @@ const uint32_t PRU0Firmware_0[] = { 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2402ac8d, +0x24029b8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402b88d, +0x2402a78d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402bc8d, +0x2402ab8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102c000, +0x2102af00, 0x13016f6f, 0x01010f0f, -0x2402c38d, +0x2402b28d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -744,36 +727,36 @@ const uint32_t PRU0Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402dc8d, +0x2402cb8d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402d98d, +0x2402c88d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402b68d, +0x2402a58d, 0x20830000, 0x1c2efefe, -0x2402df8d, +0x2402ce8d, 0x20830000, 0x1e2efefe, -0x2402df8d, +0x2402ce8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402e38d, +0x2402d28d, 0x20830000, 0xd105f003, -0x2402e88d, +0x2402d78d, 0x20830000, -0x2402f08d, +0x2402df8d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -781,55 +764,55 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x24021b8d, +0x24020a8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24021b8d, +0x24020a8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402b68d, +0x2402a58d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x21030100, +0x2102f000, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2403058d, +0x2402f48d, 0x20830000, 0x1e0efefe, -0x2403088d, +0x2402f78d, 0x20830000, -0x24030a8d, +0x2402f98d, 0x20830000, 0x1c0efefe, 0x61080f03, -0x2403108d, +0x2402ff8d, 0x20830000, -0x2402fd8d, +0x2402ec8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x2403148d, +0x2403038d, 0x20830000, 0x1e0efefe, -0x2403178d, +0x2403068d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21031b00, +0x21030a00, 0x1f03f0f0, 0xd105f003, -0x2403208d, +0x24030f8d, 0x20830000, -0x24032c8d, +0x24031b8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -837,11 +820,11 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2401878d, +0x2401768d, 0x1f08cdcd, -0x24021b91, +0x24020a91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -849,54 +832,59 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2402678d, +0x2402568d, 0x20830000, -0x2401878d, +0x2401768d, 0x1f08cdcd, -0x2402b191, +0x2402a091, 0x20830000, -0x24033a8d, +0x2403298d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x2403448d, +0x2403338d, 0x20830000, -0x24034c8d, +0x2403408d, 0x20830000, 0x1e0efefe, -0x2403478d, +0x2403368d, 0x20830000, 0x1e2efefe, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, 0x24050084, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x1e2efefe, -0x24034f8d, +0x2403438d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2400008f, 0x240a00cf, -0x2403588d, +0x24034c8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x24035e8d, +0x2403528d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x504f0f03, 0x24050584, -0x21036300, +0x21035700, 0x24050684, 0x2400008f, 0x240000cf, @@ -904,23 +892,29 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, +0x2450d0dd, +0x2408109d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x1e2efefe, 0x24036b8d, 0x20830000, 0x1e0efefe, +0x01010f0f, 0x24036e8d, 0x20830000, -0x2403708d, +0x2403658d, 0x20830000, 0x1c0efefe, -0x01010f0f, -0x2403748d, +0x2403698d, 0x20830000, 0x606f0f03, -0x2403798d, +0x2403738d, 0x20830000, 0x24036b8d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050784, 0xe1080a84, 0x20830000, @@ -929,18 +923,18 @@ const uint32_t PRU0Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403888d, +0x2403828d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index 8cb346c46..7447d422c 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -162,7 +162,7 @@ const uint32_t PRU1Firmware_0[] = { 0x6911c403, 0x2400888d, 0x20830000, -0x2400c68d, +0x2400cb8d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -176,56 +176,61 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x1e0efefe, 0x1e2efefe, -0x2400938d, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x2400988d, 0x20830000, 0xf1940a50, -0x2400968d, +0x24009b8d, 0x20830000, 0xf1950a70, -0x2400998d, +0x24009e8d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a18d, +0x2400a68d, 0x20830000, -0x2400c68d, +0x2400cb8d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100a600, +0x2100ab00, 0x1f08f0f0, -0x2400a88d, +0x2400ad8d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100ad00, +0x2100b200, 0x1d00f0f0, -0x2400af8d, +0x2400b48d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b400, +0x2100b900, 0x1d01f0f0, -0x2400b68d, +0x2400bb8d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100bb00, +0x2100c000, 0x1d05f0f0, -0x2400bd8d, +0x2400c28d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c200, +0x2100c700, 0x1d04f0f0, -0x2400de8d, +0x2400e38d, 0x24050084, 0xe1080a84, 0x20830000, @@ -236,22 +241,22 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400cf8d, +0x2400d48d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400d58d, +0x2400da8d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100dc00, +0x2100e100, 0x24007a8d, 0x20830000, -0x2400cf8d, +0x2400d48d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -260,155 +265,133 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400e78d, +0x2400ec8d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400ed8d, +0x2400f28d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100f400, -0x2400f68d, +0x2100f900, +0x2400fb8d, 0x20830000, -0x2400e78d, +0x2400ec8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400fa8d, +0x2400ff8d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401028d, +0x2401078d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401068d, +0x2401108d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2400c68d, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x2400cb8d, 0x20830000, 0xf1082a84, 0x6911c403, 0x24007a8d, 0x20830000, -0x24010c8d, +0x2401168d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401598d, +0x2401438d, 0x20830000, -0x2401128d, +0x24011c8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x2401558d, -0x20830000, -0x2401188d, -0x20830000, -0xf1082a84, -0x6914c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6915c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6916c402, -0x20830000, -0x2401258d, -0x20830000, -0xf1082a84, -0x6917c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6918c402, -0x20830000, -0x20830000, -0xf1082a84, -0x6919c402, -0x20830000, -0x20830000, -0xf1082a84, -0x691ac402, -0x20830000, -0x20830000, -0xf1082a84, -0x691bc402, +0x24013f8d, 0x20830000, -0x24013a8d, +0x2401228d, 0x20830000, 0xf1082a84, -0x691cc402, +0x491cc404, +0x6114c403, +0x24013b8d, 0x20830000, -0x24013f8d, +0x2401298d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403548d, +0x2403488d, 0x20830000, -0x2401458d, +0x24012f8d, 0x20830000, 0xf1082a84, 0x691ec403, -0x2403678d, +0x24035b8d, 0x20830000, -0x24014b8d, +0x2401358d, 0x20830000, 0xf1082a84, 0x691fc403, -0x24037d8d, +0x2403778d, 0x20830000, -0x2401518d, +0x24013b8d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401d191, -0x24015d8d, +0x2401c091, +0x2401478d, 0x20830000, 0x1f02f0f0, -0x24021b91, -0x24015d8d, +0x24020a91, +0x2401478d, 0x20830000, 0x1e2efefe, 0x1e0efefe, -0x2401618d, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1c2efcfc, +0xe1003d9c, +0x2401508d, 0x20830000, 0xd108f003, 0x24007f84, -0x21016500, +0x21015400, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401698d, +0x2401588d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21016f00, +0x21015e00, 0x1d08cdcd, -0x21017700, +0x21016600, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21017500, +0x21016400, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24017b8d, +0x24016a8d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -416,32 +399,32 @@ const uint32_t PRU1Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401878d, +0x2401768d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x24018b8d, +0x24017a8d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24018f8d, +0x24017e8d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21019400, +0x21018300, 0x1c2efefe, 0x01010f0f, -0x2401978d, +0x2401868d, 0x20830000, 0x1e0efefe, -0x24019a8d, +0x2401898d, 0x20830000, -0x24019c8d, +0x24018b8d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -450,21 +433,21 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401a78d, +0x2401968d, 0x20830000, -0x24018f8d, +0x24017e8d, 0x20830000, -0x2401a98d, +0x2401988d, 0x20830000, 0x1e0efefe, 0x11000f0f, -0x2401ad8d, +0x24019c8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101b100, +0x2101a000, 0x1f03f0f0, -0x2401b38d, +0x2401a28d, 0x20830000, 0x1c0efefe, 0xd103f011, @@ -479,12 +462,12 @@ const uint32_t PRU1Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x24018f8d, +0x24017e8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401c78d, +0x2401b68d, 0x20830000, 0x2450d0dd, 0x2408149d, @@ -494,20 +477,20 @@ const uint32_t PRU1Firmware_0[] = { 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101d500, +0x2101c400, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401d98d, +0x2401c88d, 0x20830000, 0x1e0efefe, -0x2401dc8d, +0x2401cb8d, 0x20830000, -0x2401de8d, +0x2401cd8d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -516,23 +499,23 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401e98d, +0x2401d88d, 0x20830000, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2401eb8d, +0x2401da8d, 0x20830000, 0x1e0efefe, -0x2401ee8d, +0x2401dd8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101f200, +0x2101e100, 0x1f03f0f0, 0xd105f003, -0x2401f78d, +0x2401e68d, 0x20830000, -0x2402078d, +0x2401f68d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -545,10 +528,10 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x24033e8d, +0x24032d8d, 0x20830000, 0xf04f0b2f, -0x2401d18d, +0x2401c08d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -561,32 +544,32 @@ const uint32_t PRU1Firmware_0[] = { 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x24033e8d, +0x24032d8d, 0x20830000, -0x2402168d, +0x2402058d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402228d, +0x2402118d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402268d, +0x2402158d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21022a00, +0x21021900, 0x13012f2f, 0x01010f0f, -0x24022d8d, +0x24021c8d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -594,36 +577,36 @@ const uint32_t PRU1Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402468d, +0x2402358d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402438d, +0x2402328d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402208d, +0x24020f8d, 0x20830000, 0x1c2efefe, -0x2402498d, +0x2402388d, 0x20830000, 0x1e2efefe, -0x2402498d, +0x2402388d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x24024d8d, +0x24023c8d, 0x20830000, 0xd105f003, -0x2402528d, +0x2402418d, 0x20830000, -0x24025a8d, +0x2402498d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -631,33 +614,33 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x24033e8d, +0x24032d8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24033e8d, +0x24032d8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402208d, +0x24020f8d, 0x20830000, 0xc9075103, 0x1e2efefe, -0x21026b00, +0x21025a00, 0x1c2efefe, 0x09015151, 0x01010f0f, -0x24026f8d, +0x24025e8d, 0x20830000, 0x1e0efefe, -0x2402728d, +0x2402618d, 0x20830000, -0x2402748d, +0x2402638d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -666,23 +649,23 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24027f8d, +0x24026e8d, 0x20830000, -0x2402678d, +0x2402568d, 0x20830000, -0x2402818d, +0x2402708d, 0x20830000, 0x1e0efefe, -0x2402848d, +0x2402738d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21028800, +0x21027700, 0x1f03f0f0, 0xd105f003, -0x24028d8d, +0x24027c8d, 0x20830000, -0x24029d8d, +0x24028c8d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -695,10 +678,10 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401d18d, +0x2401c08d, 0x20830000, 0xf04f0b51, -0x2402678d, +0x2402568d, 0x20830000, 0x1c0efefe, 0x2450d0dd, @@ -711,32 +694,32 @@ const uint32_t PRU1Firmware_0[] = { 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2402ac8d, +0x24029b8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402b88d, +0x2402a78d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402bc8d, +0x2402ab8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102c000, +0x2102af00, 0x13016f6f, 0x01010f0f, -0x2402c38d, +0x2402b28d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -744,36 +727,36 @@ const uint32_t PRU1Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402dc8d, +0x2402cb8d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402d98d, +0x2402c88d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402b68d, +0x2402a58d, 0x20830000, 0x1c2efefe, -0x2402df8d, +0x2402ce8d, 0x20830000, 0x1e2efefe, -0x2402df8d, +0x2402ce8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402e38d, +0x2402d28d, 0x20830000, 0xd105f003, -0x2402e88d, +0x2402d78d, 0x20830000, -0x2402f08d, +0x2402df8d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -781,55 +764,55 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x24021b8d, +0x24020a8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24021b8d, +0x24020a8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402b68d, +0x2402a58d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x21030100, +0x2102f000, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2403058d, +0x2402f48d, 0x20830000, 0x1e0efefe, -0x2403088d, +0x2402f78d, 0x20830000, -0x24030a8d, +0x2402f98d, 0x20830000, 0x1c0efefe, 0x61080f03, -0x2403108d, +0x2402ff8d, 0x20830000, -0x2402fd8d, +0x2402ec8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x2403148d, +0x2403038d, 0x20830000, 0x1e0efefe, -0x2403178d, +0x2403068d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21031b00, +0x21030a00, 0x1f03f0f0, 0xd105f003, -0x2403208d, +0x24030f8d, 0x20830000, -0x24032c8d, +0x24031b8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -837,11 +820,11 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401d18d, +0x2401c08d, 0x20830000, -0x2401878d, +0x2401768d, 0x1f08cdcd, -0x24021b91, +0x24020a91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -849,54 +832,59 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2402678d, +0x2402568d, 0x20830000, -0x2401878d, +0x2401768d, 0x1f08cdcd, -0x2402b191, +0x2402a091, 0x20830000, -0x24033a8d, +0x2403298d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x2403448d, +0x2403338d, 0x20830000, -0x24034c8d, +0x2403408d, 0x20830000, 0x1e0efefe, -0x2403478d, +0x2403368d, 0x20830000, 0x1e2efefe, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, 0x24050084, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x1e2efefe, -0x24034f8d, +0x2403438d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0x2400008f, 0x240a00cf, -0x2403588d, +0x24034c8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x24035e8d, +0x2403528d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x504f0f03, 0x24050584, -0x21036300, +0x21035700, 0x24050684, 0x2400008f, 0x240000cf, @@ -904,23 +892,29 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, +0x2450d0dd, +0x2408149d, +0xf1003d9c, +0x1e2efcfc, +0xe1003d9c, +0x1e2efefe, 0x24036b8d, 0x20830000, 0x1e0efefe, +0x01010f0f, 0x24036e8d, 0x20830000, -0x2403708d, +0x2403658d, 0x20830000, 0x1c0efefe, -0x01010f0f, -0x2403748d, +0x2403698d, 0x20830000, 0x606f0f03, -0x2403798d, +0x2403738d, 0x20830000, 0x24036b8d, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050784, 0xe1080a84, 0x20830000, @@ -929,18 +923,18 @@ const uint32_t PRU1Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403888d, +0x2403828d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400de8d, +0x2400e38d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400de8d, +0x2400e38d, 0x24050084, 0xe1080a84, 0x20830000, From bc8cd4b88f2eb52963bd249f1b5121a465a7c203 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 14:47:46 +0530 Subject: [PATCH 10/29] examples: pru_i2c: SMBus protocols, open-drain bus with clock stretching SMBus (commands 0x14..0x1C, previously stubs): quick command, send/receive byte, write/read byte, write/read word, block write/read. A transfer is a write phase (command code and block count staged as prefix bytes in front of the Tx buffer, then the Tx data) and, for the reads, a repeated START and a read phase. Block read reports the target's byte count in the count register. SMBus always sends START/STOP and NACKs the last byte read, whatever CON says. 10-bit addressing is rejected (ADDRESSING_MODE_FAILED). PEC (CON bit 6, ICSS_I2C_PEC_BIT): CRC-8 (0x07) updated bit by bit over every address and data bit; appended to write-only transfers and checked on reads (new response PEC_ERROR 0x050F). Open-drain bus: SCL and SDA are never driven high. R30 keeps both bits at 0 and the lines are switched with their OUTDISABLE bits in ICSSMx_PRUy_GPIO_OUT_CTRL through a shadow register (one store per edge). The SDA direction macros are gone; the master can no longer fight a target on either line. Clock stretching: every state that follows an SCL release waits for SCL to read high. A new SCL-low timeout (instance offset 0xE8, in ticks, 0 = none) ends a transfer with TIME_OUT_ERROR. After a stretch the high period is counted from the real rising edge (tHIGH). Errors now end with a STOP: address NACK, data NACK, bad block count. Bus timing (UM10204 Table 10, SMBus = Standard-mode): - START hold, repeated START setup/hold and STOP setup are two ticks (one tick is 2.5 us at 100 kHz, below the 4.0/4.7 us minimums). - The 400 kHz tick is 680 IEP counts (367.6 kHz): with 625 the 2-tick SCL low was 1.25 us, under the Fast-mode tLOW of 1.3 us. Removed: the unreachable CMD_CODE_* / *_BURST states and the SMBus burst CON latch (bit 5 is now reserved). New interface fields: ICSS_I2C_PEC_BIT, ICSS_I2C_SCL_TIMEOUT_OFFSET, PEC_ERROR; ICSS_I2C_PRU_CMD_CODE_OFFSET is the SMBus command code (bit 0 is the R/W bit for quick command); instance offsets 0xFE/0xFF are used to stage the SMBus prefix bytes. Hardware note: SCL now needs a pull-up and its GPI path (the pad configured with rx), like SDA. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/firmware/pru_i2c_interface.h | 28 +- examples/pru_i2c/firmware/pru_i2c_macro.h | 414 +++++++------- examples/pru_i2c/firmware/pru_i2c_main.asm | 530 ++++++++++-------- 3 files changed, 494 insertions(+), 478 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_interface.h b/examples/pru_i2c/firmware/pru_i2c_interface.h index 8ad7e1e7b..208b2e1e9 100644 --- a/examples/pru_i2c/firmware/pru_i2c_interface.h +++ b/examples/pru_i2c/firmware/pru_i2c_interface.h @@ -83,10 +83,18 @@ typedef enum PRUICSS_PruCores_e #define ICSS_I2C_PRU_PIN_OFFSET (0xD8) /* The Memory offset of I2C clock value register */ #define ICSS_I2C_PRU_CLK_VAL_OFFSET (0xDC) -/* The Memory offset of I2C smbus command code register */ +/* The Memory offset of I2C smbus command code register (u8). For + * ICSS_SMBUS_QUICK_CMD, bit 0 is the R/W bit sent with the address. */ #define ICSS_I2C_PRU_CMD_CODE_OFFSET (0xE0) /* The Memory offset of I2C instance id register */ #define ICSS_I2C_PRU_INST_ID_OFFSET (0xE4) +/* The Memory offset of the SCL low timeout (u16): number of state machine + * ticks (4 per SCL period) a target may hold SCL low (clock stretching) + * before the transfer ends with TIME_OUT_ERROR. 0 = wait indefinitely. + * SMBus requires 25 ms (tTIMEOUT,MIN). Latched by ICSS_I2C_SETUP_CMD. */ +#define ICSS_I2C_SCL_TIMEOUT_OFFSET (0xE8) +/* Instance offsets 0xFE and 0xFF are used by the firmware to stage the + * SMBus command code and block count in front of the Tx buffer. */ /* The register bit for enabling i2c instance */ #define ICSS_I2C_MODULE_ENABLE_BIT (15) @@ -94,8 +102,10 @@ typedef enum PRUICSS_PruCores_e #define ICSS_I2C_MASTER_SLAVE_MODE_BIT (10) /* The register bit for selecting address mode */ #define ICSS_I2C_ADDRESSING_MODE_BIT (8) -/* The register bit for enabling i2c burst mode */ +/* Reserved (was: SMBus burst mode, never implemented) */ #define ICSS_I2C_SMBUS_BURST_BIT (5) +/* The register bit for enabling SMBus Packet Error Checking (CRC-8) */ +#define ICSS_I2C_PEC_BIT (6) /* The register bit for deciding NACK recieve */ #define ICSS_I2C_RECIEVE_NACK_BIT (4) /* The register bit for deciding ACK recieve */ @@ -170,15 +180,21 @@ typedef enum PRUICSS_PruCores_e #define INVALID_DATA_COUNT (0x050DU) /* The time out for the response to come */ #define TIME_OUT_ERROR (0x050EU) +/* The response for an SMBus read whose PEC byte did not match */ +#define PEC_ERROR (0x050FU) /* The iep counter increment value for 400KHz value */ // The IEP counts DEFAULT_INC = 5 per 200 MHz clock, so every increment // must be a multiple of 5 to land exactly on a counter value. -// 1 I2C instance, time-slice 125 (625/5) cycles. -// => bus clock time is 125*4/200e6 = 2.5 usec. -// => bus clock speed is 1/2.5e-6 = 400 kHz -#define IEP_CMP_INCREMENT_VAL_400KHZ (0x00000271U) // 400 kHz +// A bit is 4 ticks with SCL low for 2 of them. Fast-mode needs +// tLOW >= 1.3 us, and the SCL edges move by a few cycles with the work +// done in each state, so the tick is 0.68 us: time-slice 136 (680/5) +// cycles, giving tLOW >= 1.33 us. +// => bus clock time is 136*4/200e6 = 2.72 usec. +// => bus clock speed is 1/2.72e-6 = 367.6 kHz (400 kHz with 1.25 us +// tLOW would be out of spec) +#define IEP_CMP_INCREMENT_VAL_400KHZ (0x000002A8U) // 367.6 kHz #define IEP_CMP_INCREMENT_HALF_VAL_400KHZ (0x00000138U) /* The iep counter increment value for 100KHz value */ diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index 393b9c001..d976e0f43 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -233,69 +233,129 @@ STATE_TASK_OVER .macro ;************************************************************************************ ; -; Macro: SET_SCL_PIN_HIGH +; Open-drain bus pins +; +; SCL and SDA are never driven high. R30 keeps both pin bits at 0 and the +; line is controlled through the pin's OUTDISABLE bit in this core's +; ICSSMx_PRUy_GPIO_OUT_CTRL register (I2C_GPIO_OUT_CTRL): +; OUTDISABLE = 1 -> released, the external pull-up takes the line high +; OUTDISABLE = 0 -> driven low +; R23 is a shadow copy of that register and R26 holds its address, both +; set up in SETUP_I2C_SCL_SDA_HIGH, so a pin change is a single store. +; A target can therefore hold SCL low (clock stretching, see +; WAIT_SCL_HIGH) and the master never fights a target on SDA. ; -; Set high value on SCL pin -; ; PEAK cycles: -; -; Pseudo code: -; -; -; Parameters: -; None +; 2 + store ; -; Returns: -; None +; Registers modified: +; R23 ; ;************************************************************************************ SET_SCL_PIN_HIGH .macro - SET R30, R30, R14.b0 + SET R23, R23, R14.b0 + SBBO &R23, R26, 0, 4 + .endm + +SET_SCL_PIN_LOW .macro + CLR R23, R23, R14.b0 + SBBO &R23, R26, 0, 4 + .endm + +SET_SDA_PIN_HIGH .macro + SET R23, R23, R14.b1 + SBBO &R23, R26, 0, 4 + .endm + +SET_SDA_PIN_LOW .macro + CLR R23, R23, R14.b1 + SBBO &R23, R26, 0, 4 .endm ;************************************************************************************ ; -; Macro: SET_SDA_PIN_HIGH -; -; Set high value on SDA pin -; -; PEAK cycles: -; -; Pseudo code: -; +; Macro: WAIT_SCL_HIGH ; -; Parameters: -; None: +; Clock stretching. Put at the top of every state that runs one tick after +; SCL was released. If a target still holds SCL low, return without +; advancing the state, so the same state runs again on the next tick. +; R18.w0 counts the ticks SCL has been held low; when it reaches the limit +; in R18.w2 (ICSS_I2C_SCL_TIMEOUT_OFFSET, 0 = no limit) the transfer is +; abandoned with TIME_OUT_ERROR (SCL_LOW_TIMEOUT). +; When SCL comes up after being held, wait one more tick before going on, +; so the high period is counted from the moment SCL actually rose and is +; never shorter than without stretching (tHIGH). ; -; Returns: -; None +; Registers modified: +; R18.w0, R13.w0 (on timeout) ; ;************************************************************************************ -SET_SDA_PIN_HIGH .macro - SET R30, R30, R14.b1 +WAIT_SCL_HIGH .macro + QBBS scl_high?, R31, R14.b0 + ADD R18.w0, R18.w0, 1 + QBEQ scl_wait?, R18.w2, 0 + QBLT scl_wait?, R18.w2, R18.w0 + LDI R13.w0, $CODE(SCL_LOW_TIMEOUT) +scl_wait?: + STATE_TASK_OVER +scl_high?: + QBEQ scl_ok?, R18.w0, 0 + LDI R18.w0, 0 + STATE_TASK_OVER +scl_ok?: .endm - - -;---------------------------------------------------------------------- -; Macro Name: SET_SCL_PIN_LOW -; Description: Set low value on SCL pin -; Input Parameters: none -; Output Parameters: none -;---------------------------------------------------------------------- -SET_SCL_PIN_LOW .macro - CLR R30, R30, R14.b0 +;************************************************************************************ +; +; Macro: PEC_UPDATE +; +; SMBus Packet Error Code: CRC-8, x^8 + x^2 + x + 1, initial value 0, +; updated one bit at a time as bits go out or come in, MSB first. Runs +; only when SMB_F_PEC is set for the current transfer. +; +; Parameters: +; src, bitn: the bit (register, bit number) just sent or received +; +; Registers modified: +; R19.b0 (CRC), TEMP_REG6.b0 +; +;************************************************************************************ +PEC_UPDATE .macro src, bitn + QBBC pec_done?, R19.b3, SMB_F_PEC + LSR TEMP_REG6.b0, R19.b0, 7 + QBBC pec_bit0?, src, bitn + XOR TEMP_REG6.b0, TEMP_REG6.b0, 1 +pec_bit0?: + LSL R19.b0, R19.b0, 1 + QBEQ pec_done?, TEMP_REG6.b0, 0 + XOR R19.b0, R19.b0, 0x07 +pec_done?: .endm -;---------------------------------------------------------------------- -; Macro Name: SET_SDA_PIN_LOW -; Description: Set low value on SDA pin -; Input Parameters: Label on new memory location -; Output Parameters: none -;---------------------------------------------------------------------- -SET_SDA_PIN_LOW .macro - CLR R30, R30, R14.b1 - .endm +;************************************************************************************ +; +; Macro: TX_FETCH_BYTE +; +; Load byte R15.b2 of the transmit stream into dest. The stream starts at +; R11: the Tx buffer for I2C, or up to two SMBus prefix bytes (command +; code, block count) staged just in front of it. When SMB_F_PECTX is set +; the last byte of the stream is the PEC, taken from R19.b0, which by then +; covers every bit sent before it. +; +; Registers modified: +; dest, TEMP_REG4.b0 +; +;************************************************************************************ +TX_FETCH_BYTE .macro dest + QBBC fetch_buf?, R19.b3, SMB_F_PECTX + SUB TEMP_REG4.b0, R15.b3, 1 + QBNE fetch_buf?, R15.b2, TEMP_REG4.b0 + MOV dest, R19.b0 + JMP fetch_done? +fetch_buf?: + LBBO &dest, R11, R15.b2, 1 +fetch_done?: + .endm ;---------------------------------------------------------------------- ; Macro Name: READ_SDA_PIN_ACK @@ -421,32 +481,6 @@ INTERRUPT_RECEIVED_REPEAT_STATE?: .endm -;************************************************************************************ -; -; Macro: SET_OUTPUT_PIN_VALUE_HIGH -; -; Set high value on SCL and SDA pin -; -; PEAK cycles: -; -; Pseudo code: -; -; -; Parameters: -; arg1: Label on next memory location -; -; -; Returns: -; None -; -;************************************************************************************ -SET_OUTPUT_PIN_VALUE_HIGH .macro arg1 - SET_SDA_PIN_HIGH - SET_SCL_PIN_HIGH - UPDATE_NEXT_LOCAL_STATE arg1 - STATE_TASK_OVER - .endm - ;************************************************************************************ ; ; Macro: UPDATE_NEXT_GLOBAL_STATE @@ -582,7 +616,7 @@ read_rw_register_bit_done?: ;************************************************************************************ SEND_TX_DATA_CHECK_FOR_ACK .macro arg1, arg2, arg3 ; -; modify the SDA pin value based on the most significant bit of DATA value +; put the most significant bit of the data byte on SDA (SCL is low) ; tx_data_sda_begin?: QBBC tx_data_sda_low?, arg1, 7 @@ -591,13 +625,14 @@ tx_data_sda_begin?: tx_data_sda_low?: SET_SDA_PIN_LOW tx_data_sda_continue?: + PEC_UPDATE arg1, 7 LSL arg1, arg1, 1 ADD R15.b0, R15.b0, 0x01 LDI R13.w0, $CODE(tx_data_scl_begin?) STATE_TASK_OVER ; -; make SCL high for sending SDA bit +; release SCL ; tx_data_scl_begin?: SET_SCL_PIN_HIGH @@ -605,23 +640,21 @@ tx_data_scl_begin?: STATE_TASK_OVER ; -; Jump to next state as this is tx mode, done for matching timing parameter. +; SCL high period (waits here while a target stretches the clock) ; tx_data_sda_read?: + WAIT_SCL_HIGH LDI R13.w0, $CODE(tx_data_scl_end?) STATE_TASK_OVER ; -; make SCL low for stop sending SDA bit -; make decision for sending next data bit or check for ACK +; pull SCL low; after the 8th bit release SDA on this same edge, so the +; target can drive its ACK ; tx_data_scl_end?: SET_SCL_PIN_LOW QBGT tx_sda_next_bit?, R15.b0, 0x08 - ; The target may drive ACK as soon as SCL falls after the 8th bit, so - ; release SDA on this edge rather than one tick later. SCL is already low, - ; so the release cannot be seen as a STOP. - SET_SDA_PIN_INPUT_DIRECTION + SET_SDA_PIN_HIGH LDI R13.w0, $CODE(tx_data_ack_begin?) STATE_TASK_OVER @@ -637,7 +670,7 @@ tx_data_ack_begin?: STATE_TASK_OVER ; -; make SCL high for reading ACK bit +; release SCL for the ACK bit ; tx_data_ack_scl_begin?: SET_SCL_PIN_HIGH @@ -645,65 +678,35 @@ tx_data_ack_scl_begin?: STATE_TASK_OVER ; -; make SDA line for reading ACK bit +; sample the ACK bit once SCL is high ; tx_data_ack_read?: + WAIT_SCL_HIGH READ_SDA_PIN_ACK - QBBS tx_data_ack_read_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT LDI R13.w0, $CODE(tx_data_ack_scl_end?) STATE_TASK_OVER -tx_data_ack_read_next_state?: - LDI R13.w0, $CODE(tx_data_ack_scl_end_v2?) - STATE_TASK_OVER - ; -; make SCL low -; read if ACK bit is set then check if data is still left to be sent +; pull SCL low; on ACK send the next byte or finish ; tx_data_ack_scl_end?: SET_SCL_PIN_LOW - SET_SDA_PIN_OUTPUT_DIRECTION QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT ADD R15.b2, R15.b2, 0x01 - AND R15.b0, R15.b0, 0x00 + LDI R15.b0, 0x00 QBGT tx_mode_continue?, R15.b2, R15.b3 - AND R15.b2, R15.b2, 0x00 + LDI R15.b2, 0x00 LDI R13.w0, $CODE(arg2) STATE_TASK_OVER tx_mode_continue?: - LBBO &arg1, R11, R15.b2, 1 + TX_FETCH_BYTE arg1 LDI R13.w0, $CODE(tx_data_sda_begin?) - STATE_TASK_OVER ; -; make SCL low -; read if ACK bit is set then check if data is still left to be sent +; the target did not acknowledge a data byte ; - -tx_data_ack_scl_end_v2?: - SET_SCL_PIN_LOW - SET_SDA_PIN_OUTPUT_DIRECTION - QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT - AND R15.b0, R15.b0, 0x00 - AND R15.b2, R15.b2, 0x00 - CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT - LBBO &arg1, R11, R15.b2, 1 - LDI R13.w0, $CODE(arg2) - STATE_TASK_OVER - - tx_data_ack_not_recieved?: - LDI R13.w0, $CODE(no_tx_data_ack_recieved?) - STATE_TASK_OVER - -; -; if no data ack is recieved, response with no ack in response command -; raise an interrupt -; -no_tx_data_ack_recieved?: - SET_SCL_PIN_HIGH LDI TEMP_REG4.w0, DATA_ACKNOWLDEGE_FAILED SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 LDI R13.w0, $CODE(arg3) @@ -785,127 +788,134 @@ iep_counter_setup_done?: ; Output Parameters: none ;---------------------------------------------------------------------------------------------------------------------------- READ_RX_DATA_AND_SEND_ACK .macro arg1, arg2 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; release SDA line so slave can drive it. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - SET_SDA_PIN_INPUT_DIRECTION +; +; release SDA so the target can drive it +; + SET_SDA_PIN_HIGH rx_data_sda_begin?: LDI R13.w0, $CODE(rx_data_scl_begin?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for reading data value -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; release SCL for the data bit +; rx_data_scl_begin?: SET_SCL_PIN_HIGH LSL arg1, arg1, 1 LDI R13.w0, $CODE(rx_data_sda_read?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Read the SDA pin value and store it in the MSB of receive register -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; sample SDA into the LSB once SCL is high +; rx_data_sda_read?: + WAIT_SCL_HIGH QBBS rx_data_sda_high?, R31, R14.b1 AND arg1, arg1, 0xFE JMP rx_data_sda_read_continue? rx_data_sda_high?: OR arg1, arg1, 0x01 rx_data_sda_read_continue?: + PEC_UPDATE arg1, 0 ADD R15.b0, R15.b0, 0x01 LDI R13.w0, $CODE(rx_data_scl_end?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for finishing data read -; also check if all the data needed to read is over then send ACK -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; pull SCL low; after the 8th bit decide between ACK and NACK +; rx_data_scl_end?: SET_SCL_PIN_LOW QBGT rx_sda_next_bit?, R15.b0, 0x08 + QBBC rx_data_not_count?, R19.b3, SMB_F_BLKRD + ; SMBus block read: this byte is the block count. It is reported in the + ; count register and not stored. The count plus an optional PEC byte must + ; fit the 8-bit byte index. + CLR R19.b3, R19.b3, SMB_F_BLKRD + QBEQ rx_count_bad?, arg1, 0x00 + MOV R15.b3, arg1 + QBBC rx_count_ok?, R19.b3, SMB_F_PECRX + QBEQ rx_count_bad?, arg1, 0xFF + ADD R15.b3, R15.b3, 0x01 +rx_count_ok?: + LDI TEMP_REG4.w0, 0x0000 + MOV TEMP_REG4.b0, arg1 + SBBO &TEMP_REG4, R10, ICSS_I2C_CNT_OFFSET, 2 + LDI R13.w0, $CODE(rx_data_ack_begin?) + STATE_TASK_OVER +rx_count_bad?: + LDI TEMP_REG4.w0, INVALID_DATA_COUNT + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + SET R19.b3, R19.b3, SMB_F_ERR + LDI R15.w2, 0x0101 + LDI R13.w0, $CODE(rx_data_nack_begin?) + STATE_TASK_OVER +rx_data_not_count?: ADD R15.b2, R15.b2, 0x01 - QBBS rx_data_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT QBGT rx_data_next_state?, R15.b2, R15.b3 + QBBS rx_data_nack?, R19.b3, SMB_F_SMB QBBC rx_data_next_state?, R16, ICSS_I2C_RECIEVE_NACK_BIT +rx_data_nack?: LDI R13.w0, $CODE(rx_data_nack_begin?) - SET_SDA_PIN_OUTPUT_DIRECTION STATE_TASK_OVER rx_data_next_state?: LDI R13.w0, $CODE(rx_data_ack_begin?) - SET_SDA_PIN_OUTPUT_DIRECTION - STATE_TASK_OVER + STATE_TASK_OVER rx_sda_next_bit?: LDI R13.w0, $CODE(rx_data_sda_begin?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SDA line low to send an ACK. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; pull SDA low to ACK the byte +; rx_data_ack_begin?: SET_SDA_PIN_LOW LDI R13.w0, $CODE(rx_data_ack_scl_begin?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SDA line low to send an NACK. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; leave SDA released to NACK the byte +; rx_data_nack_begin?: SET_SDA_PIN_HIGH LDI R13.w0, $CODE(rx_data_ack_scl_begin?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for reading ACK bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; release SCL for the ACK/NACK bit +; rx_data_ack_scl_begin?: SET_SCL_PIN_HIGH - SBBO &R15.b3, R10, ICSS_I2C_CNT_OFFSET, 1 LDI R13.w0, $CODE(rx_data_ack_read?) STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; jump to next state, done to match the timing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; ACK/NACK high period (waits here while a target stretches the clock) +; rx_data_ack_read?: - QBBS rx_data_ack_read_next_state?, R16, ICSS_I2C_SMBUS_BURST_BIT + WAIT_SCL_HIGH LDI R13.w0, $CODE(rx_data_ack_scl_end?) STATE_TASK_OVER -rx_data_ack_read_next_state?: - LDI R13.w0, $CODE(rx_data_ack_scl_end_v2?) - STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for finishing data read -; also check if all the data needed to read is over then finish read -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; pull SCL low, store the byte, then read the next one or finish. The +; block count byte (byte index still 0) is not stored. +; rx_data_ack_scl_end?: SET_SCL_PIN_LOW - AND R15.b0, R15.b0, 0x00 + LDI R15.b0, 0x00 + QBEQ rx_mode_continue?, R15.b2, 0x00 SUB TEMP_REG4.b0, R15.b2, 1 SBBO &arg1, R12, TEMP_REG4.b0, 1 QBGT rx_mode_continue?, R15.b2, R15.b3 - AND R15.b2, R15.b2, 0x00 - LDI R13.w0, $CODE(arg2) - ; SET_SDA_PIN_INPUT_DIRECTION - STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for finishing data read -; also check if all the data needed to read is over then finish read -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -rx_data_ack_scl_end_v2?: - SET_SCL_PIN_LOW - AND R15.b0, R15.b0, 0x00 - AND R15.b2, R15.b2, 0x00 - CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT + LDI R15.b2, 0x00 LDI R13.w0, $CODE(arg2) STATE_TASK_OVER rx_mode_continue?: - SET_SDA_PIN_INPUT_DIRECTION + SET_SDA_PIN_HIGH LDI R13.w0, $CODE(rx_data_sda_begin?) STATE_TASK_OVER @@ -914,58 +924,16 @@ rx_mode_continue?: ;************************************************************************************ ; -; Macro: SET_SDA_PIN_INPUT_DIRECTION +; Macro: I2C_TRANSFER_INIT ; -; Description: Setup the Control register for SDA pin input -; -; PEAK cycles: -; -; Pseudo code: -; -; -; Parameters: -; None -; Returns: -; None +; Reset the per-transfer state: PEC, command code, flags (R19), the +; SCL-low counter and the transmit stream base (R11 = Tx buffer). ; ;************************************************************************************ -SET_SDA_PIN_INPUT_DIRECTION .macro - - ; AM261x: set the SDA pin's OUTDISABLE bit in this core's - ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) - LDI32 r29, I2C_GPIO_OUT_CTRL - LBBO &r28, r29, 0, 4 - SET r28, r28, R14.b1 - SBBO &r28, r29, 0, 4 - +I2C_TRANSFER_INIT .macro + LDI R19, 0 + LDI R18.w0, 0 + LDI R11.w0, ICSS_I2C_INSTANCE0_TX_MEM .endm -;************************************************************************************ -; -; Macro: SET_SDA_PIN_OUTPUT_DIRECTION -; -; Description: Clear the Control register for SDA pin output. -; -; PEAK cycles: -; -; Pseudo code: -; -; -; Parameters: -; None -; Returns: -; None -; -;************************************************************************************ - -SET_SDA_PIN_OUTPUT_DIRECTION .macro - - ; AM261x: clear the SDA pin's OUTDISABLE bit in this core's - ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) - LDI32 r29, I2C_GPIO_OUT_CTRL - LBBO &r28, r29, 0, 4 - CLR r28, r28, R14.b1 - SBBO &r28, r29, 0, 4 - - .endm .endif ; __icss_i2c_macros_h diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 5d2401259..a0c4af683 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -129,9 +129,21 @@ I2C_GPIO_OUT_CTRL .set ICSSM0_PRU1_GPIO_OUT_CTRL ; R13.w0 next state, R13.w2 slave address shift register, ; R14 b0 SCL pin, b1 SDA pin, b3 instance id, ; R15 b0 bit count, b1 data byte, b2 byte index, b3 byte count, -; R16 control flags (ICSS_I2C_*_BIT), R17.w0 post-address state. +; R16 control flags (ICSS_I2C_*_BIT), R17.w0 post-address state, +; R17.b2 SMBus read phase length. +; R18 w0 SCL-low tick counter, w2 SCL-low timeout (ticks, 0 = off). +; R19 b0 PEC CRC, b1 SMBus command code, b3 transfer flags SMB_F_*. ; R20-R21 next IEP compare value (64-bit), R22 frequency word. -; R27-R29 scratch for SET_SDA_PIN_*_DIRECTION. +; R23 shadow of I2C_GPIO_OUT_CTRL (open-drain SCL/SDA), R26 its address. + +; Transfer flags in R19.b3 (cleared at the start of every transfer) +SMB_F_PEC .set 0 ; update the PEC CRC +SMB_F_PECTX .set 1 ; last write-phase byte is the PEC +SMB_F_RDPHASE .set 2 ; repeated START + read after writing +SMB_F_BLKRD .set 3 ; next byte read is the block count +SMB_F_SMB .set 4 ; SMBus: always START/STOP, NACK last byte +SMB_F_PECRX .set 5 ; the read ends with the target's PEC +SMB_F_ERR .set 6 ; error already reported, end with STOP ;-------------------------------------------------------------------------------------- @@ -368,12 +380,15 @@ SETUP_I2C_INST_ID: ; This set the SCL clk line and SDA data line high. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP_I2C_SCL_SDA_HIGH: - SET_SCL_PIN_HIGH + ; Open-drain bus: R30 keeps the SCL and SDA bits at 0 and the lines are + ; switched with their OUTDISABLE bits (see SET_SCL_PIN_HIGH). Start with + ; both lines released, which is also the idle state of the bus. + LDI32 R26, I2C_GPIO_OUT_CTRL + LBBO &R23, R26, 0, 4 + CLR R30, R30, R14.b0 + CLR R30, R30, R14.b1 + SET R23, R23, R14.b0 SET_SDA_PIN_HIGH - ; SDA is released whenever the bus is idle and taken back at the start of - ; each transfer (SET_SCL_SDA_HIGH), so the master never drives SDA high - ; against a target that holds it low (e.g. a stuck bus before RESET_SLAVE). - SET_SDA_PIN_INPUT_DIRECTION UPDATE_NEXT_LOCAL_STATE SETUP_I2C_TX_FIFO_SIZE STATE_TASK_OVER @@ -483,23 +498,7 @@ SETUP_I2C_STOP_CTRL: SETUP_I2C_NO_STOP_CTRL: CLR R16, R16, ICSS_I2C_STOP_BIT -SETUP_I2C_STOP_DONE: - UPDATE_NEXT_LOCAL_STATE SETUP_I2C_SMBUS_BURST_CTRL - STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; This configures the firmware for sending start bit at beginning or not -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -SETUP_I2C_SMBUS_BURST_CTRL: - LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 - QBBC SETUP_I2C_NO_SMBUS_BURST_CTRL, TEMP_REG4, ICSS_I2C_SMBUS_BURST_BIT - SET R16, R16, ICSS_I2C_SMBUS_BURST_BIT - JMP SETUP_I2C_SMBUS_BURST_DONE - -SETUP_I2C_NO_SMBUS_BURST_CTRL: - CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT - -SETUP_I2C_SMBUS_BURST_DONE: +SETUP_I2C_STOP_DONE: UPDATE_NEXT_LOCAL_STATE SETUP_I2C_NACK_CTRL STATE_TASK_OVER @@ -524,6 +523,20 @@ SETUP_I2C_NO_NACK_CTRL: CLR R16, R16, ICSS_I2C_RECIEVE_NACK_BIT SETUP_I2C_NACK_DONE: + UPDATE_NEXT_LOCAL_STATE SETUP_I2C_SMBUS_CTRL + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; SMBus PEC enable and the SCL-low (clock stretching) timeout +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SETUP_I2C_SMBUS_CTRL: + LBBO &TEMP_REG4, R10, ICSS_I2C_CON_OFFSET, 4 + CLR R16, R16, ICSS_I2C_PEC_BIT + QBBC SETUP_I2C_NO_PEC, TEMP_REG4, ICSS_I2C_PEC_BIT + SET R16, R16, ICSS_I2C_PEC_BIT +SETUP_I2C_NO_PEC: + LBBO &R18.w2, R10, ICSS_I2C_SCL_TIMEOUT_OFFSET, 2 + LDI R18.w0, 0 UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY ;debug code @@ -627,7 +640,6 @@ ICSS_I2C_RESET_CMD_CHECK_RETURN: RESET_SCL_SDA_HIGH: SET_SDA_PIN_HIGH SET_SCL_PIN_HIGH - SET_SDA_PIN_INPUT_DIRECTION ; bus idle: release SDA UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_ERROR STATE_TASK_OVER @@ -697,17 +709,14 @@ ICSS_I2C_TX_CMD_CHECK_RETURN: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; The SMBus commands (ICSS_SMBUS_QUICK_CMD .. ICSS_SMBUS_BLOCK_READ_CMD) are -; not implemented yet: answer them with INVALID_COMMAND. Every other command -; is passed on to the next check, so READ_SCL, RESET_SLAVE and LOOPBACK stay -; reachable and an unknown command is answered instead of stalling the -; dispatcher. +; SMBus commands (ICSS_SMBUS_QUICK_CMD .. ICSS_SMBUS_BLOCK_READ_CMD) start an +; SMBus transfer. Every other command is passed on to the next check. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ICSS_SMBUS_CMD_CHECK: LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 QBLT ICSS_SMBUS_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_READ_CMD QBGT ICSS_SMBUS_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD - UPDATE_NEXT_LOCAL_STATE FIRMWARE_READY_COMMAND_ERROR + UPDATE_NEXT_LOCAL_STATE SMBUS_MODE STATE_TASK_OVER ICSS_SMBUS_CMD_CHECK_NEXT: @@ -771,34 +780,147 @@ FIRMWARE_READY_COMMAND_ERROR: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; set the local register to indicate tx mode -; set the value on iep gpo to low value for pulling the line +; I2C write: send the Tx buffer to the target ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TX_MODE: CLR R16, R16, ICSS_I2C_READ_WRITE_BIT + I2C_TRANSFER_INIT UPDATE_NEXT_GLOBAL_STATE TX_DATA_SDA_BEGIN UPDATE_NEXT_LOCAL_STATE SET_SCL_SDA_HIGH STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; set the local register to indicate rx mode -; set the value on iep gpo to low value for pulling the line +; I2C read: read the data count from the target into the Rx buffer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RX_MODE: SET R16, R16, ICSS_I2C_READ_WRITE_BIT + I2C_TRANSFER_INIT UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN UPDATE_NEXT_LOCAL_STATE SET_SCL_SDA_HIGH STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; set the value on iep gpo enable register to high value -; this will pull the line to high impedence and open drain will keep the line high -; set the value on iep gpo to low value for pulling the line +; SMBus command: decode the protocol and describe the transfer. +; +; A transfer is a write phase (the "stream": optional command code and +; block count prefix bytes, the Tx buffer, optional PEC) followed, for the +; read protocols, by a repeated START and a read phase into the Rx buffer. +; The prefix bytes are staged at the two bytes just below the Tx buffer +; (instance offsets 0xFE/0xFF), so the stream is contiguous from R11. +; +; protocol write phase read phase +; quick (address only, R/W = command code bit 0) +; send byte cmd +; receive byte 1 byte +; write byte cmd, Tx[0] +; write word cmd, Tx[0] (low), Tx[1] (high) +; block write cmd, N = count, Tx[0..N-1] +; read byte cmd Sr, 1 byte +; read word cmd Sr, 2 bytes (low first) +; block read cmd Sr, N, N bytes (N -> count) +; +; With PEC enabled (CON ICSS_I2C_PEC_BIT) a write-only transfer ends with +; the PEC byte and a read phase reads one more byte, the target's PEC, +; which is checked. Quick command has no PEC. 10-bit addressing is not +; supported for SMBus. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SMBUS_MODE: + LBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4 + QBBS SMBUS_MODE_10BIT, R16, ICSS_I2C_ADDRESSING_MODE_BIT + I2C_TRANSFER_INIT + SET R19.b3, R19.b3, SMB_F_SMB + LBBO &R19.b1, R10, ICSS_I2C_PRU_CMD_CODE_OFFSET, 1 + CLR R16, R16, ICSS_I2C_READ_WRITE_BIT + UPDATE_NEXT_GLOBAL_STATE TX_DATA_SDA_BEGIN + QBEQ SMBUS_MODE_QUICK, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD + QBBC SMBUS_MODE_NO_PEC, R16, ICSS_I2C_PEC_BIT + SET R19.b3, R19.b3, SMB_F_PEC +SMBUS_MODE_NO_PEC: + QBEQ SMBUS_MODE_RECEIVE_BYTE, TEMP_REG4.w2, ICSS_SMBUS_RECEIVE_BYTE_CMD + ; every other protocol starts with the command code + LDI TEMP_REG5, ICSS_I2C_INSTANCE0_TX_MEM - 1 + SBBO &R19.b1, TEMP_REG5, 0, 1 + LDI R11.w0, ICSS_I2C_INSTANCE0_TX_MEM - 1 + LDI R15.b3, 1 + QBEQ SMBUS_MODE_WRITE, TEMP_REG4.w2, ICSS_SMBUS_SEND_BYTE_CMD + LDI R15.b3, 2 + QBEQ SMBUS_MODE_WRITE, TEMP_REG4.w2, ICSS_SMBUS_WRITE_BYTE_CMD + LDI R15.b3, 3 + QBEQ SMBUS_MODE_WRITE, TEMP_REG4.w2, ICSS_SMBUS_WRITE_WORD_CMD + QBEQ SMBUS_MODE_BLOCK_WRITE, TEMP_REG4.w2, ICSS_SMBUS_BLOCK_WRITE_CMD + ; read byte / read word / block read: write the command code, then read + LDI R15.b3, 1 + SET R19.b3, R19.b3, SMB_F_RDPHASE + LDI R17.b2, 1 + QBEQ SMBUS_MODE_READ, TEMP_REG4.w2, ICSS_SMBUS_READ_BYTE_CMD + LDI R17.b2, 2 + QBEQ SMBUS_MODE_READ, TEMP_REG4.w2, ICSS_SMBUS_READ_WORD_CMD + SET R19.b3, R19.b3, SMB_F_BLKRD +SMBUS_MODE_READ: + QBBC SMBUS_MODE_START, R19.b3, SMB_F_PEC + SET R19.b3, R19.b3, SMB_F_PECRX + JMP SMBUS_MODE_START + +SMBUS_MODE_BLOCK_WRITE: + ; N = data count, 1..253 (252 with PEC) so that cmd, N, data and PEC fit + ; the 8-bit stream index + LBBO &TEMP_REG4.w0, R10, ICSS_I2C_CNT_OFFSET, 2 + QBEQ SMBUS_MODE_COUNT_ERROR, TEMP_REG4.w0, 0 + LDI TEMP_REG6.w0, 253 + QBBC SMBUS_MODE_BLOCK_MAX, R19.b3, SMB_F_PEC + LDI TEMP_REG6.w0, 252 +SMBUS_MODE_BLOCK_MAX: + QBLT SMBUS_MODE_COUNT_ERROR, TEMP_REG4.w0, TEMP_REG6.w0 + LDI TEMP_REG5, ICSS_I2C_INSTANCE0_TX_MEM - 2 + SBBO &R19.b1, TEMP_REG5, 0, 1 + SBBO &TEMP_REG4.b0, TEMP_REG5, 1, 1 + LDI R11.w0, ICSS_I2C_INSTANCE0_TX_MEM - 2 + ADD R15.b3, TEMP_REG4.b0, 2 +SMBUS_MODE_WRITE: + QBBC SMBUS_MODE_START, R19.b3, SMB_F_PEC + SET R19.b3, R19.b3, SMB_F_PECTX + ADD R15.b3, R15.b3, 1 + JMP SMBUS_MODE_START + +SMBUS_MODE_RECEIVE_BYTE: + SET R16, R16, ICSS_I2C_READ_WRITE_BIT + UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN + LDI R15.b3, 1 + QBBC SMBUS_MODE_START, R19.b3, SMB_F_PEC + SET R19.b3, R19.b3, SMB_F_PECRX + LDI R15.b3, 2 + JMP SMBUS_MODE_START + +SMBUS_MODE_QUICK: + ; address only; the R/W bit is bit 0 of the command code + QBBC SMBUS_MODE_QUICK_W, R19.b1, 0 + SET R16, R16, ICSS_I2C_READ_WRITE_BIT +SMBUS_MODE_QUICK_W: + LDI R15.b3, 0 + UPDATE_NEXT_GLOBAL_STATE DATA_PROCESSING_COMPLETE + +SMBUS_MODE_START: + UPDATE_NEXT_LOCAL_STATE SET_SCL_SDA_HIGH + STATE_TASK_OVER + +SMBUS_MODE_COUNT_ERROR: + LDI TEMP_REG4.w0, INVALID_DATA_COUNT + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +SMBUS_MODE_10BIT: + LDI TEMP_REG4.w0, ADDRESSING_MODE_FAILED + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; release both lines before the START condition ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SET_SCL_SDA_HIGH: SET_SDA_PIN_HIGH SET_SCL_PIN_HIGH - SET_SDA_PIN_OUTPUT_DIRECTION ; take SDA back for this transfer UPDATE_NEXT_LOCAL_STATE SLAVE_ADDRESS_SETUP STATE_TASK_OVER @@ -811,17 +933,18 @@ SLAVE_ADDRESS_SETUP: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; configure the read/write bit in the slave address register for transmission ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -SLAVE_ADDRESS_RW_SETUP: +SLAVE_ADDRESS_RW_SETUP: READ_RW_REGISTER_BIT DATA_COUNT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Read the number of 8 bits data need to be read or writen -; also initialize the data count and bit count register to 0 +; I2C: read the number of bytes to read or write and load the first byte. +; SMBus: the length was set by SMBUS_MODE, only load the first byte. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA_COUNT: + QBBS DATA_COUNT_SMBUS, R19.b3, SMB_F_SMB LBBO &TEMP_REG4.w0, R10, ICSS_I2C_CNT_OFFSET, 2 - - ;debug code + + ;debug code .if $defined("DEBUG_CODE") ; fif count LDI TEMP_REG4.w0, 1 @@ -830,16 +953,6 @@ DATA_COUNT: QBLT DATA_COUNT_ERROR, TEMP_REG4.w0, 0xFF QBGT DATA_COUNT_ERROR, TEMP_REG4.w0, 0x01 - ;debug code - .if $defined("DEBUG_CODE") - LDI R24.b0, 0x53 - LDI r24.b1, 0xFF - LDI r24.b2, 0x00 - ldi r24.b3, 0x00 - ldi r25.b0, 0x33 - SBBO &r24, R11, 0, 1 - .endif - AND R15.b3, TEMP_REG4.b0, 0xFF AND R15.b2, R15.b2, 0x00 LBBO &R15.b1, R11, R15.b2, 1 @@ -847,6 +960,14 @@ DATA_COUNT: UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW STATE_TASK_OVER +DATA_COUNT_SMBUS: + QBBS DATA_COUNT_SMBUS_DONE, R16, ICSS_I2C_READ_WRITE_BIT + QBEQ DATA_COUNT_SMBUS_DONE, R15.b3, 0 + TX_FETCH_BYTE R15.b1 +DATA_COUNT_SMBUS_DONE: + UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW + STATE_TASK_OVER + DATA_COUNT_ERROR: LDI TEMP_REG4.w0, INVALID_DATA_COUNT SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 @@ -854,28 +975,35 @@ DATA_COUNT_ERROR: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SDA low for start condition +; START condition: SDA low while SCL is high. SMBus always sends START. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; START_CONDITION_SDA_LOW: + WAIT_SCL_HIGH + QBBS START_CONDITION_SDA_LOW_DO, R19.b3, SMB_F_SMB QBBC START_CONDITION_SDA_LOW_RETURN, R16, ICSS_I2C_START_BIT +START_CONDITION_SDA_LOW_DO: SET_SDA_PIN_LOW START_CONDITION_SDA_LOW_RETURN: + UPDATE_NEXT_LOCAL_STATE START_CONDITION_HOLD + STATE_TASK_OVER + +; START hold time (tHD;STA): one more tick with SDA low and SCL high, so it +; is two ticks long (5 us at 100 kHz, Standard-mode/SMBus needs 4.0 us) +START_CONDITION_HOLD: UPDATE_NEXT_LOCAL_STATE START_CONDITION_SCL_LOW - STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for start condition -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + START_CONDITION_SCL_LOW: + QBBS START_CONDITION_SCL_LOW_DO, R19.b3, SMB_F_SMB QBBC START_CONDITION_SCL_LOW_RETURN, R16, ICSS_I2C_START_BIT +START_CONDITION_SCL_LOW_DO: SET_SCL_PIN_LOW START_CONDITION_SCL_LOW_RETURN: UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; modify the SDA pin value based on the most significant bit of Address register +; address byte(s): put the next address bit on SDA (SCL is low) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_SDA_BEGIN: RSB TEMP_REG5.b0, R15.b0, 15 @@ -885,35 +1013,27 @@ ADDRESS_SDA_BEGIN: ADDRESS_SDA_LOW: SET_SDA_PIN_LOW ADDRESS_SDA_CONTINUE: + PEC_UPDATE R13.w2, TEMP_REG5.b0 ADD R15.b0, R15.b0, 0x01 UPDATE_NEXT_LOCAL_STATE ADDRESS_SCL_BEGIN STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for sending SDA bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_SCL_BEGIN: SET_SCL_PIN_HIGH UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_READ STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; nothing to be read in address tx mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_SDA_READ: + WAIT_SCL_HIGH UPDATE_NEXT_LOCAL_STATE ADDRESS_SCL_END STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for ending the transmission of bit -; also decide the next state based on all the bits have been sent or not. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pull SCL low; after the 8th bit release SDA on this same edge, so the +; target can drive its ACK (SCL is already low, so this is not a STOP) ADDRESS_SCL_END: SET_SCL_PIN_LOW QBGT SDA_NEXT_BIT, R15.b0, 0x08 - ; release SDA on the falling edge after the 8th bit: the target may drive - ; ACK from here on (SCL is already low, so this is not a STOP) - SET_SDA_PIN_INPUT_DIRECTION + SET_SDA_PIN_HIGH UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_BEGIN STATE_TASK_OVER @@ -921,47 +1041,28 @@ SDA_NEXT_BIT: UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SDA was released in ADDRESS_SCL_END; this tick keeps the 4-tick bit timing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_ACK_BEGIN: UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_BEGIN STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for reading ACK bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_ACK_SCL_BEGIN: SET_SCL_PIN_HIGH AND R15.b0, R15.b0, 0x00 UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_READ STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SDA line for reading ACK bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADDRESS_ACK_READ: + WAIT_SCL_HIGH READ_SDA_PIN_ACK UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_END STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low -; read if ACK bit is set then start sending or receiving data else indicate no ack -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pull SCL low; on ACK continue with the second address byte (10-bit) or +; the data phase in R17.w0, on NACK abandon the transfer ADDRESS_ACK_SCL_END: SET_SCL_PIN_LOW QBBS ADDRESS_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT - ; In a read, the target starts driving the first data bit as soon as SCL - ; falls after its ACK, so SDA must stay released. Only take SDA back when - ; the master transmits next: a write, or the second byte of a 10-bit - ; address. - QBBC ADDRESS_ACK_SDA_OUTPUT, R16, ICSS_I2C_READ_WRITE_BIT - QBBC ADDRESS_ACK_SDA_DONE, R16, ICSS_I2C_ADDRESSING_MODE_BIT - QBEQ ADDRESS_ACK_SDA_DONE, R15.b2, 0x01 -ADDRESS_ACK_SDA_OUTPUT: - SET_SDA_PIN_OUTPUT_DIRECTION -ADDRESS_ACK_SDA_DONE: QBBC ADDRESS_ACK_SCL_END_DONE, R16, ICSS_I2C_ADDRESSING_MODE_BIT QBEQ ADDRESS_ACK_SCL_END_DONE, R15.b2, 0x01 ADD R15.b2, R15.b2, 0x01 @@ -977,186 +1078,97 @@ ADDRESS_ACK_NOT_RECIEVED: UPDATE_NEXT_LOCAL_STATE NO_ADDRESS_ACK_RECIEVED STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; if no address ack is recieved, response with no ack in response command -; raise an interrupt -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; no ACK for the address: report it and end the transfer with a STOP NO_ADDRESS_ACK_RECIEVED: - SET_SDA_PIN_OUTPUT_DIRECTION - SET_SCL_PIN_HIGH LDI TEMP_REG4.w0, ADDRESS_ACKNOWLDEGE_FAILED SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 - UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + SET R19.b3, R19.b3, SMB_F_ERR + UPDATE_NEXT_LOCAL_STATE DATA_PROCESSING_COMPLETE STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; start sending TX data and wait for ACK receive -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -TX_DATA_SDA_BEGIN: - SEND_TX_DATA_CHECK_FOR_ACK R15.b1, DATA_PROCESSING_COMPLETE, RAISE_HOST_INTERRUPT_MEM_FOR_READY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; start sending RX data and send ACK to device -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -RX_DATA_SDA_BEGIN: - READ_RX_DATA_AND_SEND_ACK R15.b1, DATA_PROCESSING_COMPLETE - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; start sending TX data and wait for ACK receive for smbus Burst Mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -TX_DATA_SDA_BEGIN_BURST: - SEND_TX_DATA_CHECK_FOR_ACK R17.b2, TX_DATA_SDA_BEGIN, RAISE_HOST_INTERRUPT_MEM_FOR_READY - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; start sending RX data and send ACK to device for smbus Burst Mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -RX_DATA_SDA_BEGIN_BURST: - READ_RX_DATA_AND_SEND_ACK R15.b3, RX_DATA_SDA_BEGIN - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; modify the SDA pin value based on the most significant bit of DATA value -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_SDA_BEGIN: - QBBC CMD_CODE_SDA_LOW, R15.b1, 7 - SET_SDA_PIN_HIGH - JMP CMD_CODE_SDA_CONTINUE -CMD_CODE_SDA_LOW: - SET_SDA_PIN_LOW -CMD_CODE_SDA_CONTINUE: - LSL R15.b1, R15.b1, 1 - ADD R15.b0, R15.b0, 0x01 - UPDATE_NEXT_LOCAL_STATE CMD_CODE_SCL_BEGIN - STATE_TASK_OVER - +; write phase: send the stream and check each ACK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for sending SDA bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_SCL_BEGIN: - SET_SCL_PIN_HIGH - UPDATE_NEXT_LOCAL_STATE CMD_CODE_SDA_READ - STATE_TASK_OVER - +TX_DATA_SDA_BEGIN: + SEND_TX_DATA_CHECK_FOR_ACK R15.b1, TX_PHASE_DONE, TX_DATA_NACK -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Jump to next state as this is tx mode, done for matching timing parameter. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_SDA_READ: - UPDATE_NEXT_LOCAL_STATE CMD_CODE_SCL_END +; the stream is sent: SMBus reads continue with a repeated START +TX_PHASE_DONE: + QBBS TX_PHASE_DONE_READ, R19.b3, SMB_F_RDPHASE + UPDATE_NEXT_LOCAL_STATE DATA_PROCESSING_COMPLETE STATE_TASK_OVER - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low for stop sending SDA bit -; make decision for sending next data bit or check for ACK -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_SCL_END: - SET_SCL_PIN_LOW - QBGT CMD_CODE_SDA_NEXT_BIT, R15.b0, 0x08 - UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_BEGIN +TX_PHASE_DONE_READ: + UPDATE_NEXT_LOCAL_STATE RSTART_SDA_HIGH STATE_TASK_OVER -CMD_CODE_SDA_NEXT_BIT: - UPDATE_NEXT_LOCAL_STATE CMD_CODE_SDA_BEGIN +; no ACK for a data byte (DATA_ACKNOWLDEGE_FAILED is already reported): +; end the transfer with a STOP +TX_DATA_NACK: + SET R19.b3, R19.b3, SMB_F_ERR + UPDATE_NEXT_LOCAL_STATE DATA_PROCESSING_COMPLETE STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; release SDA line so slave can drive it. +; repeated START (Sr) for the read phase of an SMBus read: release SDA and +; SCL, then SDA low while SCL is high, then the address byte with R/W = 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_ACK_BEGIN: +RSTART_SDA_HIGH: SET_SDA_PIN_HIGH - SET R13.w2, R13.w2, 0 - UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_BEGIN + UPDATE_NEXT_LOCAL_STATE RSTART_SCL_HIGH STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL high for reading ACK bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_ACK_SCL_BEGIN: +RSTART_SCL_HIGH: SET_SCL_PIN_HIGH - UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_READ + UPDATE_NEXT_LOCAL_STATE RSTART_SETUP STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SDA line for reading ACK bit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_ACK_READ: - READ_SDA_PIN_ACK - QBBS CMD_CODE_ACK_READ_NEXT_STATE, R16, ICSS_I2C_SMBUS_BURST_BIT - UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_END +; repeated START setup time (tSU;STA): SCL high for two ticks before SDA falls +RSTART_SETUP: + WAIT_SCL_HIGH + UPDATE_NEXT_LOCAL_STATE RSTART_SDA_LOW STATE_TASK_OVER -CMD_CODE_ACK_READ_NEXT_STATE: - UPDATE_NEXT_LOCAL_STATE CMD_CODE_ACK_SCL_END_V2 +RSTART_SDA_LOW: + SET_SDA_PIN_LOW + CLR R19.b3, R19.b3, SMB_F_RDPHASE + SET R16, R16, ICSS_I2C_READ_WRITE_BIT + SET R13.w2, R13.w2, 8 + LDI R15.w0, 0x0000 + MOV R15.b3, R17.b2 + QBBC RSTART_SDA_LOW_NO_PEC, R19.b3, SMB_F_PECRX + ADD R15.b3, R15.b3, 1 +RSTART_SDA_LOW_NO_PEC: + LDI R15.b2, 0x00 + UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN + UPDATE_NEXT_LOCAL_STATE RSTART_HOLD STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low -; read if ACK bit is set then check if data is still left to be sent -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_ACK_SCL_END: - SET_SCL_PIN_LOW - QBBS CMD_CODE_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT - AND R15.b2, R15.b2, 0x00 - AND R15.b0, R15.b0, 0x00 - QBBS CMD_CODE_RX, R16, ICSS_I2C_READ_WRITE_BIT - LBBO &R15.b1, R11, R15.b2, 1 - UPDATE_NEXT_LOCAL_STATE TX_DATA_SDA_BEGIN +; repeated START hold time (tHD;STA) +RSTART_HOLD: + UPDATE_NEXT_LOCAL_STATE RSTART_SCL_LOW STATE_TASK_OVER -CMD_CODE_RX: - UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW - SET R13.w2, R13.w2, 8 - UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN - STATE_TASK_OVER - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; make SCL low -; read if ACK bit is set then check if data is still left to be sent -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CMD_CODE_ACK_SCL_END_V2: +RSTART_SCL_LOW: SET_SCL_PIN_LOW - QBBS CMD_CODE_ACK_NOT_RECIEVED, R16, ICSS_I2C_ACK_RECIEVED_BIT - AND R15.b2, R15.b2, 0x00 - AND R15.b0, R15.b0, 0x00 - QBBS CMD_CODE_RX_V2, R16, ICSS_I2C_READ_WRITE_BIT - LBBO &R15.b1, R11, R15.b2, 1 - UPDATE_NEXT_LOCAL_STATE TX_DATA_SDA_BEGIN_BURST - STATE_TASK_OVER - -CMD_CODE_RX_V2: - UPDATE_NEXT_LOCAL_STATE START_CONDITION_SDA_LOW - SET R13.w2, R13.w2, 8 - UPDATE_NEXT_GLOBAL_STATE RX_DATA_SDA_BEGIN_BURST - STATE_TASK_OVER - - -CMD_CODE_ACK_NOT_RECIEVED: - UPDATE_NEXT_LOCAL_STATE NO_CMD_CODE_ACK_RECIEVED + UPDATE_NEXT_LOCAL_STATE ADDRESS_SDA_BEGIN STATE_TASK_OVER - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; if no data ack is received, response with no ack in response command -; raise an interrupt +; read phase: read bytes into the Rx buffer, ACK all but the last ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -NO_CMD_CODE_ACK_RECIEVED: - LDI TEMP_REG4.w0, DATA_ACKNOWLDEGE_FAILED - SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 - UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY - STATE_TASK_OVER - +RX_DATA_SDA_BEGIN: + READ_RX_DATA_AND_SEND_ACK R15.b1, DATA_PROCESSING_COMPLETE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; data transmit or receive is over -; check whether to sent stop bit or not +; end of the transfer (SCL is low). Send STOP if CON asks for it, and always +; for SMBus and after an error. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA_PROCESSING_COMPLETE: SET_SDA_PIN_LOW + QBBS COMPLETE_WITH_STOP, R19.b3, SMB_F_SMB + QBBS COMPLETE_WITH_STOP, R19.b3, SMB_F_ERR QBBC COMPLETE_WITH_NO_STOP, R16, ICSS_I2C_STOP_BIT +COMPLETE_WITH_STOP: UPDATE_NEXT_LOCAL_STATE STOP_CONDITION_SCL_HIGH STATE_TASK_OVER @@ -1165,35 +1177,42 @@ COMPLETE_WITH_NO_STOP: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; send stop condition by making SCL high first +; STOP condition: release SCL, then release SDA while SCL is high. The bus +; is then idle with both lines released. Report the result unless an error +; was already reported; an SMBus read with PEC must end with a zero CRC. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STOP_CONDITION_SCL_HIGH: SET_SCL_PIN_HIGH + UPDATE_NEXT_LOCAL_STATE STOP_CONDITION_SETUP + STATE_TASK_OVER + +; STOP setup time (tSU;STO): SCL high for two ticks before SDA rises +STOP_CONDITION_SETUP: + WAIT_SCL_HIGH UPDATE_NEXT_LOCAL_STATE STOP_CONDITION_SDA_HIGH STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; send stop condition by making SDA high next -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STOP_CONDITION_SDA_HIGH: SET_SDA_PIN_HIGH - SET_SDA_PIN_INPUT_DIRECTION ; bus idle: release SDA (line stays high) + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + QBBS STOP_CONDITION_REPORTED, R19.b3, SMB_F_ERR LDI TEMP_REG4.w0, COMMAND_SUCCESS + QBBC STOP_CONDITION_REPORT, R19.b3, SMB_F_PECRX + QBEQ STOP_CONDITION_REPORT, R19.b0, 0 + LDI TEMP_REG4.w0, PEC_ERROR +STOP_CONDITION_REPORT: SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 - UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY +STOP_CONDITION_REPORTED: STATE_TASK_OVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; do not send stop condition by making SDA high first +; no STOP (I2C with CON STOP clear): release SDA, then SCL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NO_STOP_CONDITION_SDA_HIGH: SET_SDA_PIN_HIGH UPDATE_NEXT_LOCAL_STATE NO_STOP_CONDITION_SCL_HIGH STATE_TASK_OVER -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; do not send stop condition by making SCL high next -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NO_STOP_CONDITION_SCL_HIGH: SET_SCL_PIN_HIGH LDI TEMP_REG4.w0, COMMAND_SUCCESS @@ -1201,6 +1220,20 @@ NO_STOP_CONDITION_SCL_HIGH: UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY STATE_TASK_OVER +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; a target held SCL low for longer than the configured timeout: release +; both lines and report TIME_OUT_ERROR (no STOP is possible while SCL is +; held low) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +SCL_LOW_TIMEOUT: + SET_SDA_PIN_HIGH + SET_SCL_PIN_HIGH + LDI R18.w0, 0 + LDI TEMP_REG4.w0, TIME_OUT_ERROR + SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 + UPDATE_NEXT_LOCAL_STATE RAISE_HOST_INTERRUPT_MEM_FOR_READY + STATE_TASK_OVER + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; prepare to read clk value for 10 clk cycles ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1252,7 +1285,6 @@ RESET_SLAVE_SCL_BEGIN: ; Bus recovery: make sure SDA is released so a target that holds it low ; can let go, then clock SCL until it does. SDA stays released afterwards, ; as on an idle bus. - SET_SDA_PIN_INPUT_DIRECTION SET_SDA_PIN_HIGH UPDATE_NEXT_LOCAL_STATE RESET_SLAVE_SCL_LOW STATE_TASK_OVER From cf27c1da82affad85f98be18725cc5eff5f55c90 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 14:47:48 +0530 Subject: [PATCH 11/29] examples: pru_i2c: regenerate pru0/pru1_load_bin.h Byte-identical to the ELFs exercised on pru-simulator. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- .../firmware/am261x-lp/pru0_load_bin.h | 958 +++++++++--------- .../firmware/am261x-lp/pru1_load_bin.h | 958 +++++++++--------- 2 files changed, 958 insertions(+), 958 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index 5c914bca9..81e4a11e7 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -162,7 +162,7 @@ const uint32_t PRU0Firmware_0[] = { 0x6911c403, 0x2400888d, 0x20830000, -0x2400cb8d, +0x2400cd8d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -174,63 +174,65 @@ const uint32_t PRU0Firmware_0[] = { 0xf1e40a6e, 0x24008f8d, 0x20830000, -0x1e0efefe, -0x1e2efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2400988d, +0x2450d0da, +0x2408109a, +0xf1003a97, +0x1c0efefe, +0x1c2efefe, +0x1e0ef7f7, +0x1e2ef7f7, +0xe1003a97, +0x2400998d, 0x20830000, 0xf1940a50, -0x24009b8d, +0x24009c8d, 0x20830000, 0xf1950a70, -0x24009e8d, +0x24009f8d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a68d, +0x2400a78d, 0x20830000, -0x2400cb8d, +0x2400cd8d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100ab00, +0x2100ac00, 0x1f08f0f0, -0x2400ad8d, +0x2400ae8d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100b200, +0x2100b300, 0x1d00f0f0, -0x2400b48d, +0x2400b58d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b900, +0x2100ba00, 0x1d01f0f0, -0x2400bb8d, -0x20830000, -0xf1a42a84, -0xc905e403, -0x1f05f0f0, -0x2100c000, -0x1d05f0f0, -0x2400c28d, +0x2400bc8d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c700, +0x2100c100, 0x1d04f0f0, -0x2400e38d, +0x2400c38d, +0x20830000, +0xf1a42a84, +0x1d06f0f0, +0xc906e402, +0x1f06f0f0, +0xf1e80ad2, +0x24000092, +0x2400e58d, 0x24050084, 0xe1080a84, 0x20830000, @@ -241,22 +243,22 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400d48d, +0x2400d68d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400da8d, +0x2400dc8d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100e100, +0x2100e300, 0x24007a8d, 0x20830000, -0x2400d48d, +0x2400d68d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -265,626 +267,626 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400ec8d, +0x2400ee8d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400f28d, +0x2400f48d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100f900, -0x2400fb8d, +0x2100fb00, +0x2400fd8d, 0x20830000, -0x2400ec8d, +0x2400ee8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400ff8d, +0x2401018d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401078d, +0x2401098d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401108d, +0x24010f8d, 0x20830000, -0x1e2efefe, -0x1e0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2400cb8d, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x2400cd8d, 0x20830000, 0xf1082a84, 0x6911c403, 0x24007a8d, 0x20830000, -0x2401168d, +0x2401158d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401438d, +0x2401458d, 0x20830000, -0x24011c8d, +0x24011b8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013f8d, +0x24013e8d, 0x20830000, -0x2401228d, +0x2401218d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24013b8d, +0x24014c8d, 0x20830000, -0x2401298d, +0x2401288d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403488d, +0x24034a8d, 0x20830000, -0x24012f8d, +0x24012e8d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035b8d, +0x24035d8d, 0x20830000, -0x2401358d, +0x2401348d, 0x20830000, 0xf1082a84, 0x691fc403, 0x2403778d, 0x20830000, -0x24013b8d, +0x24013a8d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c091, -0x2401478d, +0x240000f3, +0x24000092, +0x2402008b, +0x24023091, +0x2401918d, +0x20830000, +0x1f02f0f0, +0x240000f3, +0x24000092, +0x2402008b, +0x2402b191, +0x2401918d, 0x20830000, +0xf1082a84, +0xd108f040, +0x240000f3, +0x24000092, +0x2402008b, +0x1f047373, +0xf1e00a33, +0x1d02f0f0, +0x24023091, +0x5114c42e, +0xc906f002, +0x1f007373, +0x5116c424, +0x2401ffe5, +0xe1000533, +0x2401ff8b, +0x2400016f, +0x5115c41b, +0x2400026f, +0x5117c419, +0x2400036f, +0x5119c417, +0x511bc40b, +0x2400016f, +0x1f027373, +0x24000151, +0x5118c404, +0x24000251, +0x511ac402, +0x1f037373, +0xc900731d, +0x1f057373, +0x21018700, +0xf1980a84, +0x5100841b, +0x2400fd86, +0xc9007302, +0x2400fc86, +0x48868417, +0x2401fee5, +0xe1000533, +0xe1010504, +0x2401fe8b, +0x0102046f, +0xc900730f, +0x1f017373, +0x01016f6f, +0x21018700, 0x1f02f0f0, -0x24020a91, -0x2401478d, -0x20830000, -0x1e2efefe, -0x1e0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x2401508d, +0x2402b191, +0x2400016f, +0xc9007308, +0x1f057373, +0x2400026f, +0x21018700, +0xc9003302, +0x1f02f0f0, +0x2400006f, +0x24031591, +0x2401918d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400e58d, +0x20830000, +0x24050b84, +0xe1080a84, +0x2400e58d, +0x20830000, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x2401978d, 0x20830000, 0xd108f003, 0x24007f84, -0x21015400, +0x21019b00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401588d, +0x24019f8d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21015e00, +0x2101a500, 0x1d08cdcd, -0x21016600, +0x2101ad00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21016400, +0x2101ab00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24016a8d, +0x2401b18d, 0x20830000, +0xd1047309, 0xf1980a84, -0x49ff8407, -0x61018406, +0x49ff8411, +0x61018410, 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401768d, +0x2401c88d, +0x20830000, +0xd102f008, +0x51006f07, +0xc9017305, +0x05016f04, +0x68044f03, +0x1013132f, +0x2101c200, +0xf04f0b2f, +0x2401c88d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400e58d, 0x20830000, -0xc900f002, -0x1c2efefe, -0x24017a8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0xc900f002, -0x1c0efefe, -0x24017e8d, +0x51009203, +0x24000092, +0x20830000, +0xd1047302, +0xc900f003, +0x1c2ef7f7, +0xe1003a97, +0x2401d78d, +0x20830000, +0x2401d98d, +0x20830000, +0xd1047302, +0xc900f003, +0x1c0ef7f7, +0xe1003a97, +0x2401df8d, 0x20830000, 0x0d0f0f05, -0xc805cd03, -0x1e2efefe, -0x21018300, -0x1c2efefe, +0xc805cd04, +0x1e2ef7f7, +0xe1003a97, +0x2101e600, +0x1c2ef7f7, +0xe1003a97, +0xc9007307, +0x0b071306, +0xc805cd02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, 0x01010f0f, -0x2401868d, +0x2401f08d, 0x20830000, -0x1e0efefe, -0x2401898d, +0x1e0ef7f7, +0xe1003a97, +0x2401f48d, 0x20830000, -0x24018b8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2401968d, +0x51009203, +0x24000092, +0x20830000, +0x2401ff8d, 0x20830000, -0x24017e8d, +0x1c0ef7f7, +0xe1003a97, +0x61080f05, +0x1e2ef7f7, +0xe1003a97, +0x2402088d, 0x20830000, -0x2401988d, +0x2401df8d, 0x20830000, -0x1e0efefe, +0x24020a8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, 0x11000f0f, -0x24019c8d, +0x24020f8d, +0x20830000, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, +0x20830000, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101a000, +0x21021c00, 0x1f03f0f0, -0x2401a28d, +0x24021e8d, 0x20830000, -0x1c0efefe, -0xd103f011, -0xc902f003, -0xc908f007, -0x51014f06, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, +0x1c0ef7f7, +0xe1003a97, +0xd103f009, 0xc908f005, 0x51014f04, 0x01014f4f, -0x24017e8d, +0x2401df8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401b68d, +0x24022b8d, 0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400e38d, -0x20830000, -0xc9072f03, -0x1e2efefe, -0x2101c400, -0x1c2efefe, +0x1f067373, +0x2403158d, +0x20830000, +0xc9072f04, +0x1e2ef7f7, +0xe1003a97, +0x21023600, +0x1c2ef7f7, +0xe1003a97, +0xc9007307, +0x0b071306, +0xc9072f02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, 0x09012f2f, 0x01010f0f, -0x2401c88d, +0x2402418d, 0x20830000, -0x1e0efefe, -0x2401cb8d, +0x1e0ef7f7, +0xe1003a97, +0x2402458d, 0x20830000, -0x2401cd8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2401d88d, +0x51009203, +0x24000092, +0x20830000, +0x2402508d, 0x20830000, -0x2401c08d, +0x1c0ef7f7, +0xe1003a97, +0x61080f05, +0x1e2ef7f7, +0xe1003a97, +0x2402598d, 0x20830000, -0x2401da8d, +0x2402308d, 0x20830000, -0x1e0efefe, -0x2401dd8d, +0x24025b8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, +0x24025f8d, +0x20830000, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, +0x20830000, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101e100, +0x21026c00, 0x1f03f0f0, -0xd105f003, -0x2401e68d, -0x20830000, -0x2401f68d, +0x24026e8d, 0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f017, +0x1c0ef7f7, +0xe1003a97, +0xd103f00f, 0x01014f4f, -0x11000f0f, +0x2400000f, 0x606f4f04, -0x11004f4f, -0x24032d8d, -0x20830000, -0xf04f0b2f, -0x2401c08d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f007, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, +0x2400004f, +0x2402838d, +0x20830000, +0xc9017305, +0x05016f04, +0x68044f03, +0x1013132f, +0x21027d00, 0xf04f0b2f, -0x24032d8d, -0x20830000, -0x2402058d, +0x2402308d, 0x20830000, -0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2402888d, 0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402118d, +0xd1027303, +0x2403158d, 0x20830000, -0x1e0efefe, -0x09012f2f, -0x2402158d, -0x20830000, -0xd02eff03, -0x11fe2f2f, -0x21021900, -0x13012f2f, -0x01010f0f, -0x24021c8d, -0x20830000, -0x1c0efefe, -0x61080f13, -0x01014f4f, -0xd105f00a, -0x606f4f09, -0xc904f008, -0x2402358d, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402328d, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x24020f8d, -0x20830000, -0x1c2efefe, -0x2402388d, -0x20830000, -0x1e2efefe, -0x2402388d, +0x24028b8d, 0x20830000, -0x1e0efefe, -0xe1980a6f, -0x24023c8d, +0x1f067373, +0x2403158d, 0x20830000, -0xd105f003, -0x2402418d, +0x1e2ef7f7, +0xe1003a97, +0x24028f8d, 0x20830000, -0x2402498d, +0x1e0ef7f7, +0xe1003a97, +0x2402938d, 0x20830000, -0x1c0efefe, -0x11000f0f, -0x05014f04, -0xe0040c2f, -0x606f4f0a, -0x11004f4f, -0x24032d8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0x24032d8d, +0x51009203, +0x24000092, 0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x24020f8d, +0x24029e8d, 0x20830000, -0xc9075103, -0x1e2efefe, -0x21025a00, -0x1c2efefe, -0x09015151, -0x01010f0f, -0x24025e8d, +0x1c2ef7f7, +0xe1003a97, +0x1d027373, +0x1f02f0f0, +0x1f08cdcd, +0x2400008f, +0x1051516f, +0xc9057302, +0x01016f6f, +0x2400004f, +0x2402b191, +0x2402ab8d, 0x20830000, -0x1e0efefe, -0x2402618d, +0x2402ad8d, 0x20830000, -0x2402638d, +0x1c0ef7f7, +0xe1003a97, +0x2401df8d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x24026e8d, +0x1e2ef7f7, +0xe1003a97, +0x2402b58d, 0x20830000, -0x2402568d, +0x1e0ef7f7, +0xe1003a97, +0x09012f2f, +0x2402ba8d, 0x20830000, -0x2402708d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1e0efefe, -0x2402738d, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, -0x1d03f0f0, -0x21027700, -0x1f03f0f0, -0xd105f003, -0x24027c8d, -0x20830000, -0x24028c8d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f017, -0x01014f4f, -0x11000f0f, -0x606f4f04, -0x11004f4f, -0x2401c08d, -0x20830000, -0xf04f0b51, -0x2402568d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f007, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0xf04f0b51, -0x2401c08d, -0x20830000, -0x24029b8d, +0x11fe2f2f, +0x2102c700, +0x13012f2f, +0xc9007307, +0x0b071306, +0xc9002f02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, +0x01010f0f, +0x2402d18d, +0x20830000, +0x1c0ef7f7, +0xe1003a97, +0x61080f1b, +0xc9037312, +0x1d037373, +0x51002f0a, +0x102f2f6f, +0xc9057303, +0x51ff2f07, +0x01016f6f, +0x24000084, +0x102f2f04, +0xe1980a84, +0x2402f08d, 0x20830000, -0x1e0efefe, -0x24050984, +0x24050d84, 0xe1080a84, -0x2400e38d, -0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402a78d, -0x20830000, -0x1e0efefe, -0x09016f6f, -0x2402ab8d, -0x20830000, -0xd02eff03, -0x11fe6f6f, -0x2102af00, -0x13016f6f, -0x01010f0f, -0x2402b28d, +0x1f067373, +0x240101cf, +0x2402f48d, 0x20830000, -0x1c0efefe, -0x61080f13, 0x01014f4f, -0xd105f00a, -0x606f4f09, -0xc904f008, -0x2402cb8d, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402c88d, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402a58d, -0x20830000, -0x1c2efefe, -0x2402ce8d, -0x20830000, -0x1e2efefe, -0x2402ce8d, -0x20830000, -0x1e0efefe, -0xe1980a6f, -0x2402d28d, -0x20830000, -0xd105f003, -0x2402d78d, -0x20830000, -0x2402df8d, -0x20830000, -0x1c0efefe, -0x11000f0f, -0x05014f04, -0xe0040c6f, -0x606f4f0a, -0x11004f4f, -0x24020a8d, -0x20830000, -0x1c0efefe, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0x24020a8d, -0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402a58d, -0x20830000, -0xc9072f03, -0x1e2efefe, -0x2102f000, -0x1c2efefe, -0x09012f2f, -0x01010f0f, +0x606f4f05, +0xd1047302, +0xc904f003, 0x2402f48d, 0x20830000, -0x1e0efefe, -0x2402f78d, +0x2402f08d, 0x20830000, -0x2402f98d, +0x2402b38d, 0x20830000, -0x1c0efefe, -0x61080f03, -0x2402ff8d, +0x1c2ef7f7, +0xe1003a97, +0x2402f88d, 0x20830000, -0x2402ec8d, +0x1e2ef7f7, +0xe1003a97, +0x2402f88d, 0x20830000, -0x1e2efefe, -0x1f00cdcd, -0x2403038d, +0x1e0ef7f7, +0xe1003a97, +0x2402fc8d, 0x20830000, -0x1e0efefe, -0x2403068d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0xd02eff03, -0x1d03f0f0, -0x21030a00, -0x1f03f0f0, -0xd105f003, -0x24030f8d, +0x51009203, +0x24000092, 0x20830000, -0x24031b8d, +0x2403078d, 0x20830000, -0x1c0efefe, -0xd103f017, -0x11004f4f, -0x11000f0f, -0xd102f004, -0xf04f0b2f, -0x2401c08d, +0x1c0ef7f7, +0xe1003a97, +0x2400000f, +0x51004f07, +0x05014f04, +0xe0040c2f, +0x606f4f04, +0x2400004f, +0x2403158d, 0x20830000, -0x2401768d, -0x1f08cdcd, -0x24020a91, +0x1e2ef7f7, +0xe1003a97, +0x2402b38d, 0x20830000, -0x1c0efefe, -0xd103f00b, -0x11004f4f, -0x11000f0f, -0xd102f004, -0xf04f0b2f, -0x2402568d, +0x1c2ef7f7, +0xe1003a97, +0xd1047303, +0xd1067302, +0xc901f003, +0x24031e8d, 0x20830000, -0x2401768d, -0x1f08cdcd, -0x2402a091, +0x2403378d, 0x20830000, -0x2403298d, +0x1e0ef7f7, +0xe1003a97, +0x2403228d, 0x20830000, -0x24050984, -0xe1080a84, -0x2400e38d, -0x20830000, -0x1c2efefe, -0xc901f003, -0x2403338d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x2403408d, +0x51009203, +0x24000092, 0x20830000, -0x1e0efefe, -0x2403368d, +0x24032d8d, 0x20830000, -0x1e2efefe, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, +0x1e2ef7f7, +0xe1003a97, +0x2400e58d, +0xd1067306, 0x24050084, +0xc9057303, +0x51001302, +0x24050f84, 0xe1080a84, -0x2400e38d, 0x20830000, -0x1e2efefe, -0x2403438d, +0x1e2ef7f7, +0xe1003a97, +0x24033b8d, 0x20830000, -0x1e0efefe, +0x1e0ef7f7, +0xe1003a97, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400e58d, +0x20830000, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x24000092, +0x24050e84, +0xe1080a84, +0x2400e58d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034c8d, +0x24034e8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403528d, +0x2403548d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x504f0f03, 0x24050584, -0x21035700, +0x21035900, 0x24050684, 0x2400008f, 0x240000cf, @@ -892,29 +894,27 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x1e2efefe, -0x24036b8d, -0x20830000, -0x1e0efefe, +0x1e2ef7f7, +0xe1003a97, +0x24036a8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, 0x01010f0f, 0x24036e8d, 0x20830000, -0x2403658d, +0x2403638d, 0x20830000, -0x1c0efefe, -0x2403698d, +0x1c0ef7f7, +0xe1003a97, +0x2403688d, 0x20830000, 0x606f0f03, 0x2403738d, 0x20830000, -0x24036b8d, +0x24036a8d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050784, 0xe1080a84, 0x20830000, @@ -927,14 +927,14 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400e58d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index 7447d422c..37fcebda6 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -162,7 +162,7 @@ const uint32_t PRU1Firmware_0[] = { 0x6911c403, 0x2400888d, 0x20830000, -0x2400cb8d, +0x2400cd8d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -174,63 +174,65 @@ const uint32_t PRU1Firmware_0[] = { 0xf1e40a6e, 0x24008f8d, 0x20830000, -0x1e0efefe, -0x1e2efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2400988d, +0x2450d0da, +0x2408149a, +0xf1003a97, +0x1c0efefe, +0x1c2efefe, +0x1e0ef7f7, +0x1e2ef7f7, +0xe1003a97, +0x2400998d, 0x20830000, 0xf1940a50, -0x24009b8d, +0x24009c8d, 0x20830000, 0xf1950a70, -0x24009e8d, +0x24009f8d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a68d, +0x2400a78d, 0x20830000, -0x2400cb8d, +0x2400cd8d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100ab00, +0x2100ac00, 0x1f08f0f0, -0x2400ad8d, +0x2400ae8d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100b200, +0x2100b300, 0x1d00f0f0, -0x2400b48d, +0x2400b58d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b900, +0x2100ba00, 0x1d01f0f0, -0x2400bb8d, -0x20830000, -0xf1a42a84, -0xc905e403, -0x1f05f0f0, -0x2100c000, -0x1d05f0f0, -0x2400c28d, +0x2400bc8d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c700, +0x2100c100, 0x1d04f0f0, -0x2400e38d, +0x2400c38d, +0x20830000, +0xf1a42a84, +0x1d06f0f0, +0xc906e402, +0x1f06f0f0, +0xf1e80ad2, +0x24000092, +0x2400e58d, 0x24050084, 0xe1080a84, 0x20830000, @@ -241,22 +243,22 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400d48d, +0x2400d68d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400da8d, +0x2400dc8d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100e100, +0x2100e300, 0x24007a8d, 0x20830000, -0x2400d48d, +0x2400d68d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -265,626 +267,626 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400ec8d, +0x2400ee8d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400f28d, +0x2400f48d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100f900, -0x2400fb8d, +0x2100fb00, +0x2400fd8d, 0x20830000, -0x2400ec8d, +0x2400ee8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400ff8d, +0x2401018d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401078d, +0x2401098d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401108d, +0x24010f8d, 0x20830000, -0x1e2efefe, -0x1e0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2400cb8d, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x2400cd8d, 0x20830000, 0xf1082a84, 0x6911c403, 0x24007a8d, 0x20830000, -0x2401168d, +0x2401158d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401438d, +0x2401458d, 0x20830000, -0x24011c8d, +0x24011b8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013f8d, +0x24013e8d, 0x20830000, -0x2401228d, +0x2401218d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24013b8d, +0x24014c8d, 0x20830000, -0x2401298d, +0x2401288d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403488d, +0x24034a8d, 0x20830000, -0x24012f8d, +0x24012e8d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035b8d, +0x24035d8d, 0x20830000, -0x2401358d, +0x2401348d, 0x20830000, 0xf1082a84, 0x691fc403, 0x2403778d, 0x20830000, -0x24013b8d, +0x24013a8d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c091, -0x2401478d, +0x240000f3, +0x24000092, +0x2402008b, +0x24023091, +0x2401918d, +0x20830000, +0x1f02f0f0, +0x240000f3, +0x24000092, +0x2402008b, +0x2402b191, +0x2401918d, 0x20830000, +0xf1082a84, +0xd108f040, +0x240000f3, +0x24000092, +0x2402008b, +0x1f047373, +0xf1e00a33, +0x1d02f0f0, +0x24023091, +0x5114c42e, +0xc906f002, +0x1f007373, +0x5116c424, +0x2401ffe5, +0xe1000533, +0x2401ff8b, +0x2400016f, +0x5115c41b, +0x2400026f, +0x5117c419, +0x2400036f, +0x5119c417, +0x511bc40b, +0x2400016f, +0x1f027373, +0x24000151, +0x5118c404, +0x24000251, +0x511ac402, +0x1f037373, +0xc900731d, +0x1f057373, +0x21018700, +0xf1980a84, +0x5100841b, +0x2400fd86, +0xc9007302, +0x2400fc86, +0x48868417, +0x2401fee5, +0xe1000533, +0xe1010504, +0x2401fe8b, +0x0102046f, +0xc900730f, +0x1f017373, +0x01016f6f, +0x21018700, 0x1f02f0f0, -0x24020a91, -0x2401478d, -0x20830000, -0x1e2efefe, -0x1e0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x2401508d, +0x2402b191, +0x2400016f, +0xc9007308, +0x1f057373, +0x2400026f, +0x21018700, +0xc9003302, +0x1f02f0f0, +0x2400006f, +0x24031591, +0x2401918d, +0x20830000, +0x24050d84, +0xe1080a84, +0x2400e58d, +0x20830000, +0x24050b84, +0xe1080a84, +0x2400e58d, +0x20830000, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x2401978d, 0x20830000, 0xd108f003, 0x24007f84, -0x21015400, +0x21019b00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401588d, +0x24019f8d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21015e00, +0x2101a500, 0x1d08cdcd, -0x21016600, +0x2101ad00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21016400, +0x2101ab00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24016a8d, +0x2401b18d, 0x20830000, +0xd1047309, 0xf1980a84, -0x49ff8407, -0x61018406, +0x49ff8411, +0x61018410, 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401768d, +0x2401c88d, +0x20830000, +0xd102f008, +0x51006f07, +0xc9017305, +0x05016f04, +0x68044f03, +0x1013132f, +0x2101c200, +0xf04f0b2f, +0x2401c88d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400e58d, 0x20830000, -0xc900f002, -0x1c2efefe, -0x24017a8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0xc900f002, -0x1c0efefe, -0x24017e8d, +0x51009203, +0x24000092, +0x20830000, +0xd1047302, +0xc900f003, +0x1c2ef7f7, +0xe1003a97, +0x2401d78d, +0x20830000, +0x2401d98d, +0x20830000, +0xd1047302, +0xc900f003, +0x1c0ef7f7, +0xe1003a97, +0x2401df8d, 0x20830000, 0x0d0f0f05, -0xc805cd03, -0x1e2efefe, -0x21018300, -0x1c2efefe, +0xc805cd04, +0x1e2ef7f7, +0xe1003a97, +0x2101e600, +0x1c2ef7f7, +0xe1003a97, +0xc9007307, +0x0b071306, +0xc805cd02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, 0x01010f0f, -0x2401868d, +0x2401f08d, 0x20830000, -0x1e0efefe, -0x2401898d, +0x1e0ef7f7, +0xe1003a97, +0x2401f48d, 0x20830000, -0x24018b8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2401968d, +0x51009203, +0x24000092, +0x20830000, +0x2401ff8d, 0x20830000, -0x24017e8d, +0x1c0ef7f7, +0xe1003a97, +0x61080f05, +0x1e2ef7f7, +0xe1003a97, +0x2402088d, 0x20830000, -0x2401988d, +0x2401df8d, 0x20830000, -0x1e0efefe, +0x24020a8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, 0x11000f0f, -0x24019c8d, +0x24020f8d, +0x20830000, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, +0x20830000, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101a000, +0x21021c00, 0x1f03f0f0, -0x2401a28d, +0x24021e8d, 0x20830000, -0x1c0efefe, -0xd103f011, -0xc902f003, -0xc908f007, -0x51014f06, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, +0x1c0ef7f7, +0xe1003a97, +0xd103f009, 0xc908f005, 0x51014f04, 0x01014f4f, -0x24017e8d, +0x2401df8d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401b68d, +0x24022b8d, 0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400e38d, -0x20830000, -0xc9072f03, -0x1e2efefe, -0x2101c400, -0x1c2efefe, +0x1f067373, +0x2403158d, +0x20830000, +0xc9072f04, +0x1e2ef7f7, +0xe1003a97, +0x21023600, +0x1c2ef7f7, +0xe1003a97, +0xc9007307, +0x0b071306, +0xc9072f02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, 0x09012f2f, 0x01010f0f, -0x2401c88d, +0x2402418d, 0x20830000, -0x1e0efefe, -0x2401cb8d, +0x1e0ef7f7, +0xe1003a97, +0x2402458d, 0x20830000, -0x2401cd8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2401d88d, +0x51009203, +0x24000092, +0x20830000, +0x2402508d, 0x20830000, -0x2401c08d, +0x1c0ef7f7, +0xe1003a97, +0x61080f05, +0x1e2ef7f7, +0xe1003a97, +0x2402598d, 0x20830000, -0x2401da8d, +0x2402308d, 0x20830000, -0x1e0efefe, -0x2401dd8d, +0x24025b8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, +0x24025f8d, +0x20830000, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, +0x20830000, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101e100, +0x21026c00, 0x1f03f0f0, -0xd105f003, -0x2401e68d, -0x20830000, -0x2401f68d, +0x24026e8d, 0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f017, +0x1c0ef7f7, +0xe1003a97, +0xd103f00f, 0x01014f4f, -0x11000f0f, +0x2400000f, 0x606f4f04, -0x11004f4f, -0x24032d8d, -0x20830000, -0xf04f0b2f, -0x2401c08d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f007, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, +0x2400004f, +0x2402838d, +0x20830000, +0xc9017305, +0x05016f04, +0x68044f03, +0x1013132f, +0x21027d00, 0xf04f0b2f, -0x24032d8d, -0x20830000, -0x2402058d, +0x2402308d, 0x20830000, -0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2402888d, 0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402118d, +0xd1027303, +0x2403158d, 0x20830000, -0x1e0efefe, -0x09012f2f, -0x2402158d, -0x20830000, -0xd02eff03, -0x11fe2f2f, -0x21021900, -0x13012f2f, -0x01010f0f, -0x24021c8d, -0x20830000, -0x1c0efefe, -0x61080f13, -0x01014f4f, -0xd105f00a, -0x606f4f09, -0xc904f008, -0x2402358d, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402328d, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x24020f8d, -0x20830000, -0x1c2efefe, -0x2402388d, -0x20830000, -0x1e2efefe, -0x2402388d, +0x24028b8d, 0x20830000, -0x1e0efefe, -0xe1980a6f, -0x24023c8d, +0x1f067373, +0x2403158d, 0x20830000, -0xd105f003, -0x2402418d, +0x1e2ef7f7, +0xe1003a97, +0x24028f8d, 0x20830000, -0x2402498d, +0x1e0ef7f7, +0xe1003a97, +0x2402938d, 0x20830000, -0x1c0efefe, -0x11000f0f, -0x05014f04, -0xe0040c2f, -0x606f4f0a, -0x11004f4f, -0x24032d8d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1c0efefe, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0x24032d8d, +0x51009203, +0x24000092, 0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x24020f8d, +0x24029e8d, 0x20830000, -0xc9075103, -0x1e2efefe, -0x21025a00, -0x1c2efefe, -0x09015151, -0x01010f0f, -0x24025e8d, +0x1c2ef7f7, +0xe1003a97, +0x1d027373, +0x1f02f0f0, +0x1f08cdcd, +0x2400008f, +0x1051516f, +0xc9057302, +0x01016f6f, +0x2400004f, +0x2402b191, +0x2402ab8d, 0x20830000, -0x1e0efefe, -0x2402618d, +0x2402ad8d, 0x20830000, -0x2402638d, +0x1c0ef7f7, +0xe1003a97, +0x2401df8d, 0x20830000, -0x1c0efefe, -0x61080f08, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x24026e8d, +0x1e2ef7f7, +0xe1003a97, +0x2402b58d, 0x20830000, -0x2402568d, +0x1e0ef7f7, +0xe1003a97, +0x09012f2f, +0x2402ba8d, 0x20830000, -0x2402708d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x1e0efefe, -0x2402738d, +0x51009203, +0x24000092, 0x20830000, 0xd02eff03, -0x1d03f0f0, -0x21027700, -0x1f03f0f0, -0xd105f003, -0x24027c8d, -0x20830000, -0x24028c8d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f017, -0x01014f4f, -0x11000f0f, -0x606f4f04, -0x11004f4f, -0x2401c08d, -0x20830000, -0xf04f0b51, -0x2402568d, -0x20830000, -0x1c0efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0xd103f007, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0xf04f0b51, -0x2401c08d, -0x20830000, -0x24029b8d, +0x11fe2f2f, +0x2102c700, +0x13012f2f, +0xc9007307, +0x0b071306, +0xc9002f02, +0x15010606, +0x09011313, +0x51000602, +0x15071313, +0x01010f0f, +0x2402d18d, +0x20830000, +0x1c0ef7f7, +0xe1003a97, +0x61080f1b, +0xc9037312, +0x1d037373, +0x51002f0a, +0x102f2f6f, +0xc9057303, +0x51ff2f07, +0x01016f6f, +0x24000084, +0x102f2f04, +0xe1980a84, +0x2402f08d, 0x20830000, -0x1e0efefe, -0x24050984, +0x24050d84, 0xe1080a84, -0x2400e38d, -0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402a78d, -0x20830000, -0x1e0efefe, -0x09016f6f, -0x2402ab8d, -0x20830000, -0xd02eff03, -0x11fe6f6f, -0x2102af00, -0x13016f6f, -0x01010f0f, -0x2402b28d, +0x1f067373, +0x240101cf, +0x2402f48d, 0x20830000, -0x1c0efefe, -0x61080f13, 0x01014f4f, -0xd105f00a, -0x606f4f09, -0xc904f008, -0x2402cb8d, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402c88d, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, -0x20830000, -0x2402a58d, -0x20830000, -0x1c2efefe, -0x2402ce8d, -0x20830000, -0x1e2efefe, -0x2402ce8d, -0x20830000, -0x1e0efefe, -0xe1980a6f, -0x2402d28d, -0x20830000, -0xd105f003, -0x2402d78d, -0x20830000, -0x2402df8d, -0x20830000, -0x1c0efefe, -0x11000f0f, -0x05014f04, -0xe0040c6f, -0x606f4f0a, -0x11004f4f, -0x24020a8d, -0x20830000, -0x1c0efefe, -0x11000f0f, -0x11004f4f, -0x1d05f0f0, -0x24020a8d, -0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x2402a58d, -0x20830000, -0xc9072f03, -0x1e2efefe, -0x2102f000, -0x1c2efefe, -0x09012f2f, -0x01010f0f, +0x606f4f05, +0xd1047302, +0xc904f003, 0x2402f48d, 0x20830000, -0x1e0efefe, -0x2402f78d, +0x2402f08d, 0x20830000, -0x2402f98d, +0x2402b38d, 0x20830000, -0x1c0efefe, -0x61080f03, -0x2402ff8d, +0x1c2ef7f7, +0xe1003a97, +0x2402f88d, 0x20830000, -0x2402ec8d, +0x1e2ef7f7, +0xe1003a97, +0x2402f88d, 0x20830000, -0x1e2efefe, -0x1f00cdcd, -0x2403038d, +0x1e0ef7f7, +0xe1003a97, +0x2402fc8d, 0x20830000, -0x1e0efefe, -0x2403068d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0xd02eff03, -0x1d03f0f0, -0x21030a00, -0x1f03f0f0, -0xd105f003, -0x24030f8d, +0x51009203, +0x24000092, 0x20830000, -0x24031b8d, +0x2403078d, 0x20830000, -0x1c0efefe, -0xd103f017, -0x11004f4f, -0x11000f0f, -0xd102f004, -0xf04f0b2f, -0x2401c08d, +0x1c0ef7f7, +0xe1003a97, +0x2400000f, +0x51004f07, +0x05014f04, +0xe0040c2f, +0x606f4f04, +0x2400004f, +0x2403158d, 0x20830000, -0x2401768d, -0x1f08cdcd, -0x24020a91, +0x1e2ef7f7, +0xe1003a97, +0x2402b38d, 0x20830000, -0x1c0efefe, -0xd103f00b, -0x11004f4f, -0x11000f0f, -0xd102f004, -0xf04f0b2f, -0x2402568d, +0x1c2ef7f7, +0xe1003a97, +0xd1047303, +0xd1067302, +0xc901f003, +0x24031e8d, 0x20830000, -0x2401768d, -0x1f08cdcd, -0x2402a091, +0x2403378d, 0x20830000, -0x2403298d, +0x1e0ef7f7, +0xe1003a97, +0x2403228d, 0x20830000, -0x24050984, -0xe1080a84, -0x2400e38d, -0x20830000, -0x1c2efefe, -0xc901f003, -0x2403338d, +0xd00eff06, +0x01019292, +0x5100d203, +0x4892d202, +0x2403418d, 0x20830000, -0x2403408d, +0x51009203, +0x24000092, 0x20830000, -0x1e0efefe, -0x2403368d, +0x24032d8d, 0x20830000, -0x1e2efefe, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, +0x1e2ef7f7, +0xe1003a97, +0x2400e58d, +0xd1067306, 0x24050084, +0xc9057303, +0x51001302, +0x24050f84, 0xe1080a84, -0x2400e38d, 0x20830000, -0x1e2efefe, -0x2403438d, +0x1e2ef7f7, +0xe1003a97, +0x24033b8d, 0x20830000, -0x1e0efefe, +0x1e0ef7f7, +0xe1003a97, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400e58d, +0x20830000, +0x1e2ef7f7, +0xe1003a97, +0x1e0ef7f7, +0xe1003a97, +0x24000092, +0x24050e84, +0xe1080a84, +0x2400e58d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034c8d, +0x24034e8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403528d, +0x2403548d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x504f0f03, 0x24050584, -0x21035700, +0x21035900, 0x24050684, 0x2400008f, 0x240000cf, @@ -892,29 +894,27 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x2400008f, 0x240900cf, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1e2efcfc, -0xe1003d9c, -0x1e2efefe, -0x24036b8d, -0x20830000, -0x1e0efefe, +0x1e2ef7f7, +0xe1003a97, +0x24036a8d, +0x20830000, +0x1e0ef7f7, +0xe1003a97, 0x01010f0f, 0x24036e8d, 0x20830000, -0x2403658d, +0x2403638d, 0x20830000, -0x1c0efefe, -0x2403698d, +0x1c0ef7f7, +0xe1003a97, +0x2403688d, 0x20830000, 0x606f0f03, 0x2403738d, 0x20830000, -0x24036b8d, +0x24036a8d, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050784, 0xe1080a84, 0x20830000, @@ -927,14 +927,14 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400e58d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e38d, +0x2400e58d, 0x24050084, 0xe1080a84, 0x20830000, From aa47640e7c977d6d593da24fba21d64b8196d7df Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 2 Oct 2026 14:51:45 +0530 Subject: [PATCH 12/29] examples: pru_i2c: R5F: open-drain SCL, timing-safe tick, SCL timeout Follows the firmware's open-drain bus with clock stretching: - SysConfig: SCL (PR0_PRU1_GPIO18) gets rx and a pull-up like SDA, so the firmware can read SCL back, and SysConfig leaves both OUTDISABLE bits set (released). - Host: release both lines in ICSSM0_PRU1_GPIO_OUT_CTRL before starting the PRU, instead of enabling the SDA driver (which with R30 = 0 would hold SDA low until the firmware's setup). - The tick is the larger of 1/(4 * PRU_I2C_BUS_HZ) and 0.68 us so that SCL low meets the Fast-mode tLOW of 1.3 us (850 counts at 250 MHz, ~368 kHz). - Set the SCL-low timeout to the SMBus 25 ms. - readme: SMBus command table, open-drain/clock stretching, both lines need pull-ups; removed the "SCL is push-pull" and "SMBus stubs" limitations. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- .../am261x-lp/r5fss0-0_nortos/example.syscfg | 7 +- examples/pru_i2c/mcuplus/pru_i2c_example.c | 41 ++++++--- examples/pru_i2c/readme.md | 87 ++++++++++++------- 3 files changed, 89 insertions(+), 46 deletions(-) diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg index e9bca5832..0b7b84894 100644 --- a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg @@ -48,10 +48,13 @@ pruicss1.instance pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; pruicss1.AdditionalICSSSettings[0].PruGPIO.create(1); pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; -/* I2C SCL: PR0_PRU1_GPIO18, output only (BoosterPack J1.4) */ +/* I2C SCL: PR0_PRU1_GPIO18, open-drain, read back for clock stretching, + * internal pull-up (BoosterPack J1.4) */ pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.$assign = "GPIO120"; pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.$used = true; -/* I2C SDA: PR0_PRU1_GPIO19, input and output, internal pull-up (BoosterPack J1.3) */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.rx = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO18.pu_pd = "pu"; +/* I2C SDA: PR0_PRU1_GPIO19, open-drain, internal pull-up (BoosterPack J1.3) */ pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.$assign = "GPIO119"; pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.$used = true; pruicss1.AdditionalICSSSettings[0].PruGPIO[0]["PRU-ICSS0"].PR0_PRU1_GPIO19.rx = true; diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index 57672657b..20f035fdb 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -90,16 +90,30 @@ #define PRU_I2C_BUS_HZ (400000U) /* The firmware advances its state machine once per IEP compare event and - * needs 4 ticks per SCL period. The IEP counts PRU_I2C_IEP_DEFAULT_INC per - * IEP clock, and its clock comes from SysConfig (250 MHz by default on - * AM261x, while the IEP_CMP_INCREMENT_VAL_* constants in - * pru_i2c_interface.h assume 200 MHz). So derive the increment from the - * configured IEP clock, rounding the tick up to a whole IEP clock so that - * SCL never runs faster than PRU_I2C_BUS_HZ. */ + * needs 4 ticks per SCL period, with SCL low for 2 of them. The IEP counts + * PRU_I2C_IEP_DEFAULT_INC per IEP clock, and its clock comes from SysConfig + * (250 MHz by default on AM261x, while the IEP_CMP_INCREMENT_VAL_* constants + * in pru_i2c_interface.h assume 200 MHz). So derive the increment from the + * configured IEP clock: the tick is at least 1/(4 * PRU_I2C_BUS_HZ), and at + * least PRU_I2C_MIN_TICK_NS so that SCL low meets the Fast-mode + * tLOW >= 1.3 us (with margin for the few cycles the edges move by). At + * 400 kHz the second limit wins: about 368 kHz. */ #define PRU_I2C_IEP_DEFAULT_INC (5U) -#define PRU_I2C_IEP_CLKS_PER_TICK ((CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ + (4U * PRU_I2C_BUS_HZ) - 1U) / (4U * PRU_I2C_BUS_HZ)) +#define PRU_I2C_MIN_TICK_NS (680U) +#define PRU_I2C_IEP_CLKS_BUS \ + ((CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ + (4U * PRU_I2C_BUS_HZ) - 1U) / (4U * PRU_I2C_BUS_HZ)) +#define PRU_I2C_IEP_CLKS_TLOW \ + (((CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ / 1000U) * PRU_I2C_MIN_TICK_NS + 999999U) / 1000000U) +#define PRU_I2C_IEP_CLKS_PER_TICK \ + ((PRU_I2C_IEP_CLKS_BUS > PRU_I2C_IEP_CLKS_TLOW) ? PRU_I2C_IEP_CLKS_BUS : PRU_I2C_IEP_CLKS_TLOW) #define PRU_I2C_IEP_INCREMENT (PRU_I2C_IEP_CLKS_PER_TICK * PRU_I2C_IEP_DEFAULT_INC) +/* How long a target may hold SCL low (clock stretching) before the transfer + * ends with TIME_OUT_ERROR, in state machine ticks: the SMBus tTIMEOUT of + * 25 ms. */ +#define PRU_I2C_SCL_TIMEOUT_TICKS \ + ((25000U * 1000U) / ((PRU_I2C_IEP_CLKS_PER_TICK * 1000000U) / (CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ / 1000U))) + /* 7-bit address of the I2C target used for the demo transfers */ #define PRU_I2C_TARGET_ADDR (0x50U) /* Register pointer (first byte of every demo transfer) */ @@ -149,6 +163,7 @@ #define PRU_I2C_SCL_PIN_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_PIN_OFFSET) /* u8 */ #define PRU_I2C_SDA_PIN_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_PIN_OFFSET + 1U) /* u8 */ #define PRU_I2C_INST_ID_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_INST_ID_OFFSET) /* u8 */ +#define PRU_I2C_SCL_TIMEOUT_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_SCL_TIMEOUT_OFFSET) /* u16 */ /* Bit of the shared IRQ register that belongs to this instance. Use the core * number so a PRU0 and a PRU1 instance can run side by side. */ @@ -285,6 +300,7 @@ static int32_t PruI2c_init(void) HW_WR_REG8(gPruDmemBase + PRU_I2C_SCL_PIN_REG, PRU_I2C_SCL_PIN); HW_WR_REG8(gPruDmemBase + PRU_I2C_SDA_PIN_REG, PRU_I2C_SDA_PIN); HW_WR_REG8(gPruDmemBase + PRU_I2C_INST_ID_REG, PRU_I2C_INST_ID); + HW_WR_REG16(gPruDmemBase + PRU_I2C_SCL_TIMEOUT_REG, PRU_I2C_SCL_TIMEOUT_TICKS); /* Module enabled, master mode, 7-bit addressing, START and STOP around * every transfer, NACK the last byte of a read */ reg = (1U << ICSS_I2C_MODULE_ENABLE_BIT) | @@ -294,12 +310,13 @@ static int32_t PruI2c_init(void) (1U << ICSS_I2C_RECIEVE_NACK_BIT); HW_WR_REG32(gPruDmemBase + PRU_I2C_CON_REG, reg); - /* The firmware switches SDA between output and input with the matching - * bit of the ICSSM0_PRUx_GPIO_OUT_CTRL register (1 = output disabled). - * SysConfig sets that bit for pins configured with "rx", so make sure the - * SDA bit starts at 0 (output enabled) before the PRU runs. */ + /* The bus is open-drain: the firmware keeps the R30 bits at 0 and drives + * a line low by clearing its bit in ICSSM0_PRUx_GPIO_OUT_CTRL + * (1 = output disabled = released). Start with both lines released, so + * the PRU does not pull the bus low between reset and its setup. + * SysConfig already sets these bits for pins configured with "rx". */ reg = HW_RD_REG32(PRU_I2C_OUT_CTRL_REG); - reg &= ~(1U << PRU_I2C_SDA_PIN); + reg |= (1U << PRU_I2C_SCL_PIN) | (1U << PRU_I2C_SDA_PIN); HW_WR_REG32(PRU_I2C_OUT_CTRL_REG, reg); /* Load the firmware, this also starts the PRU core */ diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md index 0389d7944..1d7c08a7f 100644 --- a/examples/pru_i2c/readme.md +++ b/examples/pru_i2c/readme.md @@ -63,14 +63,17 @@ includes that header instead of repeating the values. DMEM0 0x000C | u16 | `I2C_BUS_FREQUENCY_OFFSET` | Shared by both cores. Bus frequency selector: `ICSS_I2C_100KHZ_FREQ` (3), `ICSS_I2C_400KHZ_FREQ` (2), `ICSS_I2C_1MHZ_FREQ` (1). Any other value sends the firmware into an error loop. DMEM0 0x000E | u16 | `I2C_BUS_FREQUENCY_OFFSET` + 2 | IEP compare increment per state tick (4 ticks per SCL period), a multiple of the IEP DEFAULT_INC (5). See "Bus frequency" below. own DMEM 0x0100 | | `ICSS_I2C_INSTANCE0_ADDR` | Start of the instance 0 block (offsets below are relative to it) - + 0x08 | u16 | `ICSS_I2C_COMMAND_OFFSET` | Response of the PRU (`COMMAND_SUCCESS` 0x0500, `ADDRESS_ACKNOWLDEGE_FAILED`, `DATA_ACKNOWLDEGE_FAILED`, `INVALID_COMMAND`, ...) - + 0x0A | u16 | `ICSS_I2C_COMMAND_OFFSET` + 2 | Command from the host (`ICSS_I2C_SETUP_CMD`, `ICSS_I2C_TX_CMD`, `ICSS_I2C_RX_CMD`, ...). The PRU clears it when it raises the response. + + 0x08 | u16 | `ICSS_I2C_COMMAND_OFFSET` | Response of the PRU (`COMMAND_SUCCESS` 0x0500, `ADDRESS_ACKNOWLDEGE_FAILED`, `DATA_ACKNOWLDEGE_FAILED`, `INVALID_DATA_COUNT`, `TIME_OUT_ERROR` (SCL held low too long), `PEC_ERROR`, `INVALID_COMMAND`, ...) + + 0x0A | u16 | `ICSS_I2C_COMMAND_OFFSET` + 2 | Command from the host (`ICSS_I2C_SETUP_CMD`, `ICSS_I2C_TX_CMD`, `ICSS_I2C_RX_CMD`, `ICSS_SMBUS_*_CMD`, ...). The PRU clears it when it raises the response. + 0x94 / + 0x95 | u8 | `ICSS_I2C_BUF_OFFSET` | TX / RX FIFO size - + 0x98 | u16 | `ICSS_I2C_CNT_OFFSET` | Number of bytes to transfer, 1..255 - + 0xA4 | u32 | `ICSS_I2C_CON_OFFSET` | Configuration: bit 15 module enable, bit 10 master (must be 1), bit 8 10-bit addressing, bit 5 SMBus burst, bit 4 NACK the last read byte, bit 1 send STOP, bit 0 send START + + 0x98 | u16 | `ICSS_I2C_CNT_OFFSET` | Number of bytes to transfer, 1..255 (I2C) or the block write length; after an SMBus block read, the byte count the target sent + + 0xA4 | u32 | `ICSS_I2C_CON_OFFSET` | Configuration: bit 15 module enable, bit 10 master (must be 1), bit 8 10-bit addressing, bit 6 SMBus PEC, bit 5 reserved, bit 4 NACK the last read byte, bit 1 send STOP, bit 0 send START (bits 4, 1 and 0 apply to I2C transfers; SMBus always sends START/STOP and NACKs the last byte) + 0xAC | u16 | `ICSS_I2C_SA_OFFSET` | 7-bit target address + 0xD8 / + 0xD9 | u8 | `ICSS_I2C_PRU_PIN_OFFSET` | SCL / SDA pin: the bit number in R30 (output) and R31 (input) + + 0xE0 | u8 | `ICSS_I2C_PRU_CMD_CODE_OFFSET` | SMBus command code (for quick command, bit 0 is the R/W bit) + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the bit used in the shared IRQ register. The example uses the core number, so a PRU0 and a PRU1 instance do not collide. + + 0xE8 | u16 | `ICSS_I2C_SCL_TIMEOUT_OFFSET` | Clock stretching limit in state machine ticks (4 per SCL period); 0 = wait indefinitely. The example uses the SMBus 25 ms. + + 0xFE / + 0xFF | | (reserved) | Used by the firmware to stage the SMBus command code and block count + 0x100 (0x0200) | 256 B| `ICSS_I2C_INSTANCE0_TX_MEM` | TX buffer + 0x200 (0x0300) | 256 B| `ICSS_I2C_INSTANCE0_RX_MEM` | RX buffer @@ -102,23 +105,47 @@ takes a one byte pointer followed by data: 3. write `[pointer]` (STOP is sent, the target keeps its pointer) 4. read 4 bytes and compare them with what was written -## SDA direction - -The firmware turns SDA into an input (to read the ACK bit or read data) by -setting the bit of the SDA pin in the `ICSSM0_PRUx_GPIO_OUT_CTRL` register of -MSS_CTRL (1 = output disabled; PRU0 at 0x50D00810, PRU1 at 0x50D00814) and -back to an output by clearing it. SysConfig sets that bit for every PRU GPIO -configured with "rx", which includes SDA. The R5F example therefore clears the -SDA bit of this register before it starts the PRU, so that the PRU can drive -the START condition. The firmware selects the register of the core it is built -for (`-DPRU0` / `-DPRU1`, and `-DICSSM1` for ICSSM1). +## SMBus + +The SMBus commands use the same buffers. Write the target address (`SA`), the +command code (+0xE0) and, for writes, the data into the TX buffer, then write +the command: + + Command | On the bus | Host input | Result + -------------------------------|-----------------------------------------|-------------------------|-------- + `ICSS_SMBUS_QUICK_CMD` | S addr+R/W P | R/W = command code bit 0 | - + `ICSS_SMBUS_SEND_BYTE_CMD` | S addr+W cmd P | cmd | - + `ICSS_SMBUS_RECEIVE_BYTE_CMD` | S addr+R data P | - | RX[0] + `ICSS_SMBUS_WRITE_BYTE_CMD` | S addr+W cmd TX[0] P | cmd, TX[0] | - + `ICSS_SMBUS_READ_BYTE_CMD` | S addr+W cmd Sr addr+R data P | cmd | RX[0] + `ICSS_SMBUS_WRITE_WORD_CMD` | S addr+W cmd low high P | cmd, TX[0] low, TX[1] high | - + `ICSS_SMBUS_READ_WORD_CMD` | S addr+W cmd Sr addr+R low high P | cmd | RX[0] low, RX[1] high + `ICSS_SMBUS_BLOCK_WRITE_CMD` | S addr+W cmd N TX[0..N-1] P | cmd, count = N (1..253, 252 with PEC) | - + `ICSS_SMBUS_BLOCK_READ_CMD` | S addr+W cmd Sr addr+R N data[N] P | cmd | count = N, RX[0..N-1] + +With PEC enabled (`CON` bit 6), writes end with the PEC byte and reads check +the target's PEC (`PEC_ERROR` if it does not match). Quick command has no PEC. +SMBus uses 7-bit addresses only. + +## Open-drain bus and clock stretching + +The firmware never drives SCL or SDA high. It keeps both R30 bits at 0 and +switches each line with its bit in the `ICSSM0_PRUx_GPIO_OUT_CTRL` register of +MSS_CTRL (PRU0 at 0x50D00810, PRU1 at 0x50D00814): 1 = output disabled, so the +pull-up takes the line high, 0 = driven low. After releasing SCL it waits +until SCL reads high, so targets can stretch the clock (up to +`ICSS_I2C_SCL_TIMEOUT_OFFSET`). Both pads therefore need the input path +("rx" in SysConfig) and a pull-up. The R5F example sets both +`OUTDISABLE` bits (released) before it starts the PRU. The firmware selects +the register of the core it is built for (`-DPRU0` / `-DPRU1`, and `-DICSSM1` +for ICSSM1). # Pin assignment (AM261x-LP) Signal | PRU GPIO (R30/R31 bit) | SoC pad | BoosterPack | Direction -------|------------------------|--------------------|-------------|---------- - SCL | PR0_PRU1_GPIO18 (18) | GPIO120 (ball C19) | J1.4 | output (push-pull) - SDA | PR0_PRU1_GPIO19 (19) | GPIO119 (ball C18) | J1.3 | input and output, internal pull-up enabled + SCL | PR0_PRU1_GPIO18 (18) | GPIO120 (ball C19) | J1.4 | open-drain (rx enabled), internal pull-up enabled + SDA | PR0_PRU1_GPIO19 (19) | GPIO119 (ball C18) | J1.3 | open-drain (rx enabled), internal pull-up enabled The bit numbers are set with `PRU_I2C_SCL_PIN` and `PRU_I2C_SDA_PIN` in `mcuplus/pru_i2c_example.c`. The pads are configured in @@ -151,10 +178,10 @@ Generic build, load and run steps are not repeated here, see the specific steps are: 1. **Wire the target.** Connect an I2C target to J1.4 (SCL), J1.3 (SDA) and - GND, and power it from 3.3 V. SDA needs a pull-up resistor (for example - 2.2 k to 4.7 k to 3.3 V). The example also enables the internal pull-up of - the SDA pad, but that one is weak, use an external resistor. SCL is driven - push-pull and needs no pull-up. The default target is an EEPROM-style device (for example a 24C02) + GND, and power it from 3.3 V. SCL and SDA both need a pull-up resistor + (for example 2.2 k to 4.7 k to 3.3 V). The example also enables the + internal pull-ups of both pads, but they are weak, use external resistors. + The default target is an EEPROM-style device (for example a 24C02) at address 0x50. Change `PRU_I2C_TARGET_ADDR` (and, if needed, `PRU_I2C_TARGET_REG`, `PRU_I2C_TEST_LEN`) in `mcuplus/pru_i2c_example.c` for another device. @@ -198,17 +225,12 @@ was not accepted. # Known limitations -* **SCL is push-pull.** The firmware drives SCL high and low; it does not - release it. Clock stretching by a target is not supported, and SCL must not - be shared with other bus masters or driven by another device. -* **Only plain I2C read and write are implemented.** The commands for - `ICSS_I2C_TX_CMD` (write) and `ICSS_I2C_RX_CMD` (read) work on a data - count of 1..255 bytes. The SMBus commands (`ICSS_SMBUS_*`: quick command, - send/receive byte, read/write byte/word, block read/write) are stubs in the - firmware and must not be used. * Master mode only, one instance (instance 0) per PRU core, no multi-master arbitration, 7-bit addressing in the example (the `CON` bit for 10-bit - addressing exists in the firmware interface but is not used here). + addressing exists in the firmware interface but is not used here; SMBus is + 7-bit only). +* The demo uses plain I2C writes and reads; the SMBus commands are described + above but not exercised by the example code. * The START and STOP bits of `CON` are latched by the setup command. The example sets both, so each transfer is a complete START ... STOP transaction. The pointer-then-read sequence of the demo therefore uses two separate @@ -219,9 +241,10 @@ was not accepted. settings of this example the IEP clock is 250 MHz (`CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ` in the generated `ti_drivers_config.h`; 200 MHz needs the R5F at 400 MHz), so the example derives the increment from - that define instead (`PRU_I2C_IEP_INCREMENT`), rounding up so SCL never runs - faster than `PRU_I2C_BUS_HZ`. At 250 MHz and 400 kHz that is 157 IEP clocks - per tick, about 398 kHz. Not yet measured on a board. + that define instead (`PRU_I2C_IEP_INCREMENT`). The tick is the larger of + 1/(4 x `PRU_I2C_BUS_HZ`) and 0.68 us, so that SCL low meets the Fast-mode + minimum of 1.3 us. At 250 MHz and 400 kHz that is 170 IEP clocks per tick, + about 368 kHz. Not yet measured on a board. * The example polls the IRQ bit instead of using the PRU interrupt. * The example is built for NORTOS on the r5fss0-0 core of the AM261x-LP only. * Build-tested only, see "Validated HW & SW". From 146ccecf645eebe374b24e7c603c9d48e32987c9 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:21:13 +0530 Subject: [PATCH 13/29] examples: pru_i2c: document IEP/context macros, mark scheduler wait Address review findings on the macros changed by the per-core IEP and scratchpad-bank fixes: - I2C_IEP_INTC_CLEAR_EVENT: add pseudocode, the arg1 no-event continuation label that was documented as 'Parameters: None', and the registers it modifies. - I2C_WAVE_FUNCTION0: add pseudocode and the registers it modifies, including the per-core context bank. - I2C_WAIT_FOR_IEP_CMP: tag the scheduler tick with INTENTIONALLY_UNBOUNDED_LOOP; there is no other time base to time it out against. Documentation only, no instruction changes. Co-Authored-By: Claude Sonnet 5.5 --- examples/pru_i2c/firmware/pru_i2c_macro.h | 27 ++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index 393b9c001..f268a9333 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -102,6 +102,7 @@ ENABLE_XIN_XOUT_SHITFTING .macro ;************************************************************************************ I2C_WAIT_FOR_IEP_CMP .macro + ; INTENTIONALLY_UNBOUNDED_LOOP: scheduler tick, see the notes above WAIT_FOR_INT?: LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4 QBBC WAIT_FOR_INT?, TEMP_REG1, I2C_IEP_CMP_STATUS_BIT @@ -118,14 +119,25 @@ WAIT_FOR_INT?: ; PEAK cycles: ; ; Pseudo code: -; +; status = IEP_CMP_STATUS_REG +; if(status.I2C_IEP_CMP_STATUS_BIT == 0) +; goto arg1 ; no tick pending for this core +; IEP_CMP_STATUS_REG = 1 << I2C_IEP_CMP_STATUS_BIT ; write-1-to-clear +; next_compare += I2C_GLOBAL_FREQ_REG.w2 ; 64-bit add +; I2C_IEP_CMP_REG = next_compare ; re-arm this core +; ICSS_INTC_SECR1 = 0x0080 ; clear the INTC event ; ; Parameters: -; None +; arg1 - required, a label in the caller that is jumped to when no compare +; event is pending for this core (the "no tick yet" continuation) ; ; Returns: ; None ; +; Registers modified: +; TEMP_REG1, TEMP_REG2.w0 (scratch) +; IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL2 (next compare value) +; ;************************************************************************************ I2C_IEP_INTC_CLEAR_EVENT .macro arg1 @@ -161,7 +173,9 @@ IEP_INTC_CLEAR?: ; PEAK cycles: ; ; Pseudo code: -; +; restore R10..R19 from I2C_CONTEXT_BANK ; this core's scratchpad bank +; call the state at R13.w0 ; return address in TEMP_REG3.w0 +; save R10..R19 to I2C_CONTEXT_BANK ; ; Parameters: ; None @@ -169,6 +183,13 @@ IEP_INTC_CLEAR?: ; Returns: ; None ; +; Registers modified: +; R0.b0 (XIN/XOUT offset), TEMP_REG3.w0 (state return address) +; R10..R19 (context: loaded from the bank, then written back to it) +; plus whatever the called state writes: states use TEMP_REG1..8 and +; R27..R29 as scratch and update the context registers. R20..R22 belong to +; the scheduler (compare value, frequency word), not to the states. +; ;************************************************************************************ I2C_WAVE_FUNCTION0 .macro From 6e436627b78e89942aea4173084ab882976428e0 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:21:54 +0530 Subject: [PATCH 14/29] examples: pru_i2c: align SDA direction macro spacing with best_practices White space between mnemonic and operand is 5 spaces for 3-letter and 4 for 4-letter operations (best_practices.md); the SET/CLR/LDI32/LBBO/SBBO lines in SET_SDA_PIN_INPUT/OUTPUT_DIRECTION used one space. Whitespace only, the assembled output is unchanged. Co-Authored-By: Claude Sonnet 5.5 --- examples/pru_i2c/firmware/pru_i2c_macro.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index f268a9333..be196b06a 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -954,10 +954,10 @@ SET_SDA_PIN_INPUT_DIRECTION .macro ; AM261x: set the SDA pin's OUTDISABLE bit in this core's ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) - LDI32 r29, I2C_GPIO_OUT_CTRL - LBBO &r28, r29, 0, 4 - SET r28, r28, R14.b1 - SBBO &r28, r29, 0, 4 + LDI32 r29, I2C_GPIO_OUT_CTRL + LBBO &r28, r29, 0, 4 + SET r28, r28, R14.b1 + SBBO &r28, r29, 0, 4 .endm @@ -983,10 +983,10 @@ SET_SDA_PIN_OUTPUT_DIRECTION .macro ; AM261x: clear the SDA pin's OUTDISABLE bit in this core's ; ICSSMx_PRUy_GPIO_OUT_CTRL (I2C_GPIO_OUT_CTRL, see pru_i2c_main.asm) - LDI32 r29, I2C_GPIO_OUT_CTRL - LBBO &r28, r29, 0, 4 - CLR r28, r28, R14.b1 - SBBO &r28, r29, 0, 4 + LDI32 r29, I2C_GPIO_OUT_CTRL + LBBO &r28, r29, 0, 4 + CLR r28, r28, R14.b1 + SBBO &r28, r29, 0, 4 .endm .endif ; __icss_i2c_macros_h From a0ca0167f33b66329da19071e2984843ff46892e Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:22:10 +0530 Subject: [PATCH 15/29] examples: pru_i2c: leave SDA released after an address or data NACK NO_ADDRESS_ACK_RECIEVED took SDA back with the SDA GPO still holding the last address bit (0 for a write), so after a NACKed write address the master pulled SDA low on a bus it never STOPped, contradicting the 'SDA is released whenever the bus is idle' rule. Leave SDA released: SET_SCL_SDA_HIGH takes it back at the start of the next transfer. The data-byte ACK slot had the same pattern (SET_SDA_PIN_OUTPUT_DIRECTION before testing the ACK bit). Take SDA back only after an ACK, when the master transmits next (data or STOP). Co-Authored-By: Claude Sonnet 5.5 --- examples/pru_i2c/firmware/pru_i2c_macro.h | 8 ++++++-- examples/pru_i2c/firmware/pru_i2c_main.asm | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index be196b06a..1f6b31745 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -684,8 +684,10 @@ tx_data_ack_read_next_state?: ; tx_data_ack_scl_end?: SET_SCL_PIN_LOW - SET_SDA_PIN_OUTPUT_DIRECTION QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT + ; ACKed: the master transmits next (data or STOP), take SDA back. On a + ; NACK SDA stays released so the bus is not held low. + SET_SDA_PIN_OUTPUT_DIRECTION ADD R15.b2, R15.b2, 0x01 AND R15.b0, R15.b0, 0x00 QBGT tx_mode_continue?, R15.b2, R15.b3 @@ -705,8 +707,10 @@ tx_mode_continue?: tx_data_ack_scl_end_v2?: SET_SCL_PIN_LOW - SET_SDA_PIN_OUTPUT_DIRECTION QBBS tx_data_ack_not_recieved?, R16, ICSS_I2C_ACK_RECIEVED_BIT + ; ACKed: the master transmits next (data or STOP), take SDA back. On a + ; NACK SDA stays released so the bus is not held low. + SET_SDA_PIN_OUTPUT_DIRECTION AND R15.b0, R15.b0, 0x00 AND R15.b2, R15.b2, 0x00 CLR R16, R16, ICSS_I2C_SMBUS_BURST_BIT diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 5d2401259..2f2d61ce0 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -982,7 +982,10 @@ ADDRESS_ACK_NOT_RECIEVED: ; raise an interrupt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NO_ADDRESS_ACK_RECIEVED: - SET_SDA_PIN_OUTPUT_DIRECTION + ; SDA stays released: it was handed to the target for the ACK slot and + ; the NACK left it high, so SCL high with SDA high is an idle bus. Taking + ; SDA back here would drive the last address bit (0 for a write) and hold + ; the bus busy. SET_SCL_SDA_HIGH takes SDA back at the next transfer. SET_SCL_PIN_HIGH LDI TEMP_REG4.w0, ADDRESS_ACKNOWLDEGE_FAILED SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2 From 466c7afbeacb191f436a5ff4105dacf0cb2a9d5c Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:22:26 +0530 Subject: [PATCH 16/29] examples: pru_i2c: derive the IEP compare increment from the frequency selector I2C_SETUP_IEP_COUNTER and I2C_IEP_INTC_CLEAR_EVENT add I2C_GLOBAL_FREQ_REG.w2 to the compare value, but startup only loaded the configuration word and nothing set w2 for the selected frequency. A configuration holding just the selector (w0) gave an increment of 0, so the compare was re-armed at the current count and the tick had no period. Set w2 from the selector (IEP_CMP_INCREMENT_VAL_100KHZ / _400KHZ / _1MHZ) before the IEP is set up. An unsupported selector keeps w2 = 0 and still ends in ERROR_LOOP. Any w2 the host wrote is now replaced by the selector's value. Co-Authored-By: Claude Sonnet 5.5 --- examples/pru_i2c/firmware/pru_i2c_main.asm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 2f2d61ce0..430d91338 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -190,7 +190,22 @@ init: LDI TEMP_REG1.w0, ICSS_I2C_CONFIG_MEMORY ADD TEMP_REG1.w0, TEMP_REG1.w0, I2C_BUS_FREQUENCY_OFFSET LBCO &I2C_GLOBAL_FREQ_REG.w0, ICSS_DMEM0_CONST, TEMP_REG1.w0, 4 - + + ; The configuration only has to carry the frequency selector (w0). Derive + ; the IEP compare increment (w2) from it here, so that a selector-only + ; configuration gets a nonzero tick period. An unsupported selector keeps + ; w2 = 0 and ends in ERROR_LOOP below. + LDI I2C_GLOBAL_FREQ_REG.w2, 0 + QBNE FREQ_NOT_100KHZ, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_100KHZ_FREQ + LDI I2C_GLOBAL_FREQ_REG.w2, IEP_CMP_INCREMENT_VAL_100KHZ +FREQ_NOT_100KHZ: + QBNE FREQ_NOT_400KHZ, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_400KHZ_FREQ + LDI I2C_GLOBAL_FREQ_REG.w2, IEP_CMP_INCREMENT_VAL_400KHZ +FREQ_NOT_400KHZ: + QBNE FREQ_NOT_1MHZ, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_1MHZ_FREQ + LDI I2C_GLOBAL_FREQ_REG.w2, IEP_CMP_INCREMENT_VAL_1MHZ +FREQ_NOT_1MHZ: + ;Debug code for testing .if $defined("DEBUG_CODE") LDI TEMP_REG1.w0, ICSS_I2C_400KHZ_FREQ From e161b919a7af06789b896059ad9038cc8b122cf4 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:22:28 +0530 Subject: [PATCH 17/29] examples: pru_i2c: document the shared-IEP start-up ordering constraint PRU0 and PRU1 share the IEP counter and IEP_CMP_CFG_REG and nothing in hardware serialises their start-up. State that the two cores must be released one after the other, and what goes wrong otherwise (lost enable bit, counter reset under the running core). The race itself is not closed in firmware: the enable-bit update is already a read-modify-write rather than the earlier overwrite, and no cross-core lock is available to these cores in this example. Co-Authored-By: Claude Sonnet 5.5 --- examples/pru_i2c/firmware/pru_i2c_macro.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index 1f6b31745..b6d4c2c33 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -745,6 +745,16 @@ no_tx_data_ack_recieved?: ; Macro: I2C_SETUP_IEP_COUNTER ; ; Description: Setup the IEP timer counter for periodic interrupt. +; +; The IEP counter and IEP_CMP_CFG_REG are shared by PRU0 and PRU1 and there is +; no hardware lock around them. The first core to run this macro resets and +; starts the counter; the second only joins it. The read-modify-write of +; IEP_CMP_CFG_REG (enable bit) and the "counter already enabled" test are not +; atomic across the two cores, so the two PRUs must not run this macro at the +; same time: release PRU0 and PRU1 from reset one after the other, with the +; first core past its init before the second starts. Two cores starting +; together can lose an enable bit (that core then waits forever in +; I2C_WAIT_FOR_IEP_CMP) or reset the counter under the other core. ; ; PEAK cycles: ; From 766798b0e1c981015cd3561407682558bad4350f Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:23:13 +0530 Subject: [PATCH 18/29] examples: pru_i2c: regenerate pru0/pru1_load_bin.h Rebuilt with the makefile flow (make -C examples/pru_i2c pru DEVICE=am261x BUILD_MCUPLUS=y) after the review-fix changes. Not hardware tested. Co-Authored-By: Claude Sonnet 5.5 --- .../firmware/am261x-lp/pru0_load_bin.h | 384 +++++++++--------- .../firmware/am261x-lp/pru1_load_bin.h | 384 +++++++++--------- 2 files changed, 386 insertions(+), 382 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index 5c914bca9..182ca432d 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -41,7 +41,7 @@ const uint32_t PRU0Firmware_0[] = { 0x240000cb, 0x2403008c, 0x240000cc, -0x24007a8d, +0x2400818d, 0x240000cd, 0x240000ce, 0x2400008e, @@ -61,6 +61,13 @@ const uint32_t PRU0Firmware_0[] = { 0x24000081, 0x010c8181, 0x90813896, +0x240000d6, +0x69039602, +0x2409c4d6, +0x69029602, +0x240271d6, +0x69019602, +0x240140d6, 0x91003a81, 0xd100e110, 0x91107a81, @@ -97,7 +104,7 @@ const uint32_t PRU0Firmware_0[] = { 0xcf00e1ff, 0x91743a81, 0xd100e102, -0x21003e00, +0x21004500, 0x240000e1, 0x1f00e1e1, 0x81743a81, @@ -117,7 +124,7 @@ const uint32_t PRU0Firmware_0[] = { 0xcf00e1ff, 0x91743a81, 0xd100e102, -0x21005200, +0x21005900, 0x240000e1, 0x1f00e1e1, 0x81743a81, @@ -137,7 +144,7 @@ const uint32_t PRU0Firmware_0[] = { 0xcf00e1ff, 0x91743a81, 0xd100e102, -0x21006600, +0x21006d00, 0x240000e1, 0x1f00e1e1, 0x81743a81, @@ -155,24 +162,24 @@ const uint32_t PRU0Firmware_0[] = { 0x7f0000ed, 0xf1a42a84, 0xc90fe402, -0x24007e8d, +0x2400858d, 0x20830000, 0xf1082a84, 0x5100c408, 0x6911c403, -0x2400888d, +0x24008f8d, 0x20830000, -0x2400cb8d, +0x2400d28d, 0x24050c84, 0xe1080a84, 0x20830000, 0x20830000, 0xf1d82a8e, 0x2400006e, -0x24008c8d, +0x2400938d, 0x20830000, 0xf1e40a6e, -0x24008f8d, +0x2400968d, 0x20830000, 0x1e0efefe, 0x1e2efefe, @@ -181,56 +188,56 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2400988d, +0x24009f8d, 0x20830000, 0xf1940a50, -0x24009b8d, +0x2400a28d, 0x20830000, 0xf1950a70, -0x24009e8d, +0x2400a58d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a68d, +0x2400ad8d, 0x20830000, -0x2400cb8d, +0x2400d28d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100ab00, +0x2100b200, 0x1f08f0f0, -0x2400ad8d, +0x2400b48d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100b200, +0x2100b900, 0x1d00f0f0, -0x2400b48d, +0x2400bb8d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b900, +0x2100c000, 0x1d01f0f0, -0x2400bb8d, +0x2400c28d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100c000, +0x2100c700, 0x1d05f0f0, -0x2400c28d, +0x2400c98d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c700, +0x2100ce00, 0x1d04f0f0, -0x2400e38d, +0x2400ea8d, 0x24050084, 0xe1080a84, 0x20830000, @@ -241,22 +248,22 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400d48d, +0x2400db8d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400da8d, +0x2400e18d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100e100, -0x24007a8d, +0x2100e800, +0x2400818d, 0x20830000, -0x2400d48d, +0x2400db8d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -265,34 +272,34 @@ const uint32_t PRU0Firmware_0[] = { 0x90851884, 0x1e6e8484, 0x80851884, -0x2400ec8d, +0x2400f38d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400f28d, +0x2400f98d, 0x20830000, 0x24000085, 0x01088585, 0x90851884, 0xc86e8402, -0x2100f900, -0x2400fb8d, +0x21010000, +0x2401028d, 0x20830000, -0x2400ec8d, +0x2400f38d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400ff8d, +0x2401068d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401078d, +0x24010e8d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401108d, +0x2401178d, 0x20830000, 0x1e2efefe, 0x1e0efefe, @@ -301,62 +308,62 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2400cb8d, +0x2400d28d, 0x20830000, 0xf1082a84, 0x6911c403, -0x24007a8d, +0x2400818d, 0x20830000, -0x2401168d, +0x24011d8d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401438d, +0x24014a8d, 0x20830000, -0x24011c8d, +0x2401238d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013f8d, +0x2401468d, 0x20830000, -0x2401228d, +0x2401298d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24013b8d, +0x2401428d, 0x20830000, -0x2401298d, +0x2401308d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403488d, +0x24034a8d, 0x20830000, -0x24012f8d, +0x2401368d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035b8d, +0x24035d8d, 0x20830000, -0x2401358d, +0x24013c8d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403778d, +0x2403798d, 0x20830000, -0x24013b8d, +0x2401428d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c091, -0x2401478d, +0x2401c291, +0x24014e8d, 0x20830000, 0x1f02f0f0, -0x24020a91, -0x2401478d, +0x24020c91, +0x24014e8d, 0x20830000, 0x1e2efefe, 0x1e0efefe, @@ -365,33 +372,33 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0x2401508d, +0x2401578d, 0x20830000, 0xd108f003, 0x24007f84, -0x21015400, +0x21015b00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401588d, +0x24015f8d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21015e00, +0x21016500, 0x1d08cdcd, -0x21016600, +0x21016d00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21016400, +0x21016b00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24016a8d, +0x2401718d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -399,32 +406,32 @@ const uint32_t PRU0Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401768d, +0x24017d8d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x24017a8d, +0x2401818d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24017e8d, +0x2401858d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21018300, +0x21018a00, 0x1c2efefe, 0x01010f0f, -0x2401868d, +0x24018d8d, 0x20830000, 0x1e0efefe, -0x2401898d, +0x2401908d, 0x20830000, -0x24018b8d, +0x2401928d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -433,21 +440,21 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401968d, +0x24019d8d, 0x20830000, -0x24017e8d, +0x2401858d, 0x20830000, -0x2401988d, +0x24019f8d, 0x20830000, 0x1e0efefe, 0x11000f0f, -0x24019c8d, +0x2401a38d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101a000, +0x2101a700, 0x1f03f0f0, -0x2401a28d, +0x2401a98d, 0x20830000, 0x1c0efefe, 0xd103f011, @@ -462,36 +469,31 @@ const uint32_t PRU0Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x24017e8d, +0x2401858d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401b68d, +0x2401bd8d, 0x20830000, -0x2450d0dd, -0x2408109d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101c400, +0x2101c600, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0x1e0efefe, -0x2401cb8d, -0x20830000, 0x2401cd8d, 0x20830000, +0x2401cf8d, +0x20830000, 0x1c0efefe, 0x61080f08, 0x2450d0dd, @@ -499,77 +501,77 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401d88d, +0x2401da8d, 0x20830000, -0x2401c08d, +0x2401c28d, 0x20830000, -0x2401da8d, +0x2401dc8d, 0x20830000, 0x1e0efefe, -0x2401dd8d, +0x2401df8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101e100, +0x2101e300, 0x1f03f0f0, 0xd105f003, -0x2401e68d, +0x2401e88d, 0x20830000, -0x2401f68d, +0x2401f88d, 0x20830000, 0x1c0efefe, +0xd103f01c, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x24032d8d, +0x24032f8d, 0x20830000, 0xf04f0b2f, -0x2401c08d, +0x2401c28d, 0x20830000, 0x1c0efefe, +0xd103f00c, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x24032d8d, +0x24032f8d, 0x20830000, -0x2402058d, +0x2402078d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402118d, +0x2402138d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402158d, +0x2402178d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21021900, +0x21021b00, 0x13012f2f, 0x01010f0f, -0x24021c8d, +0x24021e8d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -577,36 +579,36 @@ const uint32_t PRU0Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402358d, +0x2402378d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402328d, +0x2402348d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x24020f8d, +0x2402118d, 0x20830000, 0x1c2efefe, -0x2402388d, +0x24023a8d, 0x20830000, 0x1e2efefe, -0x2402388d, +0x24023a8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x24023c8d, +0x24023e8d, 0x20830000, 0xd105f003, -0x2402418d, +0x2402438d, 0x20830000, -0x2402498d, +0x24024b8d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -614,34 +616,34 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x24032d8d, +0x24032f8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24032d8d, +0x24032f8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24020f8d, +0x2402118d, 0x20830000, 0xc9075103, 0x1e2efefe, -0x21025a00, +0x21025c00, 0x1c2efefe, 0x09015151, 0x01010f0f, -0x24025e8d, +0x2402608d, 0x20830000, 0x1e0efefe, -0x2402618d, -0x20830000, 0x2402638d, 0x20830000, +0x2402658d, +0x20830000, 0x1c0efefe, 0x61080f08, 0x2450d0dd, @@ -649,77 +651,77 @@ const uint32_t PRU0Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24026e8d, +0x2402708d, 0x20830000, -0x2402568d, +0x2402588d, 0x20830000, -0x2402708d, +0x2402728d, 0x20830000, 0x1e0efefe, -0x2402738d, +0x2402758d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21027700, +0x21027900, 0x1f03f0f0, 0xd105f003, -0x24027c8d, +0x24027e8d, 0x20830000, -0x24028c8d, +0x24028e8d, 0x20830000, 0x1c0efefe, +0xd103f01c, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401c08d, +0x2401c28d, 0x20830000, 0xf04f0b51, -0x2402568d, +0x2402588d, 0x20830000, 0x1c0efefe, +0xd103f00c, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401c08d, +0x2401c28d, 0x20830000, -0x24029b8d, +0x24029d8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402a78d, +0x2402a98d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402ab8d, +0x2402ad8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102af00, +0x2102b100, 0x13016f6f, 0x01010f0f, -0x2402b28d, +0x2402b48d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -727,36 +729,36 @@ const uint32_t PRU0Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402cb8d, +0x2402cd8d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402c88d, +0x2402ca8d, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402a58d, +0x2402a78d, 0x20830000, 0x1c2efefe, -0x2402ce8d, +0x2402d08d, 0x20830000, 0x1e2efefe, -0x2402ce8d, +0x2402d08d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402d28d, +0x2402d48d, 0x20830000, 0xd105f003, -0x2402d78d, +0x2402d98d, 0x20830000, -0x2402df8d, +0x2402e18d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -764,55 +766,55 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x24020a8d, +0x24020c8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24020a8d, +0x24020c8d, 0x20830000, 0x2450d0dd, 0x2408109d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402a58d, +0x2402a78d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2102f000, +0x2102f200, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2402f48d, +0x2402f68d, 0x20830000, 0x1e0efefe, -0x2402f78d, -0x20830000, 0x2402f98d, 0x20830000, +0x2402fb8d, +0x20830000, 0x1c0efefe, 0x61080f03, -0x2402ff8d, +0x2403018d, 0x20830000, -0x2402ec8d, +0x2402ee8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x2403038d, +0x2403058d, 0x20830000, 0x1e0efefe, -0x2403068d, +0x2403088d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21030a00, +0x21030c00, 0x1f03f0f0, 0xd105f003, -0x24030f8d, +0x2403118d, 0x20830000, -0x24031b8d, +0x24031d8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -820,11 +822,11 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401c08d, +0x2401c28d, 0x20830000, -0x2401768d, +0x24017d8d, 0x1f08cdcd, -0x24020a91, +0x24020c91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -832,26 +834,26 @@ const uint32_t PRU0Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2402568d, +0x2402588d, 0x20830000, -0x2401768d, +0x24017d8d, 0x1f08cdcd, -0x2402a091, +0x2402a291, 0x20830000, -0x2403298d, +0x24032b8d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x2403338d, +0x2403358d, 0x20830000, -0x2403408d, +0x2403428d, 0x20830000, 0x1e0efefe, -0x2403368d, +0x2403388d, 0x20830000, 0x1e2efefe, 0x2450d0dd, @@ -861,30 +863,30 @@ const uint32_t PRU0Firmware_0[] = { 0xe1003d9c, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x1e2efefe, -0x2403438d, +0x2403458d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034c8d, +0x24034e8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403528d, +0x2403548d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x504f0f03, 0x24050584, -0x21035700, +0x21035900, 0x24050684, 0x2400008f, 0x240000cf, @@ -898,23 +900,23 @@ const uint32_t PRU0Firmware_0[] = { 0x1e2efcfc, 0xe1003d9c, 0x1e2efefe, -0x24036b8d, +0x24036d8d, 0x20830000, 0x1e0efefe, 0x01010f0f, -0x24036e8d, +0x2403708d, 0x20830000, -0x2403658d, +0x2403678d, 0x20830000, 0x1c0efefe, -0x2403698d, +0x24036b8d, 0x20830000, 0x606f0f03, -0x2403738d, +0x2403758d, 0x20830000, -0x24036b8d, +0x24036d8d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050784, 0xe1080a84, 0x20830000, @@ -923,18 +925,18 @@ const uint32_t PRU0Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403828d, +0x2403848d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index 7447d422c..d868dbcaf 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -41,7 +41,7 @@ const uint32_t PRU1Firmware_0[] = { 0x240000cb, 0x2403008c, 0x240000cc, -0x24007a8d, +0x2400818d, 0x240000cd, 0x240000ce, 0x2400008e, @@ -61,6 +61,13 @@ const uint32_t PRU1Firmware_0[] = { 0x24000081, 0x010c8181, 0x90813996, +0x240000d6, +0x69039602, +0x2409c4d6, +0x69029602, +0x240271d6, +0x69019602, +0x240140d6, 0x91003a81, 0xd100e110, 0x91107a81, @@ -97,7 +104,7 @@ const uint32_t PRU1Firmware_0[] = { 0xcf01e1ff, 0x91743a81, 0xd101e102, -0x21003e00, +0x21004500, 0x240000e1, 0x1f01e1e1, 0x81743a81, @@ -117,7 +124,7 @@ const uint32_t PRU1Firmware_0[] = { 0xcf01e1ff, 0x91743a81, 0xd101e102, -0x21005200, +0x21005900, 0x240000e1, 0x1f01e1e1, 0x81743a81, @@ -137,7 +144,7 @@ const uint32_t PRU1Firmware_0[] = { 0xcf01e1ff, 0x91743a81, 0xd101e102, -0x21006600, +0x21006d00, 0x240000e1, 0x1f01e1e1, 0x81743a81, @@ -155,24 +162,24 @@ const uint32_t PRU1Firmware_0[] = { 0x7f0000ed, 0xf1a42a84, 0xc90fe402, -0x24007e8d, +0x2400858d, 0x20830000, 0xf1082a84, 0x5100c408, 0x6911c403, -0x2400888d, +0x24008f8d, 0x20830000, -0x2400cb8d, +0x2400d28d, 0x24050c84, 0xe1080a84, 0x20830000, 0x20830000, 0xf1d82a8e, 0x2400006e, -0x24008c8d, +0x2400938d, 0x20830000, 0xf1e40a6e, -0x24008f8d, +0x2400968d, 0x20830000, 0x1e0efefe, 0x1e2efefe, @@ -181,56 +188,56 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2400988d, +0x24009f8d, 0x20830000, 0xf1940a50, -0x24009b8d, +0x2400a28d, 0x20830000, 0xf1950a70, -0x24009e8d, +0x2400a58d, 0x20830000, 0xf1a42a84, 0xc90ae403, -0x2400a68d, +0x2400ad8d, 0x20830000, -0x2400cb8d, +0x2400d28d, 0x24050a84, 0xe1080a84, 0x20830000, 0xf1a42a84, 0xd108e403, 0x1d08f0f0, -0x2100ab00, +0x2100b200, 0x1f08f0f0, -0x2400ad8d, +0x2400b48d, 0x20830000, 0xf1a42a84, 0xc900e403, 0x1f00f0f0, -0x2100b200, +0x2100b900, 0x1d00f0f0, -0x2400b48d, +0x2400bb8d, 0x20830000, 0xf1a42a84, 0xc901e403, 0x1f01f0f0, -0x2100b900, +0x2100c000, 0x1d01f0f0, -0x2400bb8d, +0x2400c28d, 0x20830000, 0xf1a42a84, 0xc905e403, 0x1f05f0f0, -0x2100c000, +0x2100c700, 0x1d05f0f0, -0x2400c28d, +0x2400c98d, 0x20830000, 0xf1a42a84, 0xc904e403, 0x1f04f0f0, -0x2100c700, +0x2100ce00, 0x1d04f0f0, -0x2400e38d, +0x2400ea8d, 0x24050084, 0xe1080a84, 0x20830000, @@ -241,22 +248,22 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400d48d, +0x2400db8d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400da8d, +0x2400e18d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100e100, -0x24007a8d, +0x2100e800, +0x2400818d, 0x20830000, -0x2400d48d, +0x2400db8d, 0x20830000, 0x24000084, 0xe10a0a84, @@ -265,34 +272,34 @@ const uint32_t PRU1Firmware_0[] = { 0x90851984, 0x1e6e8484, 0x80851984, -0x2400ec8d, +0x2400f38d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400f28d, +0x2400f98d, 0x20830000, 0x24000085, 0x01088585, 0x90851984, 0xc86e8402, -0x2100f900, -0x2400fb8d, +0x21010000, +0x2401028d, 0x20830000, -0x2400ec8d, +0x2400f38d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2400ff8d, +0x2401068d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401078d, +0x24010e8d, 0x24050084, 0xe1080a84, 0x20830000, -0x2401108d, +0x2401178d, 0x20830000, 0x1e2efefe, 0x1e0efefe, @@ -301,62 +308,62 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2400cb8d, +0x2400d28d, 0x20830000, 0xf1082a84, 0x6911c403, -0x24007a8d, +0x2400818d, 0x20830000, -0x2401168d, +0x24011d8d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401438d, +0x24014a8d, 0x20830000, -0x24011c8d, +0x2401238d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013f8d, +0x2401468d, 0x20830000, -0x2401228d, +0x2401298d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24013b8d, +0x2401428d, 0x20830000, -0x2401298d, +0x2401308d, 0x20830000, 0xf1082a84, 0x691dc403, -0x2403488d, +0x24034a8d, 0x20830000, -0x24012f8d, +0x2401368d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035b8d, +0x24035d8d, 0x20830000, -0x2401358d, +0x24013c8d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403778d, +0x2403798d, 0x20830000, -0x24013b8d, +0x2401428d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050c84, 0xe1080a84, 0x20830000, 0x1d02f0f0, -0x2401c091, -0x2401478d, +0x2401c291, +0x24014e8d, 0x20830000, 0x1f02f0f0, -0x24020a91, -0x2401478d, +0x24020c91, +0x24014e8d, 0x20830000, 0x1e2efefe, 0x1e0efefe, @@ -365,33 +372,33 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0x2401508d, +0x2401578d, 0x20830000, 0xd108f003, 0x24007f84, -0x21015400, +0x21015b00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x2401588d, +0x24015f8d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x21015e00, +0x21016500, 0x1d08cdcd, -0x21016600, +0x21016d00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x21016400, +0x21016b00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x24016a8d, +0x2401718d, 0x20830000, 0xf1980a84, 0x49ff8407, @@ -399,32 +406,32 @@ const uint32_t PRU1Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401768d, +0x24017d8d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xc900f002, 0x1c2efefe, -0x24017a8d, +0x2401818d, 0x20830000, 0xc900f002, 0x1c0efefe, -0x24017e8d, +0x2401858d, 0x20830000, 0x0d0f0f05, 0xc805cd03, 0x1e2efefe, -0x21018300, +0x21018a00, 0x1c2efefe, 0x01010f0f, -0x2401868d, +0x24018d8d, 0x20830000, 0x1e0efefe, -0x2401898d, +0x2401908d, 0x20830000, -0x24018b8d, +0x2401928d, 0x20830000, 0x1c0efefe, 0x61080f08, @@ -433,21 +440,21 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401968d, +0x24019d8d, 0x20830000, -0x24017e8d, +0x2401858d, 0x20830000, -0x2401988d, +0x24019f8d, 0x20830000, 0x1e0efefe, 0x11000f0f, -0x24019c8d, +0x2401a38d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101a000, +0x2101a700, 0x1f03f0f0, -0x2401a28d, +0x2401a98d, 0x20830000, 0x1c0efefe, 0xd103f011, @@ -462,36 +469,31 @@ const uint32_t PRU1Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x24017e8d, +0x2401858d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x2401b68d, +0x2401bd8d, 0x20830000, -0x2450d0dd, -0x2408149d, -0xf1003d9c, -0x1c2efcfc, -0xe1003d9c, 0x1e0efefe, 0x24050884, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2101c400, +0x2101c600, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0x1e0efefe, -0x2401cb8d, -0x20830000, 0x2401cd8d, 0x20830000, +0x2401cf8d, +0x20830000, 0x1c0efefe, 0x61080f08, 0x2450d0dd, @@ -499,77 +501,77 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2401d88d, +0x2401da8d, 0x20830000, -0x2401c08d, +0x2401c28d, 0x20830000, -0x2401da8d, +0x2401dc8d, 0x20830000, 0x1e0efefe, -0x2401dd8d, +0x2401df8d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x2101e100, +0x2101e300, 0x1f03f0f0, 0xd105f003, -0x2401e68d, +0x2401e88d, 0x20830000, -0x2401f68d, +0x2401f88d, 0x20830000, 0x1c0efefe, +0xd103f01c, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x24032d8d, +0x24032f8d, 0x20830000, 0xf04f0b2f, -0x2401c08d, +0x2401c28d, 0x20830000, 0x1c0efefe, +0xd103f00c, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b2f, -0x24032d8d, +0x24032f8d, 0x20830000, -0x2402058d, +0x2402078d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402118d, +0x2402138d, 0x20830000, 0x1e0efefe, 0x09012f2f, -0x2402158d, +0x2402178d, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x21021900, +0x21021b00, 0x13012f2f, 0x01010f0f, -0x24021c8d, +0x24021e8d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -577,36 +579,36 @@ const uint32_t PRU1Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402358d, +0x2402378d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402328d, +0x2402348d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x24020f8d, +0x2402118d, 0x20830000, 0x1c2efefe, -0x2402388d, +0x24023a8d, 0x20830000, 0x1e2efefe, -0x2402388d, +0x24023a8d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x24023c8d, +0x24023e8d, 0x20830000, 0xd105f003, -0x2402418d, +0x2402438d, 0x20830000, -0x2402498d, +0x24024b8d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -614,34 +616,34 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c2f, 0x606f4f0a, 0x11004f4f, -0x24032d8d, +0x24032f8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24032d8d, +0x24032f8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24020f8d, +0x2402118d, 0x20830000, 0xc9075103, 0x1e2efefe, -0x21025a00, +0x21025c00, 0x1c2efefe, 0x09015151, 0x01010f0f, -0x24025e8d, +0x2402608d, 0x20830000, 0x1e0efefe, -0x2402618d, -0x20830000, 0x2402638d, 0x20830000, +0x2402658d, +0x20830000, 0x1c0efefe, 0x61080f08, 0x2450d0dd, @@ -649,77 +651,77 @@ const uint32_t PRU1Firmware_0[] = { 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x24026e8d, +0x2402708d, 0x20830000, -0x2402568d, +0x2402588d, 0x20830000, -0x2402708d, +0x2402728d, 0x20830000, 0x1e0efefe, -0x2402738d, +0x2402758d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21027700, +0x21027900, 0x1f03f0f0, 0xd105f003, -0x24027c8d, +0x24027e8d, 0x20830000, -0x24028c8d, +0x24028e8d, 0x20830000, 0x1c0efefe, +0xd103f01c, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f017, 0x01014f4f, 0x11000f0f, 0x606f4f04, 0x11004f4f, -0x2401c08d, +0x2401c28d, 0x20830000, 0xf04f0b51, -0x2402568d, +0x2402588d, 0x20830000, 0x1c0efefe, +0xd103f00c, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, -0xd103f007, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, 0xf04f0b51, -0x2401c08d, +0x2401c28d, 0x20830000, -0x24029b8d, +0x24029d8d, 0x20830000, 0x1e0efefe, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402a78d, +0x2402a98d, 0x20830000, 0x1e0efefe, 0x09016f6f, -0x2402ab8d, +0x2402ad8d, 0x20830000, 0xd02eff03, 0x11fe6f6f, -0x2102af00, +0x2102b100, 0x13016f6f, 0x01010f0f, -0x2402b28d, +0x2402b48d, 0x20830000, 0x1c0efefe, 0x61080f13, @@ -727,36 +729,36 @@ const uint32_t PRU1Firmware_0[] = { 0xd105f00a, 0x606f4f09, 0xc904f008, -0x2402cb8d, +0x2402cd8d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402c88d, +0x2402ca8d, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1c2efcfc, 0xe1003d9c, 0x20830000, -0x2402a58d, +0x2402a78d, 0x20830000, 0x1c2efefe, -0x2402ce8d, +0x2402d08d, 0x20830000, 0x1e2efefe, -0x2402ce8d, +0x2402d08d, 0x20830000, 0x1e0efefe, 0xe1980a6f, -0x2402d28d, +0x2402d48d, 0x20830000, 0xd105f003, -0x2402d78d, +0x2402d98d, 0x20830000, -0x2402df8d, +0x2402e18d, 0x20830000, 0x1c0efefe, 0x11000f0f, @@ -764,55 +766,55 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c6f, 0x606f4f0a, 0x11004f4f, -0x24020a8d, +0x24020c8d, 0x20830000, 0x1c0efefe, 0x11000f0f, 0x11004f4f, 0x1d05f0f0, -0x24020a8d, +0x24020c8d, 0x20830000, 0x2450d0dd, 0x2408149d, 0xf1003d9c, 0x1e2efcfc, 0xe1003d9c, -0x2402a58d, +0x2402a78d, 0x20830000, 0xc9072f03, 0x1e2efefe, -0x2102f000, +0x2102f200, 0x1c2efefe, 0x09012f2f, 0x01010f0f, -0x2402f48d, +0x2402f68d, 0x20830000, 0x1e0efefe, -0x2402f78d, -0x20830000, 0x2402f98d, 0x20830000, +0x2402fb8d, +0x20830000, 0x1c0efefe, 0x61080f03, -0x2402ff8d, +0x2403018d, 0x20830000, -0x2402ec8d, +0x2402ee8d, 0x20830000, 0x1e2efefe, 0x1f00cdcd, -0x2403038d, +0x2403058d, 0x20830000, 0x1e0efefe, -0x2403068d, +0x2403088d, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21030a00, +0x21030c00, 0x1f03f0f0, 0xd105f003, -0x24030f8d, +0x2403118d, 0x20830000, -0x24031b8d, +0x24031d8d, 0x20830000, 0x1c0efefe, 0xd103f017, @@ -820,11 +822,11 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2401c08d, +0x2401c28d, 0x20830000, -0x2401768d, +0x24017d8d, 0x1f08cdcd, -0x24020a91, +0x24020c91, 0x20830000, 0x1c0efefe, 0xd103f00b, @@ -832,26 +834,26 @@ const uint32_t PRU1Firmware_0[] = { 0x11000f0f, 0xd102f004, 0xf04f0b2f, -0x2402568d, +0x2402588d, 0x20830000, -0x2401768d, +0x24017d8d, 0x1f08cdcd, -0x2402a091, +0x2402a291, 0x20830000, -0x2403298d, +0x24032b8d, 0x20830000, 0x24050984, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x1c2efefe, 0xc901f003, -0x2403338d, +0x2403358d, 0x20830000, -0x2403408d, +0x2403428d, 0x20830000, 0x1e0efefe, -0x2403368d, +0x2403388d, 0x20830000, 0x1e2efefe, 0x2450d0dd, @@ -861,30 +863,30 @@ const uint32_t PRU1Firmware_0[] = { 0xe1003d9c, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x1e2efefe, -0x2403438d, +0x2403458d, 0x20830000, 0x1e0efefe, 0x24050084, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034c8d, +0x24034e8d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403528d, +0x2403548d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x504f0f03, 0x24050584, -0x21035700, +0x21035900, 0x24050684, 0x2400008f, 0x240000cf, @@ -898,23 +900,23 @@ const uint32_t PRU1Firmware_0[] = { 0x1e2efcfc, 0xe1003d9c, 0x1e2efefe, -0x24036b8d, +0x24036d8d, 0x20830000, 0x1e0efefe, 0x01010f0f, -0x24036e8d, +0x2403708d, 0x20830000, -0x2403658d, +0x2403678d, 0x20830000, 0x1c0efefe, -0x2403698d, +0x24036b8d, 0x20830000, 0x606f0f03, -0x2403738d, +0x2403758d, 0x20830000, -0x24036b8d, +0x24036d8d, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050784, 0xe1080a84, 0x20830000, @@ -923,18 +925,18 @@ const uint32_t PRU1Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403828d, +0x2403848d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e38d, +0x2400ea8d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e38d, +0x2400ea8d, 0x24050084, 0xe1080a84, 0x20830000, From 9b8099ee89cd0ff4d4be0d3c547da4f80d87896d Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:49:44 +0530 Subject: [PATCH 19/29] examples: pru_i2c: keep a host-written IEP compare increment Derive w2 from the frequency selector only when the host left it at 0, so a nonzero increment written by the host stays an override. Co-Authored-By: Claude Opus 5.5 --- examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h | 2 +- examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h | 2 +- examples/pru_i2c/firmware/pru_i2c_main.asm | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index 182ca432d..efac88636 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -61,7 +61,7 @@ const uint32_t PRU0Firmware_0[] = { 0x24000081, 0x010c8181, 0x90813896, -0x240000d6, +0x6900d607, 0x69039602, 0x2409c4d6, 0x69029602, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index d868dbcaf..15146d22e 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -61,7 +61,7 @@ const uint32_t PRU1Firmware_0[] = { 0x24000081, 0x010c8181, 0x90813996, -0x240000d6, +0x6900d607, 0x69039602, 0x2409c4d6, 0x69029602, diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index 430d91338..4c84fbfbb 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -191,11 +191,12 @@ init: ADD TEMP_REG1.w0, TEMP_REG1.w0, I2C_BUS_FREQUENCY_OFFSET LBCO &I2C_GLOBAL_FREQ_REG.w0, ICSS_DMEM0_CONST, TEMP_REG1.w0, 4 - ; The configuration only has to carry the frequency selector (w0). Derive - ; the IEP compare increment (w2) from it here, so that a selector-only - ; configuration gets a nonzero tick period. An unsupported selector keeps - ; w2 = 0 and ends in ERROR_LOOP below. - LDI I2C_GLOBAL_FREQ_REG.w2, 0 + ; The configuration only has to carry the frequency selector (w0). If the + ; host left the IEP compare increment (w2) at 0, derive it from the + ; selector here so that a selector-only configuration gets a nonzero tick + ; period. A nonzero w2 written by the host is kept as an override. An + ; unsupported selector ends in ERROR_LOOP below. + QBNE FREQ_NOT_1MHZ, I2C_GLOBAL_FREQ_REG.w2, 0 QBNE FREQ_NOT_100KHZ, I2C_GLOBAL_FREQ_REG.w0, ICSS_I2C_100KHZ_FREQ LDI I2C_GLOBAL_FREQ_REG.w2, IEP_CMP_INCREMENT_VAL_100KHZ FREQ_NOT_100KHZ: From e3082439d887dddb3431cc813eb8c730e230bb6c Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 13:54:01 +0530 Subject: [PATCH 20/29] examples: pru_i2c: R5F: add file name headers to host sources Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c | 1 + examples/pru_i2c/mcuplus/pru_i2c_example.c | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c index ad9984816..58db51ec3 100644 --- a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c @@ -1,3 +1,4 @@ +/* File: main.c */ /* * Copyright (C) 2026 Texas Instruments Incorporated * diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index 20f035fdb..3b6e55ca4 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -1,3 +1,4 @@ +/* File: pru_i2c_example.c */ /* * Copyright (C) 2026 Texas Instruments Incorporated * From 70d0def102a4eec4d2347130d92738296ff3555e Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 13:54:10 +0530 Subject: [PATCH 21/29] examples: pru_i2c: R5F: order PRU data writes before the command write Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/mcuplus/pru_i2c_example.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index 3b6e55ca4..e95a56178 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -244,6 +244,9 @@ static int32_t PruI2c_sendCommand(uint16_t command, uint16_t *response) { int32_t status; + /* Make sure the configuration and the TX data written by the caller are + * visible to the PRU before it sees the command. */ + __sync_synchronize(); HW_WR_REG16(gPruDmemBase + PRU_I2C_COMMAND_REG, command); status = PruI2c_waitForPru(PRU_I2C_TIMEOUT_US); From c9fc41c8d0552c3d64e2614860400b43d8fe4236 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 13:54:48 +0530 Subject: [PATCH 22/29] examples: pru_i2c: R5F: tell a firmware SCL timeout from a host polling timeout Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/mcuplus/pru_i2c_example.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index e95a56178..a5f53ae0f 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -205,7 +205,7 @@ static const char *PruI2c_responseToString(uint16_t response) case ADDRESSING_MODE_FAILED: str = "ADDRESSING_MODE_FAILED"; break; case INVALID_COMMAND: str = "INVALID_COMMAND"; break; case INVALID_DATA_COUNT: str = "INVALID_DATA_COUNT"; break; - case TIME_OUT_ERROR: str = "TIME_OUT_ERROR (no response from PRU)"; break; + case TIME_OUT_ERROR: str = "TIME_OUT_ERROR (SCL held low too long)"; break; default: str = "unknown response"; break; } return str; @@ -257,6 +257,8 @@ static int32_t PruI2c_sendCommand(uint16_t command, uint16_t *response) } else { + /* Not a firmware response: the PRU did not report anything in time */ + DebugP_log("PRU I2C: no response from PRU within %u us\r\n", PRU_I2C_TIMEOUT_US); *response = TIME_OUT_ERROR; } return status; From 7c69e09f12532f00dc2f0410f52cf018333fc596 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 13:55:12 +0530 Subject: [PATCH 23/29] examples: pru_i2c: name the SMBus block write count limits Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/firmware/pru_i2c_main.asm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_main.asm b/examples/pru_i2c/firmware/pru_i2c_main.asm index a0c4af683..6708e2729 100644 --- a/examples/pru_i2c/firmware/pru_i2c_main.asm +++ b/examples/pru_i2c/firmware/pru_i2c_main.asm @@ -145,6 +145,12 @@ SMB_F_SMB .set 4 ; SMBus: always START/STOP, NACK SMB_F_PECRX .set 5 ; the read ends with the target's PEC SMB_F_ERR .set 6 ; error already reported, end with STOP +; SMBus block write data count limits, in bytes. The stream (command code, +; count, data and the optional PEC byte) has to fit the 8-bit stream index, +; so the PEC byte takes one byte off the limit. +SMBUS_BLOCK_MAX_LEN .set 253 +SMBUS_BLOCK_MAX_LEN_PEC .set 252 + ;-------------------------------------------------------------------------------------- @@ -862,13 +868,13 @@ SMBUS_MODE_READ: JMP SMBUS_MODE_START SMBUS_MODE_BLOCK_WRITE: - ; N = data count, 1..253 (252 with PEC) so that cmd, N, data and PEC fit - ; the 8-bit stream index + ; N = data count, 1..SMBUS_BLOCK_MAX_LEN (SMBUS_BLOCK_MAX_LEN_PEC with + ; PEC) so that cmd, N, data and PEC fit the 8-bit stream index LBBO &TEMP_REG4.w0, R10, ICSS_I2C_CNT_OFFSET, 2 QBEQ SMBUS_MODE_COUNT_ERROR, TEMP_REG4.w0, 0 - LDI TEMP_REG6.w0, 253 + LDI TEMP_REG6.w0, SMBUS_BLOCK_MAX_LEN QBBC SMBUS_MODE_BLOCK_MAX, R19.b3, SMB_F_PEC - LDI TEMP_REG6.w0, 252 + LDI TEMP_REG6.w0, SMBUS_BLOCK_MAX_LEN_PEC SMBUS_MODE_BLOCK_MAX: QBLT SMBUS_MODE_COUNT_ERROR, TEMP_REG4.w0, TEMP_REG6.w0 LDI TEMP_REG5, ICSS_I2C_INSTANCE0_TX_MEM - 2 From 8aac84c19f68d1bd46ee690242ef61c14ee663f8 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 14:04:27 +0530 Subject: [PATCH 24/29] examples: pru_i2c: R5F: drop the 'check return status' note on Drivers_open Drivers_open() returns void in this SDK, so there is no status to check. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Pratheesh Gangadhar --- examples/pru_i2c/mcuplus/pru_i2c_example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index a5f53ae0f..71df68963 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -417,7 +417,7 @@ void pru_i2c_example_main(void *args) int32_t status; int32_t testStatus = SystemP_SUCCESS; - Drivers_open(); // check return status + Drivers_open(); status = Board_driversOpen(); DebugP_assert(SystemP_SUCCESS == status); From 8f4c1c2c1af68524d08414519b3233995ba0d8f1 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 13:56:59 +0530 Subject: [PATCH 25/29] examples: pru_i2c: one IRQ flag byte per instance The firmware set its bit in the shared 16-bit IRQ word with a load, set and store, and the host cleared it with a read-modify-write. If both ran at the same moment, or PRU0 and PRU1 raised their flags together, one write erased the other's bit and that host timed out. Each instance now owns the byte IRQ_COMMON_REGISTER_OFFSET + instance id: the PRU writes 1 with one store (no load first), the host writes 0. Regenerate pru0/pru1_load_bin.h. The raise macro drops one load and one set and adds one add and one load immediate; the check macro adds one add. Not tested on hardware. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Pratheesh Gangadhar --- .../firmware/am261x-lp/pru0_load_bin.h | 290 +++++++++--------- .../firmware/am261x-lp/pru1_load_bin.h | 290 +++++++++--------- examples/pru_i2c/firmware/pru_i2c_interface.h | 6 +- examples/pru_i2c/firmware/pru_i2c_macro.h | 14 +- examples/pru_i2c/mcuplus/pru_i2c_example.c | 22 +- examples/pru_i2c/readme.md | 16 +- 6 files changed, 324 insertions(+), 314 deletions(-) diff --git a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h index 81e4a11e7..c8a7c1557 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h @@ -232,7 +232,7 @@ const uint32_t PRU0Firmware_0[] = { 0x1f06f0f0, 0xf1e80ad2, 0x24000092, -0x2400e58d, +0x2400e68d, 0x24050084, 0xe1080a84, 0x20830000, @@ -240,9 +240,9 @@ const uint32_t PRU0Firmware_0[] = { 0xe10a0a84, 0x24000085, 0x01088585, -0x90851884, -0x1e6e8484, -0x80851884, +0x006e8585, +0x24000104, +0x80851804, 0x2400d68d, 0x20830000, 0x24020085, @@ -253,9 +253,10 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x24000085, 0x01088585, -0x90851884, -0xc86e8402, -0x2100e300, +0x006e8585, +0x90851804, +0x51000402, +0x2100e400, 0x24007a8d, 0x20830000, 0x2400d68d, @@ -264,37 +265,38 @@ const uint32_t PRU0Firmware_0[] = { 0xe10a0a84, 0x24000085, 0x01088585, -0x90851884, -0x1e6e8484, -0x80851884, -0x2400ee8d, +0x006e8585, +0x24000104, +0x80851804, +0x2400ef8d, 0x20830000, 0x24020085, 0x240010c6, 0x24000086, 0x80852086, -0x2400f48d, +0x2400f58d, 0x20830000, 0x24000085, 0x01088585, -0x90851884, -0xc86e8402, -0x2100fb00, -0x2400fd8d, +0x006e8585, +0x90851804, +0x51000402, +0x2100fd00, +0x2400ff8d, 0x20830000, -0x2400ee8d, +0x2400ef8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2401018d, +0x2401038d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401098d, +0x24010b8d, 0x24050084, 0xe1080a84, 0x20830000, -0x24010f8d, +0x2401118d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, @@ -306,46 +308,46 @@ const uint32_t PRU0Firmware_0[] = { 0x6911c403, 0x24007a8d, 0x20830000, -0x2401158d, +0x2401178d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401458d, +0x2401478d, 0x20830000, -0x24011b8d, +0x24011d8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013e8d, +0x2401408d, 0x20830000, -0x2401218d, +0x2401238d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24014c8d, +0x24014e8d, 0x20830000, -0x2401288d, +0x24012a8d, 0x20830000, 0xf1082a84, 0x691dc403, -0x24034a8d, +0x24034c8d, 0x20830000, -0x24012e8d, +0x2401308d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035d8d, +0x24035f8d, 0x20830000, -0x2401348d, +0x2401368d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403778d, +0x2403798d, 0x20830000, -0x24013a8d, +0x24013c8d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -353,15 +355,15 @@ const uint32_t PRU0Firmware_0[] = { 0x240000f3, 0x24000092, 0x2402008b, -0x24023091, -0x2401918d, +0x24023291, +0x2401938d, 0x20830000, 0x1f02f0f0, 0x240000f3, 0x24000092, 0x2402008b, -0x2402b191, -0x2401918d, +0x2402b391, +0x2401938d, 0x20830000, 0xf1082a84, 0xd108f040, @@ -371,7 +373,7 @@ const uint32_t PRU0Firmware_0[] = { 0x1f047373, 0xf1e00a33, 0x1d02f0f0, -0x24023091, +0x24023291, 0x5114c42e, 0xc906f002, 0x1f007373, @@ -395,7 +397,7 @@ const uint32_t PRU0Firmware_0[] = { 0x1f037373, 0xc900731d, 0x1f057373, -0x21018700, +0x21018900, 0xf1980a84, 0x5100841b, 0x2400fd86, @@ -410,59 +412,59 @@ const uint32_t PRU0Firmware_0[] = { 0xc900730f, 0x1f017373, 0x01016f6f, -0x21018700, +0x21018900, 0x1f02f0f0, -0x2402b191, +0x2402b391, 0x2400016f, 0xc9007308, 0x1f057373, 0x2400026f, -0x21018700, +0x21018900, 0xc9003302, 0x1f02f0f0, 0x2400006f, -0x24031591, -0x2401918d, +0x24031791, +0x2401938d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x24050b84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, 0x1e0ef7f7, 0xe1003a97, -0x2401978d, +0x2401998d, 0x20830000, 0xd108f003, 0x24007f84, -0x21019b00, +0x21019d00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x24019f8d, +0x2401a18d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x2101a500, +0x2101a700, 0x1d08cdcd, -0x2101ad00, +0x2101af00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x2101ab00, +0x2101ad00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x2401b18d, +0x2401b38d, 0x20830000, 0xd1047309, 0xf1980a84, @@ -471,7 +473,7 @@ const uint32_t PRU0Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0xd102f008, 0x51006f07, @@ -479,19 +481,19 @@ const uint32_t PRU0Firmware_0[] = { 0x05016f04, 0x68044f03, 0x1013132f, -0x2101c200, +0x2101c400, 0xf04f0b2f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, @@ -500,21 +502,21 @@ const uint32_t PRU0Firmware_0[] = { 0xc900f003, 0x1c2ef7f7, 0xe1003a97, -0x2401d78d, -0x20830000, 0x2401d98d, 0x20830000, +0x2401db8d, +0x20830000, 0xd1047302, 0xc900f003, 0x1c0ef7f7, 0xe1003a97, -0x2401df8d, +0x2401e18d, 0x20830000, 0x0d0f0f05, 0xc805cd04, 0x1e2ef7f7, 0xe1003a97, -0x2101e600, +0x2101e800, 0x1c2ef7f7, 0xe1003a97, 0xc9007307, @@ -525,53 +527,53 @@ const uint32_t PRU0Firmware_0[] = { 0x51000602, 0x15071313, 0x01010f0f, -0x2401f08d, +0x2401f28d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2401f48d, +0x2401f68d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2401ff8d, +0x2402018d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, 0x61080f05, 0x1e2ef7f7, 0xe1003a97, -0x2402088d, +0x24020a8d, 0x20830000, -0x2401df8d, +0x2401e18d, 0x20830000, -0x24020a8d, +0x24020c8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x11000f0f, -0x24020f8d, +0x2402118d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21021c00, +0x21021e00, 0x1f03f0f0, -0x24021e8d, +0x2402208d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -579,22 +581,22 @@ const uint32_t PRU0Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x2401df8d, +0x2401e18d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x24022b8d, +0x24022d8d, 0x20830000, 0x24050884, 0xe1080a84, 0x1f067373, -0x2403158d, +0x2403178d, 0x20830000, 0xc9072f04, 0x1e2ef7f7, 0xe1003a97, -0x21023600, +0x21023800, 0x1c2ef7f7, 0xe1003a97, 0xc9007307, @@ -606,52 +608,52 @@ const uint32_t PRU0Firmware_0[] = { 0x15071313, 0x09012f2f, 0x01010f0f, -0x2402418d, +0x2402438d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402458d, +0x2402478d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2402508d, +0x2402528d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, 0x61080f05, 0x1e2ef7f7, 0xe1003a97, -0x2402598d, +0x24025b8d, 0x20830000, -0x2402308d, +0x2402328d, 0x20830000, -0x24025b8d, +0x24025d8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x24025f8d, +0x2402618d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21026c00, +0x21026e00, 0x1f03f0f0, -0x24026e8d, +0x2402708d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -660,46 +662,46 @@ const uint32_t PRU0Firmware_0[] = { 0x2400000f, 0x606f4f04, 0x2400004f, -0x2402838d, +0x2402858d, 0x20830000, 0xc9017305, 0x05016f04, 0x68044f03, 0x1013132f, -0x21027d00, +0x21027f00, 0xf04f0b2f, -0x2402308d, +0x2402328d, 0x20830000, 0x24050984, 0xe1080a84, -0x2402888d, +0x24028a8d, 0x20830000, 0xd1027303, -0x2403158d, +0x2403178d, 0x20830000, -0x24028b8d, +0x24028d8d, 0x20830000, 0x1f067373, -0x2403158d, +0x2403178d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x24028f8d, +0x2402918d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402938d, +0x2402958d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x24029e8d, +0x2402a08d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, @@ -711,36 +713,36 @@ const uint32_t PRU0Firmware_0[] = { 0xc9057302, 0x01016f6f, 0x2400004f, -0x2402b191, -0x2402ab8d, -0x20830000, +0x2402b391, 0x2402ad8d, 0x20830000, +0x2402af8d, +0x20830000, 0x1c0ef7f7, 0xe1003a97, -0x2401df8d, +0x2401e18d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402b58d, +0x2402b78d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x09012f2f, -0x2402ba8d, +0x2402bc8d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x2102c700, +0x2102c900, 0x13012f2f, 0xc9007307, 0x0b071306, @@ -750,7 +752,7 @@ const uint32_t PRU0Firmware_0[] = { 0x51000602, 0x15071313, 0x01010f0f, -0x2402d18d, +0x2402d38d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -765,46 +767,46 @@ const uint32_t PRU0Firmware_0[] = { 0x24000084, 0x102f2f04, 0xe1980a84, -0x2402f08d, +0x2402f28d, 0x20830000, 0x24050d84, 0xe1080a84, 0x1f067373, 0x240101cf, -0x2402f48d, +0x2402f68d, 0x20830000, 0x01014f4f, 0x606f4f05, 0xd1047302, 0xc904f003, -0x2402f48d, +0x2402f68d, 0x20830000, -0x2402f08d, +0x2402f28d, 0x20830000, -0x2402b38d, +0x2402b58d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, -0x2402f88d, +0x2402fa8d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402f88d, +0x2402fa8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402fc8d, +0x2402fe8d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2403078d, +0x2403098d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -814,39 +816,39 @@ const uint32_t PRU0Firmware_0[] = { 0xe0040c2f, 0x606f4f04, 0x2400004f, -0x2403158d, +0x2403178d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402b38d, +0x2402b58d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, 0xd1047303, 0xd1067302, 0xc901f003, -0x24031e8d, +0x2403208d, 0x20830000, -0x2403378d, +0x2403398d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2403228d, +0x2403248d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x24032d8d, +0x24032f8d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2400e58d, +0x2400e68d, 0xd1067306, 0x24050084, 0xc9057303, @@ -856,13 +858,13 @@ const uint32_t PRU0Firmware_0[] = { 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x24033b8d, +0x24033d8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x24050084, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, @@ -871,22 +873,22 @@ const uint32_t PRU0Firmware_0[] = { 0x24000092, 0x24050e84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034e8d, +0x2403508d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403548d, +0x2403568d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x504f0f03, 0x24050584, -0x21035900, +0x21035b00, 0x24050684, 0x2400008f, 0x240000cf, @@ -896,25 +898,25 @@ const uint32_t PRU0Firmware_0[] = { 0x240900cf, 0x1e2ef7f7, 0xe1003a97, -0x24036a8d, +0x24036c8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x01010f0f, -0x24036e8d, +0x2403708d, 0x20830000, -0x2403638d, +0x2403658d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, -0x2403688d, +0x24036a8d, 0x20830000, 0x606f0f03, -0x2403738d, +0x2403758d, 0x20830000, -0x24036a8d, +0x24036c8d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050784, 0xe1080a84, 0x20830000, @@ -923,18 +925,18 @@ const uint32_t PRU0Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403828d, +0x2403848d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h index 37fcebda6..b3f144771 100644 --- a/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h +++ b/examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h @@ -232,7 +232,7 @@ const uint32_t PRU1Firmware_0[] = { 0x1f06f0f0, 0xf1e80ad2, 0x24000092, -0x2400e58d, +0x2400e68d, 0x24050084, 0xe1080a84, 0x20830000, @@ -240,9 +240,9 @@ const uint32_t PRU1Firmware_0[] = { 0xe10a0a84, 0x24000085, 0x01088585, -0x90851984, -0x1e6e8484, -0x80851984, +0x006e8585, +0x24000104, +0x80851904, 0x2400d68d, 0x20830000, 0x24020085, @@ -253,9 +253,10 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x24000085, 0x01088585, -0x90851984, -0xc86e8402, -0x2100e300, +0x006e8585, +0x90851904, +0x51000402, +0x2100e400, 0x24007a8d, 0x20830000, 0x2400d68d, @@ -264,37 +265,38 @@ const uint32_t PRU1Firmware_0[] = { 0xe10a0a84, 0x24000085, 0x01088585, -0x90851984, -0x1e6e8484, -0x80851984, -0x2400ee8d, +0x006e8585, +0x24000104, +0x80851904, +0x2400ef8d, 0x20830000, 0x24020085, 0x240020c6, 0x24000086, 0x80852086, -0x2400f48d, +0x2400f58d, 0x20830000, 0x24000085, 0x01088585, -0x90851984, -0xc86e8402, -0x2100fb00, -0x2400fd8d, +0x006e8585, +0x90851904, +0x51000402, +0x2100fd00, +0x2400ff8d, 0x20830000, -0x2400ee8d, +0x2400ef8d, 0x20830000, 0xf1082a84, 0x5100c402, -0x2401018d, +0x2401038d, 0x20830000, 0xf1082a84, 0x6910c405, -0x2401098d, +0x24010b8d, 0x24050084, 0xe1080a84, 0x20830000, -0x24010f8d, +0x2401118d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, @@ -306,46 +308,46 @@ const uint32_t PRU1Firmware_0[] = { 0x6911c403, 0x24007a8d, 0x20830000, -0x2401158d, +0x2401178d, 0x20830000, 0xf1082a84, 0x6912c403, -0x2401458d, +0x2401478d, 0x20830000, -0x24011b8d, +0x24011d8d, 0x20830000, 0xf1082a84, 0x6913c403, -0x24013e8d, +0x2401408d, 0x20830000, -0x2401218d, +0x2401238d, 0x20830000, 0xf1082a84, 0x491cc404, 0x6114c403, -0x24014c8d, +0x24014e8d, 0x20830000, -0x2401288d, +0x24012a8d, 0x20830000, 0xf1082a84, 0x691dc403, -0x24034a8d, +0x24034c8d, 0x20830000, -0x24012e8d, +0x2401308d, 0x20830000, 0xf1082a84, 0x691ec403, -0x24035d8d, +0x24035f8d, 0x20830000, -0x2401348d, +0x2401368d, 0x20830000, 0xf1082a84, 0x691fc403, -0x2403778d, +0x2403798d, 0x20830000, -0x24013a8d, +0x24013c8d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050c84, 0xe1080a84, 0x20830000, @@ -353,15 +355,15 @@ const uint32_t PRU1Firmware_0[] = { 0x240000f3, 0x24000092, 0x2402008b, -0x24023091, -0x2401918d, +0x24023291, +0x2401938d, 0x20830000, 0x1f02f0f0, 0x240000f3, 0x24000092, 0x2402008b, -0x2402b191, -0x2401918d, +0x2402b391, +0x2401938d, 0x20830000, 0xf1082a84, 0xd108f040, @@ -371,7 +373,7 @@ const uint32_t PRU1Firmware_0[] = { 0x1f047373, 0xf1e00a33, 0x1d02f0f0, -0x24023091, +0x24023291, 0x5114c42e, 0xc906f002, 0x1f007373, @@ -395,7 +397,7 @@ const uint32_t PRU1Firmware_0[] = { 0x1f037373, 0xc900731d, 0x1f057373, -0x21018700, +0x21018900, 0xf1980a84, 0x5100841b, 0x2400fd86, @@ -410,59 +412,59 @@ const uint32_t PRU1Firmware_0[] = { 0xc900730f, 0x1f017373, 0x01016f6f, -0x21018700, +0x21018900, 0x1f02f0f0, -0x2402b191, +0x2402b391, 0x2400016f, 0xc9007308, 0x1f057373, 0x2400026f, -0x21018700, +0x21018900, 0xc9003302, 0x1f02f0f0, 0x2400006f, -0x24031591, -0x2401918d, +0x24031791, +0x2401938d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x24050b84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, 0x1e0ef7f7, 0xe1003a97, -0x2401978d, +0x2401998d, 0x20830000, 0xd108f003, 0x24007f84, -0x21019b00, +0x21019d00, 0x2403ff84, 0xf1ac0acd, 0x1084cdcd, -0x24019f8d, +0x2401a18d, 0x20830000, 0xd108f007, 0x0909cdcd, 0xc902f003, 0x1f08cdcd, -0x2101a500, +0x2101a700, 0x1d08cdcd, -0x2101ad00, +0x2101af00, 0x09016d6d, 0xc902f003, 0x1f006d6d, -0x2101ab00, +0x2101ad00, 0x1d006d6d, 0x11076d6d, 0x13f06d6d, 0x11000f0f, 0x11004f4f, -0x2401b18d, +0x2401b38d, 0x20830000, 0xd1047309, 0xf1980a84, @@ -471,7 +473,7 @@ const uint32_t PRU1Firmware_0[] = { 0x11ff046f, 0x11004f4f, 0xf04f0b2f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0xd102f008, 0x51006f07, @@ -479,19 +481,19 @@ const uint32_t PRU1Firmware_0[] = { 0x05016f04, 0x68044f03, 0x1013132f, -0x2101c200, +0x2101c400, 0xf04f0b2f, -0x2401c88d, +0x2401ca8d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, @@ -500,21 +502,21 @@ const uint32_t PRU1Firmware_0[] = { 0xc900f003, 0x1c2ef7f7, 0xe1003a97, -0x2401d78d, -0x20830000, 0x2401d98d, 0x20830000, +0x2401db8d, +0x20830000, 0xd1047302, 0xc900f003, 0x1c0ef7f7, 0xe1003a97, -0x2401df8d, +0x2401e18d, 0x20830000, 0x0d0f0f05, 0xc805cd04, 0x1e2ef7f7, 0xe1003a97, -0x2101e600, +0x2101e800, 0x1c2ef7f7, 0xe1003a97, 0xc9007307, @@ -525,53 +527,53 @@ const uint32_t PRU1Firmware_0[] = { 0x51000602, 0x15071313, 0x01010f0f, -0x2401f08d, +0x2401f28d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2401f48d, +0x2401f68d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2401ff8d, +0x2402018d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, 0x61080f05, 0x1e2ef7f7, 0xe1003a97, -0x2402088d, +0x24020a8d, 0x20830000, -0x2401df8d, +0x2401e18d, 0x20830000, -0x24020a8d, +0x24020c8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x11000f0f, -0x24020f8d, +0x2402118d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21021c00, +0x21021e00, 0x1f03f0f0, -0x24021e8d, +0x2402208d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -579,22 +581,22 @@ const uint32_t PRU1Firmware_0[] = { 0xc908f005, 0x51014f04, 0x01014f4f, -0x2401df8d, +0x2401e18d, 0x20830000, 0x11004f4f, 0x1091918d, 0x20830000, -0x24022b8d, +0x24022d8d, 0x20830000, 0x24050884, 0xe1080a84, 0x1f067373, -0x2403158d, +0x2403178d, 0x20830000, 0xc9072f04, 0x1e2ef7f7, 0xe1003a97, -0x21023600, +0x21023800, 0x1c2ef7f7, 0xe1003a97, 0xc9007307, @@ -606,52 +608,52 @@ const uint32_t PRU1Firmware_0[] = { 0x15071313, 0x09012f2f, 0x01010f0f, -0x2402418d, +0x2402438d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402458d, +0x2402478d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2402508d, +0x2402528d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, 0x61080f05, 0x1e2ef7f7, 0xe1003a97, -0x2402598d, +0x24025b8d, 0x20830000, -0x2402308d, +0x2402328d, 0x20830000, -0x24025b8d, +0x24025d8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x24025f8d, +0x2402618d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x1d03f0f0, -0x21026c00, +0x21026e00, 0x1f03f0f0, -0x24026e8d, +0x2402708d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -660,46 +662,46 @@ const uint32_t PRU1Firmware_0[] = { 0x2400000f, 0x606f4f04, 0x2400004f, -0x2402838d, +0x2402858d, 0x20830000, 0xc9017305, 0x05016f04, 0x68044f03, 0x1013132f, -0x21027d00, +0x21027f00, 0xf04f0b2f, -0x2402308d, +0x2402328d, 0x20830000, 0x24050984, 0xe1080a84, -0x2402888d, +0x24028a8d, 0x20830000, 0xd1027303, -0x2403158d, +0x2403178d, 0x20830000, -0x24028b8d, +0x24028d8d, 0x20830000, 0x1f067373, -0x2403158d, +0x2403178d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x24028f8d, +0x2402918d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402938d, +0x2402958d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x24029e8d, +0x2402a08d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, @@ -711,36 +713,36 @@ const uint32_t PRU1Firmware_0[] = { 0xc9057302, 0x01016f6f, 0x2400004f, -0x2402b191, -0x2402ab8d, -0x20830000, +0x2402b391, 0x2402ad8d, 0x20830000, +0x2402af8d, +0x20830000, 0x1c0ef7f7, 0xe1003a97, -0x2401df8d, +0x2401e18d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402b58d, +0x2402b78d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x09012f2f, -0x2402ba8d, +0x2402bc8d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, 0xd02eff03, 0x11fe2f2f, -0x2102c700, +0x2102c900, 0x13012f2f, 0xc9007307, 0x0b071306, @@ -750,7 +752,7 @@ const uint32_t PRU1Firmware_0[] = { 0x51000602, 0x15071313, 0x01010f0f, -0x2402d18d, +0x2402d38d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -765,46 +767,46 @@ const uint32_t PRU1Firmware_0[] = { 0x24000084, 0x102f2f04, 0xe1980a84, -0x2402f08d, +0x2402f28d, 0x20830000, 0x24050d84, 0xe1080a84, 0x1f067373, 0x240101cf, -0x2402f48d, +0x2402f68d, 0x20830000, 0x01014f4f, 0x606f4f05, 0xd1047302, 0xc904f003, -0x2402f48d, +0x2402f68d, 0x20830000, -0x2402f08d, +0x2402f28d, 0x20830000, -0x2402b38d, +0x2402b58d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, -0x2402f88d, +0x2402fa8d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402f88d, +0x2402fa8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2402fc8d, +0x2402fe8d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x2403078d, +0x2403098d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, @@ -814,39 +816,39 @@ const uint32_t PRU1Firmware_0[] = { 0xe0040c2f, 0x606f4f04, 0x2400004f, -0x2403158d, +0x2403178d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2402b38d, +0x2402b58d, 0x20830000, 0x1c2ef7f7, 0xe1003a97, 0xd1047303, 0xd1067302, 0xc901f003, -0x24031e8d, +0x2403208d, 0x20830000, -0x2403378d, +0x2403398d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, -0x2403228d, +0x2403248d, 0x20830000, 0xd00eff06, 0x01019292, 0x5100d203, 0x4892d202, -0x2403418d, +0x2403438d, 0x20830000, 0x51009203, 0x24000092, 0x20830000, -0x24032d8d, +0x24032f8d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x2400e58d, +0x2400e68d, 0xd1067306, 0x24050084, 0xc9057303, @@ -856,13 +858,13 @@ const uint32_t PRU1Firmware_0[] = { 0x20830000, 0x1e2ef7f7, 0xe1003a97, -0x24033b8d, +0x24033d8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x24050084, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x1e2ef7f7, 0xe1003a97, @@ -871,22 +873,22 @@ const uint32_t PRU1Firmware_0[] = { 0x24000092, 0x24050e84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0x2400008f, 0x240a00cf, -0x24034e8d, +0x2403508d, 0x20830000, 0x01010f0f, 0xd00eff02, 0x01014f4f, 0x606f0f02, -0x2403548d, +0x2403568d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x504f0f03, 0x24050584, -0x21035900, +0x21035b00, 0x24050684, 0x2400008f, 0x240000cf, @@ -896,25 +898,25 @@ const uint32_t PRU1Firmware_0[] = { 0x240900cf, 0x1e2ef7f7, 0xe1003a97, -0x24036a8d, +0x24036c8d, 0x20830000, 0x1e0ef7f7, 0xe1003a97, 0x01010f0f, -0x24036e8d, +0x2403708d, 0x20830000, -0x2403638d, +0x2403658d, 0x20830000, 0x1c0ef7f7, 0xe1003a97, -0x2403688d, +0x24036a8d, 0x20830000, 0x606f0f03, -0x2403738d, +0x2403758d, 0x20830000, -0x24036a8d, +0x24036c8d, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050784, 0xe1080a84, 0x20830000, @@ -923,18 +925,18 @@ const uint32_t PRU1Firmware_0[] = { 0x61018405, 0x11ff046f, 0x11004f4f, -0x2403828d, +0x2403848d, 0x20830000, 0x24050d84, 0xe1080a84, -0x2400e58d, +0x2400e68d, 0x20830000, 0xf04f0b2f, 0xe04f0c2f, 0x01014f4f, 0x704f6f02, 0x20830000, -0x2400e58d, +0x2400e68d, 0x24050084, 0xe1080a84, 0x20830000, diff --git a/examples/pru_i2c/firmware/pru_i2c_interface.h b/examples/pru_i2c/firmware/pru_i2c_interface.h index 208b2e1e9..4ffe83587 100644 --- a/examples/pru_i2c/firmware/pru_i2c_interface.h +++ b/examples/pru_i2c/firmware/pru_i2c_interface.h @@ -210,7 +210,11 @@ typedef enum PRUICSS_PruCores_e #define IEP_CMP_INCREMENT_VAL_1MHZ (0x00000140U) // 781.25 kHz, 1x instance #define IEP_CMP_INCREMENT_HALF_VAL_1MHZ (0x000000A0U) -/* The register offset of IRQ status for host to read */ +/* The register offset of IRQ status for host to read. One u8 flag per + * instance at IRQ_COMMON_REGISTER_OFFSET + instance id (0..3): the PRU sets + * it to 1 when a response is ready and the host writes 0 to acknowledge it. + * Each side only writes the byte of its own instance, so no read-modify-write + * is needed. */ #define IRQ_COMMON_REGISTER_OFFSET (0x0008U) /* The register offset of global frequency set */ #define I2C_BUS_FREQUENCY_OFFSET (0x000CU) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index d976e0f43..8a5180174 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -388,6 +388,9 @@ COPY_LOCAL_TO_GLOBAL_STATE .macro ; Macro: RAISE_INTERRUPT_MEM_FOR_HOST ; ; raise the interrupt memory for telling host which instance raise the interrupt. +; Each instance owns one byte of the shared IRQ word (IRQ_COMMON_REGISTER_OFFSET +; + instance id) and writes it with a single byte store, so two instances +; cannot overwrite each other's flag. ; ; PEAK cycles: ; @@ -407,9 +410,9 @@ RAISE_INTERRUPT_MEM_FOR_HOST .macro arg1 LDI TEMP_REG5.w0, ICSS_I2C_CONFIG_MEMORY ADD TEMP_REG5.w0, TEMP_REG5.w0, IRQ_COMMON_REGISTER_OFFSET - LBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 - SET TEMP_REG4.w0, TEMP_REG4.w0, R14.b3 - SBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 + ADD TEMP_REG5.w0, TEMP_REG5.w0, R14.b3 + LDI TEMP_REG4.b0, 1 + SBCO &TEMP_REG4.b0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 1 UPDATE_NEXT_LOCAL_STATE arg1 STATE_TASK_OVER .endm @@ -467,8 +470,9 @@ RAISE_INTERRUPT_FOR_HOST .macro arg1 CHECK_INTERRUPT_RECEIVED .macro arg1, arg2 LDI TEMP_REG5.w0, ICSS_I2C_CONFIG_MEMORY ADD TEMP_REG5.w0, TEMP_REG5.w0, IRQ_COMMON_REGISTER_OFFSET - LBCO &TEMP_REG4.w0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 2 - QBBC INTERRUPT_RECEIVED_JMP_STATE?, TEMP_REG4.w0, R14.b3 + ADD TEMP_REG5.w0, TEMP_REG5.w0, R14.b3 + LBCO &TEMP_REG4.b0, ICSS_DMEM0_CONST, TEMP_REG5.w0, 1 + QBEQ INTERRUPT_RECEIVED_JMP_STATE?, TEMP_REG4.b0, 0 JMP INTERRUPT_RECEIVED_REPEAT_STATE? INTERRUPT_RECEIVED_JMP_STATE?: diff --git a/examples/pru_i2c/mcuplus/pru_i2c_example.c b/examples/pru_i2c/mcuplus/pru_i2c_example.c index 71df68963..72031bd01 100644 --- a/examples/pru_i2c/mcuplus/pru_i2c_example.c +++ b/examples/pru_i2c/mcuplus/pru_i2c_example.c @@ -147,7 +147,7 @@ /* Global words, shared by both PRU cores. The firmware reads them through * ICSS_DMEM0_CONST, which is DMEM0 on PRU0 and on PRU1 alike, so they always * live in PRU0's data RAM. The layout is defined by pru_i2c_interface.h. */ -#define PRU_I2C_IRQ_REG (IRQ_COMMON_REGISTER_OFFSET) /* u16: bit n set by PRU, cleared by R5F */ +#define PRU_I2C_IRQ_REG (IRQ_COMMON_REGISTER_OFFSET) /* u8 per instance: set by PRU, cleared by R5F */ #define PRU_I2C_FREQ_REG (I2C_BUS_FREQUENCY_OFFSET) /* u16: frequency selection */ #define PRU_I2C_IEP_INC_REG (I2C_BUS_FREQUENCY_OFFSET + 2U) /* u16: IEP compare increment */ @@ -166,8 +166,8 @@ #define PRU_I2C_INST_ID_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_PRU_INST_ID_OFFSET) /* u8 */ #define PRU_I2C_SCL_TIMEOUT_REG (ICSS_I2C_INSTANCE0_ADDR + ICSS_I2C_SCL_TIMEOUT_OFFSET) /* u16 */ -/* Bit of the shared IRQ register that belongs to this instance. Use the core - * number so a PRU0 and a PRU1 instance can run side by side. */ +/* Instance id: selects this instance's byte in the shared IRQ register. Use + * the core number so a PRU0 and a PRU1 instance can run side by side. */ #define PRU_I2C_INST_ID (PRU_I2C_PRU_CORE) /* The firmware accepts a data count of 1..255 */ @@ -211,7 +211,7 @@ static const char *PruI2c_responseToString(uint16_t response) return str; } -/* Wait until the PRU sets this instance's bit in the IRQ register. +/* Wait until the PRU sets this instance's flag in the IRQ register. * The PRU also raises INTC system event SRSR1 bit 20 (PRU0) / 21 (PRU1) at * the same time (ICSS_I2C_INTC_PRU0_BIT_VAL / ICSS_I2C_INTC_PRU1_BIT_VAL). * This example does not use the interrupt, it polls the data RAM flag. */ @@ -219,7 +219,7 @@ static int32_t PruI2c_waitForPru(uint32_t timeoutUs) { uint64_t start = ClockP_getTimeUsec(); - while ((HW_RD_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG) & (1U << PRU_I2C_INST_ID)) == 0U) + while (HW_RD_REG8(gPruGlobalBase + PRU_I2C_IRQ_REG + PRU_I2C_INST_ID) == 0U) { if ((ClockP_getTimeUsec() - start) > timeoutUs) { @@ -229,14 +229,12 @@ static int32_t PruI2c_waitForPru(uint32_t timeoutUs) return SystemP_SUCCESS; } -/* Acknowledge the PRU response. The PRU waits for the bit to be cleared - * before it accepts the next command. */ +/* Acknowledge the PRU response. The PRU waits for the flag to be cleared + * before it accepts the next command. Only this instance's byte is written, + * so the other core's flag cannot be lost. */ static void PruI2c_ackPru(void) { - uint16_t irq = HW_RD_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG); - - irq &= (uint16_t)~(1U << PRU_I2C_INST_ID); - HW_WR_REG16(gPruGlobalBase + PRU_I2C_IRQ_REG, irq); + HW_WR_REG8(gPruGlobalBase + PRU_I2C_IRQ_REG + PRU_I2C_INST_ID, 0U); } /* Send a command to the PRU, wait for its response and acknowledge it. */ @@ -293,7 +291,7 @@ static int32_t PruI2c_init(void) } /* Bus frequency (u16) and IEP compare increment (u16), shared by both - * cores. Clear only this instance's IRQ bit: the other core's instance + * cores. Clear only this instance's IRQ flag: the other core's instance * may be using the same register. */ HW_WR_REG16(gPruGlobalBase + PRU_I2C_FREQ_REG, PRU_I2C_BUS_FREQ); HW_WR_REG16(gPruGlobalBase + PRU_I2C_IEP_INC_REG, PRU_I2C_IEP_INCREMENT); diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md index 1d7c08a7f..a7bb027bd 100644 --- a/examples/pru_i2c/readme.md +++ b/examples/pru_i2c/readme.md @@ -59,7 +59,7 @@ includes that header instead of repeating the values. Offset | Size | Name | Description ------------------|------|----------------------------------------|------------- - DMEM0 0x0008 | u16 | `IRQ_COMMON_REGISTER_OFFSET` | Shared by both cores. Bit `` is **set by the PRU** when a response is ready and **cleared by the host** to acknowledge it. The PRU does not accept the next command until the bit is cleared. + DMEM0 0x0008 | u8[4]| `IRQ_COMMON_REGISTER_OFFSET` | Shared by both cores. One u8 flag per instance at `IRQ_COMMON_REGISTER_OFFSET + ` (0..3): **set to 1 by the PRU** when a response is ready and **cleared to 0 by the host** to acknowledge it. Each side writes only its own byte, so two instances cannot lose each other's flag. The PRU does not accept the next command until the flag is cleared. DMEM0 0x000C | u16 | `I2C_BUS_FREQUENCY_OFFSET` | Shared by both cores. Bus frequency selector: `ICSS_I2C_100KHZ_FREQ` (3), `ICSS_I2C_400KHZ_FREQ` (2), `ICSS_I2C_1MHZ_FREQ` (1). Any other value sends the firmware into an error loop. DMEM0 0x000E | u16 | `I2C_BUS_FREQUENCY_OFFSET` + 2 | IEP compare increment per state tick (4 ticks per SCL period), a multiple of the IEP DEFAULT_INC (5). See "Bus frequency" below. own DMEM 0x0100 | | `ICSS_I2C_INSTANCE0_ADDR` | Start of the instance 0 block (offsets below are relative to it) @@ -71,7 +71,7 @@ includes that header instead of repeating the values. + 0xAC | u16 | `ICSS_I2C_SA_OFFSET` | 7-bit target address + 0xD8 / + 0xD9 | u8 | `ICSS_I2C_PRU_PIN_OFFSET` | SCL / SDA pin: the bit number in R30 (output) and R31 (input) + 0xE0 | u8 | `ICSS_I2C_PRU_CMD_CODE_OFFSET` | SMBus command code (for quick command, bit 0 is the R/W bit) - + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the bit used in the shared IRQ register. The example uses the core number, so a PRU0 and a PRU1 instance do not collide. + + 0xE4 | u8 | `ICSS_I2C_PRU_INST_ID_OFFSET` | Instance id, the byte used in the shared IRQ register. The example uses the core number, so a PRU0 and a PRU1 instance do not collide. + 0xE8 | u16 | `ICSS_I2C_SCL_TIMEOUT_OFFSET` | Clock stretching limit in state machine ticks (4 per SCL period); 0 = wait indefinitely. The example uses the SMBus 25 ms. + 0xFE / + 0xFF | | (reserved) | Used by the firmware to stage the SMBus command code and block count + 0x100 (0x0200) | 256 B| `ICSS_I2C_INSTANCE0_TX_MEM` | TX buffer @@ -79,7 +79,7 @@ includes that header instead of repeating the values. The PRU also raises INTC system event SRSR1 bit 20 (PRU0) or bit 21 (PRU1) (`ICSS_I2C_INTC_PRU0_BIT_VAL`, `ICSS_I2C_INTC_PRU1_BIT_VAL`) when it sets the -IRQ bit. The R5F example does not use this interrupt, it polls the IRQ bit +IRQ flag. The R5F example does not use this interrupt, it polls the IRQ flag in the data RAM with a timeout. An interrupt can be added with the `PRUICSS_intcInit()` / `PRUICSS_registerIrqHandler()` APIs. @@ -90,12 +90,12 @@ in the data RAM with a timeout. An interrupt can be added with the So the host stops the core, clears the data RAM, writes the frequency words and the instance 0 block (pins, instance id, FIFO sizes, `CON` with module enable, master, START, STOP and NACK), and only then loads the firmware. -2. **Setup.** Write `ICSS_I2C_SETUP_CMD`, wait for the IRQ bit, check that the - response is `COMMAND_SUCCESS`, clear the IRQ bit. +2. **Setup.** Write `ICSS_I2C_SETUP_CMD`, wait for the IRQ flag, check that the + response is `COMMAND_SUCCESS`, clear the IRQ flag. 3. **Transfers.** For each transfer write the target address and the byte count (and the data into the TX buffer for a write), then write - `ICSS_I2C_TX_CMD` or `ICSS_I2C_RX_CMD`. Wait for the IRQ bit, read the - response (and the RX buffer for a read), clear the IRQ bit. + `ICSS_I2C_TX_CMD` or `ICSS_I2C_RX_CMD`. Wait for the IRQ flag, read the + response (and the RX buffer for a read), clear the IRQ flag. The demo uses a generic EEPROM-style target (default address 0x50) that takes a one byte pointer followed by data: @@ -245,6 +245,6 @@ was not accepted. 1/(4 x `PRU_I2C_BUS_HZ`) and 0.68 us, so that SCL low meets the Fast-mode minimum of 1.3 us. At 250 MHz and 400 kHz that is 170 IEP clocks per tick, about 368 kHz. Not yet measured on a board. -* The example polls the IRQ bit instead of using the PRU interrupt. +* The example polls the IRQ flag instead of using the PRU interrupt. * The example is built for NORTOS on the r5fss0-0 core of the AM261x-LP only. * Build-tested only, see "Validated HW & SW". From 958780a2b8052683e71bac0e5f84b544e2417481 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Tue, 1 Dec 2026 14:14:38 +0530 Subject: [PATCH 26/29] examples: pru_i2c: R5F: move the am261x-lp NORTOS project to MCU+ SDK 11.0+ The project was cloned from examples/empty before main moved AM26x to MCU+ SDK 11.0+ (402bcbbf, b12ce335). From SDK 11.0 the driver and board libraries are built per OS (drivers.am261x.r5f.ti-arm-clang.nortos.*.lib), and the old unsuffixed names no longer exist, so this example no longer linked against the SDK used by main's CI (AM261x MCU+ SDK 26.00). The same update is applied to the makefile, example.projectspec and makefile_ccs_bootimage_gen as main's examples/empty, adapted for NORTOS: - driver/board libraries use the .nortos. names; add -DOS_NORTOS - link with --gen_xml_func_hash and write a .lnkxml link-info file - the boot image is the multicore ELF (.mcelf) only, with --otfaConfigFile; the rprc/appimage steps are removed - .S files are compiled with INCLUDES and DEFINES Built with gmake against AM261x MCU+ SDK 11.00.00.29 (ti-cgt-armllvm 4.0.4.LTS, SysConfig 1.26.0): links and produces pru_i2c.release.mcelf. --- .../ti-arm-clang/example.projectspec | 10 ++-- .../r5fss0-0_nortos/ti-arm-clang/makefile | 49 ++++++------------- .../ti-arm-clang/makefile_ccs_bootimage_gen | 31 +----------- 3 files changed, 23 insertions(+), 67 deletions(-) diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec index cd2771cac..55a4a9d75 100644 --- a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -46,6 +46,7 @@ -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -DSOC_AM261X + -DOS_NORTOS " linkerBuildOptions=" -i${MCU_PLUS_SDK_PATH}/source/kernel/nortos/lib @@ -57,6 +58,7 @@ --diag_suppress=10063 --ram_model --reread_libs + --gen_xml_func_hash " postBuildStep="$(MAKE) -C ${CCS_PROJECT_DIR} -f makefile_ccs_bootimage_gen OUTNAME=${BuildArtifactFileBaseName} PROFILE=${ConfigName} MCU_PLUS_SDK_PATH=${MCU_PLUS_SDK_PATH} OPEN_PRU_PATH=${OPEN_PRU_PATH} CG_TOOL_ROOT=${CG_TOOL_ROOT} CCS_INSTALL_DIR=${CCS_INSTALL_DIR} CCS_IDE_MODE=${CCS_IDE_MODE} DEVICE=am261x" @@ -79,8 +81,8 @@ " linkerBuildOptions=" -lnortos.am261x.r5f.ti-arm-clang.debug.lib - -ldrivers.am261x.r5f.ti-arm-clang.debug.lib - -lboard.am261x.r5f.ti-arm-clang.debug.lib + -ldrivers.am261x.r5f.ti-arm-clang.nortos.debug.lib + -lboard.am261x.r5f.ti-arm-clang.nortos.debug.lib -llibc.a -llibsysbm.a " @@ -91,8 +93,8 @@ " linkerBuildOptions=" -lnortos.am261x.r5f.ti-arm-clang.release.lib - -ldrivers.am261x.r5f.ti-arm-clang.release.lib - -lboard.am261x.r5f.ti-arm-clang.release.lib + -ldrivers.am261x.r5f.ti-arm-clang.nortos.release.lib + -lboard.am261x.r5f.ti-arm-clang.nortos.release.lib -llibc.a -llibsysbm.a " diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile index 228c3c314..4942274d2 100644 --- a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile @@ -28,6 +28,7 @@ ConfigName:=$(PROFILE) OUTNAME:=pru_i2c.$(PROFILE).out BOOTIMAGE_PATH=$(abspath .) +oeconfig?=None BOOTIMAGE_NAME:=pru_i2c.$(PROFILE).appimage BOOTIMAGE_NAME_XIP:=pru_i2c.$(PROFILE).appimage_xip BOOTIMAGE_NAME_SIGNED:=pru_i2c.$(PROFILE).appimage.signed @@ -38,10 +39,10 @@ BOOTIMAGE_RPRC_NAME_XIP:=pru_i2c.$(PROFILE).rprc_xip BOOTIMAGE_RPRC_NAME_TMP:=pru_i2c.$(PROFILE).rprc_tmp BOOTIMAGE_NAME_HS:=pru_i2c.$(PROFILE).appimage.hs BOOTIMAGE_NAME_HS_FS:=pru_i2c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) +TARGETS := $(BOOTIMAGE_NAME_MCELF) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif FILES_common := \ @@ -71,6 +72,7 @@ INCLUDES_common := \ DEFINES_common := \ -DSOC_AM261X \ + -DOS_NORTOS \ CFLAGS_common := \ -mcpu=cortex-r5 \ @@ -114,8 +116,8 @@ LIBS_PATH_common = \ LIBS_common = \ -lnortos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -ldrivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - -lboard.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am261x.r5f.ti-arm-clang.nortos.${ConfigName}.lib \ + -lboard.am261x.r5f.ti-arm-clang.nortos.${ConfigName}.lib \ -llibc.a \ -llibsysbm.a \ @@ -123,12 +125,13 @@ LFLAGS_common = \ -Wl,--diag_suppress=10063 \ -Wl,--ram_model \ -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ LIBS_NAME = \ nortos.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - drivers.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ - board.am261x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am261x.r5f.ti-arm-clang.nortos.${ConfigName}.lib \ + board.am261x.r5f.ti-arm-clang.nortos.${ConfigName}.lib \ libc.a \ libsysbm.a \ @@ -171,7 +174,7 @@ $(OBJDIR)/%.obj %.obj: %.c $(OBJDIR)/%.obj %.obj: %.S @echo Compiling: am261x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< - $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< all: $(TARGETS) @@ -193,7 +196,7 @@ endif $(OUTNAME): $(SYSTEM_COMMAND) @echo . @echo Linking: am261x:r5fss0-0:nortos:ti-arm-clang $@ ... - $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + $(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:nortos:ti-arm-clang $@ Done !!! @echo . @@ -219,6 +222,7 @@ ifeq ($(OS),Windows_NT) $(RM) \*.rprc* $(RM) \*.tiimage* $(RM) \*.bin + $(RM) \*.lnkxml $(RM) \*.mcelf $(RM) \*.mcelf_xip $(RM) \*.mcelf-enc @@ -230,6 +234,7 @@ else $(RM) *.rprc* $(RM) *.tiimage* $(RM) *.bin + $(RM) *.lnkxml $(RM) *.mcelf $(RM) *.mcelf_xip $(RM) *.mcelf-enc @@ -278,8 +283,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js 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 @@ -300,54 +303,34 @@ MULTI_CORE_IMAGE_PARAMS = \ MULTI_CORE_IMAGE_PARAMS_XIP = \ $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ -$(BOOTIMAGE_NAME): $(OUTNAME) - @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... -ifneq ($(OS),Windows_NT) - $(CHMOD) a+x $(XIPGEN_CMD) -endif - $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) - @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! +$(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) + $(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_HS): $(BOOTIMAGE_NAME) +$(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) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(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) --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_HS) --rsassa_pss $(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) --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_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(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) --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_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(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:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif diff --git a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen index d1e3c1dd8..a08ec99ce 100644 --- a/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen +++ b/examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -25,21 +25,12 @@ endif OUTFILE=$(PROFILE)/$(OUTNAME).out BOOTIMAGE_PATH=$(abspath ${PROFILE}) -BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage -BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip -BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed -BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc -BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip -BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp BOOTIMAGE_NAME_MCELF:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf BOOTIMAGE_NAME_MCELF_HS:=$(BOOTIMAGE_PATH)/$(OUTNAME).mcelf.hs -BOOTIMAGE_NAME_HS:=$(BOOTIMAGE_PATH)/pru_i2c.$(PROFILE).appimage.hs -BOOTIMAGE_NAME_HS_FS:=$(BOOTIMAGE_PATH)/pru_i2c.$(PROFILE).appimage.hs_fs -TARGETS := $(BOOTIMAGE_NAME) TARGETS += $(BOOTIMAGE_NAME_MCELF) TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) ifeq ($(DEVICE_TYPE), HS) - TARGETS += $(BOOTIMAGE_NAME_HS) + TARGETS += $(BOOTIMAGE_NAME_MCELF_HS) endif # @@ -62,8 +53,6 @@ BOOTIMAGE_CORE_ID_r5fss1-1 = 3 SBL_RUN_ADDRESS=0x70002000 SBL_DEV_ID=55 -MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js -OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js 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 @@ -88,15 +77,6 @@ all: ifeq ($(CCS_IDE_MODE),cloud) # No post build steps else - @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... - $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) - $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) - $(RM) $(BOOTIMAGE_RPRC_NAME) - $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) - $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) @echo Boot multi-core ELF image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME_MCELF) ... @@ -105,36 +85,27 @@ else @echo Boot multi-core ELF image: $(BOOTIMAGE_NAME_MCELF) Done !!! @echo . - @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) 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) --key $(APP_SIGNING_KEY) --sign_key_id $(APP_SIGNING_KEY_KEYRING_ID) --hash_algo $(APP_SIGNING_HASH_ALGO) --output $(BOOTIMAGE_NAME_HS) $(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) --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_HS) --rsassa_pss $(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) --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_HS) - $(RM) $(BOOTIMAGE_NAME)-enc $(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) --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_HS) --rsassa_pss - $(RM) $(BOOTIMAGE_NAME)-enc $(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:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! @echo Boot image: am261x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_MCELF_HS) Done !!! @echo . endif From 26df1181b98d894e04f120e77d0a0078791f36b0 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Tue, 1 Dec 2026 14:18:37 +0530 Subject: [PATCH 27/29] examples: pru_i2c: list the example and report the hardware run examples/readme.md: add pru_i2c to the Projects list and to the portability table, as docs_ai/task_create_project.md D4 asks. am261x is Y (this project) and am263x is Yport (the PRU firmware ran on an LP-AM263 with only the GPIO_OUT_CTRL addresses changed). The other columns are FIXME rather than guessed: the firmware uses the MSS_CTRL ICSSM_PRUx_GPIO_OUT_CTRL output-disable bits, and whether am243x, am263px, am62x and am64x have an equivalent has not been checked. examples/pru_i2c/readme.md: "Validated HW & SW" now lists the SDK 11 build tools and the LP-AM263 run (tests, rates, tools, the one firmware change, and what was not covered). The board revision was not recorded and is marked FIXME. The AM261x-LP has still not been run on hardware. Drop the .appimage mention, since the SDK 11 boot image flow only produces the .mcelf. --- examples/pru_i2c/readme.md | 37 +++++++++++++++++++++++++++++-------- examples/readme.md | 5 +++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md index a7bb027bd..04f192e36 100644 --- a/examples/pru_i2c/readme.md +++ b/examples/pru_i2c/readme.md @@ -34,15 +34,35 @@ build infrastructure for this project; building for any other device prints # Validated HW & SW -This example has **not been validated on hardware**. It has only been built. +The AM261x-LP build in this project has **not been run on an AM261x-LP**. The +PRU firmware has run on an LP-AM263 (AM263x) board, see below. Item | Version ---------------------------|----------- - Build: MCU+ SDK | AM261x MCU+ SDK 10.02.00.15 (the version used by the OpenPRU CI) + Build: MCU+ SDK | AM261x MCU+ SDK 11.00.00.29 Build: PRU compiler | ti-cgt-pru 2.3.3 - Build: R5F compiler | ti-cgt-armllvm 4.0.3.LTS - Build: SysConfig | 1.26.2 - Hardware run | not done (no board revision, I2C target or scope capture to report) + Build: R5F compiler | ti-cgt-armllvm 4.0.4.LTS + Build: SysConfig | 1.26.0 + Hardware run (AM261x-LP) | not done + Hardware run (LP-AM263) | PRU1 firmware, AM263x MCU+ SDK 26.01.00.08, ti-cgt-armllvm 4.0.4.LTS, SysConfig 1.28. Board revision FIXME (not recorded) + +LP-AM263 run: the PRU firmware at commit 8f4c1c2c ran at 100 kHz and at the +"400 kHz" setting (367.6 kHz with the 200 MHz IEP clock and the 0.68 us tick +floor). It passed these tests against the on-board CAT23M01 EEPROM and TPIC2810 +LED driver, with the MCU I2C1 controller reading back every PRU transfer: + +* address probe: ACK at 0x61/0x52/0x53, NACK at 0x10/0x21 +* a 16-byte EEPROM read that matches the MCU I2C1 read +* TPIC2810 register writes, read back by the MCU +* an 8-byte EEPROM write and restore, each read back by the MCU + +Later commits only add the selector-to-increment fallback, which the R5F +application does not use because it always writes the IEP increment. + +The only firmware change for that board was the AM263x `ICSSM_PRUx_GPIO_OUT_CTRL` +addresses (MSS_CTRL `0x50D00824`/`0x50D00828`). That change and the AM263x +projects are not part of this project yet. No waveforms were captured, and only +one PRU instance ran at a time. # How it works @@ -192,7 +212,7 @@ specific steps are: firmware is built first, the R5F build includes the generated `pru1_load_bin.h`. The R5F image is `mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/pru_i2c.release.out` - (`.mcelf` and `.appimage` are generated next to it). With CCS, import the + (the `.mcelf` boot image is generated next to it). With CCS, import the PRU0/PRU1 firmware projects and the R5F project from `examples/pru_i2c`, build the PRU projects first. 3. **Run on the R5F core** (r5fss0-0) and open the UART0 console (the log @@ -244,7 +264,8 @@ was not accepted. that define instead (`PRU_I2C_IEP_INCREMENT`). The tick is the larger of 1/(4 x `PRU_I2C_BUS_HZ`) and 0.68 us, so that SCL low meets the Fast-mode minimum of 1.3 us. At 250 MHz and 400 kHz that is 170 IEP clocks per tick, - about 368 kHz. Not yet measured on a board. + about 368 kHz. The same floor gave 367.6 kHz on an LP-AM263 (200 MHz IEP + clock), computed from the IEP settings, not measured with a scope. * The example polls the IRQ flag instead of using the PRU interrupt. * The example is built for NORTOS on the r5fss0-0 core of the AM261x-LP only. -* Build-tested only, see "Validated HW & SW". +* Not yet run on an AM261x-LP, see "Validated HW & SW". diff --git a/examples/readme.md b/examples/readme.md index 6bb74c6f3..253b96107 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -41,6 +41,10 @@ pru_emif * Emulate an Extended Memory Interface (EMIF) client 16-bit/32-bit asynchronous parallel interface to interface with C2K F28379D +pru_i2c +* I2C/SMBus master emulated on PRU GPIOs, with an R5F NORTOS example that + drives it through a shared-memory command interface + pru_i2s * Emulate I2S/TDM protocol using PRU, both Rx and Tx supported @@ -95,6 +99,7 @@ For more information about the PRU features on each processor, refer to app note | logic_scope | Y | Yport | Yport | Yport | Yport | Yport | | pru_eqep | Y | Yport | Yport | Yport | N-sw | Yport | | pru_emif | Y | Yport | Yport | Yport | N-sw | Yport | +| pru_i2c | FIXME | Y | FIXME | Yport | FIXME | FIXME | | pru_i2s | Yport | Y | Yport | Y | N-sw | Yport | | spi_loopback | Y | Yport | Yport | Yport | N-sw | Yport | | fir | Y | Yport | Yport | Yport | Yport | Yport | From 2caa29597ae335515b9000d96d59c744876865fa Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Tue, 1 Dec 2026 14:37:42 +0530 Subject: [PATCH 28/29] examples: pru_i2c: complete the macro register lists, flag unchecked devices pru_i2c_macro.h: the I2C_WAVE_FUNCTION0 note said the states never write R26. SETUP_I2C_SCL_SDA_HIGH loads it (the GPIO_OUT_CTRL address) and clears the SCL/SDA bits of R30, so say so. Add "Registers modified" and "Registers read" blocks to RAISE_INTERRUPT_MEM_FOR_HOST, RAISE_INTERRUPT_FOR_HOST, CHECK_INTERRUPT_RECEIVED and I2C_SETUP_IEP_COUNTER, fill in RAISE_INTERRUPT_MEM_FOR_HOST's pseudo code and arg1, and replace CHECK_INTERRUPT_RECEIVED's copy-pasted description. Comments only: the regenerated pru0/pru1_load_bin.h are unchanged. examples/readme.md: add a FIXME comment to the pru_i2c portability row so the FIXME cells read as not yet checked. They stay FIXME rather than a guessed legend value, as docs_ai/task_create_project.md asks. --- examples/pru_i2c/firmware/pru_i2c_macro.h | 45 ++++++++++++++++++++--- examples/readme.md | 2 +- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/examples/pru_i2c/firmware/pru_i2c_macro.h b/examples/pru_i2c/firmware/pru_i2c_macro.h index 5063920e9..8f9ea615a 100644 --- a/examples/pru_i2c/firmware/pru_i2c_macro.h +++ b/examples/pru_i2c/firmware/pru_i2c_macro.h @@ -188,9 +188,10 @@ IEP_INTC_CLEAR?: ; R10..R19 (context: loaded from the bank, then written back to it) ; plus whatever the called state writes: states use TEMP_REG1..8 and ; R27..R29 as scratch, update the context registers, and update R23 (the -; GPIO_OUT_CTRL shadow) through the open-drain pin macros. R20..R22 -; (scheduler: compare value, frequency word) and R26 (GPIO_OUT_CTRL -; address) are not written by the states. +; GPIO_OUT_CTRL shadow) through the open-drain pin macros. The +; SETUP_I2C_SCL_SDA_HIGH state also loads R26 (GPIO_OUT_CTRL address) and +; clears the SCL and SDA bits of R30. R20..R22 (scheduler: compare value, +; frequency word) are not written by the states. ; ;************************************************************************************ I2C_WAVE_FUNCTION0 .macro @@ -418,14 +419,24 @@ COPY_LOCAL_TO_GLOBAL_STATE .macro ; PEAK cycles: ; ; Pseudo code: -; +; command word (R10 + ICSS_I2C_COMMAND_OFFSET + 2) = 0 +; DMEM0[ICSS_I2C_CONFIG_MEMORY + IRQ_COMMON_REGISTER_OFFSET + R14.b3] = 1 +; next state = arg1; return to the scheduler ; ; Parameters: -; None: +; arg1 - required, the state to run on the next tick ; ; Returns: ; None ; +; Registers modified: +; TEMP_REG4.w0, TEMP_REG5.w0 (scratch) +; R13.w0 (next state) +; +; Registers read: +; R10 (instance memory base), R14.b3 (instance id), +; TEMP_REG3.w0 (scheduler return address) +; ;************************************************************************************ RAISE_INTERRUPT_MEM_FOR_HOST .macro arg1 LDI TEMP_REG4.w0, 0x0000 @@ -458,6 +469,13 @@ RAISE_INTERRUPT_MEM_FOR_HOST .macro arg1 ; Returns: ; None ; +; Registers modified: +; TEMP_REG5.w0, TEMP_REG6 (scratch) +; R13.w0 (next state) +; +; Registers read: +; TEMP_REG3.w0 (scheduler return address) +; ;************************************************************************************ RAISE_INTERRUPT_FOR_HOST .macro arg1 LDI TEMP_REG5.w0, ICSS_INTC_SRSR1 @@ -475,7 +493,8 @@ RAISE_INTERRUPT_FOR_HOST .macro arg1 ; ; Macro: CHECK_INTERRUPT_RECEIVED ; -; raise the interrupt memory for telling host which instance raise the interrupt. +; check whether the host has acknowledged this instance's interrupt, that is, +; cleared its byte of the shared IRQ word. ; ; PEAK cycles: ; @@ -489,6 +508,13 @@ RAISE_INTERRUPT_FOR_HOST .macro arg1 ; Returns: ; None ; +; Registers modified: +; TEMP_REG4.b0, TEMP_REG5.w0 (scratch) +; R13.w0 (next state) +; +; Registers read: +; R14.b3 (instance id), TEMP_REG3.w0 (scheduler return address) +; ;************************************************************************************ CHECK_INTERRUPT_RECEIVED .macro arg1, arg2 LDI TEMP_REG5.w0, ICSS_I2C_CONFIG_MEMORY @@ -771,6 +797,13 @@ tx_data_ack_not_recieved?: ; Returns: ; None ; +; Registers modified: +; TEMP_REG1, TEMP_REG2 (scratch) +; IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL2 (first compare value) +; +; Registers read: +; I2C_GLOBAL_FREQ_REG.w2 (IEP compare increment) +; ;************************************************************************************ I2C_SETUP_IEP_COUNTER .macro diff --git a/examples/readme.md b/examples/readme.md index 253b96107..e953ad983 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -99,7 +99,7 @@ For more information about the PRU features on each processor, refer to app note | logic_scope | Y | Yport | Yport | Yport | Yport | Yport | | pru_eqep | Y | Yport | Yport | Yport | N-sw | Yport | | pru_emif | Y | Yport | Yport | Yport | N-sw | Yport | -| pru_i2c | FIXME | Y | FIXME | Yport | FIXME | FIXME | +| pru_i2c | FIXME | Y | FIXME | Yport | FIXME | FIXME | | pru_i2s | Yport | Y | Yport | Y | N-sw | Yport | | spi_loopback | Y | Yport | Yport | Yport | N-sw | Yport | | fir | Y | Yport | Yport | Yport | Yport | Yport | From 7c16c70317a91df547d3247357caae091fe0e280 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Tue, 1 Dec 2026 18:06:23 +0530 Subject: [PATCH 29/29] examples: pru_i2c: fill in the portability row The PRU I2C firmware needs only PRU GPIOs whose outputs can be disabled per pin, and the maintainer confirmed that am243x, am263px and am64x are similar in that capability, so they are Yport. am62x is N-sw like the other examples with an MCU+ R5F host: the PRU firmware may port, but the host application would have to be rewritten. Drop the board revision FIXME from the LP-AM263 hardware run row; the board is identified as LP-AM263. --- examples/pru_i2c/readme.md | 2 +- examples/readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pru_i2c/readme.md b/examples/pru_i2c/readme.md index 04f192e36..6eb8b9c89 100644 --- a/examples/pru_i2c/readme.md +++ b/examples/pru_i2c/readme.md @@ -44,7 +44,7 @@ PRU firmware has run on an LP-AM263 (AM263x) board, see below. Build: R5F compiler | ti-cgt-armllvm 4.0.4.LTS Build: SysConfig | 1.26.0 Hardware run (AM261x-LP) | not done - Hardware run (LP-AM263) | PRU1 firmware, AM263x MCU+ SDK 26.01.00.08, ti-cgt-armllvm 4.0.4.LTS, SysConfig 1.28. Board revision FIXME (not recorded) + Hardware run (LP-AM263) | PRU1 firmware, AM263x MCU+ SDK 26.01.00.08, ti-cgt-armllvm 4.0.4.LTS, SysConfig 1.28 LP-AM263 run: the PRU firmware at commit 8f4c1c2c ran at 100 kHz and at the "400 kHz" setting (367.6 kHz with the 200 MHz IEP clock and the 0.68 us tick diff --git a/examples/readme.md b/examples/readme.md index e953ad983..21f4bbb76 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -99,7 +99,7 @@ For more information about the PRU features on each processor, refer to app note | logic_scope | Y | Yport | Yport | Yport | Yport | Yport | | pru_eqep | Y | Yport | Yport | Yport | N-sw | Yport | | pru_emif | Y | Yport | Yport | Yport | N-sw | Yport | -| pru_i2c | FIXME | Y | FIXME | Yport | FIXME | FIXME | +| pru_i2c | Yport | Y | Yport | Yport | N-sw | Yport | | pru_i2s | Yport | Y | Yport | Y | N-sw | Yport | | spi_loopback | Y | Yport | Yport | Yport | N-sw | Yport | | fir | Y | Yport | Yport | Yport | Yport | Yport |