Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="spi_ex1_loopback"
|
||||
device="TMS320F28377D"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xD"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<file action="copy" path="../spi_ex1_loopback.c" targetDirectory="" />
|
||||
<file action="copy" path="../spi_ex1_loopback.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="spi_ex2_loopback_fifo_interrupts"
|
||||
device="TMS320F28377D"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xD"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=_FLASH --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../spi_ex2_loopback_fifo_interrupts.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="spi_ex3_external_loopback_fifo_interrupts"
|
||||
device="TMS320F28377D"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xD"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=_FLASH --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../spi_ex3_external_loopback_fifo_interrupts.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="spi_ex4_spifsi_full_duplex"
|
||||
device="TMS320F28377D"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xD"
|
||||
>
|
||||
<configuration name="CPU1_RAM_VCU_CRC" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${PROJECT_ROOT}/spifsi -I${PROJECT_ROOT}/c2000 -I${PROJECT_ROOT}/vcu_crc -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu0 --define=DEBUG --define=VCU_CRC --define=_STDBOOL --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_RAM_NON_VCU_CRC" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${PROJECT_ROOT}/spifsi -I${PROJECT_ROOT}/c2000 -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM_VCU_CRC,CPU1_RAM_NON_VCU_CRC" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/spifsi/spifsi.h" targetDirectory="spifsi" />
|
||||
<file action="copy" path="../../../../../../utilities/spifsi/spifsi.c" targetDirectory="spifsi" />
|
||||
<file action="copy" path="../../../../../../utilities/spifsi/spifsi_map.h" targetDirectory="spifsi" />
|
||||
<file action="copy" path="../../../../../../utilities/spifsi/c2000/spifsi_spi.h" targetDirectory="c2000" />
|
||||
<file action="copy" path="../../../../../../utilities/spifsi/c2000/spifsi_spi.c" targetDirectory="c2000" />
|
||||
<file action="copy" path="../../../../../../libraries/dsp/VCU/c28/include/vcu0/vcu0_crc.h" targetDirectory="vcu_crc" />
|
||||
<file action="copy" path="../../../../../../libraries/dsp/VCU/c28/include/vcu0/vcu0_fft.h" targetDirectory="vcu_crc" />
|
||||
<file action="copy" path="../../../../../../libraries/dsp/VCU/c28/include/vcu0/vcu0_types.h" targetDirectory="vcu_crc" />
|
||||
<file action="copy" path="../../../../../../libraries/dsp/VCU/c28/include/vcu0/vcu0_viterbi_decoder.h" targetDirectory="vcu_crc" />
|
||||
<file action="copy" path="../vcu0_crc_8.asm" targetDirectory="vcu_crc" />
|
||||
<file action="copy" path="../spi_ex4_spifsi_full_duplex.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,136 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: spi_ex1_loopback.c
|
||||
//
|
||||
// TITLE: SPI Digital Loopback
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>SPI Digital Loopback</h1>
|
||||
//!
|
||||
//! This program uses the internal loopback test mode of the SPI module. This
|
||||
//! is a very basic loopback that does not use the FIFOs or interrupts. A
|
||||
//! stream of data is sent and then compared to the received stream.
|
||||
//! The pinmux and SPI modules are configure through the sysconfig file.
|
||||
//!
|
||||
//! The sent data looks like this: \n
|
||||
//! 0000 0001 0002 0003 0004 0005 0006 0007 .... FFFE FFFF 0000
|
||||
//!
|
||||
//! This pattern is repeated forever.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b sData - Data to send
|
||||
//! - \b rData - Received data
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2013-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.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t sData = 0; // Send data
|
||||
uint16_t rData = 0; // Receive data
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop forever. Suspend or place breakpoints to observe the buffers.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
// Transmit data
|
||||
SPI_writeDataNonBlocking(mySPI0_BASE, sData);
|
||||
|
||||
// Block until data is received and then return it
|
||||
rData = SPI_readDataBlockingNonFIFO(mySPI0_BASE);
|
||||
|
||||
// Check received data against sent data
|
||||
if(rData != sData)
|
||||
{
|
||||
// Something went wrong. rData doesn't contain expected data.
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
sData++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End File
|
||||
//
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const spi = scripting.addModule("/driverlib/spi.js", {}, false);
|
||||
const spi1 = spi.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
spi1.$name = "mySPI0";
|
||||
spi1.mode = "SPI_MODE_MASTER";
|
||||
spi1.emulationMode = "SPI_EMULATION_STOP_AFTER_TRANSMIT";
|
||||
spi1.bitRate = 1000000;
|
||||
spi1.useInterrupts = false;
|
||||
spi1.useFifo = false;
|
||||
spi1.loopback = true;
|
||||
spi1.spi.$name = "MySPI1";
|
||||
spi1.spi.$assign = "SPIA";
|
||||
@@ -0,0 +1,260 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: spi_ex2_loopback_fifo_interrupt.c
|
||||
//
|
||||
// TITLE: SPI Digital Loopback with FIFO Interrupts
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>SPI Digital Loopback with FIFO Interrupts</h1>
|
||||
//!
|
||||
//! This program uses the internal loopback test mode of the SPI module. Both
|
||||
//! the SPI FIFOs and their interrupts are used.
|
||||
//!
|
||||
//! A stream of data is sent and then compared to the received stream.
|
||||
//! The sent data looks like this: \n
|
||||
//! 0000 0001 \n
|
||||
//! 0001 0002 \n
|
||||
//! 0002 0003 \n
|
||||
//! .... \n
|
||||
//! FFFE FFFF \n
|
||||
//! FFFF 0000 \n
|
||||
//! etc.. \n
|
||||
//! This pattern is repeated forever.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b sData - Data to send
|
||||
//! - \b rData - Received data
|
||||
//! - \b rDataPoint - Used to keep track of the last position in the receive
|
||||
//! stream for error checking
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2013-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.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t sData[2]; // Send data buffer
|
||||
uint16_t rData[2]; // Receive data buffer
|
||||
uint16_t rDataPoint = 0; // To keep track of where we are in the
|
||||
// data stream to check received data
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initSPIFIFO(void);
|
||||
__interrupt void spiTxFIFOISR(void);
|
||||
__interrupt void spiRxFIFOISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file.
|
||||
//
|
||||
Interrupt_register(INT_SPIA_TX, &spiTxFIFOISR);
|
||||
Interrupt_register(INT_SPIA_RX, &spiRxFIFOISR);
|
||||
|
||||
//
|
||||
// Set up SPI, initializing it for FIFO mode
|
||||
//
|
||||
initSPIFIFO();
|
||||
|
||||
//
|
||||
// Initialize the data buffers
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
sData[i] = i;
|
||||
rData[i]= 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
Interrupt_enable(INT_SPIA_TX);
|
||||
Interrupt_enable(INT_SPIA_RX);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop forever. Suspend or place breakpoints to observe the buffers.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure SPI A in FIFO mode.
|
||||
//
|
||||
void initSPIFIFO()
|
||||
{
|
||||
//
|
||||
// Must put SPI into reset before configuring it
|
||||
//
|
||||
SPI_disableModule(SPIA_BASE);
|
||||
|
||||
//
|
||||
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
|
||||
//
|
||||
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
|
||||
SPI_MODE_MASTER, 500000, 16);
|
||||
SPI_enableLoopback(SPIA_BASE);
|
||||
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_STOP_AFTER_TRANSMIT);
|
||||
|
||||
//
|
||||
// FIFO and interrupt configuration
|
||||
//
|
||||
SPI_enableFIFO(SPIA_BASE);
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF | SPI_INT_TXFF);
|
||||
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
|
||||
SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF | SPI_INT_TXFF);
|
||||
|
||||
//
|
||||
// Configuration complete. Enable the module.
|
||||
//
|
||||
SPI_enableModule(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// SPI A Transmit FIFO ISR
|
||||
//
|
||||
__interrupt void spiTxFIFOISR(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Send data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
SPI_writeDataNonBlocking(SPIA_BASE, sData[i]);
|
||||
}
|
||||
|
||||
//
|
||||
// Increment data for next cycle
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
sData[i] = sData[i] + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear interrupt flag and issue ACK
|
||||
//
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_TXFF);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
|
||||
}
|
||||
|
||||
//
|
||||
// SPI A Receive FIFO ISR
|
||||
//
|
||||
__interrupt void spiRxFIFOISR(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Read data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
rData[i] = SPI_readDataNonBlocking(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// Check received data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
if(rData[i] != (rDataPoint + i))
|
||||
{
|
||||
// Something went wrong. rData doesn't contain expected data.
|
||||
Example_Fail = 1;
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
rDataPoint++;
|
||||
|
||||
//
|
||||
// Clear interrupt flag and issue ACK
|
||||
//
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
|
||||
|
||||
Example_PassCount++;
|
||||
}
|
||||
+393
@@ -0,0 +1,393 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: spi_ex3_external_loopback_fifo_interrupt.c
|
||||
//
|
||||
// TITLE: SPI Digital Loopback with FIFO Interrupts
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>SPI Digital External Loopback with FIFO Interrupts</h1>
|
||||
//!
|
||||
//! This program uses the external loopback between two SPI modules. Both
|
||||
//! the SPI FIFOs and their interrupts are used. SPIA is configured as a slave
|
||||
//! and receives data from SPI B which is configured as a master.
|
||||
//!
|
||||
//! A stream of data is sent and then compared to the received stream.
|
||||
//! The sent data looks like this: \n
|
||||
//! 0000 0001 \n
|
||||
//! 0001 0002 \n
|
||||
//! 0002 0003 \n
|
||||
//! .... \n
|
||||
//! FFFE FFFF \n
|
||||
//! FFFF 0000 \n
|
||||
//! etc.. \n
|
||||
//! This pattern is repeated forever.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! -GPIO25 and GPIO17 - SPISOMI
|
||||
//! -GPIO24 and GPIO16 - SPISIMO
|
||||
//! -GPIO27 and GPIO19 - SPISTE
|
||||
//! -GPIO26 and GPIO18 - SPICLK
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b sData - Data to send
|
||||
//! - \b rData - Received data
|
||||
//! - \b rDataPoint - Used to keep track of the last position in the receive
|
||||
//! stream for error checking
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2013-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.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile uint16_t sData[2]; // Send data buffer
|
||||
volatile uint16_t rData[2]; // Receive data buffer
|
||||
volatile uint16_t rDataPoint = 0; // To keep track of where we are in the
|
||||
// data stream to check received data
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initSPIBMaster(void);
|
||||
void initSPIASlave(void);
|
||||
void configGPIOs(void);
|
||||
__interrupt void spibTxFIFOISR(void);
|
||||
__interrupt void spiaRxFIFOISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file.
|
||||
//
|
||||
Interrupt_register(INT_SPIB_TX, &spibTxFIFOISR);
|
||||
Interrupt_register(INT_SPIA_RX, &spiaRxFIFOISR);
|
||||
|
||||
//
|
||||
// Configure GPIOs for external loopback.
|
||||
//
|
||||
configGPIOs();
|
||||
|
||||
//
|
||||
// Set up SPI B as master, initializing it for FIFO mode
|
||||
//
|
||||
initSPIBMaster();
|
||||
|
||||
//
|
||||
// Set up SPI A as slave, initializing it for FIFO mode
|
||||
//
|
||||
initSPIASlave();
|
||||
|
||||
//
|
||||
// Initialize the data buffers
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
sData[i] = i;
|
||||
rData[i]= 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
Interrupt_enable(INT_SPIA_RX);
|
||||
Interrupt_enable(INT_SPIB_TX);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop forever. Suspend or place breakpoints to observe the buffers.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure SPI B as master with FIFO enabled.
|
||||
//
|
||||
void initSPIBMaster(void)
|
||||
{
|
||||
//
|
||||
// Must put SPI into reset before configuring it
|
||||
//
|
||||
SPI_disableModule(SPIB_BASE);
|
||||
|
||||
//
|
||||
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
|
||||
//
|
||||
SPI_setConfig(SPIB_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
|
||||
SPI_MODE_MASTER, 500000, 16);
|
||||
SPI_disableLoopback(SPIB_BASE);
|
||||
SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// FIFO and interrupt configuration
|
||||
//
|
||||
SPI_enableFIFO(SPIB_BASE);
|
||||
SPI_clearInterruptStatus(SPIB_BASE, SPI_INT_TXFF);
|
||||
SPI_setFIFOInterruptLevel(SPIB_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
|
||||
SPI_enableInterrupt(SPIB_BASE, SPI_INT_TXFF);
|
||||
|
||||
//
|
||||
// Configuration complete. Enable the module.
|
||||
//
|
||||
SPI_enableModule(SPIB_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure SPI A as slave with FIFO enabled.
|
||||
//
|
||||
void initSPIASlave(void)
|
||||
{
|
||||
//
|
||||
// Must put SPI into reset before configuring it
|
||||
//
|
||||
SPI_disableModule(SPIA_BASE);
|
||||
|
||||
//
|
||||
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
|
||||
//
|
||||
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
|
||||
SPI_MODE_SLAVE, 500000, 16);
|
||||
SPI_disableLoopback(SPIA_BASE);
|
||||
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// FIFO and interrupt configuration
|
||||
//
|
||||
SPI_enableFIFO(SPIA_BASE);
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
|
||||
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
|
||||
SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF);
|
||||
|
||||
//
|
||||
// Configuration complete. Enable the module.
|
||||
//
|
||||
SPI_enableModule(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure GPIOs for external loopback.
|
||||
//
|
||||
void configGPIOs(void)
|
||||
{
|
||||
//
|
||||
// This test is designed for an external loopback between SPIA
|
||||
// and SPIB.
|
||||
// External Connections:
|
||||
// -GPIO25 and GPIO17 - SPISOMI
|
||||
// -GPIO24 and GPIO16 - SPISIMO
|
||||
// -GPIO27 and GPIO19 - SPISTE
|
||||
// -GPIO26 and GPIO18 - SPICLK
|
||||
//
|
||||
|
||||
//
|
||||
// GPIO17 is the SPISOMIA.
|
||||
//
|
||||
GPIO_setMasterCore(17, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_17_SPISOMIA);
|
||||
GPIO_setPadConfig(17, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(17, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO16 is the SPISIMOA clock pin.
|
||||
//
|
||||
GPIO_setMasterCore(16, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_16_SPISIMOA);
|
||||
GPIO_setPadConfig(16, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(16, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO19 is the SPISTEA.
|
||||
//
|
||||
GPIO_setMasterCore(19, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_19_SPISTEA);
|
||||
GPIO_setPadConfig(19, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(19, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO18 is the SPICLKA.
|
||||
//
|
||||
GPIO_setMasterCore(18, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_18_SPICLKA);
|
||||
GPIO_setPadConfig(18, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(18, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO25 is the SPISOMIB.
|
||||
//
|
||||
GPIO_setMasterCore(25, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_25_SPISOMIB);
|
||||
GPIO_setPadConfig(25, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(25, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO24 is the SPISIMOB clock pin.
|
||||
//
|
||||
GPIO_setMasterCore(24, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_24_SPISIMOB);
|
||||
GPIO_setPadConfig(24, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(24, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO27 is the SPISTEB.
|
||||
//
|
||||
GPIO_setMasterCore(27, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_27_SPISTEB);
|
||||
GPIO_setPadConfig(27, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(27, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO26 is the SPICLKB.
|
||||
//
|
||||
GPIO_setMasterCore(26, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_26_SPICLKB);
|
||||
GPIO_setPadConfig(26, GPIO_PIN_TYPE_PULLUP);
|
||||
GPIO_setQualificationMode(26, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
//
|
||||
// SPI A Transmit FIFO ISR
|
||||
//
|
||||
__interrupt void spibTxFIFOISR(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Send data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
SPI_writeDataNonBlocking(SPIB_BASE, sData[i]);
|
||||
}
|
||||
|
||||
//
|
||||
// Increment data for next cycle
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
sData[i] = sData[i] + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear interrupt flag and issue ACK
|
||||
//
|
||||
SPI_clearInterruptStatus(SPIB_BASE, SPI_INT_TXFF);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
|
||||
}
|
||||
|
||||
//
|
||||
// SPI B Receive FIFO ISR
|
||||
//
|
||||
__interrupt void spiaRxFIFOISR(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Read data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
rData[i] = SPI_readDataNonBlocking(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// Check received data
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
if(rData[i] != (rDataPoint + i))
|
||||
{
|
||||
// Something went wrong. rData doesn't contain expected data.
|
||||
Example_Fail = 1;
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
rDataPoint++;
|
||||
|
||||
//
|
||||
// Clear interrupt flag and issue ACK
|
||||
//
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
|
||||
|
||||
Example_PassCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,577 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: spi_ex4_spifsi_full_duplex.c
|
||||
//
|
||||
// TITLE: FSI and SPI communication full-duplex.
|
||||
//
|
||||
//! \addtogroup spifsi_communication
|
||||
//! <h1>FSI and SPI communication full-duplex</h1>
|
||||
//!
|
||||
//! FSI supports SPI compatibility mode to talk to the devices not having FSI
|
||||
//! but SPI module.
|
||||
//! API to decode FSI frame received at SPI end is implemented and checks are
|
||||
//! made to ensure received details(frame tag/type, userdata, data) match with
|
||||
//! transfered frame.
|
||||
//!
|
||||
//! This program is the SPI part of SPI-to-FSI communication. It first
|
||||
//! enables SPI module as a slave, driven by FSI TX, and sends flush sequence to
|
||||
//! FSI when it receives Ping frame with tag 0. After flush sequence, SPI waits
|
||||
//! for frames from FSI. When it receives first of duplicate frames, it enables
|
||||
//! TALK bit of SPI_CTL register, decodes and encodes the frame, then stages the
|
||||
//! echo-back frame. It also assumes that when frame is N_WORD_DATA_FRAME, number
|
||||
//! of data words will be incremental by one. Then when it receives the second
|
||||
//! part of duplicate frames, it waits for TX FIFO to be emptied out or staged
|
||||
//! frames to be sent to FSI RX before disabling TALK bit of SPI_CTL register for
|
||||
//! next staging.
|
||||
//!
|
||||
//! SPI-side also profiles SPIFSI_read/writeFrame() by how many cpu-cycle each
|
||||
//! API call takes.
|
||||
//!
|
||||
//! To enable full functional duplex of SPI-to-FSI, you must load
|
||||
//! fsi_ex11_spifsi_full_duplex to f28004x device and spi_ex4_spifsi_full_duplex
|
||||
//! to any device that has SPI module. You must run SPI-side before FSI-side.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any of error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! Number in parenthesis indicates a pin number on docking station.
|
||||
//! f28004x_FSITX f2837x_SPIA f28004x_FSIRX
|
||||
//! -TXCLK, GPIO7(56) -> SPICLK, GPIO18(71)
|
||||
//! -TXD0, GPIO6(54) -> SPISIMO, GPIO16(67)
|
||||
//! -TXD1, GPIO5(52) -> ~SPISTE, GPIO19(73)
|
||||
//! -SPISOMI, GPIO17(69) -> RXD0, GPIO12(57)
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b spiRxCntr Number of Data frames received.
|
||||
//! - \b spiTxCntr Number of Data frames transmitted.
|
||||
//! - \b error Non zero for error reading/writing from SPI FIFO.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// $Release Date: $
|
||||
// $Copyright:
|
||||
// Copyright (C) 2013-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.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "cputimer.h"
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "spifsi.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initialize(void);
|
||||
void configureSPI(SPI_Mode spiMode);
|
||||
void configureGPIOs(void);
|
||||
void toggleOrOnLED(uint16_t ledType, uint16_t toggle);
|
||||
void turnOffLEDs(void);
|
||||
void turnOnLEDs(void);
|
||||
void sendFlushSeq(void);
|
||||
void disableTalk(void);
|
||||
void enableTalk(void);
|
||||
void configProfiler(uint32_t base);
|
||||
void startProfiler(uint32_t base);
|
||||
uint32_t stopProfiler(uint32_t base);
|
||||
__interrupt void spiRxFIFOISR(void);
|
||||
|
||||
//
|
||||
// Defines.
|
||||
//
|
||||
#define SPIFSI_CLK_SPEED 12500000U
|
||||
#define ON 0x0000U
|
||||
#define TOGGLE 0x0001U
|
||||
|
||||
//
|
||||
// Interrupt flag.
|
||||
//
|
||||
volatile uint32_t spiRxIntReceived = 0;
|
||||
|
||||
//
|
||||
// Globals.
|
||||
//
|
||||
SPIFSI_FrameInfo spiFrameInfo;
|
||||
SPIFSI_Error spifsiErrorStatus = SPIFSI_NO_ERROR;
|
||||
uint32_t error = 0;
|
||||
uint16_t spiRxCntr = 0;
|
||||
uint16_t spiTxCntr = 0;
|
||||
|
||||
//
|
||||
// Profile result arrays. Each holds number of cpu-cycle each frame took.
|
||||
// Ping -> 0 (index), 1_WORD -> 1, 2_WORD -> 2, N_WORD with 3 words -> 3,
|
||||
// 4_WORD -> 4, N_WORD with 5 words -> 5, 6_WORD -> 6, N_WORD with 7 words
|
||||
// -> 7, and so on.
|
||||
//
|
||||
uint32_t decodeProfile[17] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
uint32_t encodeProfile[17] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
uint16_t profileIndex = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Main
|
||||
//
|
||||
//*****************************************************************************
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize.
|
||||
//
|
||||
initialize();
|
||||
|
||||
//
|
||||
// Initialize spiFrameInfo.
|
||||
//
|
||||
uint16_t data[16] = {3};
|
||||
spiFrameInfo.data = data;
|
||||
|
||||
//
|
||||
// Stage flush.
|
||||
//
|
||||
sendFlushSeq();
|
||||
turnOffLEDs();
|
||||
|
||||
//
|
||||
// Infinite Loop.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// sendFlushSeq - pushes 0xFFFF to SPI TX FIFO.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void sendFlushSeq(void)
|
||||
{
|
||||
//
|
||||
// push the flush sequence.
|
||||
//
|
||||
uint16_t flushSeq = 0xFFFF;
|
||||
SPI_write16Bits(SPIA_BASE, &flushSeq);
|
||||
|
||||
spiTxCntr++;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Initialization module.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void initialize(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
//
|
||||
Interrupt_register(INT_SPIA_RX, &spiRxFIFOISR);
|
||||
|
||||
//
|
||||
// Configure GPIOs for SPIA_SLAVE from FSI in SPI-MODE.
|
||||
//
|
||||
configureGPIOs();
|
||||
|
||||
//
|
||||
// Configure SPI module for Rx operation
|
||||
//
|
||||
configureSPI(SPI_MODE_SLAVE);
|
||||
|
||||
//
|
||||
// Enable SPIA_RX interrupt.
|
||||
//
|
||||
Interrupt_enable(INT_SPIA_RX);
|
||||
|
||||
//
|
||||
// Init profilers.
|
||||
//
|
||||
configProfiler(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Turn off LEDs.
|
||||
//
|
||||
turnOnLEDs();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and real-time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// configureSPI - configuration of SPIA to spiMode.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void configureSPI(SPI_Mode spiMode)
|
||||
{
|
||||
//
|
||||
// Must put SPI into reset before configuring it
|
||||
//
|
||||
SPI_disableModule(SPIA_BASE);
|
||||
|
||||
//
|
||||
// SPI configuration.
|
||||
//
|
||||
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
|
||||
spiMode, SPIFSI_CLK_SPEED, 16);
|
||||
SPI_disableLoopback(SPIA_BASE);
|
||||
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// FIFO and interrupt configuration
|
||||
//
|
||||
SPI_enableFIFO(SPIA_BASE);
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
|
||||
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX1, SPI_FIFO_RX1);
|
||||
SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF);
|
||||
SPI_disableInterrupt(SPIA_BASE, SPI_INT_TXFF);
|
||||
|
||||
//
|
||||
// Configuration complete. Enable the module.
|
||||
//
|
||||
SPI_enableModule(SPIA_BASE);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// configureGPIOs - configure GPIOs for SPIA_SLAVE connected to FSI full duplex.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void configureGPIOs(void)
|
||||
{
|
||||
//
|
||||
// GPIO18 is the SPICLKA driven by FSITX_CLK.
|
||||
//
|
||||
GPIO_setMasterCore(18, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_18_SPICLKA);
|
||||
GPIO_setQualificationMode(18, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO16 is the SPISIMOA receiving TXD0.
|
||||
//
|
||||
GPIO_setMasterCore(16, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_16_SPISIMOA);
|
||||
GPIO_setQualificationMode(16, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO19 is the SPISTEA receiving TXD1.
|
||||
//
|
||||
GPIO_setMasterCore(19, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_19_SPISTEA);
|
||||
GPIO_setQualificationMode(19, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO17 is the SPISOMIA writing to RXD0.
|
||||
//
|
||||
GPIO_setMasterCore(17, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_17_SPISOMIA);
|
||||
|
||||
//
|
||||
// LED GPIO. Not sure if this will work for LaunchPad.
|
||||
//
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// spiRxFIFOISR - Interrupt Line triggered when SPIA_RX_FIFO level reaches 1.
|
||||
//
|
||||
//*****************************************************************************
|
||||
__interrupt void spiRxFIFOISR(void)
|
||||
{
|
||||
//
|
||||
// Number of received frame.
|
||||
//
|
||||
spiRxCntr++;
|
||||
|
||||
//
|
||||
// Incremental nLength when N_WORD_DATA_FRAME.
|
||||
//
|
||||
spiFrameInfo.nLength = profileIndex;
|
||||
|
||||
//
|
||||
// Disable talk in priming frame, then stage in actual frame.
|
||||
//
|
||||
if((spiRxCntr % 2U) == 1U)
|
||||
{
|
||||
//
|
||||
// Wait for FSI-SPI communication to finish.
|
||||
//
|
||||
DEVICE_DELAY_US(1000);
|
||||
disableTalk();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Profile cpu-cycle of software-defined decode.
|
||||
//
|
||||
startProfiler(CPUTIMER0_BASE);
|
||||
spifsiErrorStatus = SPIFSI_readFrame(SPIA_BASE, &spiFrameInfo);
|
||||
decodeProfile[profileIndex] = stopProfiler(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Enable transfer of staged frame in next transmission.
|
||||
//
|
||||
enableTalk();
|
||||
|
||||
//
|
||||
// Profile cpu-cycle of software-defined encode.
|
||||
//
|
||||
startProfiler(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Stage for next frame.
|
||||
//
|
||||
spifsiErrorStatus = SPIFSI_writeFrame(SPIA_BASE, &spiFrameInfo);
|
||||
encodeProfile[profileIndex] = stopProfiler(CPUTIMER0_BASE);
|
||||
profileIndex++;
|
||||
spiTxCntr++;
|
||||
|
||||
|
||||
if(spifsiErrorStatus)
|
||||
{
|
||||
error++;
|
||||
|
||||
//
|
||||
// LED2 goes high if error.
|
||||
//
|
||||
toggleOrOnLED(DEVICE_GPIO_PIN_LED2, ON);
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Reset RX FIFO.
|
||||
//
|
||||
SPI_resetRxFIFO(SPIA_BASE);
|
||||
|
||||
toggleOrOnLED(DEVICE_GPIO_PIN_LED1, TOGGLE);
|
||||
|
||||
spiRxIntReceived = 1U;
|
||||
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// toggleOrOnLED - toggles or turns on one of two LEDs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void toggleOrOnLED(uint16_t ledType, uint16_t toggle) {
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(ledType, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
if(toggle)
|
||||
{
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(ledType, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// turnOffLEDs - turns off both LEDs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void turnOffLEDs(void)
|
||||
{
|
||||
//
|
||||
// Turn off both leds
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// turnOnLEDs - turns on both LEDs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void turnOnLEDs(void)
|
||||
{
|
||||
//
|
||||
// Turn on both leds
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// disableTalk - disables SPI_CTL_TALK bit.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void disableTalk(void)
|
||||
{
|
||||
HWREGH(SPIA_BASE + SPI_O_CTL) = HWREGH(SPIA_BASE + SPI_O_CTL) & ~SPI_CTL_TALK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// enableTalk - enables SPI_CTL_TALK bit.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void enableTalk(void)
|
||||
{
|
||||
HWREGH(SPIA_BASE + SPI_O_CTL) = HWREGH(SPIA_BASE + SPI_O_CTL) | SPI_CTL_TALK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// configProfiler - configures the CPUTimer specified by the parameter base for
|
||||
// profiling cycle counts. base is the base address of a valid CPUTimer.
|
||||
//
|
||||
//
|
||||
//*****************************************************************************
|
||||
void configProfiler(uint32_t base)
|
||||
{
|
||||
//
|
||||
// Clear overflow flag.
|
||||
//
|
||||
CPUTimer_clearOverflowFlag(base);
|
||||
|
||||
//
|
||||
// Initialize timer period.
|
||||
//
|
||||
CPUTimer_setPeriod(base, 0xFFFFFFFFU);
|
||||
|
||||
//
|
||||
// Initialize pre-scaler.
|
||||
//
|
||||
CPUTimer_setPreScaler(base, 0U);
|
||||
|
||||
//
|
||||
// Reload timer counter.
|
||||
//
|
||||
CPUTimer_reloadTimerCounter(base);
|
||||
|
||||
//
|
||||
// Set the timer to stop after next decrement on emulation halt.
|
||||
//
|
||||
CPUTimer_setEmulationMode(base, CPUTIMER_EMULATIONMODE_RUNFREE);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// startProfiler - starts the CPUTimer used for profiling cycles.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void startProfiler(uint32_t base)
|
||||
{
|
||||
//
|
||||
// Set TSS bit of register TCR
|
||||
//
|
||||
HWREGH(base + CPUTIMER_O_TCR) |= CPUTIMER_TCR_TSS;
|
||||
|
||||
//
|
||||
// Reload the timer counter.
|
||||
//
|
||||
HWREGH(base + CPUTIMER_O_TCR) |= CPUTIMER_TCR_TRB;
|
||||
|
||||
//
|
||||
// Clear TSS bit of register TCR
|
||||
//
|
||||
HWREGH(base + CPUTIMER_O_TCR) &= ~CPUTIMER_TCR_TSS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// stopProfiler - stops the CPUTimer used for profiling cycles.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t stopProfiler(uint32_t base)
|
||||
{
|
||||
//
|
||||
// Set TSS bit of register TCR
|
||||
//
|
||||
HWREGH(base + CPUTIMER_O_TCR) |= CPUTIMER_TCR_TSS;
|
||||
|
||||
//
|
||||
// Return the cycle count
|
||||
//
|
||||
return(0xFFFFFFFFU - HWREG(base + CPUTIMER_O_TIM));
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,137 @@
|
||||
;;*****************************************************************************
|
||||
;;! \file source/vcu0/vcu0_crc_8.asm
|
||||
;;!
|
||||
;;! \brief 8-bit CRC that uses the polynomial 0x07
|
||||
;;
|
||||
;; \date Apr 7, 2011
|
||||
;;!
|
||||
;;
|
||||
;; Group: C2000
|
||||
;; Target Family: F2837x
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;
|
||||
;; $Release Date: $
|
||||
;; $Copyright:
|
||||
;// Copyright (C) 2013-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
|
||||
;;*****************************************************************************
|
||||
;;
|
||||
;;*****************************************************************************
|
||||
;; global defines
|
||||
;;*****************************************************************************
|
||||
;; CRC Routine defines
|
||||
|
||||
;
|
||||
;/*! ASM- function to get the 8-bit CRC
|
||||
; *
|
||||
; * \param ACC = The initial value of crc, in case the message has been
|
||||
; * chopped into several parts, you can use the crc8 of the previous
|
||||
; * segment as the init value for the current segment crc8 calculation
|
||||
; * until the final crc is derived.
|
||||
; * \param *+XAR4 = Address of the message buffer
|
||||
; * \param AR5 = Parity of the first message byte, i.e. whether its on an even
|
||||
; * or odd address
|
||||
; * \param *-SP[1]/AR0 = Length of the message in bytes
|
||||
; *
|
||||
; * Calculate the 8-bit CRC of a message buffer by using the VCU instructions,
|
||||
; * VCRC8L_1 and VCRC8H_1
|
||||
; *
|
||||
; * \return CRC result in AL
|
||||
; */
|
||||
|
||||
.if __TI_EABI__
|
||||
.asg getCRC8_vcu, _getCRC8_vcu
|
||||
.endif
|
||||
|
||||
.def _getCRC8_vcu
|
||||
|
||||
_getCRC8_vcu:
|
||||
PUSH XAR0
|
||||
PUSH XAR1
|
||||
MOVZ AR0, *-SP[7] ; load rxLen
|
||||
ADDB SP, #4 ; allocate 4 words for local
|
||||
VMOV32 *-SP[2], VCRC ; Store current CRC
|
||||
VCRCCLR
|
||||
MOV *-SP[4], ACC
|
||||
VMOV32 VCRC,*-SP[4] ; VCRC = Inital value
|
||||
MOV AL, AR5 ; check the parity
|
||||
SBF _CRC8_loop_prep, EQ
|
||||
VCRC8H_1 *XAR4++ ; if parity=1, calculate high byte first
|
||||
DEC AR0
|
||||
SBF _CRC8done, EQ
|
||||
|
||||
_CRC8_loop_prep:
|
||||
MOV AL, AR0
|
||||
MOV AH, AR0
|
||||
AND AL, #0xFFF8 ; check to see if the length is greater than 8 bytes
|
||||
BF _CRC8_LSB,EQ
|
||||
LSR AL, #3 ; loop in 8 bytes
|
||||
MOV AR1, AL
|
||||
SUB AR1, #1
|
||||
|
||||
.align (2) ; align at 32-bit boundary to remove penalty
|
||||
RPTB _CRC8_post, AR1 ; loop for the middle part of the packet
|
||||
VCRC8L_1 *XAR4
|
||||
VCRC8H_1 *XAR4++
|
||||
VCRC8L_1 *XAR4
|
||||
VCRC8H_1 *XAR4++
|
||||
VCRC8L_1 *XAR4
|
||||
VCRC8H_1 *XAR4++
|
||||
VCRC8L_1 *XAR4
|
||||
VCRC8H_1 *XAR4++
|
||||
_CRC8_post
|
||||
|
||||
LSL AL, #3 ; calculating remaining number of bytes
|
||||
SUB AH, AL
|
||||
SBF _CRC8done, EQ ; if multiple of 8, done
|
||||
MOV AR0, AH
|
||||
_CRC8_LSB
|
||||
VCRC8L_1 *XAR4 ; if parity=0, calculate the low byte
|
||||
DEC AR0
|
||||
SBF _CRC8done, EQ
|
||||
VCRC8H_1 *XAR4++
|
||||
DEC AR0
|
||||
SBF _CRC8_LSB, NEQ
|
||||
_CRC8done
|
||||
VMOV32 *-SP[4], VCRC ; Store CRC
|
||||
MOV AL, *-SP[4] ; return AL
|
||||
VMOV32 VCRC, *-SP[2] ; Restore VCRC
|
||||
SUBB SP, #4 ; restore stack pointer
|
||||
POP XAR1
|
||||
POP XAR0
|
||||
LRETR
|
||||
|
||||
;; End of file
|
||||
Reference in new issue
Block a user