Update repo

This commit is contained in:
hangpersonal committed 2026-08-30 23:04:35 -07:00
1 parent 749dab5721
commit ce65a0f59a
14950 files changed
+4408250 -1

No files matched your search

@@ -0,0 +1,185 @@
//###########################################################################
//
// FILE: stl_can_ram.c
//
// TITLE: Diagnostic Library CAN message RAM test software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_can_ram.h"
#include "stl_util.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// STL_CAN_RAM_testRAM(const uint32_t canBase,
// const STL_March_Pattern pattern,
// const uint16_t startAddress,
// const uint16_t endAddress,
// const uint32_t copyAddress)
//
//*****************************************************************************
void STL_CAN_RAM_testRAM(const uint32_t canBase,
const STL_March_Pattern pattern,
const uint32_t startAddress,
const uint32_t endAddress,
const uint32_t copyAddress)
{
uint32_t length;
ASSERT(CAN_isBaseValid(canBase));
ASSERT(endAddress >= startAddress);
ASSERT((canBase + STL_CAN_RAM_ADDR_OFFSET) <= startAddress);
ASSERT((canBase + STL_CAN_RAM_MAX_ADDR_OFFSET) >= endAddress);
//
// The length needs to be divided by 2 since the test function expects a
// length in terms of 32-bit words.
//
if(endAddress >= startAddress)
{
length = (endAddress - startAddress) / 2U;
}
else
{
length = 0U;
}
//
// Make sure parity checking is turned on.
//
HWREGH(canBase + CAN_O_CTL) &= ~CAN_CTL_PMD_M;
//
// Turn on message RAM direct access mode.
//
CAN_enableTestMode(canBase, 0U);
CAN_enableMemoryAccessMode(canBase);
//
// Run the March test.
//
if(STL_CAN_RAM_NO_COPY == copyAddress)
{
STL_March_testRAM(pattern, startAddress, length);
}
else
{
STL_March_testRAMCopy(pattern, startAddress, length, copyAddress);
}
//
// Disable the test modes.
//
CAN_disableMemoryAccessMode(canBase);
CAN_disableTestMode(canBase);
}
//*****************************************************************************
//
// STL_CAN_RAM_injectError(const uint32_t canBase, const uint32_t address,
// const uint32_t xorMask);
//
//*****************************************************************************
void STL_CAN_RAM_injectError(const uint32_t canBase, const uint32_t address,
const uint32_t xorMask)
{
ASSERT(CAN_isBaseValid(canBase));
ASSERT((address >= (canBase + STL_CAN_RAM_ADDR_OFFSET)) &&
(address <= (canBase + STL_CAN_RAM_MAX_ADDR_OFFSET)));
//
// Turn off parity, so we can flip a bit without updating it.
//
HWREGH(canBase + CAN_O_CTL) =
(HWREGH(canBase + CAN_O_CTL) & ~CAN_CTL_PMD_M) | STL_CAN_RAM_PARITY_OFF;
//
// Turn on message RAM direct access mode.
//
CAN_enableTestMode(canBase, 0U);
CAN_enableMemoryAccessMode(canBase);
//
// Flip a bit.
//
HWREG_BP(address) ^= xorMask;
//
// Turn parity back on.
//
HWREGH(canBase + CAN_O_CTL) &= ~CAN_CTL_PMD_M;
//
// Disable the test modes.
//
CAN_disableMemoryAccessMode(canBase);
CAN_disableTestMode(canBase);
}
//*****************************************************************************
//
// STL_CAN_RAM_checkErrorStatus(const uint32_t canBase)
//
//*****************************************************************************
uint16_t STL_CAN_RAM_checkErrorStatus(const uint32_t canBase)
{
uint16_t status;
if((CAN_getStatus(canBase) & CAN_STATUS_PERR) != 0U)
{
status = STL_CAN_RAM_ERROR;
//
// Set global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_CAN_RAM_PARITY);
}
else
{
status = STL_CAN_RAM_PASS;
}
return(status);
}
//
// End of File
//
@@ -0,0 +1,614 @@
;;//###########################################################################
;;//
;;// FILE: stl_cpu_reg.asm
;;//
;;// TITLE: Diagnostic Library CPU register test
;;//
;;//###########################################################################
;;// $TI Release: C2000 Diagnostic Library v5.00.01 $
;;// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
;;// $Copyright:
;// Copyright (C) 2024 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.
;// $
;;//###########################################################################
.global STL_CPU_REG_testCPURegisters
.global STL_CPU_REG_testFPURegisters
.global STL_CPU_REG_testVCRCRegisters
;;*****************************************************************************
; Constants
;;*****************************************************************************
TEST_ITERATIONS .set 0x1
RPC_TEST_MASK_MSB .set 0x003F
ST1_CLR_TEST_MASK .set 0xFF5B
ST1_SET_TEST_MASK .set 0x0A00
STF_TEST_MASK_MSB .set 0x0000
STF_TEST_MASK_LSB .set 0x027C
VSTATUS_TEST_MASK_MSB .set 0x8000
VSTATUS_TEST_MASK_LSB .set 0x0000
VCRCSIZE_TEST_MASK_MSB .set 0x001F
VCRCSIZE_TEST_MASK_LSB .set 0x0007
REG_TEST_PATTERN .set 0xAAAA
N_REG_TEST_PATTERN .set 0x5555
REG_ERROR_PATTERN .set 0x555D
TEST_PASSED .set 0x0
TEST_FAILED .set 0x1
.text
;;*****************************************************************************
;;
;; uint16_t STL_CPU_TEST_testCPURegisters(bool injectError)
;; AL
;;
;;*****************************************************************************
STL_CPU_REG_testCPURegisters:
;
; Push save-on-entry registers onto the stack
;
PUSH XAR1
PUSH XAR2
PUSH XAR3
;
; First test ACC register using opcode only
; ACC is used to test other registers
;
MOV AH, #REG_TEST_PATTERN
;
; See if the injectError parameter is set
; Skip error injection if not
;
CMP AL, #0x1 ; AL contains injectError parameter
B skipCPUErrorTest, NEQ
MOV AH, #REG_ERROR_PATTERN ; Write the error pattern to AH
skipCPUErrorTest:
CMP @AH, #REG_TEST_PATTERN
B failCPURegTest, NEQ ; Test AH for pattern
MOV AL, #REG_TEST_PATTERN
CMP @AL, #REG_TEST_PATTERN
B failCPURegTest, NEQ ; Test AL for pattern
MOV AH, #N_REG_TEST_PATTERN
CMP @AH, #N_REG_TEST_PATTERN
B failCPURegTest, NEQ ; Test AH for pattern inverse
MOV AL, #N_REG_TEST_PATTERN
CMP @AL, #N_REG_TEST_PATTERN
B failCPURegTest, NEQ ; Test AH for pattern inverse
;
; Second Test P register using ACC,
; P register is used as a loop counter
; P is used as a loop for other register tests
;
MOVL P, @ACC
CMPL ACC, @P
B failCPURegTest, NEQ ; Test P for pattern inverse
NOT ACC
MOVL P, @ACC
CMPL ACC, @P
B failCPURegTest, NEQ ; Test P for pattern
;
; Use PL as a loop counter
; Test pattern first then pattern inverse
;
MOV PL, #TEST_ITERATIONS
loopCPURegTest:
;
; Test Auxiliary Registers
;
NOT ACC
MOVL XAR0, @ACC
MOVL XAR1, @ACC
MOVL XAR2, @ACC
MOVL XAR3, @ACC
MOVL XAR4, @ACC
MOVL XAR5, @ACC
MOVL XAR6, @ACC
MOVL XAR7, @ACC
CMPL ACC, @XAR0
B failCPURegTest, NEQ
CMPL ACC, @XAR1
B failCPURegTest, NEQ
CMPL ACC, @XAR2
B failCPURegTest, NEQ
CMPL ACC, @XAR3
B failCPURegTest, NEQ
CMPL ACC, @XAR4
B failCPURegTest, NEQ
CMPL ACC, @XAR5
B failCPURegTest, NEQ
CMPL ACC, @XAR6
B failCPURegTest, NEQ
CMPL ACC, @XAR7
B failCPURegTest, NEQ
;
; Test Multiplicand register
;
MOVL XT, @ACC
CMPL ACC, @XT
B failCPURegTest, NEQ
DEC PL
B loopCPURegTest, GEQ
;
; Test stack pointer
;
MOVZ AR4, @SP ; save SP contents in AR4
MOV @SP, AL
CMP AL, @SP
B failSPTest, NEQ
NOT ACC
MOV @SP, AL
CMP AL, @SP
B failSPTest, NEQ
MOV @SP, AR4
B rpcRegTest, UNC
failSPTest:
MOV @SP, AR4 ; try restoring stack pointer
B failCPURegTest, UNC
;
; Test return program counter
;
rpcRegTest:
MOVL XAR6, @ACC ; save ACC contents
AND AH, #RPC_TEST_MASK_MSB ; RPC is 22 bits
PUSH RPC
POP P ; save RPC in P
PUSH ACC
POP RPC ; write to RPC
PUSH RPC
POP XAR4
CMPL ACC, XAR4
B failRPCTest, NEQ
NOT ACC
AND AH, #RPC_TEST_MASK_MSB
PUSH ACC
POP RPC ; write to RPC
PUSH RPC
POP XAR4
CMPL ACC, XAR4
B failRPCTest, NEQ
B restoreRPC, UNC
failRPCTest:
PUSH P
POP RPC ; restore RPC
B failCPURegTest, UNC
restoreRPC:
PUSH P
POP RPC ; restore RPC
MOVL ACC, @XAR6 ; restore ACC contents
cpu16BitRegTest:
;
; Test ST0, ST1, DP, IER, IFR and DBGIER register
;
PUSH ST0
POP @PL ; save ST0 in PL
PUSH ST1
POP @AR3 ; save ST1 in AR3
PUSH DP
POP @PH ; save DP in PH
MOV @AR0, IER ; save IER in AR0
PUSH IFR
POP @TH ; save IFR in TH
PUSH DBGIER
POP @AR5 ; save DBGIER in AR5
;
; Test ST0, IER, IFR, DBGIER and DP
;
MOV AR6, #TEST_ITERATIONS ; use AR6 as a loop counter
loopCPUReg2Test:
;
; Note that these checks have a different fail branch
; Need to restore registers before the returning
;
PUSH @AL
POP DP ; write to DP
PUSH DP
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
PUSH @AL
POP ST0 ; write to ST0
PUSH ST0
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
PUSH @AL
POP IFR ; write to IFR
PUSH IFR
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
PUSH @AL
POP DBGIER ; write to DBGIER
PUSH DBGIER
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
MOV IER, @AL ; write to IER
MOV @AR4, IER
CMP AL, @AR4
B fail16BitRegTest, NEQ
NOT ACC
DEC AR6 ; decrement loop counter
B loopCPUReg2Test, GEQ;
;
; Test ST1. Treatment of each bit is as follows:
;
; ARP 15:13 Tested
; XF 12 Tested
; M0M1MAP 11 Always 1 for C28x object mode
; rsvd 10 Tested
; OBJMODE 9 Always 1 for C28x object mode
; AMODE 8 Tested
; IDLESTAT 7 NOT tested
; EALLOW 6 Tested
; LOOP 5 NOT tested
; SPA 4 Tested
; VMAP 3 Tested
; PAGE0 2 Always 1 for suggested C28x operating mode
; DBGM 1 Tested
; INTM 0 Tested
;
st1RegTest:
MOVL XAR6, @ACC ; save ACC contents
AND IER, #0 ; clear IER so we can test INTM
AND AL, #ST1_CLR_TEST_MASK ; clear the bits that need to stay 0
OR AL, #ST1_SET_TEST_MASK ; set the bits that need to stay 1
PUSH @AL
POP ST1 ; write to ST1
PUSH ST1
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
NOT ACC
AND AL, #ST1_CLR_TEST_MASK ; clear the bits that need to stay 0
OR AL, #ST1_SET_TEST_MASK ; set the bits that need to stay 1
PUSH @AL
POP ST1 ; write to ST1
PUSH ST1
POP AR4
CMP AL, @AR4
B fail16BitRegTest, NEQ
MOVL ACC, @XAR6 ; restore ACC contents
passCPURegTest:
MOV AL, #TEST_PASSED ; return a success code
B restore16BitReg, UNC
fail16BitRegTest:
MOV AL, #TEST_FAILED ; return a fail code
restore16BitReg:
PUSH @PL
POP ST0 ; restore ST0
PUSH @AR3
POP ST1 ; restore ST1
PUSH @PH
POP DP ; restore DP
MOV IER, @AR0 ; restore IER
PUSH @TH
POP IFR ; restore IFR
PUSH @AR5
POP DBGIER ; restore DBGIER
B endCPURegTest, UNC
failCPURegTest:
MOV AL, #TEST_FAILED ; return a fail code
endCPURegTest:
POP XAR3
POP XAR2
POP XAR1
LRETR
;;*****************************************************************************
;;
;; uint16_t STL_CPU_TEST_testFPURegisters(bool injectError)
;; AL
;;
;;*****************************************************************************
STL_CPU_REG_testFPURegisters:
;
; Push save-on-entry registers onto the stack
;
MOV32 *SP++, R4H
MOV32 *SP++, R5H
MOV32 *SP++, R6H
MOV32 *SP++, R7H
MOV32 *SP++, R4L
MOV32 *SP++, R5L
MOV32 *SP++, R6L
MOV32 *SP++, R7L
;
; Save injectError parameter to AR5
;
MOV AR5, AL
;
; Push status register onto the stack
;
MOV32 *SP++, STF
;
; ACC = Test pattern
;
MOV AH, #REG_TEST_PATTERN
MOV AL, #REG_TEST_PATTERN
;
; Use PL as a loop counter
; Test pattern first then pattern inverse
;
MOV PL, #TEST_ITERATIONS ; loop TEST_ITERATIONS + 1 times
loopFPURegTest:
NOT ACC ; write pattern to FPU registers
MOV32 R0H, @ACC
MOV32 R1H, @ACC
MOV32 R2H, @ACC
MOV32 R3H, @ACC
MOV32 R4H, @ACC
MOV32 R5H, @ACC
MOV32 R6H, @ACC
MOV32 R7H, @ACC
MOV32 R0L, @ACC
MOV32 R1L, @ACC
MOV32 R2L, @ACC
MOV32 R3L, @ACC
MOV32 R4L, @ACC
MOV32 R5L, @ACC
MOV32 R6L, @ACC
MOV32 R7L, @ACC
;
; See if the injectError parameter is set
; Skip error injection if not
;
CMP AR5, #0x1 ; AR5 contains injectError parameter
B skipFPUErrorTest, NEQ
MOVXI R5H, #REG_ERROR_PATTERN ; Write the error pattern to R5H
skipFPUErrorTest:
;
; SAVE/RESTORE will write/read the shadow registers
;
SAVE
RESTORE
MOV32 @XAR0, R0H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R1H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R2H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R3H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R4H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R5H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R6H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R7H
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R0L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R1L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R2L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R3L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R4L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R5L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R6L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOV32 @XAR0, R7L
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOVL XAR6, @ACC ; save ACC contents
AND AH, #STF_TEST_MASK_MSB
AND AL, #STF_TEST_MASK_LSB ; Use mask to test STF register
PUSH ACC
MOV32 STF, *--SP ; STF = ACC
SAVE ; Write/read the shadow register
RESTORE
MOV32 *SP++, STF
POP XAR0
CMPL ACC, @XAR0
B failFPURegTest, NEQ
MOVL ACC, @XAR6 ; restore ACC contents
DEC PL ; decrement loop counter
B loopFPURegTest, GEQ
passFPURegTest:
MOV AL, #TEST_PASSED ; return a success code
B endFPURegTest, UNC
failFPURegTest:
MOV AL, #TEST_FAILED
endFPURegTest:
MOV32 STF, *--SP ; restore FPU registers
MOV32 R7L, *--SP
MOV32 R6L, *--SP
MOV32 R5L, *--SP
MOV32 R4L, *--SP
MOV32 R7H, *--SP
MOV32 R6H, *--SP
MOV32 R5H, *--SP
MOV32 R4H, *--SP
LRETR
;;*****************************************************************************
;;
;; uint16_t STL_CPU_REG_testVCRCRegisters(uint32_t *scratchRAM,bool injectError)
;; XAR4 AL
;;
;;*****************************************************************************
STL_CPU_REG_testVCRCRegisters:
;
; Save contents of VCRCSIZE and VCRCPOLY to stack, VSTATUS to XAR7
;
VMOV32 *XAR4, VCRCPOLY
MOVL XAR7, *XAR4
PUSH XAR7
VMOV32 *XAR4, VCRCSIZE
MOVL XAR7, *XAR4
PUSH XAR7
VMOV32 *XAR4, VSTATUS
MOVL XAR7, *XAR4
;
; Save injectError parameter to AR5
;
MOV AR5, AL
;
; ACC = Test pattern
;
MOV AH, #REG_TEST_PATTERN
MOV AL, #REG_TEST_PATTERN
;
; Use PL as a loop counter
; Test pattern first then pattern inverse
;
MOV PL, #TEST_ITERATIONS
loopVCRCRegTest:
NOT ACC
MOVL *XAR4, ACC ; write pattern to VCRC registers
VMOV32 VCRC, *XAR4
VMOV32 VCRCPOLY, *XAR4
;
; See if the injectError parameter is set
; Skip error injection if not
;
CMP AR5, #0x1 ; AR5 contains injectError parameter
B skipVCRCErrorTest, NEQ
VMOVZI VCRCPOLY, #REG_ERROR_PATTERN ; Write the error pattern to lower word
skipVCRCErrorTest:
VMOV32 *XAR4, VCRC
CMPL ACC, *XAR4
B failVCRCRegTest, NEQ
VMOV32 *XAR4, VCRCPOLY
CMPL ACC, *XAR4
B failVCRCRegTest, NEQ
MOVL XAR6, @ACC ; save ACC contents
AND AH, #VSTATUS_TEST_MASK_MSB ; use a mask to test VSTATUS reg
AND AL, #VSTATUS_TEST_MASK_LSB
MOVL *XAR4, ACC
VMOV32 VSTATUS, *XAR4
VMOV32 *XAR4, VSTATUS
CMPL ACC, *XAR4
B failVCRCRegTest, NEQ
MOVL ACC, @XAR6 ; restore ACC contents
AND AH, #VCRCSIZE_TEST_MASK_MSB ; use a mask to test VCRCSIZE reg
AND AL, #VCRCSIZE_TEST_MASK_LSB
MOVL *XAR4, ACC
VMOV32 VCRCSIZE, *XAR4
VMOV32 *XAR4, VCRCSIZE
CMPL ACC, *XAR4
B failVCRCRegTest, NEQ
MOVL ACC, @XAR6 ; restore ACC contents
DEC PL ; decrement loop counter
B loopVCRCRegTest, GEQ
passVCRCRegTest:
MOV AL, #TEST_PASSED
B endVCRCRegTest, UNC ; return success code if pass
failVCRCRegTest:
MOV AL, #TEST_FAILED
endVCRCRegTest:
MOVL *XAR4, XAR7
VMOV32 VSTATUS, *XAR4
POP XAR7
MOVL *XAR4, XAR7
VMOV32 VCRCSIZE, *XAR4
POP XAR7
MOVL *XAR4, XAR7
VMOV32 VCRCPOLY, *XAR4
LRETR
@@ -0,0 +1,106 @@
//###########################################################################
//
// FILE: stl_crc.c
//
// TITLE: Diagnostic Library CRC software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_crc.h"
//*****************************************************************************
//
// STL_CRC_checkCRC(const uint32_t startAddress, const uint32_t endAddress,
// const uint32_t goldenCRC)
//
//*****************************************************************************
uint16_t STL_CRC_checkCRC(const uint32_t startAddress,
const uint32_t endAddress,
const uint32_t goldenCRC)
{
uint16_t testStatus;
STL_CRC_Obj crcObj;
//
// Calculate number of bytes to calculate a CRC on, inclusive of the end
// address. Remember words are two bytes.
//
uint16_t numBytes = (uint16_t)(endAddress - startAddress + 1U) << 1;
//
// Calculate the CRC of the received data using the VCU.
//
// Step 1: Initialize the CRC object.
//
crcObj.seedValue = STL_CRC_INIT_CRC;
crcObj.numBytes = numBytes;
crcObj.parity = STL_CRC_PARITY_EVEN;
crcObj.crcResult = 0U;
crcObj.msgBuffer = (void *)startAddress;
//
// Step 2: Run the 32-bit CRC on the received data.
//
STL_CRC_reset();
STL_CRC_calculate(&crcObj);
//
// Compare calculated CRC and golden CRC.
//
if(goldenCRC != crcObj.crcResult)
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_CRC);
testStatus = STL_CRC_FAIL;
}
else
{
testStatus = STL_CRC_PASS;
}
return(testStatus);
}
//
// End of File
//
@@ -0,0 +1,270 @@
;;//###########################################################################
;;//
;;// FILE: stl_crc_s.asm
;;//
;;// TITLE: Diagnostic Library CLA software module assembly
;;//
;;//###########################################################################
;;// $TI Release: C2000 Diagnostic Library v5.00.01 $
;;// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
;;// $Copyright:
;// Copyright (C) 2024 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.
;// $
;;//###########################################################################
;;
;;
;; Macros
;;
;; Context save. PUSH XAR1
;;
CRC_CONTEXT_SAVE .macro
PUSH XAR1
.endm
;;
;; Context restore. POP XAR1
;;
CRC_CONTEXT_RESTORE .macro
POP XAR1
.endm
;;
;; Globals
;;
;
; Module definition for external reference
;
.global STL_CRC_calculate
.global STL_CRC_calculateLowBytes
.global STL_CRC_reset
;;
;; Argument structure defines
;;
ARG_SEEDVAL .set 0
ARG_NBYTES .set 2
ARG_PARITY .set 3
ARG_CRCRESULT .set 4
ARG_MSGBUFFER .set 6
.text
;;*****************************************************************************
;; Subroutine STL_CRC_calculateLowBytes
;;*****************************************************************************
STL_CRC_calculateLowBytes:
CRC_CONTEXT_SAVE
;
; Clear out the CRC result register
; Load number of message bytes into AR0
; Load seed value into the CRC result register
; XAR5 points to the message buffer
;
VCRCCLR
MOVL XAR0, *+XAR4[ARG_NBYTES]
VMOV32 VCRC, *+XAR4[ARG_SEEDVAL]
MOVL XAR5, *+XAR4[ARG_MSGBUFFER]
STL_CRC_run32BitPoly1_LowBytes_Loop:
;
; Check to see if length greater than 8 bytes
; if true, handle the <8 bytes in a loop
; AL is now a multiple of 8
;
MOV AL, AR0
MOV AH, AR0
AND AL, #0xFFF8
;
; loop in 8 bytes at a time
; move count into AR1
; subtract 1, accounts for the RPTB instruction i.e. it loops
; N + 1 times
;
SBF STL_CRC_run32BitPoly1_LowBytes_LT8BytesLeft, EQ
LSR AL, #3
MOV AR1, AL
SUB AR1, #1
;
; align at 32-bit boundary to remove penalty
;
.align 2
;
; loop through the message 8 bytes at a time
;
RPTB STL_CRC_run32BitPoly1_LowBytes_RepeatBlock, AR1
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
VCRC32L_1 *XAR5++
STL_CRC_run32BitPoly1_LowBytes_RepeatBlock:
;
; multiply by 8 to get the pre RPTB count
; AH holds the number of remaining bytes(<8)
; if multiple of 8, AH is 0, done processing
;
LSL AL, #3
SUB AH, AL
SBF STL_CRC_run32BitPoly1_LowBytes_End, EQ
MOV AR0, AH
STL_CRC_run32BitPoly1_LowBytes_LT8BytesLeft:
VCRC32L_1 *XAR5++
DEC AR0
SBF STL_CRC_run32BitPoly1_LowBytes_LT8BytesLeft, NEQ
STL_CRC_run32BitPoly1_LowBytes_End:
;
; Save the result to the structure
;
VMOV32 *+XAR4[ARG_CRCRESULT], VCRC
CRC_CONTEXT_RESTORE
LRETR
;;*****************************************************************************
;; Subroutine STL_CRC_calculate
;;*****************************************************************************
STL_CRC_calculate:
CRC_CONTEXT_SAVE
;
; Clear out the CRC result register
; Load number of message bytes into AR0
; Load seed value into the CRC result register
; XAR5 points to the message buffer
; Check the parity
; If Parity = LOW_BYTE, skip to loop
; Parity = HIGH_BYTE, calculate high byte of the first word,
; ignore the low byte and proceed to next word
;
VCRCCLR
MOVL XAR0, *+XAR4[ARG_NBYTES]
VMOV32 VCRC, *+XAR4[ARG_SEEDVAL]
MOVL XAR5, *+XAR4[ARG_MSGBUFFER]
MOV AL, *+XAR4[ARG_PARITY]
SBF STL_CRC_run32BitPoly1_Loop, EQ
VCRC32H_1 *XAR5++
DEC AR0
;
; Jump to end if no more bytes
;
SBF STL_CRC_run32BitPoly1_End, EQ
STL_CRC_run32BitPoly1_Loop:
;
; Check to see if length greater than 8 bytes
; if true, handle the <8 bytes in a loop
; AL is now a multiple of 8
;
MOV AL, AR0
MOV AH, AR0
AND AL, #0xFFF8
;
; loop in 8 bytes at a time
; move count into AR1
; subtract 1, accounts for the RPTB instruction i.e. it loops
; N + 1 times
;
SBF STL_CRC_run32BitPoly1_LT8BytesLeft, EQ
LSR AL, #3
MOV AR1, AL
SUB AR1, #1
;
; align at 32-bit boundary to remove penalty
;
.align 2
;
; loop through the message 8 bytes at a time
;
RPTB STL_CRC_run32BitPoly1_RepeatBlock, AR1
VCRC32L_1 *XAR5
VCRC32H_1 *XAR5++
VCRC32L_1 *XAR5
VCRC32H_1 *XAR5++
VCRC32L_1 *XAR5
VCRC32H_1 *XAR5++
VCRC32L_1 *XAR5
VCRC32H_1 *XAR5++
STL_CRC_run32BitPoly1_RepeatBlock:
;
; multiply by 8 to get the pre RPTB count
; AH holds the number of remaining bytes(<8)
; if multiple of 8, AH is 0, done processing
;
LSL AL, #3
SUB AH, AL
SBF STL_CRC_run32BitPoly1_End, EQ
MOV AR0, AH
STL_CRC_run32BitPoly1_LT8BytesLeft:
VCRC32L_1 *XAR5
DEC AR0
SBF STL_CRC_run32BitPoly1_End, EQ
VCRC32H_1 *XAR5++
DEC AR0
SBF STL_CRC_run32BitPoly1_LT8BytesLeft, NEQ
STL_CRC_run32BitPoly1_End:
;
; Save the result to the structure
;
VMOV32 *+XAR4[ARG_CRCRESULT], VCRC
CRC_CONTEXT_RESTORE
LRETR
;;*****************************************************************************
;; Subroutine STL_CRC_reset
;;*****************************************************************************
STL_CRC_reset:
;
; resets the VCRC and clears the VCRC register
;
MOVB XAR7, #0
VCRC8L_1 *XAR7
VCRCCLR
LRETR
;;
;; End of File
;;
@@ -0,0 +1,532 @@
//#############################################################################
//
// FILE: stl_hwbist.c
//
// TITLE: Diagnostic Library HWBIST software module source
//
//#############################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//#############################################################################
//
// Includes
//
#include "stl_hwbist.h"
#include "stl_util.h"
#include "sysctl.h"
#include "interrupt.h"
//
// Defines
//
#define STL_HWBIST_NMI_CPU1_HWBISTERR 0x0010U
#define STL_HWBIST_NMI_CPU2_HWBISTERR 0x0020U
//
// Externs
//
extern void STL_HWBIST_runMicroTest(void);
//*****************************************************************************
//
// STL_HWBIST_errorNMIISR(void)
//
//*****************************************************************************
#ifndef __cplusplus
#pragma CODE_SECTION(STL_HWBIST_errorNMIISR, ".TI.ramfunc");
#else
#pragma CODE_SECTION(".TI.ramfunc");
#endif
__interrupt void STL_HWBIST_errorNMIISR(void)
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_NMI_INT);
//
// Clear the NMI CPU1 HWBIST Error flag and NMIINT flag if it is
// the only flag left.
//
SysCtl_clearNMIStatus(STL_HWBIST_NMI_CPU1_HWBISTERR);
//
// Clear the NMI CPU2 HWBIST Error flag and NMIINT flag if it is
// the only flag left.
//
SysCtl_clearNMIStatus(STL_HWBIST_NMI_CPU2_HWBISTERR);
}
//*****************************************************************************
//
// STL_HWBIST_runFull(const STL_HWBIST_Error errorType)
//
//*****************************************************************************
#ifndef __cplusplus
#pragma CODE_SECTION(STL_HWBIST_runFull, ".TI.ramfunc");
#else
#pragma CODE_SECTION(".TI.ramfunc");
#endif
uint16_t STL_HWBIST_runFull(const STL_HWBIST_Error errorType)
{
uint16_t microResult = 0U, bistDone = 0U, microCount = 0U;
uint32_t prevNMIVector;
//
// Initialize the HWBIST 99% run 1 patterns.
//
STL_HWBIST_init(STL_HWBIST_99_RUN1);
//
// Inject an error or no error.
//
STL_HWBIST_injectError(errorType);
//
// Enable vector fetching from PIE block.
//
HWREGH(PIECTRL_BASE + PIE_O_CTRL) |= PIE_CTRL_ENPIE;
//
// Save previous NMI vector.
//
prevNMIVector = HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI);
//
// Register NMI ISR.
//
Interrupt_register(INT_NMI, STL_HWBIST_errorNMIISR);
//
// Execute HWBIST 99% run 1 patterns.
//
while((bistDone == 0U) && (microCount < STL_HWBIST_MICRO_LIMIT_99_RUN1))
{
//
// Increment micro-run counter.
//
microCount++;
//
// Call HWBIST assembly self test micro-run.
//
STL_HWBIST_runMicroTest();
EDIS;
//
// Get the micro-run status.
//
microResult = HWREGH(HWBIST_BASE + HWBIST_O_CSTGSTAT);
if(STL_HWBIST_BIST_DONE == (microResult & STL_HWBIST_BIST_DONE))
{
//
// HWBIST is done.
//
bistDone = 1U;
}
}
//
// Check if there where any errors and return if so.
//
if(bistDone == 0U)
{
//
// HWBIST failed. It did not complete in the correct number of
// micro-runs.
//
// Report global error for over-run error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_OVERRUN);
//
// Restore previous NMI vector.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) = prevNMIVector;
EDIS;
return(STL_HWBIST_OVERRUN_FAIL);
}
else if(STL_HWBIST_NMI == (microResult & STL_HWBIST_NMI))
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_NMI_TEST);
//
// Restore previous NMI vector.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) = prevNMIVector;
EDIS;
return(microResult);
}
else if((microResult & STL_HWBIST_BIST_FAIL) == STL_HWBIST_BIST_FAIL)
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_FAIL);
//
// Restore previous NMI vector.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) = prevNMIVector;
EDIS;
return(microResult);
}
else
{
//
// No error found.
//
}
//
// Set HWBIST done status back to 0.
//
bistDone = 0U;
//
// Initialize the HWBIST for 99% run 2 patterns.
//
STL_HWBIST_init(STL_HWBIST_99_RUN2);
//
// Execute HWBIST for 99% run 2 patterns.
//
while((bistDone == 0U) && (microCount < STL_HWBIST_MICRO_LIMIT_99))
{
//
// Increment micro-run counter.
//
microCount++;
//
// Call HWBIST assembly self test micro-run.
//
STL_HWBIST_runMicroTest();
EDIS;
//
// Get the micro-run status.
//
microResult = HWREGH(HWBIST_BASE + HWBIST_O_CSTGSTAT);
if(STL_HWBIST_BIST_DONE == (microResult & STL_HWBIST_BIST_DONE))
{
//
// HWBIST is done.
//
bistDone = 1U;
}
}
//
// Restore previous NMI vector.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) = prevNMIVector;
EDIS;
//
// Check if there where any errors and return if so.
//
if(bistDone == 0U)
{
//
// HWBIST failed. It did not complete in the correct number of
// micro-runs.
//
// Report global error for over-run error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_OVERRUN);
return(STL_HWBIST_OVERRUN_FAIL);
}
else if(STL_HWBIST_NMI == (microResult & STL_HWBIST_NMI))
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_NMI_TEST);
}
else if((microResult & STL_HWBIST_BIST_FAIL) == STL_HWBIST_BIST_FAIL)
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_FAIL);
}
else
{
//
// No error found.
//
}
//
// Return the result.
//
return(microResult);
}
//*****************************************************************************
//
// STL_HWBIST_runMicro(void)
//
//*****************************************************************************
#ifndef __cplusplus
#pragma CODE_SECTION(STL_HWBIST_runMicro, ".TI.ramfunc");
#else
#pragma CODE_SECTION(".TI.ramfunc");
#endif
uint16_t STL_HWBIST_runMicro(void)
{
uint16_t microResult;
uint32_t prevNMIVector;
//
// Save previous NMI vector.
//
prevNMIVector = HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI);
//
// Enable vector fetching from PIE block
//
HWREGH(PIECTRL_BASE + PIE_O_CTRL) |= PIE_CTRL_ENPIE;
//
// Register NMI ISR.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) =
(uint32_t)STL_HWBIST_errorNMIISR;
EDIS;
//
// Call HWBIST assembly self test micro-run.
//
STL_HWBIST_runMicroTest();
//
// Restore previous NMI vector.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + STL_UTIL_PIEVECTTABLE_NMI) = prevNMIVector;
EDIS;
//
// Get the micro-run status.
//
microResult = HWREGH(HWBIST_BASE + HWBIST_O_CSTGSTAT);
if(STL_HWBIST_NMI == (microResult & STL_HWBIST_NMI))
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_NMI_TEST);
}
else if((microResult & STL_HWBIST_BIST_FAIL) == STL_HWBIST_BIST_FAIL)
{
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_HWBIST_FAIL);
}
else
{
//
// No error found.
//
}
//
// Return the result.
//
return(microResult);
}
//*****************************************************************************
//
// STL_HWBIST_restoreContext(void)
//
//*****************************************************************************
#pragma RETAIN(STL_HWBIST_restoreContext);
#ifndef __cplusplus
#pragma CODE_SECTION(STL_HWBIST_restoreContext, "hwbist");
#else
#pragma CODE_SECTION("hwbist");
#endif
void STL_HWBIST_restoreContext(void)
{
//
// Initialize the stack pointer.
//
STL_HWBIST_REF_STACK;
STL_HWBIST_MOV_SP_STACK;
//
// Select C28x object mode.
//
STL_HWBIST_C28OBJ;
//
// Select C27x/C28x addressing.
//
STL_HWBIST_C28ADDR;
//
// Set blocks M0/M1 for C28x mode.
//
STL_HWBIST_C28MAP;
//
// Always use stack addressing mode.
//
STL_HWBIST_CLRC_PAGE0;
//
// Initialize DP to point to the low 64K.
//
STL_HWBIST_MOVW_DP_0;
STL_HWBIST_CLRC_OVM;
STL_HWBIST_SPM_0;
EALLOW;
//
// Branch to reset handler and context restore.
//
STL_HWBIST_REF_HANDLE_RESET_FXN;
STL_HWBIST_LCR_HANDLE_RESET_FXN;
}
//*****************************************************************************
//
// STL_HWBIST_init(const STL_HWBIST_Coverage coverage)
//
//*****************************************************************************
#ifndef __cplusplus
#pragma CODE_SECTION(STL_HWBIST_init, ".TI.ramfunc");
#else
#pragma CODE_SECTION(".TI.ramfunc");
#endif
void STL_HWBIST_init(const STL_HWBIST_Coverage coverage)
{
EALLOW;
//
// Soft reset the HWBIST controller to put it into a known state.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR5) = 0x80000000UL;
//
// Clear the HWBIST soft reset bit.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR5) = 0x0000UL;
//
// Load target coverage metric.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR6) = (uint32_t)coverage & 1U;
//
// Restart HWBIST.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR5) = 0x000AUL;
//
// Load a micro run cycle count.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR1) = 48UL;
//
// Run launch-on-shift at clock divide of 1.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR7) = 20UL;
//
// Number of tests after which intermediate comparison is done.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCGCR8) = 50UL;
//
// Configure micro run based on coverage requested.
//
if(coverage == STL_HWBIST_95)
{
HWREG(HWBIST_BASE + HWBIST_O_CSTCSADDR) = 20020UL << 16;
HWREG(HWBIST_BASE + HWBIST_O_CSTCPCNT) = STL_HWBIST_MICRO_LIMIT_95;
}
else if(coverage == STL_HWBIST_99_RUN1)
{
HWREG(HWBIST_BASE + HWBIST_O_CSTCSADDR) = 20020UL << 16;
HWREG(HWBIST_BASE + HWBIST_O_CSTCPCNT) = STL_HWBIST_MICRO_LIMIT_99_RUN1 << 16;
}
else
{
HWREG(HWBIST_BASE + HWBIST_O_CSTCSADDR) = (20300UL << 16) | 17010UL;
HWREG(HWBIST_BASE + HWBIST_O_CSTCPCNT) = STL_HWBIST_MICRO_LIMIT_99_RUN2 << 16;
}
//
// Configuration is done.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCCONFIG) = 0x0005UL;
//
// Set return address.
//
HWREG(HWBIST_BASE + HWBIST_O_CSTCRET) = 0x0000UL;
NOP;
NOP;
NOP;
EDIS;
}
//
// End of File
//
@@ -0,0 +1,427 @@
;;//###########################################################################
;;//
;;// FILE: stl_hwbist_s.asm
;;//
;;// TITLE: Diagnostic Library HWBIST software module assembly
;;//
;;//###########################################################################
;;// $TI Release: C2000 Diagnostic Library v5.00.01 $
;;// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
;;// $Copyright:
;// Copyright (C) 2024 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.
;// $
;;//###########################################################################
.cdecls C, LIST, "inc/hw_memmap.h"
.cdecls C, LIST, "inc/hw_sysctl.h"
;;
;; C-Callable function defs
;;
.def STL_HWBIST_runMicroTest
.def STL_HWBIST_handleReset
;;
;; RAM section globals
;;
.global biststack ; HWBIST Stack (for BIST context save/rest)
;;
;; C-Callable function globals
;;
.global STL_HWBIST_runMicroTest
.global STL_HWBIST_handleReset
;;
;; RAM section (stack addresses filled in by the linker)
;; Reserve 82 (0x52) words for stack. Use blocking flag and alignment flag to
;; allocate 82 words on a long word boundary.
;;
biststack: .usect "hwbiststack", 82, 1, 2
;;
;; HWBIST Macros
;;
HWBRegs .set 0x1780 ; DP to HWB resisters (64 * 0x1780 = 0x5E000)
CSTCCRD .set 0x0038 ; Register in DP
CSTCGCR2 .set 0x0008 ; Register in DP
CSTCGCR3 .set 0x000C ; Register in DP
CSTCGCR4 .set 0x0010 ; Register in DP
;;
;; CPU Timer Macros
;;
TmrRegs .set 0x0030 ; DP to HWB resisters (64 * 0x30 = 0xC00)
TMR1TCR .set 0x000C ; Register in DP
TMR2TCR .set 0x0014 ; Register in DP
;;
;; Code section
;;
.sect ".TI.ramfunc"
;;*****************************************************************************
;;
;; BIST reset handler. This is the entry point that is called by BootROM after
;; a BIST reset. This function is NOT C-Callable and does NOT return anywhere.
;; After this function is called, the processor context is restored (the PC is
;; set to retpcloc: in STL_HWBIST_runMicroTest).
;;
;;*****************************************************************************
STL_HWBIST_handleReset:
MOVW DP, #0 ; Set DP so we can access @SP
;
; 14 NOPs
;
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
;
; Begin Context Restore
;
MOV SP, #(biststack + 0x4C) ; Move SP last BIST stack str loc
POP RPC ; Start restoring in reverse order
POP DP:ST1
POP T:ST0
POP XAR7
POP XAR6
POP XAR5
POP XAR4
POP XAR3
POP XAR2
POP XAR1
POP XAR0
POP P
POP ACC ; Remember: AH = ST1, AL = ST0 from user context
POP XT
NASP ; Un-align stack pointer
POP IER
POP RB ; Restore FPU Registers
MOV32 STF, *--SP
MOV32 R7L, *--SP
MOV32 R6L, *--SP
MOV32 R5L, *--SP
MOV32 R4L, *--SP
MOV32 R3L, *--SP
MOV32 R2L, *--SP
MOV32 R1L, *--SP
MOV32 R0L, *--SP
MOV32 R7H, *--SP
MOV32 R6H, *--SP
MOV32 R5H, *--SP
MOV32 R4H, *--SP
MOV32 R3H, *--SP
MOV32 R2H, *--SP
MOV32 R1H, *--SP
MOV32 R0H, *--SP
VMOV32 VCRCSIZE, *--SP ; Restore VCRC Registers
VMOV32 VCRCPOLY, *--SP
VMOV32 VSTATUS, *--SP
VMOV32 VCRC, *--SP
MOV SP, #(biststack + 0x4E) ; Move SP to end of BIST Stack to
; Restore XAR7
POP XAR7 ; Get return PC into XAR7
MOV @SP, *(0:biststack) ; Restore user SP
;
; End ContextRestore
;
EALLOW
;
; Reset HW BIST reset source bits
;
MOVW DP, #((CPUSYS_BASE + SYSCTL_O_RESC) >> 6)
MOV @(SYSCTL_O_RESC & 0x40), #0x00000000
;
; Context restore done, re-issue logged interrupts
;
MOVW DP, #HWBRegs
MOVW @CSTCCRD, #0x0A
;
; 14 NOPs
;
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
;
; Restore the CPU Timer 1 & 2 interrupt enable status. If the TCR.TIF bit
; is set and interrupts were enabled force the corresponding bit in IFR.
;
MOVW DP, #TmrRegs
TBIT AL, #14 ; Branch if TIE wasn't set
SB noEnableTIE1, NTC
TBIT @TMR1TCR, #15 ; Branch if TIE was set, but TIF isn't
SB enableTIE1, NTC
OR IFR, #(1 << 12) ; Set the IFR flag for INT13
enableTIE1:
MOV AL, @TMR1TCR ; Reenable CPU Timer 1 interrupts
AND AL, #~(1 << 15) ; TIF is W1C, so take care not to clear it
OR AL, #(1 << 14)
MOV @TMR1TCR, AL
noEnableTIE1:
TBIT AH, #14 ; Check if TIE was set
SB noEnableTIE2, NTC
TBIT @TMR2TCR, #15 ; Branch if TIE was set, but TIF isn't
SB enableTIE2, NTC
OR IFR, #(1 << 13) ; Set the IFR flag for INT14
enableTIE2:
MOV AL, @TMR2TCR ; Reenable CPU Timer 2 interrupts
AND AL, #~(1 << 15) ; TIF is W1C, so take care not to clear it
OR AL, #(1 << 14)
MOV @TMR2TCR, AL
noEnableTIE2:
;
; Restore PC (this will branch back to retpcloc: in STL_HWBIST_runMicroTest)
;
LB *XAR7
;;*****************************************************************************
;;
;; void STL_HWBIST_runMicroTest(void)
;; C-callable function that starts the self test run. This function will
;; return to user code after the BIST reset cycle. It may also return if
;; BISTDISABLE = 0xA.
;;
;;*****************************************************************************
STL_HWBIST_runMicroTest:
;
; Explicitly save modified regs on user stack because they are modified in
; this function. While this is saved by the calling function in the normal
; convention, we are explicitly saving it just in case someone wants to call
; this from ASM.
;
PUSH ACC
PUSH XAR4
PUSH XAR7
PUSH ST1 ; Save the user's ST1 register
; This preserves EALLOW, INTM, and status bits
POP AH
PUSH ST0 ; Save the user's ST0 register
POP AL
MOVL XAR4, ACC ; Back up ST0/ST1 settings to XAR4
;
; This is a workaround for a corner case where generation of a spurious
; CPU Timer 1 & 2 interrupt is possible. CPU Timer interrupts will be
; saved and disabled before HWBIST interrupt logging is started and
; restored after it is ended.
;
MOVW DP, #TmrRegs
MOV AL, @TMR1TCR ; Save TCR registers in the ACC
MOV AH, @TMR2TCR
AND @TMR1TCR, #~(3 << 14) ; Clear TIE bit without clearing TIF
AND @TMR2TCR, #~(3 << 14) ; Clear TIE bit without clearing TIF
EALLOW
MOVW DP, #HWBRegs
MOVW @CSTCGCR3, #0x0A ; Start logging interrupts
;
; Pipeline flush (9 NOPs).
; These NOPs MUST be located here in order to guarantee that pending
; interrupts in the IFR register are serviced before moving onto the
; context save (which cannot be interrupted).
;
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
EDIS
MOVW DP, #0 ; For @SP accesses
;
; Begin Context Save Routine
;
MOV *(0:biststack), @SP ; (0) Save user SP to top of stack
MOV SP, #(biststack + 2) ; Load SP with next BIST stack loc
VMOV32 *SP++, VCRC ; Save VCRC Registers
VMOV32 *SP++, VSTATUS
VMOV32 *SP++, VCRCPOLY
VMOV32 *SP++, VCRCSIZE
MOV32 *SP++, R0H ; Save FPU Registers
MOV32 *SP++, R1H
MOV32 *SP++, R2H
MOV32 *SP++, R3H
MOV32 *SP++, R4H
MOV32 *SP++, R5H
MOV32 *SP++, R6H
MOV32 *SP++, R7H
MOV32 *SP++, R0L
MOV32 *SP++, R1L
MOV32 *SP++, R2L
MOV32 *SP++, R3L
MOV32 *SP++, R4L
MOV32 *SP++, R5L
MOV32 *SP++, R6L
MOV32 *SP++, R7L
MOV32 *SP++, STF
PUSH RB
PUSH IER ; (0)
ASP ; Align stack pointer (SP+1)
PUSH XT ; (2:3)
PUSH ACC ; (4:5) AH = ST1 AL = ST0 user context
PUSH P ; (6:7)
PUSH XAR0 ; (8:9)
PUSH XAR1 ; (A:B)
PUSH XAR2 ; (C:D)
PUSH XAR3 ; (E:F)
PUSH XAR4 ; (10:11)
PUSH XAR5 ; (12:13)
PUSH XAR6 ; (14:15)
PUSH XAR7 ; (16:17)
PUSH T:ST0 ; (18:19)
PUSH DP:ST1 ; (1A:1B)
PUSH RPC ; (1C:1D)
curpcloc:
MOV XAR7, PC ; Add PC return offset
ADD AR7, #(retpcloc - curpcloc) ; instruction after BIST_GO
PUSH XAR7 ; (1E:1F) Push PC
;
; End Context Save Routine
;
EALLOW
NOP ; Pipeline flush (17 NOPs)
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
;
; Start BIST Self Test
;
MOVW DP, #HWBRegs
MOVW @CSTCGCR4, #0x0A ; (BIST_GO)
RPT #20 || NOP
NOP ; Pipeline flush (9 NOPs)
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
retpcloc:
;
; This is the return point from the BIST ResetHandler routine. XAR4
; contains the ST0/ST1 values from before the BIST_GO was triggered. ST1
; must be restored now to return the EALLOW, INTM, DBGM state back to
; original status.
;
MOVL ACC, XAR4 ; ACC = backed up ST0/ST1 registers
PUSH AL ; Restore user's ST0
POP ST0 ; ST0 = AL
PUSH AH ; Restore user's ST1
POP ST1 ; ST1 = AH
;
; At this point, INTM and DBGM will be restored to original state
;
POP XAR7 ; Restore regs from user stack
POP XAR4
POP ACC
LRETR
;;
;; End of File
;;
@@ -0,0 +1,123 @@
//###########################################################################
//
// FILE: stl_march.c
//
// TITLE: Diagnostic Library March13N software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_march.h"
#include "stl_util.h"
#include "memcfg.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// STL_March_injectError(const STL_March_InjectErrorHandle errorHandle)
//
//*****************************************************************************
void STL_March_injectError(const STL_March_InjectErrorHandle errorHandle)
{
//
// Enter user-specified test mode.
//
MemCfg_setTestMode(errorHandle->ramSection, errorHandle->testMode);
//
// XOR the data at the specified address with the mask provided.
//
HWREG(errorHandle->address) ^= errorHandle->xorMask;
//
// Go back to functional mode.
//
MemCfg_setTestMode(errorHandle->ramSection, MEMCFG_TEST_FUNCTIONAL);
}
//*****************************************************************************
//
// STL_March_checkErrorStatus(void)
//
//*****************************************************************************
uint16_t STL_March_checkErrorStatus(void)
{
uint16_t status;
if((HWREG(MEMORYERROR_BASE + MEMCFG_O_UCERRFLG) != 0U) &&
(HWREG(MEMORYERROR_BASE + MEMCFG_O_CERRFLG) == 0U))
{
status = STL_MARCH_UNC_ERROR;
//
// Set global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_MARCH);
}
else if((HWREG(MEMORYERROR_BASE + MEMCFG_O_CERRFLG) != 0U) &&
(HWREG(MEMORYERROR_BASE + MEMCFG_O_UCERRFLG) == 0U))
{
status = STL_MARCH_CORR_ERROR;
//
// Set global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_MARCH);
}
else if((HWREG(MEMORYERROR_BASE + MEMCFG_O_CERRFLG) != 0U) &&
(HWREG(MEMORYERROR_BASE + MEMCFG_O_UCERRFLG) != 0U))
{
status = STL_MARCH_BOTH_ERROR;
//
// Set global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_MARCH);
}
else
{
status = STL_MARCH_PASS;
}
return(status);
}
//
// End of File
//
@@ -0,0 +1,233 @@
;;//###########################################################################
;;//
;;// FILE: stl_march_s.asm
;;//
;;// TITLE: Diagnostic Library March13N software module assembly
;;//
;;//###########################################################################
;;// $TI Release: C2000 Diagnostic Library v5.00.01 $
;;// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
;;// $Copyright:
;// Copyright (C) 2024 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.
;// $
;;//###########################################################################
.global STL_March_testRAMCopy
.global STL_March_testRAM
.asg "*-SP[4]", STARTADDR
.asg "*-SP[6]", LENGTH
.asg "*-SP[8]", COPYADDR
;;*****************************************************************************
;; Subroutine STL_March_testRAMCopy
;; ACC contains the test pattern
;; SP-2 contains previous RPC
;; SP-4 contains the start address
;; SP-6 contains the length
;; SP-8 contains the copy address
;;*****************************************************************************
STL_March_testRAMCopy:
MOVL XAR7, LENGTH ; XAR7 = length (permanent)
MOVL XT, STARTADDR ; XT = start address
MOV AR5, #0001 ; AR5 = 1
MOVL XAR6, XT ; XAR6 = start address
MOVL XAR0, XAR7 ; XAR0 = length
; ACC = pattern
MOVL XAR4, COPYADDR ; XAR4 = copy address
DINT ; Disable interrupts
;
; Save from start to end
;
aSave:
MOVL P, *XAR6++ ; Get content
MOVL *XAR4++, P ; Save content to stack
BANZ aSave, AR0-- ; Continue until done
; XAR4 = copy end address + 1
MOVL XAR6, XT ; XAR6 = start address
MOVL XAR0, XAR7 ; XAR0 = length
; ACC = pattern
aFill:
MOVL *XAR6++, ACC ; Write(1) fill with pattern (ACC)
BANZ aFill, AR0-- ; Continue for length words
aAscend:
;
; Get ready to ascend
;
NOT ACC ; Invert the pattern in ACC
MOVL XAR6, XT ; XAR6 = start address
MOVL XAR0, XAR7 ; XAR0 = length
; ACC = pattern
aAscendInner:
MOVL P, *XAR6 ; Read(2) pattern / Read(5) inverse
MOVL *XAR6, ACC ; Write(3) inverse / Write(6) pattern
MOVL P, *XAR6++ ; Read(4) inverse / Read(7) pattern
BANZ aAscendInner, AR0-- ; Continue for length words
BANZ aAscend, AR5-- ; Continue for 2x ascending
; 1st with inverse pattern
; 2nd with pattern
MOV AR5, #0001 ; AR5 = 1
; ACC = pattern
; XAR6 = end address + 1
MOVL XT, XAR6 ; XT = end address + 1
; XT no longer needed to hold start addr
aDescend:
;
; Get ready to descend
;
NOT ACC ; Invert the pattern in ACC
MOVL XAR0, XAR7 ; XAR0 = length
aDescendInner:
MOVL P, *--XAR6 ; Read(8) pattern / Read(11) inverse
MOVL *XAR6, ACC ; Write(9) inverse / Write(12) pattern
MOVL P, *XAR6 ; Read(10) inverse / Read(13) pattern
BANZ aDescendInner, AR0-- ; Continue for length words
MOVL XAR6, XT ; XAR6 = end address + 1 (stored in XT)
BANZ aDescend, AR5-- ; Continue for 2x descending
; 1st with inverse pattern
; 2nd with pattern
;
; Get ready to restore
;
MOVL XAR0, XAR7 ; XAR0 = length
; XAR4 = copy address + 1
; XAR6 = end address + 1
;
; Restore from end to start
;
aRestore:
MOVL ACC,*--XAR4 ; Get content from copy address
MOVL *--XAR6,ACC ; Restore content to original address
BANZ aRestore, AR0-- ; Continue for length
EINT ; Enable interrupts
LRETR ; Return
;;
;; End of STL_March_testRAMCopy
;;
;;*****************************************************************************
;; Subroutine STL_March_testRAM
;; ACC contains the test pattern
;; SP-2 contains previous RPC
;; SP-4 contains the start address
;; SP-6 contains the length
;;*****************************************************************************
STL_March_testRAM:
MOVL XAR7, LENGTH ; XAR7 = length (permanent)
MOVL XT, STARTADDR ; XT = start address (permanent)
MOV AR5, #0001 ; AR5 = 1
MOVL XAR6, XT ; XAR6 = start address
MOVL XAR0, XAR7 ; XAR0 = length
; ACC = pattern
DINT ; Disable interrupts
bFill:
MOVL *XAR6++, ACC ; Write(1) fill with pattern (ACC)
BANZ bFill, AR0-- ; Continue for length words
bAscend:
;
; Get ready to ascend
;
NOT ACC ; Invert the pattern in ACC
MOVL XAR6, XT ; XAR6 = start address
MOVL XAR0, XAR7 ; XAR0 = length
; ACC = pattern
bAscendInner:
MOVL P, *XAR6 ; Read(2) pattern / Read(5) inverse
MOVL *XAR6, ACC ; Write(3) inverse / Write(6) pattern
MOVL P, *XAR6++ ; Read(4) inverse / Read(7) pattern
BANZ bAscendInner, AR0-- ; Continue for length words
BANZ bAscend, AR5-- ; Continue for 2x ascending
; 1st with inverse pattern
; 2nd with pattern
MOV AR5, #0001 ; AR5 = 1
; ACC = pattern
; XAR6 = end address + 1
MOVL XT, XAR6 ; XT = end address + 1
; XT no longer needed to hold start addr
bDescend:
;
; Get ready to descend
;
NOT ACC ; Invert the pattern in ACC
MOVL XAR0, XAR7 ; XAR0 = length
bDescendInner:
MOVL P, *--XAR6 ; Read(8) pattern / Read(11) inverse
MOVL *XAR6, ACC ; Write(9) inverse / Write(12) pattern
MOVL P, *XAR6 ; Read(10) inverse / Read(13) pattern
BANZ bDescendInner, AR0-- ; Continue for length words
MOVL XAR6, XT ; XAR6 = end address + 1 (stored in XT)
BANZ bDescend, AR5-- ; Continue for 2x descending
; 1st with inverse pattern
; 2nd with pattern
EINT ; Enable interrupts
LRETR ; Return
;;
;; End of STL_March_testRAM
;;
.unasg STARTADDR
.unasg LENGTH
.unasg COPYADDR
;;
;; End of File
;;
@@ -0,0 +1,172 @@
//###########################################################################
//
// FILE: stl_mcan_ram.c
//
// TITLE: Diagnostic Library MCAN message RAM test software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_mcan_ram.h"
#include "stl_util.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// STL_MCAN_RAM_testRAM(const uint32_t mcanBase,
// const STL_March_Pattern pattern,
// const uint16_t startAddress,
// const uint16_t endAddress,
// const uint32_t copyAddress)
//
//*****************************************************************************
void STL_MCAN_RAM_testRAM(const uint32_t mcanBase,
const STL_March_Pattern pattern,
const uint32_t startAddress,
const uint32_t endAddress,
const uint32_t copyAddress)
{
uint32_t length;
ASSERT(mcanBase == MCANA_DRIVER_BASE);
ASSERT(endAddress >= startAddress);
ASSERT(mcanBase <= startAddress);
ASSERT((mcanBase + STL_MCAN_RAM_MAX_ADDR_OFFSET) >= endAddress);
//
// The length needs to be divided by 2 since the test function expects a
// length in terms of 32-bit words.
//
if(endAddress >= startAddress)
{
length = (endAddress - startAddress) / 2U;
}
else
{
length = 0U;
}
//
// Run the March test.
//
if(STL_MCAN_RAM_NO_COPY == copyAddress)
{
STL_March_testRAM(pattern, startAddress, length);
}
else
{
STL_March_testRAMCopy(pattern, startAddress, length, copyAddress);
}
}
//*****************************************************************************
//
// STL_MCAN_RAM_injectError(const uint32_t mcanBase, const uint32_t address,
// const uint32_t xorMask);
//
//*****************************************************************************
void STL_MCAN_RAM_injectError(const uint32_t mcanBase, const uint32_t address,
const uint32_t xorMask)
{
MCAN_ECCConfigParams eccConfig;
ASSERT(mcanBase == MCANA_DRIVER_BASE);
ASSERT((address >= mcanBase) &&
(address <= (mcanBase + STL_MCAN_RAM_MAX_ADDR_OFFSET)));
//
// Turn off ECC, so we can flip a bit without updating it.
//
eccConfig.enable = 0U;
eccConfig.enableChk = 0U;
eccConfig.enableRdModWr = 0U;
MCAN_eccConfig(mcanBase, &eccConfig);
//
// Flip a bit (or multiple bits).
//
HWREG_BP(address) ^= xorMask;
//
// Turn ECC back on.
//
eccConfig.enable = 1U;
eccConfig.enableChk = 1U;
eccConfig.enableRdModWr = 0U;
MCAN_eccConfig(mcanBase, &eccConfig);
}
//*****************************************************************************
//
// STL_MCAN_RAM_checkErrorStatus(const uint32_t mcanBase,
// MCAN_ECCErrStatus *errStatus)
//
//*****************************************************************************
uint16_t STL_MCAN_RAM_checkErrorStatus(const uint32_t mcanBase,
MCAN_ECCErrStatus *errStatus)
{
uint16_t status;
ASSERT(mcanBase == MCANA_DRIVER_BASE);
//
// Read the error status fields from the MCAN registers.
//
MCAN_eccGetErrorStatus(mcanBase, errStatus);
if((errStatus->dedErr == 0U) && (errStatus->secErr == 0U))
{
status = STL_MCAN_RAM_PASS;
}
else
{
status = STL_MCAN_RAM_ERROR;
//
// Set global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_MCAN_RAM_ECC);
}
return(status);
}
//
// End of File
//
@@ -0,0 +1,146 @@
//###########################################################################
//
// FILE: stl_osc_ct.c
//
// TITLE: Diagnostic Library Oscillator CPU Timer software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_osc_ct.h"
#include "stl_util.h"
#include "cputimer.h"
//*****************************************************************************
//
// STL_OSC_CT_startTest(const STL_OSC_CT_Handle oscTimer2Handle)
//
//*****************************************************************************
void STL_OSC_CT_startTest(const STL_OSC_CT_Handle oscTimer2Handle)
{
//
// Stop Timer2.
//
CPUTimer_stopTimer(CPUTIMER2_BASE);
//
// Clear overflow flag.
//
CPUTimer_clearOverflowFlag(CPUTIMER2_BASE);
//
// Disable interrupt.
//
CPUTimer_disableInterrupt(CPUTIMER2_BASE);
//
// Initialize Timer2 period to maximum.
//
CPUTimer_setPeriod(CPUTIMER2_BASE, STL_OSC_CT_PERIOD);
//
// Initialize pre-scaler counter to divide by 1 (SYSCLKOUT).
//
CPUTimer_setPreScaler(CPUTIMER2_BASE, 0U);
//
// Reload Timer2 counter.
//
CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);
//
// Set prescaler to the input prescaler value.
// Select Timer2 clock source.
//
CPUTimer_selectClockSource(CPUTIMER2_BASE, oscTimer2Handle->clockSource,
oscTimer2Handle->prescaler);
//
// Start CPU Timer2.
//
CPUTimer_startTimer(CPUTIMER2_BASE);
}
//*****************************************************************************
//
// STL_OSC_CT_stopTest(const STL_OSC_CT_Handle oscTimer2Handle)
//
//*****************************************************************************
uint16_t STL_OSC_CT_stopTest(const STL_OSC_CT_Handle oscTimer2Handle)
{
uint32_t counterDelta;
uint16_t testStatus;
//
// Stop CPU Timer 2.
//
CPUTimer_stopTimer(CPUTIMER2_BASE);
//
// Get the Timer2 counter delta.
//
counterDelta = (uint32_t)STL_OSC_CT_PERIOD -
CPUTimer_getTimerCount(CPUTIMER2_BASE);
//
// Check if Timer2 has overflowed or if Timer2 counter
// is outside of the bounds.
//
if((counterDelta <= oscTimer2Handle->minCount) ||
(counterDelta >= oscTimer2Handle->maxCount) ||
CPUTimer_getTimerOverflowStatus(CPUTIMER2_BASE))
{
//
// Set the global error flag.
//
STL_Util_setErrorFlag(STL_UTIL_OSC_TIMER2);
testStatus = STL_OSC_CT_FAIL;
}
else
{
testStatus = STL_OSC_CT_PASS;
}
return(testStatus);
}
//
// End of File
//
@@ -0,0 +1,171 @@
//#############################################################################
//
// FILE: stl_osc_hr.c
//
// TITLE: Diagnostic Library Oscillator HRPWM software module source
//
//#############################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//#############################################################################
//
// Includes
//
#include "stl_osc_hr.h"
//
// Global used by the SFO() library.
//
extern int32_t MEP_ScaleFactor;
//*****************************************************************************
//
// STL_OSC_HR_testSFO(const STL_OSC_HR_Handle oscHRHandle)
//
//*****************************************************************************
uint16_t STL_OSC_HR_testSFO(const STL_OSC_HR_Handle oscHRHandle)
{
int16_t sfoStatus, sfoReturnValue;
uint16_t autoConversionEnabled, prevEdge;
uint32_t delayCount = oscHRHandle->sfoDelay;
uint16_t testStatus = STL_OSC_HR_FAIL;
bool loopBreak;
MEP_ScaleFactor = 0;
//
// Save previous high-resolution edge(s) controlled by Micro Edge
// Positioner (MEP) and set the new edges for given channel.
//
prevEdge = ((HWREGH(oscHRHandle->ePWMBase + HRPWM_O_HRCNFG) &
((uint16_t)0x3U << (uint16_t)oscHRHandle->channel)) >>
(uint16_t)oscHRHandle->channel);
HRPWM_setMEPEdgeSelect(oscHRHandle->ePWMBase, oscHRHandle->channel,
oscHRHandle->mepEdgeMode);
//
// Get status on whether auto-conversion is enabled.
//
autoConversionEnabled = (HWREGH(oscHRHandle->ePWMBase + HRPWM_O_HRCNFG) &
HRPWM_HRCNFG_AUTOCONV);
//
// Enable the MEP to automatically scale HRMSTEP.
//
HRPWM_enableAutoConversion(oscHRHandle->ePWMBase);
//
// Call SFO() until calibration is complete.
//
sfoReturnValue = (int16_t)SFO();
sfoStatus = sfoReturnValue;
while(delayCount != 0U)
{
if(sfoStatus == STL_OSC_HR_SFO_INCOMPLETE)
{
sfoReturnValue = (int16_t)SFO();
sfoStatus = sfoReturnValue;
loopBreak = false;
}
else if(sfoStatus == STL_OSC_HR_SFO_COMPLETE)
{
//
// Check if MEP_ScaleFactor is within the specified range.
//
if((MEP_ScaleFactor >= oscHRHandle->mepMin) &&
(MEP_ScaleFactor <= oscHRHandle->mepMax))
{
//
// Return pass.
//
testStatus = STL_OSC_HR_PASS;
loopBreak = true;
}
else
{
//
// MEP scale factor is out of range.
//
STL_Util_setErrorFlag(STL_UTIL_OSC_HR_MEP_RANGE);
testStatus = STL_OSC_HR_FAIL;
loopBreak = true;
}
}
else
{
//
// SFO calibration failed to calculate scale factor.
//
STL_Util_setErrorFlag(STL_UTIL_OSC_HR_SFO);
testStatus = STL_OSC_HR_FAIL;
loopBreak = true;
}
if(loopBreak == true)
{
break;
}
delayCount--;
}
if(delayCount == 0U)
{
//
// SFO took too long to execute.
//
STL_Util_setErrorFlag(STL_UTIL_OSC_HR_DELAY);
testStatus = STL_OSC_HR_FAIL;
}
//
// Restore edge controlled by MEP for given channel.
//
HRPWM_setMEPEdgeSelect(oscHRHandle->ePWMBase, oscHRHandle->channel,
(HRPWM_MEPEdgeMode)prevEdge);
//
// Disable the MEP from automatically scaling HRMSTEP if it was originally
// disabled.
//
if(autoConversionEnabled == 0U)
{
HRPWM_disableAutoConversion(oscHRHandle->ePWMBase);
}
return(testStatus);
}
//
// End of File
//
@@ -0,0 +1,304 @@
//###########################################################################
//
// FILE: stl_pie_ram.c
//
// TITLE: Diagnostic Library PIE RAM software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_pie_ram.h"
#include "stl_util.h"
#include "interrupt.h"
//
// Globals.
//
volatile static uint16_t STL_PIE_RAM_handlerFlag;
//*****************************************************************************
//
// void STL_PIE_RAM_handler(void)
//
//*****************************************************************************
void STL_PIE_RAM_handler(void)
{
//
// Set the global flag.
//
STL_PIE_RAM_handlerFlag = 1;
}
//*****************************************************************************
//
// STL_PIE_RAM_configHandler(void)
//
//*****************************************************************************
void STL_PIE_RAM_configHandler(const void *handlerPtr)
{
//
// Configure the function as the PIE RAM error handler.
//
EALLOW;
HWREG(CPUSYS_BASE + SYSCTL_O_PIEVERRADDR) = (uint32_t)handlerPtr;
EDIS;
}
//*****************************************************************************
//
// STL_PIE_RAM_injectFault(uint16_t entry)
//
//*****************************************************************************
void STL_PIE_RAM_injectFault(const uint16_t entry)
{
//
// Assert the entry is within the limits of the PIE vector table and
// a multiple of 2 to ensure it is 32-bit aligned.
//
ASSERT(entry >= STL_PIE_RAM_MIN_INDEX);
ASSERT(entry < STL_PIE_RAM_MAX_INDEX);
ASSERT((entry & 0x0001U) == 0U);
//
// Inject an error by bit-flipping the entry specified in the redundant
// PIE RAM vector table.
//
EALLOW;
HWREG(STL_PIE_RAM_REDUNDANT_PIE_ADDRESS + entry) =
~HWREG(PIEVECTTABLE_BASE + entry);
EDIS;
}
//*****************************************************************************
//
// STL_PIE_RAM_restoreVector(const uint16_t entry)
//
//*****************************************************************************
void STL_PIE_RAM_restoreVector(const uint16_t entry)
{
//
// Rewrite the vector table entry. This will update the redundant table
// as well.
//
EALLOW;
HWREG(PIEVECTTABLE_BASE + entry) = HWREG(PIEVECTTABLE_BASE + entry);
EDIS;
}
//*****************************************************************************
//
// STL_PIE_RAM_retoreTable(const uint32_t *pieTableSourcePtr)
//
//*****************************************************************************
void STL_PIE_RAM_restoreTable(const uint32_t *pieTableSourcePtr)
{
uint16_t index;
EALLOW;
//
// Restore the PIE vector table.
//
for(index = STL_PIE_RAM_MIN_INDEX; index < STL_PIE_RAM_MAX_INDEX;
index = index + 2U)
{
HWREG(PIEVECTTABLE_BASE + index) = pieTableSourcePtr[(index >> 1)];
}
EDIS;
}
//*****************************************************************************
//
// STL_PIE_RAM_testRAM(void)
//
//*****************************************************************************
uint16_t STL_PIE_RAM_testRAM(void)
{
uint16_t index;
uint16_t status;
status = STL_PIE_RAM_PASS;
//
// Loop over the whole PIE RAM table.
//
for(index = STL_PIE_RAM_MIN_INDEX; index < STL_PIE_RAM_MAX_INDEX;
index = index + 2U)
{
//
// Compare redundant table entry to the main table entry
//
if(HWREG(PIEVECTTABLE_BASE + index) !=
HWREG(STL_PIE_RAM_REDUNDANT_PIE_ADDRESS + index))
{
//
// Set the return status to the index. This will provide some
// additional error information.
//
status = index + PIEVECTTABLE_BASE;
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_PIE_RAM_MISMATCH);
}
}
return(status);
}
//*****************************************************************************
//
// STL_PIE_RAM_testHandler(void)
//
//*****************************************************************************
uint16_t STL_PIE_RAM_testHandler(const uint32_t interruptNumber)
{
uint16_t intGroup, groupMask, intMask, testStatus;
uint32_t prevHandler;
//
// Assert the interrupt number is a PIE interrupt.
// This test will only work for PIE interrupts.
//
ASSERT(((uint16_t)(interruptNumber >> 16U) >= 0x20U) &&
((uint16_t)(interruptNumber >> 16U) <= 0xDFU));
//
// Get the PIE RAM vector entry.
//
uint16_t pieEntry = (uint16_t)(((interruptNumber & STL_PIE_RAM_VECT_ID_M) >>
STL_PIE_RAM_VECT_ID_S) * 2U);
//
// Configure the default handler for the STL.
//
prevHandler = HWREG(CPUSYS_BASE + SYSCTL_O_PIEVERRADDR);
STL_PIE_RAM_configHandler(&STL_PIE_RAM_handler);
//
// Inject a fault at the entry.
//
STL_PIE_RAM_injectFault(pieEntry);
//
// Enable and force the interruptNumber. This should trigger the mismatch
// handler. If the handler is not serviced, then this test will FAIL.
//
//
// Determine the PIE interrupt group.
//
intGroup = ((uint16_t)(interruptNumber & STL_PIE_RAM_TABLE_COL_M) >>
STL_PIE_RAM_TABLE_COL_S) - 1U;
intMask = (uint16_t)1U << ((uint16_t)(interruptNumber &
STL_PIE_RAM_TABLE_ROW_M) - 1U);
groupMask = (uint16_t)1U << intGroup;
//
// Enable the PIE interrupt.
//
HWREGH(PIECTRL_BASE + PIE_O_IER1 + (intGroup * 2U)) |= intMask;
//
// Enable PIE Group Interrupt.
//
IER |= groupMask;
//
// Reset the global handler flag.
//
STL_PIE_RAM_handlerFlag = 0U;
//
// Force the PIE interrupt.
//
HWREGH(PIECTRL_BASE + PIE_O_IFR1 + (intGroup * 2U)) |= intMask;
//
// Short delay to ensure the exception was handled.
//
SysCtl_delay(5);
//
// Check that the PIE error interrupt occurred as expected.
//
if(STL_PIE_RAM_handlerFlag == 1U)
{
testStatus = STL_PIE_RAM_PASS;
}
else
{
testStatus = STL_PIE_RAM_FAIL_HANDLER;
//
// Report global error.
//
STL_Util_setErrorFlag(STL_UTIL_PIE_RAM_INT);
}
//
// Restore the interruptNumber in PIE RAM redundant table.
//
STL_PIE_RAM_restoreVector(pieEntry);
//
// Restore the PIEVERRADDR.
//
STL_PIE_RAM_configHandler((void *)prevHandler);
//
// Acknowledge the PIE group. This must occur or else the PIE group
// will not be able to service further interrupts.
//
//
// This can also be accomplished in the error handler by looking at the
// PIECTRL register and determining which group the PIE RAM mismatch
// occurred for during a vector fetch.
//
Interrupt_clearACKGroup(groupMask);
return(testStatus);
}
//
// End of File
//
@@ -0,0 +1,95 @@
//###########################################################################
//
// FILE: stl_util.c
//
// TITLE: Diagnostic Library Utility software module source
//
//###########################################################################
// $TI Release: C2000 Diagnostic Library v5.00.01 $
// $Release Date: Tue Oct 29 00:57:20 IST 2024 $
// $Copyright:
// Copyright (C) 2024 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.
// $
//###########################################################################
//
// Includes
//
#include "stl_util.h"
//
// Globals
//
#pragma DATA_ALIGN (STL_Util_globalErrorFlags, 4);
static volatile uint32_t STL_Util_globalErrorFlags = 0UL;
//*****************************************************************************
//
// STL_Util_setErrorFlag(const uint32_t errorFlag)
//
//*****************************************************************************
void STL_Util_setErrorFlag(const STL_Util_ErrorFlag errorFlag)
{
//
// Set the global flag associated with errorFlag
//
STL_Util_globalErrorFlags |= (uint32_t)errorFlag;
}
//*****************************************************************************
//
// STL_Util_getErrorFlag(void)
//
//*****************************************************************************
uint32_t STL_Util_getErrorFlag(void)
{
//
// Return the global flag status
//
return((uint32_t)STL_Util_globalErrorFlags);
}
//*****************************************************************************
//
// STL_Util_clearErrorFlag(const uint32_t errorFlag)
//
//*****************************************************************************
void STL_Util_clearErrorFlag(const STL_Util_ErrorFlag errorFlag)
{
//
// Clear the global flag associated with errorFlag
//
STL_Util_globalErrorFlags &= ~(uint32_t)errorFlag;
}
//
// End of File
//