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,34 @@
<projectSpec>
<project
name="baud_tune_via_uart"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
;if ${GUI_SUPPORT} == 1 &quot;${BuildDirectory}/syscfg/gui_setup.bat&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --define=generic_ram_lnk --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_ram_lnk" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} --define=_FLASH --define=generic_flash_lnk -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_flash_lnk" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<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" />
<buildVariable name="CLB_DEBUG" value="0" scope="project" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<buildVariable name="GUI_SUPPORT" value="0" scope="project" />
<file action="copy" path="../baud_tune_via_uart.c" targetDirectory="" />
<file action="copy" path="../baud_tune_via_uart.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,34 @@
<projectSpec>
<project
name="sci_ex1_loopback"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
;if ${GUI_SUPPORT} == 1 &quot;${BuildDirectory}/syscfg/gui_setup.bat&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --define=generic_ram_lnk --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_ram_lnk" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} --define=_FLASH --define=generic_flash_lnk -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_flash_lnk" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<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" />
<buildVariable name="CLB_DEBUG" value="0" scope="project" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<buildVariable name="GUI_SUPPORT" value="0" scope="project" />##
<file action="copy" path="../sci_ex1_loopback.c" targetDirectory="" />
<file action="copy" path="../sci_ex1_loopback.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="sci_ex2_loopback_interrupts"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<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" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../sci_ex2_loopback_interrupts.c" targetDirectory="" />
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="sci_ex3_echoback"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<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" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../sci_ex3_echoback.c" targetDirectory="" />
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,42 @@
<projectSpec>
<project
name="sci_ex4_stdout_redirect"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<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" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../sci_ex4_stdout_redirect.c" targetDirectory="" />
<file action="copy" path="../uart_drv.c" targetDirectory="" />
<file action="copy" path="../uart_drv.h" targetDirectory="" />
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,523 @@
//#############################################################################
//
// FILE: baud_tune_via_uart.c
//
// TITLE: Tune Baud Rate Via UART.
//
//! \addtogroup driver_example_list
//! <h1>Tune Baud Rate via UART Example</h1>
//!
//! This example demonstrates the process of tuning the UART/SCI baud rate of
//! a C2000 device based on the UART input from another device. As UART does
//! not have a clock signal, reliable communication requires baud rates to
//! be reasonably matched. This example addresses cases where a clock
//! mismatch between devices is greater than is acceptable for communications,
//! requiring baud compensation between boards. As reliable communication
//! only requires matching the EFFECTIVE baud rate, it does not matter which
//! of the two boards executes the tuning (the board with the less-accurate
//! clock source does not need to be the one to tune; as long as one of the
//! two devices tunes to the other, then proper communication can
//! be established).
//!
//! To tune the baud rate of this device, SCI data (of the desired baud rate)
//! must be sent to this device. The input SCI baud rate must be within the
//! +/- MARGINPERCENT of the TARGETBAUD chosen below. These two variables are
//! defined below, and should be chosen based on the application requirements.
//! Higher MARGINPERCENT will allow more data to be considered "correct" in
//! noisy conditions, and may decrease accuracy. The TARGETBAUD is what was
//! expected to be the baud rate, but due to clock differences, needs to be
//! tuned for better communication robustness with the other device.
//!
//! NOTE: Lower baud rates have more granularity in register options,
//! and therefore tuning is more affective at these speeds.
//!
//! \note This example project has support for migration across our C2000
//! device families. If you are wanting to build this project from launchpad
//! or controlCARD, please specify in the .syscfg file the board you're using.
//! At any time you can select another device to migrate this example.
//!
//! \b External \b Connections for Control Card \n
//! - SCIA_RX/eCAP1 is on GPIO9, connect to incoming SCI communications
//! - SCIA_TX is on GPIO8, for observation externally
//!
//! \b Watch \b Variables \n
//! - \b avgBaud - Baud rate that was detected and set after tuning
//
//#############################################################################
// $Copyright:
// Copyright (C) 2021 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"
//
// Defines
//
// must replace with the GPIO number of the SCIRX pin chosen in .syscfg
#define GPIO_SCIRX_NUMBER 9
//
// choose baud rate being received from target baud rate device
// closest baud rate to 9600 that can be set in register is 9601
//
#define TARGETBAUD 9601
//
// number of samples in the array (higher = better averaging, lower = faster)
//
#define NUMSAMPLES 32
//
// margin for what is considered a "good" pulse width:
// set this higher to allow more samples to be considered "good" data,
// if losing too much data set this lower to prevent "bad" samples to
// be discarded more strictly
//
#define MARGINPERCENT 0.05
//
// at least this percentage of the samples array must be "good"
// to not flag an error
//
#define MINSAMPLEPERCENT 0.50
//
// Globals
//
volatile uint32_t capCountArr[4];
volatile int capCountIter = 0;
volatile float sampleArr[NUMSAMPLES];
volatile uint16_t sampleArrIter = 0;
volatile uint16_t stopCaptures = 0;
//
// Function Prototypes
//
void initECAP(void);
__interrupt void ecap1ISR(void);
uint16_t arrTo1PulseWidth(volatile float arr[], int size, float targetWidth);
float computeAvgWidth(volatile float arr[], int size);
uint32_t getAverageBaud(volatile float arr[], int size, float targetBaudRate);
//
// Main
//
void main(void)
{
stopCaptures = 0;
//
// 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();
//
// Configure SCIRX pin's GPIO location as eCAP input
// Fill this GPIO number in based on SCIRX from .syscfg file
//
XBAR_setInputPin(INPUTXBAR_BASE, XBAR_INPUT7, GPIO_SCIRX_NUMBER);
//
// Interrupts that are used in this example are re-mapped to ISR functions
// found within this file.
//
Interrupt_register(INT_ECAP1, &ecap1ISR);
//
// Initialize basic settings for eCAP monitoring of SCI RX
//
initECAP();
//
// Enable interrupts required for this example
//
Interrupt_enable(INT_ECAP1);
//
// Enable Global Interrupt (INTM) and Real time interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop forever. Suspend or place breakpoints to observe the buffers.
//
for(;;)
{
//
// Array is filled, begin tuning
//
if(stopCaptures==1)
{
//
// Get an average baud rate from the array of samples
//
uint32_t avgBaud = getAverageBaud(sampleArr,NUMSAMPLES,TARGETBAUD);
//
// if the baud function returns the error code '0', then flag an
// error
//
if(avgBaud==0)
{
ESTOP0;
}
//
// Update the device's baud rate to match the measured baud rate
//
SCI_setBaud(mySCI0_BASE, DEVICE_LSPCLK_FREQ, avgBaud);
//
// Wait for user to view the results in "Expressions" window
//
ESTOP0;
//
// (OPTIONAL) Continuously send data to SCITX once tuning
// is complete for external observation (by logic analyzer or
// scope)
//
//unsigned char *msg;
//while(1)
//{
// msg = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\0";
// SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 51);
//}
//
// If continuing, reset the array iterator and unlock the ISR for
// new captures
//
sampleArrIter=0;
stopCaptures=0;
}
}
}
void initECAP()
{
//
// Disable ,clear all capture flags and interrupts
//
ECAP_disableInterrupt(ECAP1_BASE,
(ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_2 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_3 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_4 |
ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
ECAP_ISR_SOURCE_COUNTER_PERIOD |
ECAP_ISR_SOURCE_COUNTER_COMPARE));
ECAP_clearInterrupt(ECAP1_BASE,
(ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_2 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_3 |
ECAP_ISR_SOURCE_CAPTURE_EVENT_4 |
ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
ECAP_ISR_SOURCE_COUNTER_PERIOD |
ECAP_ISR_SOURCE_COUNTER_COMPARE));
//
// Disable CAP1-CAP4 register loads
//
ECAP_disableTimeStampCapture(ECAP1_BASE);
//
// Configure eCAP
// Enable capture mode.
// One shot mode, stop capture at event 4.
// Set polarity of the events to rising, falling, rising, falling edge.
// Set capture in time difference mode.
// Select input from XBAR7.
// Enable eCAP module.
// Enable interrupt.
//
ECAP_stopCounter(ECAP1_BASE);
ECAP_enableCaptureMode(ECAP1_BASE);
ECAP_setCaptureMode(ECAP1_BASE, ECAP_ONE_SHOT_CAPTURE_MODE, ECAP_EVENT_4);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_1, ECAP_EVNT_FALLING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_2, ECAP_EVNT_RISING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_3, ECAP_EVNT_FALLING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_4, ECAP_EVNT_RISING_EDGE);
ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_1);
ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_2);
ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_3);
ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_4);
ECAP_selectECAPInput(ECAP1_BASE, ECAP_INPUT_INPUTXBAR7);
ECAP_enableLoadCounter(ECAP1_BASE);
ECAP_setSyncOutMode(ECAP1_BASE, ECAP_SYNC_OUT_DISABLED);
ECAP_startCounter(ECAP1_BASE);
ECAP_enableTimeStampCapture(ECAP1_BASE);
ECAP_reArm(ECAP1_BASE);
ECAP_enableInterrupt(ECAP1_BASE, ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
}
__interrupt void ecap1ISR(void)
{
if(stopCaptures==0)
{
//
// Get the capture counts, interrupt every 4. Can be 1-bit or more
// wide. Add one to account for partial eCAP counts at higher baud
// rates (for example: count = 40, but if had higher resolution, this
// would be 40.5)
capCountArr[0] = 1+ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_1);
capCountArr[1] = 1+ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_2);
capCountArr[2] = 1+ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_3);
capCountArr[3] = 1+ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_4);
//
// Add samples to a buffer. Get average baud and tune if buffer filled.
//
capCountIter = 0;
for(capCountIter=0;capCountIter<4;capCountIter++)
{
//
// if we still have samples left to capture, add it to the
// samples array
//
if(sampleArrIter<NUMSAMPLES)
{
sampleArr[sampleArrIter] = capCountArr[capCountIter];
sampleArrIter++;
}
//
// else, all samples were received, break to begin tuning
//
else
{
stopCaptures=1;
break;
}
}
}
//
// Clear interrupt flags for more interrupts.
//
ECAP_clearInterrupt(ECAP1_BASE,ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
ECAP_clearGlobalInterrupt(ECAP1_BASE);
//
// Start eCAP
//
ECAP_reArm(ECAP1_BASE);
//
// Acknowledge the group interrupt for more interrupts.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
}
//
// FUNCTION: getAverageBaud
// PURPOSE: get the average baud rate of the array
// INPUTS: array of pulse widths (in number eCAP counts),
// size of array, and target baud rate
// RETURNS: average baud rate
//
uint32_t getAverageBaud(volatile float arr[], int size, float targetBaudRate)
{
//
// clean up variable width array to single-bit-width array
//
float calcTargetWidth = (float)DEVICE_SYSCLK_FREQ/targetBaudRate;
uint16_t pass = arrTo1PulseWidth(arr, size, calcTargetWidth);
//
// pass only if enough good samples provided
//
if(pass == 0)
{
return(0);
}
//
// convert 2-bit width, 3-bit width, and so on to 1-bit width values by
// dividing, and average these values. skip unrelated values
//
float averageBitWidth = computeAvgWidth(arr, size);
//
// get the rounded baud rate from the average number of clocks and the
// sysclk frequency
//
return((uint32_t)(((float)DEVICE_SYSCLK_FREQ/(float)averageBitWidth)+0.5));
}
//
// FUNCTION: arrTo1PulseWidth
// PURPOSE: convert 2-bit and higher widths to 1-bit equivalent,
// set "bad" values to zero
// INPUTS: array of pulse widths in number eCAP counts, size of array,
// and target pulse-width (in number of eCAP counts)
// RETURNS: pass if enough "good" data received,
// fail if not enough "good" data
//
uint16_t arrTo1PulseWidth(volatile float arr[], int size, float targetWidth)
{
int iterator = 0, numBitWidths=0;
uint16_t goodDataCount = 0, pass = 0;
for(iterator=0;iterator<size;iterator++)
{
//
// if the item is less than 10 times the bit width,
//
if(arr[iterator] < targetWidth*10)
{
//
// if the item is not within +/-MARGINPERCENT% of the targetWidth,
// then it is a multiple of 1-bit
//
bool belowBound = arr[iterator] < targetWidth*(1.0-MARGINPERCENT);
bool aboveBound = arr[iterator] > targetWidth*(1.0+MARGINPERCENT);
if(belowBound || aboveBound)
{
//
// estimate how many bit-widths this is
//
numBitWidths = (int)((arr[iterator]/targetWidth)+0.5);
//
// multiply the multi-bit baudrate value by the estimated
// number of bits to make this a 1-bit baud estimate
//
arr[iterator] = arr[iterator]/numBitWidths;
//
// find if this new value is within the bounds
//
belowBound = arr[iterator] < targetWidth*(1.0-MARGINPERCENT);
aboveBound = arr[iterator] > targetWidth*(1.0+MARGINPERCENT);
if(belowBound || aboveBound)
{
arr[iterator] = 0; // discard if not within margins
}
else
{
goodDataCount++; // iterate good data counter
}
}
else
{
//
// this is a 1-bit value so increment the counter for it
//
goodDataCount++;
}
}
else
{
arr[iterator] = 0;
}
}
//
// if at least MINSAMPLEPERCENT% of the sampled values
// are "good" samples, then return a pass
//
if((float)goodDataCount/(float)size > MINSAMPLEPERCENT)
{
pass=1;
}
return(pass); //return if the array had enough good samples or not
}
//
// FUNCTION: computeAvgWidth
// PURPOSE: average all non-zero items in the array
// INPUTS: array of 1-bit pulse widths in number eCAP counts,
// and size of array
// RETURNS: average width
//
float computeAvgWidth(volatile float arr[], int size)
{
int iterator = 0, totSamples = 0;
float total = 0;
for(iterator=0;iterator<size;iterator++)
{
//
// if the item has not been removed
//
if(arr[iterator] != 0)
{
//
// iterate the number of samples that are included in the total
//
totSamples++;
//
//add it to the moving average
//
total+=arr[iterator];
}
}
return(total/totSamples); //return the average
}
@@ -0,0 +1,67 @@
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F2838x" --package "337bga" --part "F2838x_337bga" --context "CPU1" --product "C2000WARE@5.02.00.00"
* @versions {"tool":"1.0.0+dev"}
*/
/**
* Import the modules used in this configuration.
*/
const device_support = scripting.addModule("/driverlib/device_support.js");
const sysctl = scripting.addModule("/driverlib/sysctl.js");
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
const CMD1 = CMD.addInstance();
const CMD2 = CMD.addInstance();
const memcfg = scripting.addModule("/driverlib/memcfg.js");
const sci = scripting.addModule("/driverlib/sci.js", {}, false);
const sci1 = sci.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
sci1.$name = "mySCI0";
sci1.baudRates = 9600;
sci1.sci.$assign = "SCIA";
sci1.sci.sci_rxPin.$assign = "GPIO9";
sci1.sci.sci_txPin.$assign = "GPIO8";
CMD1.$name = "generic_ram_lnk";
CMD2.$name = "generic_flash_lnk";
CMD1.sectionMemory_text = ["RAMLS0","RAMLS1","RAMLS2","RAMLS3","RAMLS4"];
CMD1.sectionMemory_ramfunc = ["RAMM0"];
CMD1.sectionMemory_cinit = ["RAMM0"];
CMD1.sectionMemory_stack = ["RAMM1"];
CMD1.sectionMemory_init_array = ["RAMM0"];
CMD1.sectionMemory_bss = ["RAMLS5"];
CMD1.sectionMemory_const = ["RAMLS5"];
CMD1.sectionMemory_data = ["RAMLS5"];
CMD1.sectionMemory_switch = ["RAMM0"];
CMD1.sectionMemory_sysmem = ["RAMLS5"];
CMD2.sectionAlignEnable_ramfunc = true;
CMD2.sectionAlignEnable_text = true;
CMD2.sectionAlignEnable_binit = true;
CMD2.sectionAlignEnable_cinit = true;
CMD2.sectionAlignEnable_switch = true;
CMD2.sectionAlignEnable_init_array = true;
CMD2.sectionAlignEnable_const = true;
CMD2.sectionAlignEnable_ovly = true;
CMD2.sectionMemory_codestart = "0x080000";
CMD2.sectionMemory_stack = ["RAMM1"];
CMD2.sectionMemory_bss = ["RAMLS5"];
CMD2.sectionMemory_data = ["RAMLS5"];
CMD2.sectionMemory_sysmem = ["RAMLS5"];
CMD2.sectionMemory_ramfunc = ["FLASH3"];
CMD2.sectionMemory_text = ["FLASH1","FLASH2","FLASH3","FLASH4"];
CMD2.sectionMemory_binit = ["FLASH4"];
CMD2.sectionMemory_cinit = ["FLASH4"];
CMD2.sectionMemory_switch = ["FLASH1"];
CMD2.sectionMemory_init_array = ["FLASH1"];
CMD2.sectionMemory_const = ["FLASH5"];
CMD2.sectionMemory_ovly = ["FLASH6"];
CMD2.sectionRunFromDifferentAddr_ramfunc = true;
CMD2.sectionRun_ramfunc = ["RAMLS0"];
CMD2.sectionBinit_ramfunc = false;
@@ -0,0 +1,183 @@
//###########################################################################
//
// FILE: sci_ex1_loopback.c
//
// TITLE: SCI FIFO Digital Loop Back.
//
//! \addtogroup driver_example_list
//! <h1>SCI FIFO Digital Loop Back</h1>
//!
//! This program uses the internal loop back test mode of the peripheral.
//! Other then boot mode pin configuration, no other hardware configuration
//! is required. The pinmux and SCI modules are configured through the
//! sysconfig file.
//!
//! This test uses the loopback test mode of the SCI module to send
//! characters starting with 0x00 through 0xFF. The test will send
//! a character and then check the receive buffer for a correct match.
//!
//! \note This example project has support for migration across our C2000
//! device families. If you are wanting to build this project from launchpad
//! or controlCARD, please specify in the .syscfg file the board you're using.
//! At any time you can select another device to migrate this example.
//!
//! \b Watch \b Variables \n
//! - \b loopCount - Number of characters sent
//! - \b errorCount - Number of errors detected
//! - \b sendChar - Character sent
//! - \b receivedChar - Character received
//!
//
//#############################################################################
//
//
//
// C2000Ware v5.04.00.00
//
// 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.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Globals
//
uint16_t loopCount;
uint16_t errorCount;
//
// Function Prototypes
//
void error();
//
// Main
//
void main(void)
{
uint16_t sendChar;
uint16_t receivedChar;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Setup GPIO by disabling pin locks and enabling 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();
//
// Enables CPU interrupts
//
Interrupt_enableGlobal();
//
// Initialize counts
//
loopCount = 0;
errorCount = 0;
//
// Send a character starting with 0
//
sendChar = 0;
//
// Send Characters forever starting with 0x00 and going through 0xFF.
// After sending each, check the receive buffer for the correct value.
//
for(;;)
{
SCI_writeCharNonBlocking(mySCI0_BASE, sendChar);
//
// Wait for RRDY/RXFFST = 1 for 1 data available in FIFO
//
while(SCI_getRxFIFOStatus(mySCI0_BASE) == SCI_FIFO_RX0)
{
;
}
//
// Check received character
//
receivedChar = SCI_readCharBlockingFIFO(mySCI0_BASE);
//
// Received character not correct
//
if(receivedChar != sendChar)
{
errorCount++;
// asm(" ESTOP0"); // Uncomment to stop the test here
for (;;);
}
//
// Move to the next character and repeat the test
//
sendChar++;
//
// Limit the character to 8-bits
//
sendChar &= 0x00FF;
loopCount++;
}
}
//
// End of file
//
@@ -0,0 +1,65 @@
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F2838x" --package "337bga" --part "F2838x_337bga" --context "CPU1" --product "C2000WARE@5.02.00.00"
* @versions {"tool":"1.0.0+dev"}
*/
/**
* Import the modules used in this configuration.
*/
const device_support = scripting.addModule("/driverlib/device_support.js");
const sysctl = scripting.addModule("/driverlib/sysctl.js");
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
const CMD1 = CMD.addInstance();
const CMD2 = CMD.addInstance();
const memcfg = scripting.addModule("/driverlib/memcfg.js");
const sci = scripting.addModule("/driverlib/sci.js", {}, false);
const sci1 = sci.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
sci1.$name = "mySCI0";
sci1.loopback = true;
sci1.baudRates = 9600;
sci1.sci.$assign = "SCIA";
CMD1.$name = "generic_ram_lnk";
CMD2.$name = "generic_flash_lnk";
CMD1.sectionMemory_text = ["RAMLS0","RAMLS1","RAMLS2","RAMLS3","RAMLS4"];
CMD1.sectionMemory_ramfunc = ["RAMM0"];
CMD1.sectionMemory_cinit = ["RAMM0"];
CMD1.sectionMemory_stack = ["RAMM1"];
CMD1.sectionMemory_init_array = ["RAMM0"];
CMD1.sectionMemory_bss = ["RAMLS5"];
CMD1.sectionMemory_const = ["RAMLS5"];
CMD1.sectionMemory_data = ["RAMLS5"];
CMD1.sectionMemory_switch = ["RAMM0"];
CMD1.sectionMemory_sysmem = ["RAMLS5"];
CMD2.sectionAlignEnable_ramfunc = true;
CMD2.sectionAlignEnable_text = true;
CMD2.sectionAlignEnable_binit = true;
CMD2.sectionAlignEnable_cinit = true;
CMD2.sectionAlignEnable_switch = true;
CMD2.sectionAlignEnable_init_array = true;
CMD2.sectionAlignEnable_const = true;
CMD2.sectionAlignEnable_ovly = true;
CMD2.sectionMemory_codestart = "0x080000";
CMD2.sectionMemory_stack = ["RAMM1"];
CMD2.sectionMemory_bss = ["RAMLS5"];
CMD2.sectionMemory_data = ["RAMLS5"];
CMD2.sectionMemory_sysmem = ["RAMLS5"];
CMD2.sectionMemory_ramfunc = ["FLASH3"];
CMD2.sectionMemory_text = ["FLASH1","FLASH2","FLASH3","FLASH4"];
CMD2.sectionMemory_binit = ["FLASH4"];
CMD2.sectionMemory_cinit = ["FLASH4"];
CMD2.sectionMemory_switch = ["FLASH1"];
CMD2.sectionMemory_init_array = ["FLASH1"];
CMD2.sectionMemory_const = ["FLASH5"];
CMD2.sectionMemory_ovly = ["FLASH6"];
CMD2.sectionRunFromDifferentAddr_ramfunc = true;
CMD2.sectionRun_ramfunc = ["RAMLS0"];
CMD2.sectionBinit_ramfunc = false;
@@ -0,0 +1,292 @@
//###########################################################################
//
// FILE: sci_ex2_loopback_interrupts.c
//
// TITLE: SCI Digital Loop Back with Interrupts.
//
//! \addtogroup driver_example_list
//! <h1> SCI Digital Loop Back with Interrupts </h1>
//!
//! This test uses the internal loop back test mode of the peripheral.
//! Other then boot mode pin configuration, no other hardware configuration
//! is required. Both interrupts and the SCI FIFOs are used.
//!
//! A stream of data is sent and then compared to the received stream.
//! The SCI-A sent data looks like this: \n
//! 00 01 \n
//! 01 02 \n
//! 02 03 \n
//! .... \n
//! FE FF \n
//! FF 00 \n
//! etc.. \n
//! The pattern is repeated forever.
//!
//! \b Watch \b Variables \n
//! - \b sDataA - Data being sent
//! - \b rDataA - Data received
//! - \b rDataPointA - Keep track of where we are in the data stream.
//! This is used to check the incoming data
//!
//
//###########################################################################
//
//
//
// C2000Ware v5.04.00.00
//
// 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.
// $
//###########################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Globals
//
//
// Send data for SCI-A
//
uint16_t sDataA[2];
//
// Received data for SCI-A
//
uint16_t rDataA[2];
//
// Used for checking the received data
//
uint16_t rDataPointA;
//
// Function Prototypes
//
__interrupt void sciaTXFIFOISR(void);
__interrupt void sciaRXFIFOISR(void);
void initSCIAFIFO(void);
void error(void);
//
// Main
//
void main(void)
{
uint16_t i;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Setup GPIO by disabling pin locks and enabling pullups
//
Device_initGPIO();
//
// GPIO28 is the SCI Rx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
//
// GPIO29 is the SCI Tx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
//
// 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_SCIA_RX, sciaRXFIFOISR);
Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);
//
// Initialize the Device Peripherals:
//
initSCIAFIFO();
//
// Init the send data. After each transmission this data
// will be updated for the next transmission
//
for(i = 0; i < 2; i++)
{
sDataA[i] = i;
}
rDataPointA = sDataA[0];
Interrupt_enable(INT_SCIA_RX);
Interrupt_enable(INT_SCIA_TX);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// IDLE loop. Just sit and loop forever (optional):
//
for(;;);
}
//
// error - Function to halt debugger on error
//
void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}
//
// sciaTXFIFOISR - SCIA Transmit FIFO ISR
//
__interrupt void sciaTXFIFOISR(void)
{
uint16_t i;
SCI_writeCharArray(SCIA_BASE, sDataA, 2);
//
// Increment send data for next cycle
//
for(i = 0; i < 2; i++)
{
sDataA[i] = (sDataA[i] + 1) & 0x00FF;
}
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF);
//
// Issue PIE ACK
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
//
// sciaRXFIFOISR - SCIA Receive FIFO ISR
//
__interrupt void sciaRXFIFOISR(void)
{
uint16_t i;
SCI_readCharArray(SCIA_BASE, rDataA, 2);
//
// Check received data
//
for(i = 0; i < 2; i++)
{
if(rDataA[i] != ((rDataPointA + i) & 0x00FF))
{
error();
}
}
rDataPointA = (rDataPointA + 1) & 0x00FF;
SCI_clearOverflowStatus(SCIA_BASE);
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);
//
// Issue PIE ack
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
//
// initSCIAFIFO - Configure SCIA FIFO
//
void initSCIAFIFO()
{
//
// 8 char bits, 1 stop bit, no parity. Baud rate is 9600.
//
SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_enableModule(SCIA_BASE);
SCI_enableLoopback(SCIA_BASE);
SCI_resetChannels(SCIA_BASE);
SCI_enableFIFO(SCIA_BASE);
//
// RX and TX FIFO Interrupts Enabled
//
SCI_enableInterrupt(SCIA_BASE, (SCI_INT_RXFF | SCI_INT_TXFF));
SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR);
//
// The transmit FIFO generates an interrupt when FIFO status
// bits are less than or equal to 2 out of 16 words
// The receive FIFO generates an interrupt when FIFO status
// bits are greater than equal to 2 out of 16 words
//
SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX2);
SCI_performSoftwareReset(SCIA_BASE);
SCI_resetTxFIFO(SCIA_BASE);
SCI_resetRxFIFO(SCIA_BASE);
}
//
// End of file
//
@@ -0,0 +1,205 @@
//#############################################################################
//
// FILE: sci_ex3_echoback.c
//
// TITLE: SCI echoback example.
//
//! \addtogroup driver_example_list
//! <h1>SCI Echoback</h1>
//!
//! This test receives and echo-backs data through the SCI-A port.
//!
//! A terminal such as 'putty' can be used to view the data from
//! the SCI and to send information to the SCI. Characters received
//! by the SCI port are sent back to the host.
//!
//! \b Running \b the \b Application
//! Open a COM port with the following settings using a terminal:
//! - Find correct COM port
//! - Bits per second = 9600
//! - Data Bits = 8
//! - Parity = None
//! - Stop Bits = 1
//! - Hardware Control = None
//!
//! The program will print out a greeting and then ask you to
//! enter a character which it will echo back to the terminal.
//!
//! \b Watch \b Variables \n
//! - loopCounter - the number of characters sent
//!
//! \b External \b Connections \n
//! Connect the USB cable from Control card J1:A to PC
//!
//
//#############################################################################
//
//
//
// C2000Ware v5.04.00.00
//
// 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.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Defines
//
// Define AUTOBAUD to use the autobaud lock feature
//#define AUTOBAUD
//
// Globals
//
uint16_t loopCounter = 0;
//
// Main
//
void main(void)
{
uint16_t receivedChar;
unsigned char *msg;
uint16_t rxStatus = 0U;
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// GPIO28 is the SCI Rx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
//
// GPIO29 is the SCI Tx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
//
// Initialize interrupt controller and vector table.
//
Interrupt_initModule();
Interrupt_initVectorTable();
//
// Initialize SCIA and its FIFO.
//
SCI_performSoftwareReset(SCIA_BASE);
//
// Configure SCIA for echoback.
//
SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIA_BASE);
SCI_resetRxFIFO(SCIA_BASE);
SCI_resetTxFIFO(SCIA_BASE);
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF);
SCI_enableFIFO(SCIA_BASE);
SCI_enableModule(SCIA_BASE);
SCI_performSoftwareReset(SCIA_BASE);
#ifdef AUTOBAUD
//
// Perform an autobaud lock.
// SCI expects an 'a' or 'A' to lock the baud rate.
//
SCI_lockAutobaud(SCIA_BASE);
#endif
//
// Send starting message.
//
msg = "\r\n\n\nHello World!\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 17);
msg = "\r\nYou will enter a character, and the DSP will echo it back!\n\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 62);
for(;;)
{
msg = "\r\nEnter a character: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 22);
//
// Read a character from the FIFO.
//
receivedChar = SCI_readCharBlockingFIFO(SCIA_BASE);
rxStatus = SCI_getRxStatus(SCIA_BASE);
if((rxStatus & SCI_RXSTATUS_ERROR) != 0)
{
//
//If Execution stops here there is some error
//Analyze SCI_getRxStatus() API return value
//
ESTOP0;
}
//
// Echo back the character.
//
msg = " You sent: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar);
//
// Increment the loop count variable.
//
loopCounter++;
}
}
//
// End of File
//
@@ -0,0 +1,245 @@
//#############################################################################
//
// TITLE: stdout redirect example
//!
//! \addtogroup driver_example_list
//! <h1> stdout redirect example </h1>
//! This test transmits data through the SCI-A port to a terminal
//!
//! A terminal such as 'putty' can be used to view the data from
//! the SCI. Characters received by the SCI port are sent back to the host.
//!
//! \b Running \b the \b Application
//! Open a COM port with the following settings using a terminal:
//! - Find correct COM port
//! - Bits per second = 9600
//! - Data Bits = 8
//! - Parity = None
//! - Stop Bits = 1
//! - Hardware Control = None
//!
//! The program will print out three sentences: one to the SCIA, one to CCS,
//! and a final one to SCIA.
//!
//! \b External \b Connections \n
//! Connect the SCI-A port to a PC via a transceiver and cable.
//! - DEVICE_GPIO_PIN_SCIRXDA is SCI_A-RXD (Connect to Pin3, PC-TX, of serial DB9 cable)
//! - DEVICE_GPIO_PIN_SCITXDA is SCI_A-TXD (Connect to Pin2, PC-RX, of serial DB9 cable)
//
//#############################################################################
//
//
//
// C2000Ware v5.04.00.00
//
// 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.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include <assert.h>
#include <stdio.h>
#include <file.h>
#include "uart_drv.h"
//
// Defines
//
//
// Globals
//
uint16_t loopCounter = 0;
//
// Declarations
//
void UartSetup();
void UartPutChar(uint16_t charToWrite);
//
// Main
//
void main(void)
{
uint16_t receivedChar;
unsigned char *msg;
uint16_t rxStatus = 0U;
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//**************************************************************************
// NOTE: SCI Configuration for this example is done in UartSetup()
// As an alternative, the user can configure SCI here in the main, and then
// provide an empty UartSetup() function. UartSetup() must be defined, even
// if it is empty.
//**************************************************************************
/*-----------------------------------------------------------------------*/
/* STDOUT CONFIG START */
/*-----------------------------------------------------------------------*/
FILE *uart = NULL;
/*-----------------------------------------------------------------------*/
/* Add the UART device. When fopen is called with a filename that */
/* begins "uart:", the UART device will be used to handle the file. */
/*-----------------------------------------------------------------------*/
add_device("uart",
_SSA,
UART_open,
UART_close,
UART_read,
UART_write,
UART_lseek,
UART_unlink,
UART_rename);
/*-----------------------------------------------------------------------*/
/* Open a UART file. Because the "uart" device is _SSA, only one UART */
/* file may be open at once. */
/*-----------------------------------------------------------------------*/
uart = fopen("uart:", "w");
assert(uart != NULL);
/*-----------------------------------------------------------------------*/
/* Now, write something to the UART device */
/*-----------------------------------------------------------------------*/
fputs("\r\n\r\n", uart);
fputs("hello, world on UART\r\n", uart);
/*-----------------------------------------------------------------------*/
/* We must close the UART file before opening another with freopen, */
/* below. Closing a file will flush the buffer automatically. */
/*-----------------------------------------------------------------------*/
fclose(uart);
/*-----------------------------------------------------------------------*/
/* Add delay here based on the number of bytes being sent and baud rate */
/* This allows time for buffer to flush */
/* In this example: 22 chars for last fputs = 176 bits */
/* 176 bits * (1/9600 bits/sec) = ~20 ms delay required for all bytes */
/*-----------------------------------------------------------------------*/
DEVICE_DELAY_US(20000);
/*-----------------------------------------------------------------------*/
/* Show that stdout still works. */
/*-----------------------------------------------------------------------*/
puts("hello, world on stdout\r\n");
/*-----------------------------------------------------------------------*/
/* Now reassign stdout to be a UART device! */
/*-----------------------------------------------------------------------*/
assert(freopen("uart:", "w", stdout) != NULL);
/*-----------------------------------------------------------------------*/
/* Now, writing to stdout actually writes to UART */
/*-----------------------------------------------------------------------*/
puts("hello, world on the new UART stdout\r\n");
/*-----------------------------------------------------------------------*/
/* All files are flushed when the program exits. */
/*-----------------------------------------------------------------------*/
return 0;
/*-----------------------------------------------------------------------*/
/* UART CONFIG END */
/*-----------------------------------------------------------------------*/
}
void UartSetup()
{
//
// DEVICE_GPIO_PIN_SCIRXDA is the SCI Rx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
//
// DEVICE_GPIO_PIN_SCITXDA is the SCI Tx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
//
// Initialize SCIA and its FIFO.
//
SCI_performSoftwareReset(SCIA_BASE);
//
// Configure SCIA with FIFO
//
SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIA_BASE);
SCI_resetRxFIFO(SCIA_BASE);
SCI_resetTxFIFO(SCIA_BASE);
SCI_enableFIFO(SCIA_BASE);
SCI_enableModule(SCIA_BASE);
SCI_performSoftwareReset(SCIA_BASE);
}
void UartPutChar(uint16_t charToWrite)
{
SCI_writeCharBlockingFIFO(SCIA_BASE, charToWrite);
}
//
// End of File
//
@@ -0,0 +1,142 @@
/*****************************************************************************/
/* UART_LOWLEV.C - Example user-defined device. */
/*****************************************************************************/
#include <file.h>
#include "uart_drv.h"
//#include "uart.h"
/*****************************************************************************/
//! //! <h1> Example user-defined device. </h1>
/* This is a sample implementation of a user-defined device. The device */
/* must define the seven basic functions (open, close, read, write, lseek, */
/* unlink, rename). These are expected to behave just like the Unix */
/* functions of these names. Some devices might not have a reasonable */
/* action to take for some functions; a UART or TTY device might not be */
/* lseek-able, but can still be opened and written to. A device is added */
/* using the add_device() RTS function call (q.v.). */
/*****************************************************************************/
/* The low-level interface is based on file names and file descriptors. */
/* The file names don't need to be valid Unix file names, but must mean */
/* something to the device. The device must keep track of its own file */
/* descriptors, which will be used by the calling functions to read and */
/* write to the device. If there can only be one instance of a "file" on a */
/* device, the file descriptor doesn't matter much, so just pass a */
/* non-negative integer such as zero. */
/*****************************************************************************/
/*****************************************************************************/
/* */
/* UART_open() */
/* */
/*****************************************************************************/
int UART_open(const char *path, unsigned flags, int llv_fd)
{
/*-----------------------------------------------------------------------*/
/* Only one UART device exists (_SSA). For an _SSA device, file names */
/* are not meaningful, so ignore the file name. */
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Don't allow attempts to open the UART device that aren't O_WRONLY. */
/*-----------------------------------------------------------------------*/
if (!(flags & O_WRONLY)) return -1;
/*-----------------------------------------------------------------------*/
/* Set up the UART */
/*-----------------------------------------------------------------------*/
UartSetup();
/*-----------------------------------------------------------------------*/
/* Arbitrarily give it file descriptor 1. File descriptors are */
/* device-specific; this file descriptor 1 is not the same as HOST file */
/* descriptor 1 (stdout). */
/*-----------------------------------------------------------------------*/
return 1;
}
/*****************************************************************************/
/* */
/* UART_close() */
/* */
/*****************************************************************************/
int UART_close(int dev_fd)
{
/*-----------------------------------------------------------------------*/
/* Only one UART device exists, so we don't do anything upon close. */
/*-----------------------------------------------------------------------*/
return 0;
}
/*****************************************************************************/
/* */
/* UART_read() reads *at most* count bytes. */
/* */
/*****************************************************************************/
int UART_read(int dev_fd, char *buf, unsigned count)
{
/*-----------------------------------------------------------------------*/
/* Only one UART device exists, and it is write-only, so return error */
/*-----------------------------------------------------------------------*/
return -1;
}
/*****************************************************************************/
/* */
/* UART_write() */
/* */
/*****************************************************************************/
int UART_write(int dev_fd, const char *buf, unsigned count)
{
unsigned i;
/*-----------------------------------------------------------------------*/
/* Output character-by-character */
/*-----------------------------------------------------------------------*/
for (i=0; i < count; i++)
UartPutChar(buf[i]);
return count;
}
/*****************************************************************************/
/* */
/* UART_lseek() */
/* */
/*****************************************************************************/
off_t UART_lseek(int dev_fd, off_t offset, int origin)
{
/*-----------------------------------------------------------------------*/
/* lseek is not possible on UART. */
/*-----------------------------------------------------------------------*/
return -1;
}
/*****************************************************************************/
/* */
/* UART_unlink() */
/* */
/*****************************************************************************/
int UART_unlink(const char *path)
{
/*-----------------------------------------------------------------------*/
/* unlink is not possible on UART */
/*-----------------------------------------------------------------------*/
return -1;
}
/*****************************************************************************/
/* */
/* UART_rename() */
/* */
/*****************************************************************************/
/* rename is unusual among the low-level functions in that it is also */
/* specified in the ISO C standard. It has the same prototype and */
/* semantics, so it's not really an issue. */
/*****************************************************************************/
int UART_rename(const char *old_name, const char *new_name)
{
/*-----------------------------------------------------------------------*/
/* rename is not possible on UART */
/*-----------------------------------------------------------------------*/
return -1;
}
@@ -0,0 +1,12 @@
/*****************************************************************************/
/* Must include stdio.h before this file for the definition of fpos_t */
/*****************************************************************************/
#include <stdio.h>
int UART_open(const char *path, unsigned flags, int llv_fd);
int UART_close(int dev_fd);
int UART_read(int dev_fd, char *buf, unsigned count);
int UART_write(int dev_fd, const char *buf, unsigned count);
fpos_t UART_lseek(int dev_fd, fpos_t offset, int origin);
int UART_unlink(const char *path);
int UART_rename(const char *old_name, const char *new_name);