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,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex10_host_hub"
|
||||
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} -I${USB_LIB_ROOT} -I${COMMON_ROOT} -v28 -ml -mt --define=ccs_c2k --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} -I${USB_LIB_ROOT} -I${COMMON_ROOT} -v28 -ml -mt --define=ccs_c2k --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" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" scope="project" />
|
||||
<pathVariable name="COMMON_ROOT" path="../../../../../../device_support/f2837xd/common/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex10_host_hub.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex10_host_hub.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex10_host_keyboard.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex10_host_mouse.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,38 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex1_dev_serial"
|
||||
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${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${COMMON_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --gen_func_subsections=on --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 -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} -I${COMMON_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --float_support=fpu32 --define=DEBUG --define=_FLASH --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" scope="project" />
|
||||
<pathVariable name="COMMON_ROOT" path="../../../../../../device_support/F2837xD/common/" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex1_dev_serial.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex1_dev_serial.syscfg" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex2_dev_mouse"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex2_dev_mouse.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex2_dev_mouse.syscfg" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex3_dev_keyboard"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex3_dev_keyboard.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex3_dev_keyboard.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex4_dev_bulk"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex4_dev_bulk.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex4_dev_bulk.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex5_host_mouse"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex5_host_mouse.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex5_host_mouse.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex6_host_keyboard"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex6_host_keyboard.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex6_host_keyboard.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,44 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex7_host_msc"
|
||||
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} -I${USB_LIB_ROOT} -I${COMMON_ROOT} -I${THIRD_PARTY} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -I${COMMON_ROOT} -I${THIRD_PARTY} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" scope="project" />
|
||||
<pathVariable name="COMMON_ROOT" path="../../../../../../device_support/f2837xd/common/" scope="project" />
|
||||
<pathVariable name="THIRD_PARTY" path="../../../../../../utilities/third_party/f2837xd/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex7_host_msc.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/cmdline.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/cmdline.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/third_party/f2837xd/fatfs/port/fat_usbmsc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/third_party/f2837xd/fatfs/src/ff.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex7_host_msc.syscfg" targetDirectory="" />
|
||||
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex8_dual_detect"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex8_descriptors.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex8_dev_mouse.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex8_host_mouse.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex8_dual_detect.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex8_dual_detect.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex8_dual_detect.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="usb_ex9_dev_bulk_throughput"
|
||||
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} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${USB_LIB_ROOT} -v28 -ml -mt --define=ccs_c2k --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 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="USB_LIB_ROOT" path="../../../../../../libraries/communications/usb/f2837xd/include/" 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_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1_USB.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../libraries/communications/usb/f2837xd/lib/usblib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../usb_ex9_dev_bulk_throughput.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.c" targetDirectory="" />
|
||||
<file action="copy" path="../usb_hal.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/ustdlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../utilities/tools/f2837xd/utils/scistdio.h" targetDirectory="" />
|
||||
<file action="copy" path="../usb_ex9_dev_bulk_throughput.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,590 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex10_host_hub.c
|
||||
//
|
||||
// TITLE: An example using that supports a USB Hub, USB keyboard, and
|
||||
// a USB mass storage device.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB HUB Host example </h1>
|
||||
//!
|
||||
//! This example application demonstrates how to support a USB keyboard and USB
|
||||
//! Mouse with a USB Hub. The display will show the connected devices on the
|
||||
//! USB hub.
|
||||
//!
|
||||
//! To run the example you should connect a USB Hub to the microUSB port on the
|
||||
//! top of the controlCARD and open up a serial terminal with the above settings
|
||||
//! to view the characters typed on the keyboard. Allow the example to run with
|
||||
//! the hub connected and then connect the USB Host Mouse or Keyboard.
|
||||
//!
|
||||
//! When a USB Mouse is connected on the Hub the position of the mouse pointer
|
||||
//! and the state of the mouse buttons are output to the display. Similarly
|
||||
//! when a USB Keyboard is connected, any key press on the keyboard will cause
|
||||
//! them to be sent out the SCI at 115200 baud with no parity, 8 bits and 1
|
||||
//! stop bit.
|
||||
//!
|
||||
//! This example is for depicting the usage of Hub.
|
||||
//!
|
||||
//! There are some limitations in this example :
|
||||
//! 1. The Example fails to recognize the USB Hub and the device if the
|
||||
//! Mouse/Keyboard is already connected to the USB Hub and the Hub is
|
||||
//! connected to the Micro USB of the Control Card.
|
||||
//! 2. The same port should not be used to connect a Keyboard and mouse.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhub.h"
|
||||
#include "host/usbhhidkeyboard.h"
|
||||
#include "scistdio.h"
|
||||
#include "ustdlib.h"
|
||||
#include "usb_ex10_host_hub.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of the host controller's memory pool in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HCD_MEMORY_SIZE 128
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the Host controller driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8HCDPool[HCD_MEMORY_SIZE * MAX_USB_DEVICES];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Declare the USB Events driver interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The global that holds all of the host drivers in use in the application.
|
||||
// In this case, only the Keyboard class is loaded.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
|
||||
{
|
||||
&g_sUSBHostMSCClassDriver,
|
||||
&g_sUSBHIDClassDriver,
|
||||
&g_sUSBHubClassDriver,
|
||||
&g_sUSBEventDriver
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The current USB operating mode - Host, Device or unknown.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBMode g_eCurrentUSBMode;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This global holds the number of class drivers in the g_ppHostClassDrivers
|
||||
// list.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static const uint32_t g_ui32NumHostClassDrivers =
|
||||
sizeof(g_ppHostClassDrivers) / sizeof(tUSBHostClassDriver *);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Status bar boxes for hub ports.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define NUM_HUB_STATUS 4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure for Hub Status.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct
|
||||
{
|
||||
//
|
||||
// Holds if there is a device connected to this port.
|
||||
//
|
||||
bool bConnected;
|
||||
|
||||
//
|
||||
// The instance data for the device if bConnected is true.
|
||||
//
|
||||
uint32_t ui32Instance;
|
||||
}
|
||||
g_psHubStatus[NUM_HUB_STATUS];
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Configure the SCI and its pins. This must be called before SCIprintf().
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function updates the status area of the screen. It uses the current
|
||||
// state of the application to print the status bar.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
UpdateStatus(uint32_t ui32Port)
|
||||
{
|
||||
|
||||
uint8_t ui8DevClass, ui8DevProtocol;
|
||||
|
||||
if(g_psHubStatus[ui32Port].bConnected)
|
||||
{
|
||||
ui8DevClass = USBHCDDevClass(g_psHubStatus[ui32Port].ui32Instance, 0);
|
||||
ui8DevProtocol = USBHCDDevProtocol(
|
||||
g_psHubStatus[ui32Port].ui32Instance, 0);
|
||||
|
||||
if(ui8DevClass == USB_CLASS_HID)
|
||||
{
|
||||
if(ui8DevProtocol == USB_HID_PROTOCOL_MOUSE)
|
||||
{
|
||||
//
|
||||
// Mouse is currently connected.
|
||||
//
|
||||
SCIprintf("\nHost Mouse is connected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else if(ui8DevProtocol == USB_HID_PROTOCOL_KEYB)
|
||||
{
|
||||
//
|
||||
// Keyboard is currently connected.
|
||||
//
|
||||
SCIprintf("\nHost Keyboard is connected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unknown device is currently connected.
|
||||
//
|
||||
SCIprintf("\nUnkown Device is connected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
}
|
||||
else if(ui8DevClass == USB_CLASS_MASS_STORAGE)
|
||||
{
|
||||
//
|
||||
// MSC device is currently connected.
|
||||
//
|
||||
SCIprintf("\nMass Storage Device is connected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else if(ui8DevClass == USB_CLASS_HUB)
|
||||
{
|
||||
//
|
||||
// USB Hub device is currently connected.
|
||||
//
|
||||
SCIprintf("\nUSB Hub is connected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unknown device is currently connected.
|
||||
//
|
||||
SCIprintf("\nUnkown Device is connected\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui8DevClass = USBHCDDevClass(g_psHubStatus[ui32Port].ui32Instance, 0);
|
||||
ui8DevProtocol = USBHCDDevProtocol(
|
||||
g_psHubStatus[ui32Port].ui32Instance, 0);
|
||||
|
||||
if(ui8DevClass == USB_CLASS_HID)
|
||||
{
|
||||
if(ui8DevProtocol == USB_HID_PROTOCOL_MOUSE)
|
||||
{
|
||||
//
|
||||
// Mouse is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nHost Mouse is Disconnected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else if(ui8DevProtocol == USB_HID_PROTOCOL_KEYB)
|
||||
{
|
||||
//
|
||||
// Keyboard is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nHost Keyboard is Disconnected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unknown device is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nUnkown Device is Disconnected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
}
|
||||
else if(ui8DevClass == USB_CLASS_MASS_STORAGE)
|
||||
{
|
||||
//
|
||||
// MSC device is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nMass Storage Device is Disconnected on Hub Port %d\n",
|
||||
ui32Port);
|
||||
}
|
||||
else if(ui8DevClass == USB_CLASS_HUB)
|
||||
{
|
||||
//
|
||||
// USB Hub device is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nUSB Hub is Disconnected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unknown device is currently disconnected.
|
||||
//
|
||||
SCIprintf("\nUnkown Device is Disconnected\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the generic callback from host stack.
|
||||
//
|
||||
// pvData is actually a pointer to a tEventInfo structure.
|
||||
//
|
||||
// This function will be called to inform the application when a USB event has
|
||||
// occurred that is outside those related to the keyboard device. At this
|
||||
// point this is used to detect unsupported devices being inserted and removed.
|
||||
// It is also used to inform the application when a power fault has occurred.
|
||||
// This function is required when the g_USBGenericEventDriver is included in
|
||||
// the host controller driver array that is passed in to the
|
||||
// USBHCDRegisterDrivers() function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBHCDEvents(void *pvData)
|
||||
{
|
||||
tEventInfo *pEventInfo;
|
||||
uint8_t ui8Port;
|
||||
|
||||
//
|
||||
// Cast this pointer to its actual type.
|
||||
//
|
||||
pEventInfo = (tEventInfo *)pvData;
|
||||
|
||||
//
|
||||
// Get the hub port number that the device is connected to.
|
||||
//
|
||||
ui8Port = USBHCDDevHubPort(pEventInfo->ui32Instance);
|
||||
|
||||
switch(pEventInfo->ui32Event)
|
||||
{
|
||||
case USB_EVENT_UNKNOWN_CONNECTED:
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
|
||||
//
|
||||
// If this is the hub then ignore this connection.
|
||||
//
|
||||
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HUB))
|
||||
{
|
||||
//
|
||||
// USB Hub device is currently connected.
|
||||
//
|
||||
SCIprintf("\nUSB Hub is connected\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// If this is not a direct connection, then the hub is on
|
||||
// port 0 so the index should be moved down from 1-4 to 0-3.
|
||||
//
|
||||
if(ui8Port > 0)
|
||||
{
|
||||
ui8Port--;
|
||||
}
|
||||
|
||||
//
|
||||
// Save the device instance data.
|
||||
//
|
||||
g_psHubStatus[ui8Port].ui32Instance = pEventInfo->ui32Instance;
|
||||
g_psHubStatus[ui8Port].bConnected = true;
|
||||
|
||||
//
|
||||
// Update the port status for the new device.
|
||||
//
|
||||
UpdateStatus(ui8Port);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// A device has been unplugged.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// If this is the hub then ignore this.
|
||||
//
|
||||
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HUB))
|
||||
{
|
||||
//
|
||||
// USB Hub device has been disconnected.
|
||||
//
|
||||
SCIprintf("\nUSB Hub is Disconnected\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// If this is not a direct connection, then the hub is on
|
||||
// port 0 so the index should be moved down from 1-4 to 0-3.
|
||||
//
|
||||
if(ui8Port > 0)
|
||||
{
|
||||
ui8Port--;
|
||||
}
|
||||
|
||||
//
|
||||
// Device is no longer connected.
|
||||
//
|
||||
g_psHubStatus[ui8Port].ui32Instance = 0;
|
||||
g_psHubStatus[ui8Port].bConnected = false;
|
||||
|
||||
//
|
||||
// Update the port status for the new device.
|
||||
//
|
||||
UpdateStatus(ui8Port);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HUB mouse handler.
|
||||
//
|
||||
// pvCBData is ignored by this function.
|
||||
// ui32Event is one of the valid events for a mouse device.
|
||||
// ui32MsgParam is defined by the event that occurs.
|
||||
// pvMsgData is a pointer to data that is defined by the event that occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a mouse has
|
||||
// been plugged in or removed and any time mouse movement or button pressed
|
||||
// is detected.
|
||||
//
|
||||
// This function will return 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
HubCallback(tHubInstance *psHubInstance, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The main application loop.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uint32_t i32Idx;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Configure the required pins for USB operation.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
|
||||
//
|
||||
// Register the interrupt handler for USB Interrupts.
|
||||
//
|
||||
Interrupt_register(INT_USBA, &f28x_USB0OTGModeIntHandler);
|
||||
|
||||
//
|
||||
// Enable Interrupts
|
||||
//
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Configure SCIA for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
|
||||
//
|
||||
// Initialize the hub port status.
|
||||
//
|
||||
for(i32Idx = 0; i32Idx < NUM_HUB_STATUS; i32Idx++)
|
||||
{
|
||||
g_psHubStatus[i32Idx].bConnected = false;
|
||||
g_psHubStatus[i32Idx].ui32Instance = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Open the Mouse and Keyboard Interface.
|
||||
//
|
||||
MouseOpen();
|
||||
KeyboardOpen();
|
||||
|
||||
//
|
||||
// Initialize the USB stack mode and pass in a mode callback.
|
||||
//
|
||||
USBStackModeSet(0, eUSBModeForceHost, 0);
|
||||
|
||||
//
|
||||
// Register the host class drivers.
|
||||
//
|
||||
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
|
||||
|
||||
//
|
||||
// Open a hub instance and provide it with the memory required to hold
|
||||
// configuration descriptors for each attached device.
|
||||
//
|
||||
USBHHubOpen(HubCallback);
|
||||
|
||||
//
|
||||
// Initialize the power configuration. This sets the power enable signal
|
||||
// to be active high and does not enable the power fault.
|
||||
//
|
||||
USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
|
||||
|
||||
//
|
||||
// Initialize the USB controller for Host mode.
|
||||
//
|
||||
USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool));
|
||||
|
||||
SCIprintf("USB Host Hub Example\n");
|
||||
|
||||
//
|
||||
// The main loop for the application.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Call the USB library to let non-interrupt code run.
|
||||
//
|
||||
USBHCDMain();
|
||||
|
||||
//
|
||||
// Call the keyboard main routine.
|
||||
//
|
||||
KeyboardMain();
|
||||
|
||||
//
|
||||
// Call the Mouse main routine.
|
||||
//
|
||||
MouseMain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// usb_ex10_host_hub.h - The common definitions for the usb_host_hub
|
||||
// application.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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.
|
||||
// $
|
||||
//##############################################################################
|
||||
|
||||
#ifndef USB_EX10_HOST_HUB_H
|
||||
#define USB_EX10_HOST_HUB_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The ASCII code for a backspace character.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define ASCII_BACKSPACE 0x08
|
||||
|
||||
void KeyboardOpen(void);
|
||||
void MouseOpen(void);
|
||||
void KeyboardMain(void);
|
||||
void MouseMain(void);
|
||||
void UpdateStatus(uint32_t ui32Port);
|
||||
|
||||
#endif //USB_EX10_HOST_HUB_H
|
||||
@@ -0,0 +1,362 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// usb_ex10_host_keyboard.c - The USB keyboard handling routines.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "scistdio.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhidkeyboard.h"
|
||||
#include "usb_ex10_host_hub.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of the keyboard device interface's memory pool in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYBOARD_MEMORY_SIZE 128
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the keyboard device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8Buffer[KEYBOARD_MEMORY_SIZE];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The global value used to store the keyboard instance value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHKeyboard * g_psKeyboardInstance;
|
||||
|
||||
extern const tHIDKeyboardUsageTable g_sUSKeyboardMap;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This enumerated type is used to hold the states of the keyboard.
|
||||
//
|
||||
//*****************************************************************************
|
||||
enum
|
||||
{
|
||||
//
|
||||
// No device is present.
|
||||
//
|
||||
eStateNoDevice,
|
||||
|
||||
//
|
||||
// Keyboard has been detected and needs to be initialized in the main
|
||||
// loop.
|
||||
//
|
||||
eStateKeyboardInit,
|
||||
|
||||
//
|
||||
// Keyboard is connected and waiting for events.
|
||||
//
|
||||
eStateKeyboardConnected,
|
||||
|
||||
//
|
||||
// Keyboard has received a key press that requires updating the keyboard
|
||||
// in the main loop.
|
||||
//
|
||||
eStateKeyboardUpdate,
|
||||
}
|
||||
g_iKeyboardState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This variable holds the current status of the modifiers keys.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32Modifiers;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function prints the character out the SCI and into the text area of
|
||||
// the screen.
|
||||
//
|
||||
// \param cChar is the character to print out.
|
||||
//
|
||||
// This function handles all of the detail of printing a character to both the
|
||||
// SCI and to the text area of the screen on the evaluation board. The text
|
||||
// area of the screen will be cleared any time the text goes beyond the end
|
||||
// of the text area.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
PrintChar(const char cChar)
|
||||
{
|
||||
|
||||
//
|
||||
// Send the character to the SCI.
|
||||
//
|
||||
SCIprintf("%c", cChar);
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HID keyboard handler.
|
||||
//
|
||||
// pvCBData is ignored by this function.
|
||||
// ui32Event is one of the valid events for a keyboard device.
|
||||
// ui32MsgParam is defined by the event that occurs.
|
||||
// pvMsgData is a pointer to data that is defined by the event that
|
||||
// occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a keyboard has
|
||||
// been plugged in or removed and any time a key is pressed or released.
|
||||
//
|
||||
// This function will return 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
KeyboardCallback(tUSBHKeyboard *psKbInstance, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
char cChar;
|
||||
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// New keyboard detected.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Proceed to the STATE_KEYBOARD_INIT state so that the main loop
|
||||
// can finish initialized the mouse since USBHKeyboardInit() cannot
|
||||
// be called from within a callback.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardInit;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Keyboard has been unplugged.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// Change the state so that the main loop knows that the keyboard
|
||||
// is no longer present.
|
||||
//
|
||||
g_iKeyboardState = eStateNoDevice;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// New Key press detected.
|
||||
//
|
||||
case USBH_EVENT_HID_KB_PRESS:
|
||||
{
|
||||
//
|
||||
// If this was a Caps Lock key then update the Caps Lock state.
|
||||
//
|
||||
if(ui32MsgParam == HID_KEYB_USAGE_CAPSLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Caps Lock
|
||||
// state.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardUpdate;
|
||||
|
||||
//
|
||||
// Toggle the current Caps Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_CAPS_LOCK;
|
||||
}
|
||||
else if(ui32MsgParam == HID_KEYB_USAGE_SCROLLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Scroll Lock
|
||||
// state.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardUpdate;
|
||||
|
||||
//
|
||||
// Toggle the current Scroll Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_SCROLL_LOCK;
|
||||
}
|
||||
else if(ui32MsgParam == HID_KEYB_USAGE_NUMLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Scroll Lock
|
||||
// state.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardUpdate;
|
||||
|
||||
//
|
||||
// Toggle the current Num Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_NUM_LOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Was this the backspace key?
|
||||
//
|
||||
if((uint8_t)ui32MsgParam == HID_KEYB_USAGE_BACKSPACE)
|
||||
{
|
||||
//
|
||||
// Yes - set the ASCII code for a backspace key. This is
|
||||
// not returned by USBHKeyboardUsageToChar since this only
|
||||
// returns printable characters.
|
||||
//
|
||||
cChar = ASCII_BACKSPACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// This is not backspace so try to map the usage code to a
|
||||
// printable ASCII character.
|
||||
//
|
||||
cChar = (char)
|
||||
USBHKeyboardUsageToChar(g_psKeyboardInstance,
|
||||
&g_sUSKeyboardMap,
|
||||
(uint8_t)ui32MsgParam);
|
||||
}
|
||||
|
||||
//
|
||||
// A zero value indicates there was no textual mapping of this
|
||||
// usage code.
|
||||
//
|
||||
if(cChar != 0)
|
||||
{
|
||||
PrintChar(cChar);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_HID_KB_MOD:
|
||||
{
|
||||
//
|
||||
// This application ignores the state of the shift or control
|
||||
// and other special keys.
|
||||
//
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_HID_KB_REL:
|
||||
{
|
||||
//
|
||||
// This applications ignores the release of keys as well.
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The main routine for handling the USB keyboard.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
KeyboardMain(void)
|
||||
{
|
||||
switch(g_iKeyboardState)
|
||||
{
|
||||
//
|
||||
// This state is entered when they keyboard is first detected.
|
||||
//
|
||||
case eStateKeyboardInit:
|
||||
{
|
||||
//
|
||||
// Initialized the newly connected keyboard.
|
||||
//
|
||||
USBHKeyboardInit(g_psKeyboardInstance);
|
||||
|
||||
//
|
||||
// Proceed to the keyboard connected state.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardConnected;
|
||||
|
||||
//
|
||||
// Set the current state of the modifiers.
|
||||
//
|
||||
USBHKeyboardModifierSet(g_psKeyboardInstance, g_ui32Modifiers);
|
||||
|
||||
break;
|
||||
}
|
||||
case eStateKeyboardUpdate:
|
||||
{
|
||||
//
|
||||
// If the application detected a change that required an
|
||||
// update to be sent to the keyboard to change the modifier
|
||||
// state then call it and return to the connected state.
|
||||
//
|
||||
g_iKeyboardState = eStateKeyboardConnected;
|
||||
|
||||
USBHKeyboardModifierSet(g_psKeyboardInstance, g_ui32Modifiers);
|
||||
|
||||
break;
|
||||
}
|
||||
case eStateKeyboardConnected:
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Open the Keyboard Interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
KeyboardOpen(void)
|
||||
{
|
||||
//
|
||||
// Open an instance of the keyboard driver.
|
||||
//
|
||||
g_psKeyboardInstance = USBHKeyboardOpen(KeyboardCallback, g_pui8Buffer,
|
||||
KEYBOARD_MEMORY_SIZE);
|
||||
g_iKeyboardState = eStateNoDevice;
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// usb_ex10_host_mouse.c - The USB Mouse handling routines.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "scistdio.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhub.h"
|
||||
#include "host/usbhhidmouse.h"
|
||||
#include "scistdio.h"
|
||||
#include "usb_ex10_host_hub.h"
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global values used to store the mouse state.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t g_ui32Buttons;
|
||||
static int32_t g_i32CursorX;
|
||||
static int32_t g_i32CursorY;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global value used to store the mouse instance value.
|
||||
//
|
||||
//******************************************************************************
|
||||
static tUSBHMouse *g_psMouseInstance;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The size of the mouse device interface's memory pool in bytes.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define MOUSE_MEMORY_SIZE 128
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the mouse device.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t g_pui8BufferMouse[MOUSE_MEMORY_SIZE];
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumerated type is used to hold the states of the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
enum
|
||||
{
|
||||
//
|
||||
// No device is present.
|
||||
//
|
||||
STATE_NO_DEVICE,
|
||||
|
||||
//
|
||||
// Mouse has been detected and needs to be initialized in the main
|
||||
// loop.
|
||||
//
|
||||
STATE_MOUSE_INIT,
|
||||
|
||||
//
|
||||
// Mouse is connected and waiting for events.
|
||||
//
|
||||
STATE_MOUSE_CONNECTED,
|
||||
|
||||
//
|
||||
// An unsupported device has been attached.
|
||||
//
|
||||
STATE_UNKNOWN_DEVICE,
|
||||
|
||||
//
|
||||
// A power fault has occurred.
|
||||
//
|
||||
STATE_POWER_FAULT
|
||||
}
|
||||
g_eUSBState;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HID mouse handler.
|
||||
//
|
||||
// \param psMsInstance is ignored by this function.
|
||||
// \param ui32Event is one of the valid events for a mouse device.
|
||||
// \param ui32MsgParam is defined by the event that occurs.
|
||||
// \param pvMsgData is a pointer to data that is defined by the event that
|
||||
// occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a mouse has
|
||||
// been plugged in or removed and any time mouse movement or button pressed
|
||||
// is detected.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
MouseCallback(tUSBHMouse *psMsInstance, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
int32_t i32DoUpdate;
|
||||
volatile char pcBuffer[20];
|
||||
|
||||
//
|
||||
// Do an update unless there is no reason to.
|
||||
//
|
||||
i32DoUpdate = 0;
|
||||
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// Mouse button press detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_PRESS:
|
||||
{
|
||||
//
|
||||
// Save the new button that was pressed.
|
||||
//
|
||||
g_ui32Buttons |= ui32MsgParam;
|
||||
i32DoUpdate = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse button release detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_REL:
|
||||
{
|
||||
//
|
||||
// Remove the button from the pressed state.
|
||||
//
|
||||
g_ui32Buttons &= ~ui32MsgParam;
|
||||
i32DoUpdate = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse X movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_X:
|
||||
{
|
||||
//
|
||||
// The mouse returns a 8 bit signed value...check to see if we
|
||||
// need to sign extend
|
||||
//
|
||||
if(ui32MsgParam & 0x80)
|
||||
ui32MsgParam |= 0xFF00;
|
||||
//
|
||||
// Update the cursor X position.
|
||||
//
|
||||
g_i32CursorX += (int16_t)ui32MsgParam ;
|
||||
|
||||
//
|
||||
// Cap the value to not cause an overflow.
|
||||
//
|
||||
if(g_i32CursorX > 9999)
|
||||
{
|
||||
g_i32CursorX = 9999;
|
||||
}
|
||||
|
||||
if(g_i32CursorX < -9999)
|
||||
{
|
||||
g_i32CursorX = -9999;
|
||||
}
|
||||
i32DoUpdate = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Y movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_Y:
|
||||
{
|
||||
//
|
||||
// The mouse returns a 8 bit signed value...check to see if we
|
||||
// need to sign extend
|
||||
//
|
||||
if(ui32MsgParam & 0x80)
|
||||
ui32MsgParam |= 0xFF00;
|
||||
|
||||
//
|
||||
// Update the cursor Y position.
|
||||
//
|
||||
g_i32CursorY += (int16_t)ui32MsgParam;
|
||||
|
||||
//
|
||||
// Cap the value to not cause an overflow.
|
||||
//
|
||||
if(g_i32CursorY > 9999)
|
||||
{
|
||||
g_i32CursorY = 9999;
|
||||
}
|
||||
|
||||
if(g_i32CursorY < -9999)
|
||||
{
|
||||
g_i32CursorY = -9999;
|
||||
}
|
||||
i32DoUpdate = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
//
|
||||
// No reason to update.
|
||||
//
|
||||
i32DoUpdate = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Display the current mouse position and button state if there was an
|
||||
// update.
|
||||
//
|
||||
if(i32DoUpdate)
|
||||
{
|
||||
//
|
||||
// Display the current mouse position and button state.
|
||||
//
|
||||
SCIprintf("\rPos: %l, %l Buttons: %l%l%l ", g_i32CursorX,
|
||||
g_i32CursorY, g_ui32Buttons & 1, (g_ui32Buttons & 2) >> 1,
|
||||
(g_ui32Buttons & 4) >> 2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The main routine for handling the USB Mouse.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
MouseMain(void)
|
||||
{
|
||||
switch(g_eUSBState)
|
||||
{
|
||||
//
|
||||
// This state is entered when the mouse is first detected.
|
||||
//
|
||||
case STATE_MOUSE_INIT:
|
||||
{
|
||||
//
|
||||
// Initialize the newly connected mouse.
|
||||
//
|
||||
USBHMouseInit(g_psMouseInstance);
|
||||
|
||||
//
|
||||
// Proceed to the mouse connected state.
|
||||
//
|
||||
g_eUSBState = STATE_MOUSE_CONNECTED;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_MOUSE_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Nothing is currently done in the main loop when the mouse
|
||||
// is connected.
|
||||
//
|
||||
g_eUSBState = STATE_MOUSE_INIT;
|
||||
MouseOpen();
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_NO_DEVICE:
|
||||
{
|
||||
//
|
||||
// The mouse is not connected so nothing needs to be done here.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Open the instance of the mouse driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
MouseOpen(void)
|
||||
{
|
||||
//
|
||||
// Open an instance of the mouse driver. The mouse does not need
|
||||
// to be present at this time, this just saves a place for it and allows
|
||||
// the applications to be notified when a mouse is present.
|
||||
//
|
||||
g_psMouseInstance = USBHMouseOpen(MouseCallback, g_pui8BufferMouse,
|
||||
MOUSE_MEMORY_SIZE);
|
||||
|
||||
//
|
||||
// Initialized the cursor.
|
||||
//
|
||||
g_ui32Buttons = 0;
|
||||
g_i32CursorX = 0;
|
||||
g_i32CursorY = 0;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.pfltQual.$name = "myGPIOQUAL2";
|
||||
usb1.epenQual.$name = "myGPIOQUAL3";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
|
||||
/**
|
||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||
* re-solve from scratch.
|
||||
*/
|
||||
usb1.usb.$suggestSolution = "USB0";
|
||||
@@ -0,0 +1,510 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex2_dev_mouse.c
|
||||
//
|
||||
// TITLE: Main routines for the USB HID mouse example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> USB HID Mouse Device </h1>
|
||||
//!
|
||||
//! This example application turns the evaluation board into a USB mouse
|
||||
//! supporting the Human Interface Device class. After loading and running the
|
||||
//! example simply connect the PC to the controlCARDs microUSB port using a USB
|
||||
//! cable, and the mouse pointer will move in a square pattern for the duration
|
||||
//! of the time it is plugged in.
|
||||
//!
|
||||
//! SCIA, connected to the FTDI virtual COM port and running at 115200,
|
||||
//! 8-N-1, is used to display messages from this application.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdhid.h"
|
||||
//#include "device/usbdhidmouse.h"
|
||||
//#include "usb_ex2_mouse_structs.h"
|
||||
#include "usb_structs.h"
|
||||
#include "scistdio.h"
|
||||
|
||||
void INT_myUSB0_ISR(void);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
//******************************************************************************
|
||||
#define MOUSE_MOVE_INC 1 // The incremental update for the mouse.
|
||||
#define MOUSE_MOVE_DEC -1
|
||||
#define TICKS_PER_SECOND 100
|
||||
#define MS_PER_SYSTICK (1000 / TICKS_PER_SECOND)
|
||||
#define TICK_EVENT 0
|
||||
|
||||
#ifdef DEBUG // Debug output is available via SCIA if DEBUG is defined.
|
||||
//
|
||||
// Map all debug print calls to SCIprintf in debug builds.
|
||||
//
|
||||
#define DEBUG_PRINT SCIprintf
|
||||
#else
|
||||
//
|
||||
// Compile out all debug print calls in release builds.
|
||||
//
|
||||
#define DEBUG_PRINT while(0) ((int32_t (*)(char *, ...))0)
|
||||
#endif
|
||||
|
||||
#define MAX_SEND_DELAY 50 // The number of system ticks to wait for
|
||||
// each USB packet to be sent before
|
||||
// we assume the host has disconnected.
|
||||
// The value 50 equates to half a second.
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile uint32_t g_ui32Commands; // Holds command bits used to signal
|
||||
// the main loop to perform
|
||||
// various tasks.
|
||||
volatile bool g_bConnected; // A flag used to indicate whether or
|
||||
// not we are currently connected to
|
||||
// the USB host.
|
||||
volatile uint32_t g_ui32TickCount; // Global system tick counter holds
|
||||
// elapsed time since the application
|
||||
// started expressed in 100ths of a
|
||||
// second.
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumeration holds the various states that the mouse can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
MOUSE_STATE_UNCONFIGURED,
|
||||
|
||||
//
|
||||
// No keys to send and not waiting on data.
|
||||
//
|
||||
MOUSE_STATE_IDLE,
|
||||
|
||||
//
|
||||
// Waiting on data to be sent out.
|
||||
//
|
||||
MOUSE_STATE_SENDING
|
||||
}
|
||||
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// MouseHandler - This function handles notification messages from the
|
||||
// mouse device driver.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
MouseHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
|
||||
void *pvMsgData)
|
||||
{
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// The USB host has connected to and configured the device.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
g_eMouseState = MOUSE_STATE_IDLE;
|
||||
g_bConnected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The USB host has disconnected from the device.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
g_bConnected = false;
|
||||
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// A report was sent to the host. We are not free to send another.
|
||||
//
|
||||
case USB_EVENT_TX_COMPLETE:
|
||||
{
|
||||
g_eMouseState = MOUSE_STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore the other events.
|
||||
//
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// WaitForSendIdle - Wait for a period of time for the state to become idle.
|
||||
//
|
||||
// \param ui32TimeoutTick is the number of system ticks to wait before declaring
|
||||
// a timeout and returning \b false.
|
||||
//
|
||||
// This function polls the current keyboard state for ui32TimeoutTicks system
|
||||
// ticks waiting for it to become idle. If the state becomes idle, the
|
||||
// function returns true. If it ui32TimeoutTicks occur prior to the state
|
||||
// becoming idle, false is returned to indicate a timeout.
|
||||
//
|
||||
// \return Returns \b true on success or \b false on timeout.
|
||||
//
|
||||
//******************************************************************************
|
||||
bool
|
||||
WaitForSendIdle(uint32_t ui32TimeoutTicks)
|
||||
{
|
||||
uint32_t ui32Start;
|
||||
uint32_t ui32Now;
|
||||
uint32_t ui32Elapsed;
|
||||
|
||||
ui32Start = g_ui32TickCount;
|
||||
ui32Elapsed = 0;
|
||||
|
||||
while(ui32Elapsed < ui32TimeoutTicks)
|
||||
{
|
||||
//
|
||||
// Is the mouse is idle, return immediately.
|
||||
//
|
||||
if(g_eMouseState == MOUSE_STATE_IDLE)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
//
|
||||
// Determine how much time has elapsed since we started waiting. This
|
||||
// should be safe across a wrap of g_ui32TickCount.
|
||||
//
|
||||
ui32Now = g_ui32TickCount;
|
||||
ui32Elapsed = ((ui32Start < ui32Now) ? (ui32Now - ui32Start) :
|
||||
(((uint32_t)0xFFFFFFFF - ui32Start) + ui32Now + 1));
|
||||
}
|
||||
|
||||
//
|
||||
// If we get here, we timed out so return a bad return code to let the
|
||||
// caller know.
|
||||
//
|
||||
return(false);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// MoveHandler - This function provides simulated movements of the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
MoveHandler(void)
|
||||
{
|
||||
uint32_t ui32Retcode;
|
||||
char cDeltaX, cDeltaY;
|
||||
|
||||
//
|
||||
// Determine the direction to move the mouse.
|
||||
//
|
||||
ui32Retcode = g_ui32TickCount % (4 * TICKS_PER_SECOND);
|
||||
if(ui32Retcode < TICKS_PER_SECOND)
|
||||
{
|
||||
cDeltaX = MOUSE_MOVE_INC;
|
||||
cDeltaY = 0;
|
||||
}
|
||||
else if(ui32Retcode < (2 * TICKS_PER_SECOND))
|
||||
{
|
||||
cDeltaX = 0;
|
||||
cDeltaY = MOUSE_MOVE_INC;
|
||||
}
|
||||
else if(ui32Retcode < (3 * TICKS_PER_SECOND))
|
||||
{
|
||||
cDeltaX = (char)MOUSE_MOVE_DEC;
|
||||
cDeltaY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cDeltaX = 0;
|
||||
cDeltaY = (char)MOUSE_MOVE_DEC;
|
||||
}
|
||||
|
||||
//
|
||||
// Tell the HID driver to send this new report.
|
||||
//
|
||||
g_eMouseState = MOUSE_STATE_SENDING;
|
||||
ui32Retcode = USBDHIDMouseStateChange((void *)&g_sMouseDevice, cDeltaX,
|
||||
cDeltaY, 0);
|
||||
|
||||
//
|
||||
// Did we schedule the report for transmission?
|
||||
//
|
||||
if(ui32Retcode == MOUSE_SUCCESS)
|
||||
{
|
||||
//
|
||||
// Wait for the host to acknowledge the transmission if all went well.
|
||||
//
|
||||
if(!WaitForSendIdle(MAX_SEND_DELAY))
|
||||
{
|
||||
//
|
||||
// The transmission failed, so assume the host disconnected and go
|
||||
// back to waiting for a new connection.
|
||||
//
|
||||
g_bConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// CPUTimerIntHandler - This is the interrupt handler for the CPU Timer
|
||||
// interrupt. It is called periodically and updates a global tick counter then
|
||||
// sets a flag to tell the main loop to move the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
CPUTimerIntHandler(void)
|
||||
{
|
||||
GPIO_writePin(0,1);
|
||||
|
||||
g_ui32TickCount++;
|
||||
|
||||
HWREG(&g_ui32Commands) |= 1;
|
||||
|
||||
GPIO_writePin(0,0);
|
||||
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called before
|
||||
// DEBUG_PRINT(). It configures the SCI GPIOs and the Console I/O.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the main application entry function.
|
||||
//
|
||||
//******************************************************************************
|
||||
int main(void)
|
||||
{
|
||||
g_bConnected = false;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
//
|
||||
// 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_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Configure the SCI for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
#endif
|
||||
|
||||
USBGPIOEnable();
|
||||
//Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Initialize the USB stack for device mode.
|
||||
//
|
||||
//USBStackModeSet(0, eUSBModeForceDevice, 0);
|
||||
GPIO_setDirectionMode(0, GPIO_DIR_MODE_OUT);
|
||||
|
||||
//
|
||||
// Register the interrupt handler, returning an error if an error occurs.
|
||||
//
|
||||
Interrupt_register(INT_TIMER0, &CPUTimerIntHandler);
|
||||
|
||||
CPUTimerInit();
|
||||
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE,
|
||||
(SysCtl_getClock(DEVICE_OSCSRC_FREQ) / TICKS_PER_SECOND));
|
||||
|
||||
//
|
||||
// Enable the CPU Timer interrupt.
|
||||
//
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Show the application name on the display and SCI output.
|
||||
//
|
||||
DEBUG_PRINT("\nC2000 F2837xD Series USB HID Mouse device example\n");
|
||||
DEBUG_PRINT("---------------------------------\n\n");
|
||||
|
||||
//
|
||||
// Pass the USB library our device information, initialize the USB
|
||||
// controller and connect the device to the bus.
|
||||
//
|
||||
//USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
|
||||
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Drop into the main loop.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Tell the user what we are doing.
|
||||
//
|
||||
DEBUG_PRINT("Waiting for host...\n");
|
||||
|
||||
//
|
||||
// Wait for USB configuration to complete.
|
||||
//
|
||||
while(!g_bConnected)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Update the status.
|
||||
//
|
||||
DEBUG_PRINT("Host connected...\n");
|
||||
|
||||
//
|
||||
// Now keep processing the mouse as long as the host is connected.
|
||||
//
|
||||
while(g_bConnected)
|
||||
{
|
||||
//
|
||||
// If it is time to move the mouse then do so.
|
||||
//
|
||||
if(HWREG(&g_ui32Commands) & 1)
|
||||
{
|
||||
HWREG(&g_ui32Commands) &= ~1;
|
||||
MoveHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Device interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0DeviceIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.deviceClasses = "Mouse";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.pfltQual.$name = "myGPIOQUAL2";
|
||||
usb1.epenQual.$name = "myGPIOQUAL3";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
|
||||
/**
|
||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||
* re-solve from scratch.
|
||||
*/
|
||||
usb1.usb.$suggestSolution = "USB0";
|
||||
@@ -0,0 +1,790 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex3_dev_keyboard.c
|
||||
//
|
||||
// TITLE: Main routines for the keyboard example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB Device Keyboard </h1>
|
||||
//!
|
||||
//! This example application turns the evaluation board into a USB keyboard
|
||||
//! supporting the Human Interface Device class. The global variable ui32Button
|
||||
//! should be modified to wake up the USB. Care should be taken to ensure that
|
||||
//! the active window can safely receive the text; enter is not pressed at any
|
||||
//! point so no actions are attempted by the host if a terminal window is used.
|
||||
//!
|
||||
//! The device implemented by this application also supports USB remote wake up
|
||||
//! allowing it to request the host to reactivate a suspended bus. If the bus
|
||||
//! is suspended (as indicated on the application display), updating ui32Button
|
||||
//! will request a remote wakeup assuming the host has not specifically
|
||||
//! disabled such requests.
|
||||
//!
|
||||
//! To run the example compile the project, load to the target, and run the
|
||||
//! example. After the example is running, connect a USB cable from the PC to
|
||||
//! the microUSB port on the controlCARD.Modify ui32Button value in the
|
||||
//! expressions window and then focus should be on the window so that we
|
||||
//! can receive keyboard input (i.e. NotePad).
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usb_structs.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidkeyb.h"
|
||||
#include "scistdio.h"
|
||||
|
||||
#ifdef DEBUG // Debug output is available via SCIA if DEBUG is defined.
|
||||
//
|
||||
// Map all debug print calls to SCIprintf in debug builds.
|
||||
//
|
||||
#define DEBUG_PRINT SCIprintf
|
||||
#else
|
||||
//
|
||||
// Compile out all debug print calls in release builds.
|
||||
//
|
||||
#define DEBUG_PRINT while(0) ((int32_t (*)(char *, ...))0)
|
||||
#endif
|
||||
void INT_myUSB0_ISR(void);
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define TICKS_PER_SECOND 100 // The system tick timer period.
|
||||
#define MAX_SEND_DELAY 50 // The number of system ticks to wait for
|
||||
// each USB packet to be sent before we
|
||||
// assume the host has disconnected. The
|
||||
// value 50 equates to half a second.
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// A mapping from the ASCII value received from the SCI to the corresponding
|
||||
// USB HID usage code.
|
||||
//
|
||||
//******************************************************************************
|
||||
static const int8_t g_ppi8KeyUsageCodes[][2] =
|
||||
{
|
||||
{ 0, HID_KEYB_USAGE_SPACE }, // 0x20
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_1 }, // ! 0x21
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_FQUOTE }, // " 0x22
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_3 }, // # 0x23
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_4 }, // $ 0x24
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_5 }, // % 0x25
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_7 }, // & 0x26
|
||||
{ 0, HID_KEYB_USAGE_FQUOTE }, // ' 0x27
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_9 }, // ( 0x28
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_0 }, // ) 0x29
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_8 }, // * 0x2a
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_EQUAL }, // + 0x2b
|
||||
{ 0, HID_KEYB_USAGE_COMMA }, // , 0x2c
|
||||
{ 0, HID_KEYB_USAGE_MINUS }, // - 0x2d
|
||||
{ 0, HID_KEYB_USAGE_PERIOD }, // . 0x2e
|
||||
{ 0, HID_KEYB_USAGE_FSLASH }, // / 0x2f
|
||||
{ 0, HID_KEYB_USAGE_0 }, // 0 0x30
|
||||
{ 0, HID_KEYB_USAGE_1 }, // 1 0x31
|
||||
{ 0, HID_KEYB_USAGE_2 }, // 2 0x32
|
||||
{ 0, HID_KEYB_USAGE_3 }, // 3 0x33
|
||||
{ 0, HID_KEYB_USAGE_4 }, // 4 0x34
|
||||
{ 0, HID_KEYB_USAGE_5 }, // 5 0x35
|
||||
{ 0, HID_KEYB_USAGE_6 }, // 6 0x36
|
||||
{ 0, HID_KEYB_USAGE_7 }, // 7 0x37
|
||||
{ 0, HID_KEYB_USAGE_8 }, // 8 0x38
|
||||
{ 0, HID_KEYB_USAGE_9 }, // 9 0x39
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_SEMICOLON }, // : 0x3a
|
||||
{ 0, HID_KEYB_USAGE_SEMICOLON }, // ; 0x3b
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_COMMA }, // < 0x3c
|
||||
{ 0, HID_KEYB_USAGE_EQUAL }, // = 0x3d
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_PERIOD }, // > 0x3e
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_FSLASH }, // ? 0x3f
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_2 }, // @ 0x40
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_A }, // A 0x41
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_B }, // B 0x42
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_C }, // C 0x43
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_D }, // D 0x44
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_E }, // E 0x45
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_F }, // F 0x46
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_G }, // G 0x47
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_H }, // H 0x48
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_I }, // I 0x49
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_J }, // J 0x4a
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_K }, // K 0x4b
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_L }, // L 0x4c
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_M }, // M 0x4d
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_N }, // N 0x4e
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_O }, // O 0x4f
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_P }, // P 0x50
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_Q }, // Q 0x51
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_R }, // R 0x52
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_S }, // S 0x53
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_T }, // T 0x54
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_U }, // U 0x55
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_V }, // V 0x56
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_W }, // W 0x57
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_X }, // X 0x58
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_Y }, // Y 0x59
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_Z }, // Z 0x5a
|
||||
{ 0, HID_KEYB_USAGE_LBRACKET }, // [ 0x5b
|
||||
{ 0, HID_KEYB_USAGE_BSLASH }, // \ 0x5c
|
||||
{ 0, HID_KEYB_USAGE_RBRACKET }, // ] 0x5d
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_6 }, // ^ 0x5e
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_MINUS }, // _ 0x5f
|
||||
{ 0, HID_KEYB_USAGE_BQUOTE }, // ` 0x60
|
||||
{ 0, HID_KEYB_USAGE_A }, // a 0x61
|
||||
{ 0, HID_KEYB_USAGE_B }, // b 0x62
|
||||
{ 0, HID_KEYB_USAGE_C }, // c 0x63
|
||||
{ 0, HID_KEYB_USAGE_D }, // d 0x64
|
||||
{ 0, HID_KEYB_USAGE_E }, // e 0x65
|
||||
{ 0, HID_KEYB_USAGE_F }, // f 0x66
|
||||
{ 0, HID_KEYB_USAGE_G }, // g 0x67
|
||||
{ 0, HID_KEYB_USAGE_H }, // h 0x68
|
||||
{ 0, HID_KEYB_USAGE_I }, // i 0x69
|
||||
{ 0, HID_KEYB_USAGE_J }, // j 0x6a
|
||||
{ 0, HID_KEYB_USAGE_K }, // k 0x6b
|
||||
{ 0, HID_KEYB_USAGE_L }, // l 0x6c
|
||||
{ 0, HID_KEYB_USAGE_M }, // m 0x6d
|
||||
{ 0, HID_KEYB_USAGE_N }, // n 0x6e
|
||||
{ 0, HID_KEYB_USAGE_O }, // o 0x6f
|
||||
{ 0, HID_KEYB_USAGE_P }, // p 0x70
|
||||
{ 0, HID_KEYB_USAGE_Q }, // q 0x71
|
||||
{ 0, HID_KEYB_USAGE_R }, // r 0x72
|
||||
{ 0, HID_KEYB_USAGE_S }, // s 0x73
|
||||
{ 0, HID_KEYB_USAGE_T }, // t 0x74
|
||||
{ 0, HID_KEYB_USAGE_U }, // u 0x75
|
||||
{ 0, HID_KEYB_USAGE_V }, // v 0x76
|
||||
{ 0, HID_KEYB_USAGE_W }, // w 0x77
|
||||
{ 0, HID_KEYB_USAGE_X }, // x 0x78
|
||||
{ 0, HID_KEYB_USAGE_Y }, // y 0x79
|
||||
{ 0, HID_KEYB_USAGE_Z }, // z 0x7a
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_LBRACKET }, // { 0x7b
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_BSLASH }, // | 0x7c
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_RBRACKET }, // } 0x7d
|
||||
{ HID_KEYB_LEFT_SHIFT, HID_KEYB_USAGE_BQUOTE }, // ~ 0x7e
|
||||
};
|
||||
|
||||
volatile bool g_bConnected = false; // This global indicates whether or not we
|
||||
// are connected to a USB host.
|
||||
volatile bool g_bSuspended = false; // This global indicates whether or not the
|
||||
//USB bus is currently in the suspend state
|
||||
volatile uint32_t g_ui32TickCount; // Global system tick counter holds
|
||||
//elapsed time since the application
|
||||
//started expressed in 100ths of a second
|
||||
volatile bool g_bDisplayUpdateRequired; // This global is set to true if the
|
||||
// host sends a request to set or clear
|
||||
// any keyboard LED.
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumeration holds the various states that the keyboard can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
STATE_UNCONFIGURED,
|
||||
|
||||
//
|
||||
// No keys to send and not waiting on data.
|
||||
//
|
||||
STATE_IDLE,
|
||||
|
||||
//
|
||||
// Waiting on data to be sent out.
|
||||
//
|
||||
STATE_SENDING
|
||||
}
|
||||
g_eKeyboardState = STATE_UNCONFIGURED;
|
||||
|
||||
#ifdef DEBUG
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called before
|
||||
// DEBUG_PRINT(). This configures the SCI GPIO's and SCI for Console I/O.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// KeyboardHandler - Handles asynchronous events from the HID keyboard driver.
|
||||
//
|
||||
// \param pvCBData is the event callback pointer provided during
|
||||
// USBDHIDKeyboardInit(). This is a pointer to our keyboard device structure
|
||||
// (&g_sKeyboardDevice).
|
||||
// \param ui32Event identifies the event we are being called back for.
|
||||
// \param ui32MsgData is an event-specific value.
|
||||
// \param pvMsgData is an event-specific pointer.
|
||||
//
|
||||
// This function is called by the HID keyboard driver to inform the application
|
||||
// of particular asynchronous events related to operation of the keyboard HID
|
||||
// device.
|
||||
//
|
||||
// \return Returns 0 in all cases.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
KeyboardHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
|
||||
void *pvMsgData)
|
||||
{
|
||||
switch (ui32Event)
|
||||
{
|
||||
//
|
||||
// The host has connected to us and configured the device.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
g_bConnected = true;
|
||||
g_bSuspended = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The host has disconnected from us.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
g_bConnected = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// We receive this event every time the host acknowledges transmission
|
||||
// of a report. It is used here purely as a way of determining whether
|
||||
// the host is still talking to us or not.
|
||||
//
|
||||
case USB_EVENT_TX_COMPLETE:
|
||||
{
|
||||
//
|
||||
// Enter the idle state since we finished sending something.
|
||||
//
|
||||
g_eKeyboardState = STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// This event indicates that the host has suspended the USB bus.
|
||||
//
|
||||
case USB_EVENT_SUSPEND:
|
||||
{
|
||||
g_bSuspended = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// This event signals that the host has resumed signalling on the bus.
|
||||
//
|
||||
case USB_EVENT_RESUME:
|
||||
{
|
||||
g_bSuspended = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// This event indicates that the host has sent us an Output or
|
||||
// Feature report and that the report is now in the buffer we provided
|
||||
// on the previous USBD_HID_EVENT_GET_REPORT_BUFFER callback.
|
||||
//
|
||||
case USBD_HID_KEYB_EVENT_SET_LEDS:
|
||||
{
|
||||
//
|
||||
// Set the LED to match the current state of the caps lock LED.
|
||||
//
|
||||
GPIO_writePin(31,((ui32MsgData & HID_KEYB_CAPS_LOCK) ? 1 : 0));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// We ignore all other events.
|
||||
//
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// WaitForSendIdle - Wait for a period of time for the state to become idle.
|
||||
//
|
||||
// \param ui32TimeoutTick is the number of system ticks to wait before
|
||||
// declaring a timeout and returning \b false.
|
||||
//
|
||||
// This function polls the current keyboard state for ui32TimeoutTicks system
|
||||
// ticks waiting for it to become idle. If the state becomes idle, the
|
||||
// function returns true. If it ui32TimeoutTicks occur prior to the state
|
||||
// becoming idle, false is returned to indicate a timeout.
|
||||
//
|
||||
// \return Returns \b true on success or \b false on timeout.
|
||||
//
|
||||
//******************************************************************************
|
||||
bool
|
||||
WaitForSendIdle(uint_fast32_t ui32TimeoutTicks)
|
||||
{
|
||||
uint32_t ui32Start;
|
||||
uint32_t ui32Now;
|
||||
uint32_t ui32Elapsed;
|
||||
|
||||
ui32Start = g_ui32TickCount;
|
||||
ui32Elapsed = 0;
|
||||
|
||||
while(ui32Elapsed < ui32TimeoutTicks)
|
||||
{
|
||||
//
|
||||
// Is the keyboard is idle, return immediately.
|
||||
//
|
||||
if(g_eKeyboardState == STATE_IDLE)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
//
|
||||
// Determine how much time has elapsed since we started waiting. This
|
||||
// should be safe across a wrap of g_ui32TickCount.
|
||||
//
|
||||
ui32Now = g_ui32TickCount;
|
||||
ui32Elapsed = ((ui32Start < ui32Now) ? (ui32Now - ui32Start) :
|
||||
(((uint32_t)0xFFFFFFFF - ui32Start) + ui32Now + 1));
|
||||
}
|
||||
|
||||
//
|
||||
// If we get here, we timed out so return a bad return code to let the
|
||||
// caller know.
|
||||
//
|
||||
return(false);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// SendString - Sends a string of characters via the USB HID keyboard
|
||||
// interface.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
SendString(char *pcStr)
|
||||
{
|
||||
uint32_t ui32Char;
|
||||
|
||||
//
|
||||
// Loop while there are more characters in the string.
|
||||
//
|
||||
while(*pcStr)
|
||||
{
|
||||
//
|
||||
// Get the next character from the string.
|
||||
//
|
||||
ui32Char = *pcStr++;
|
||||
|
||||
//
|
||||
// Skip this character if it is a non-printable character.
|
||||
//
|
||||
if((ui32Char < ' ') || (ui32Char > '~'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert the character into an index into the keyboard usage code
|
||||
// table.
|
||||
//
|
||||
ui32Char -= ' ';
|
||||
|
||||
//
|
||||
// Send the key press message.
|
||||
//
|
||||
g_eKeyboardState = STATE_SENDING;
|
||||
if(USBDHIDKeyboardKeyStateChange((void *)&g_sKeyboardDevice,
|
||||
g_ppi8KeyUsageCodes[ui32Char][0],
|
||||
g_ppi8KeyUsageCodes[ui32Char][1],
|
||||
true) != KEYB_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Wait until the key press message has been sent.
|
||||
//
|
||||
if(!WaitForSendIdle(MAX_SEND_DELAY))
|
||||
{
|
||||
g_bConnected = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Send the key release message.
|
||||
//
|
||||
g_eKeyboardState = STATE_SENDING;
|
||||
if(USBDHIDKeyboardKeyStateChange((void *)&g_sKeyboardDevice,
|
||||
0, g_ppi8KeyUsageCodes[ui32Char][1],
|
||||
false) != KEYB_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Wait until the key release message has been sent.
|
||||
//
|
||||
if(!WaitForSendIdle(MAX_SEND_DELAY))
|
||||
{
|
||||
g_bConnected = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// CPUTimerIntHandler - This is the interrupt handler for the CPU Timer
|
||||
// interrupt. It is used to update our local tick count which, in turn, is used
|
||||
// to check for transmit timeouts.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
CPUTimerIntHandler(void)
|
||||
{
|
||||
g_ui32TickCount++;
|
||||
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Main
|
||||
//
|
||||
//******************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uint_fast32_t ui32LastTickCount;
|
||||
uint32_t ui32Button, ui32Previous;
|
||||
bool bLastSuspend;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
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();
|
||||
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Configure the SCI for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
#endif
|
||||
|
||||
USBGPIOEnable();
|
||||
|
||||
//
|
||||
// Register the interrupt handler for USB Interrupts.
|
||||
//
|
||||
//Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Initialize the buttons driver
|
||||
//
|
||||
GPIO_setDirectionMode(0, GPIO_DIR_MODE_IN);
|
||||
GPIO_setDirectionMode(31, GPIO_DIR_MODE_OUT);
|
||||
GPIO_writePin(31, 1);
|
||||
|
||||
//
|
||||
// Not configured initially.
|
||||
//
|
||||
g_bConnected = false;
|
||||
g_bSuspended = false;
|
||||
bLastSuspend = false;
|
||||
|
||||
//
|
||||
// Initialize the USB stack for device mode.
|
||||
//
|
||||
//USBStackModeSet(0, eUSBModeForceDevice, 0);
|
||||
|
||||
//
|
||||
// Pass our device information to the USB HID device class driver,
|
||||
// initialize the USB
|
||||
// controller and connect the device to the bus.
|
||||
//
|
||||
//USBDHIDKeyboardInit(0, &g_sKeyboardDevice);
|
||||
|
||||
//
|
||||
// Register the interrupt handler, returning an error if an error occurs.
|
||||
//
|
||||
Interrupt_register(INT_TIMER0, &CPUTimerIntHandler);
|
||||
|
||||
CPUTimerInit();
|
||||
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE,
|
||||
(SysCtl_getClock(DEVICE_OSCSRC_FREQ) / TICKS_PER_SECOND));
|
||||
|
||||
//
|
||||
// Enable the CPU Timer interrupt.
|
||||
//
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
//
|
||||
// Start the CPU Timer.
|
||||
//
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Show the application name on the display and SCI output.
|
||||
//
|
||||
DEBUG_PRINT("\nC2000 F2837xD Series USB HID Keyboard device example\n");
|
||||
DEBUG_PRINT("---------------------------------\n\n");
|
||||
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// The main loop starts here. We begin by waiting for a host connection
|
||||
// then drop into the main keyboard handling section. If the host
|
||||
// disconnects, we return to the top and wait for a new connection.
|
||||
//
|
||||
ui32Previous = 1;
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Tell the user what we are doing and provide some basic instructions.
|
||||
//
|
||||
DEBUG_PRINT("Waiting for host...\n");
|
||||
|
||||
//
|
||||
// Wait here until USB device is connected to a host.
|
||||
//
|
||||
while(!g_bConnected)
|
||||
{
|
||||
//
|
||||
// Remember the current time.
|
||||
//
|
||||
ui32LastTickCount = g_ui32TickCount;
|
||||
|
||||
//
|
||||
// Has the suspend state changed since last time we checked?
|
||||
//
|
||||
if(bLastSuspend != g_bSuspended)
|
||||
{
|
||||
//
|
||||
// Yes - the state changed so update the display.
|
||||
//
|
||||
bLastSuspend = g_bSuspended;
|
||||
DEBUG_PRINT(bLastSuspend ? "Bus suspended...\n" :
|
||||
"Waiting for host...\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Update the global variable ui32Button in the expression window
|
||||
// to request a remote wake up of the USB.
|
||||
//
|
||||
if((ui32Button == 0) && (ui32Previous != 0) && g_bSuspended)
|
||||
{
|
||||
//
|
||||
// Request a remote wakeup.
|
||||
//
|
||||
USBDHIDKeyboardRemoteWakeupRequest((void *)&g_sKeyboardDevice);
|
||||
}
|
||||
ui32Previous = ui32Button;
|
||||
|
||||
//
|
||||
// Wait for at least 1 system tick to have gone by before we poll
|
||||
// the buttons again.
|
||||
//
|
||||
while(g_ui32TickCount == ui32LastTickCount)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update the status.
|
||||
//
|
||||
DEBUG_PRINT("Host connected...\n");
|
||||
|
||||
//
|
||||
// Enter the idle state.
|
||||
//
|
||||
g_eKeyboardState = STATE_IDLE;
|
||||
|
||||
//
|
||||
// Assume that the bus is not currently suspended if we have just been
|
||||
// configured.
|
||||
//
|
||||
bLastSuspend = false;
|
||||
|
||||
//
|
||||
// Keep transferring characters from the SCI to the USB host for as
|
||||
// long as we are connected to the host.
|
||||
//
|
||||
while(g_bConnected)
|
||||
{
|
||||
//
|
||||
// Remember the current time.
|
||||
//
|
||||
ui32LastTickCount = g_ui32TickCount;
|
||||
|
||||
//
|
||||
// Has the suspend state changed since last time we checked?
|
||||
//
|
||||
if(bLastSuspend != g_bSuspended)
|
||||
{
|
||||
//
|
||||
// Yes - the state changed so update the display.
|
||||
//
|
||||
bLastSuspend = g_bSuspended;
|
||||
DEBUG_PRINT(bLastSuspend ? "Bus suspended...\n" :
|
||||
"Host connected...\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Update the global variable ui32Button in the expression window
|
||||
// to send the string if the bus is not suspended.
|
||||
//
|
||||
if((ui32Button == 0) && (ui32Previous != 0))
|
||||
{
|
||||
//
|
||||
// If the bus is suspended then resume it. Otherwise, type
|
||||
// some "random" characters.
|
||||
//
|
||||
if(g_bSuspended)
|
||||
{
|
||||
USBDHIDKeyboardRemoteWakeupRequest(
|
||||
(void *)&g_sKeyboardDevice);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendString("Make the Switch to TI Microcontrollers!");
|
||||
}
|
||||
}
|
||||
ui32Previous = ui32Button;
|
||||
|
||||
//
|
||||
// Wait for at least 1 system tick to have gone by before we poll
|
||||
// the buttons again.
|
||||
//
|
||||
while(g_ui32TickCount == ui32LastTickCount)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Device interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0DeviceIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.deviceClasses = "Keyboard";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.pfltQual.$name = "myGPIOQUAL2";
|
||||
usb1.epenQual.$name = "myGPIOQUAL3";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
|
||||
/**
|
||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||
* re-solve from scratch.
|
||||
*/
|
||||
usb1.usb.$suggestSolution = "USB0";
|
||||
@@ -0,0 +1,565 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: usb_ex4_dev_bulk.c
|
||||
//
|
||||
// TITLE: Main routines for the generic bulk device example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB Generic Bulk Device </h1>
|
||||
//!
|
||||
//! This example provides a generic USB device offering simple bulk data
|
||||
//! transfer to and from the host. The device uses a vendor-specific class ID
|
||||
//! and supports a single bulk IN endpoint and a single bulk OUT endpoint.
|
||||
//! Data received from the host is assumed to be ASCII text and it is
|
||||
//! echoed back with the case of all alphabetic characters swapped.
|
||||
//!
|
||||
//! SCIA, connected to the FTDI virtual COM port and running at 115200,
|
||||
//! 8-N-1, is used to display messages from this application.
|
||||
//!
|
||||
//! A Windows INF file for the device is provided under the windows drivers
|
||||
//! directory. This INF contains information required to install the WinUSB
|
||||
//! subsystem on WindowsXP, Windows 7 and Windows 10. WinUSB is a Windows
|
||||
//! subsystem allowing user mode applications to access the USB device without
|
||||
//! the need for a vendor-specific kernel mode driver.
|
||||
//!
|
||||
//! A sample Windows command-line application, usb_bulk_example, illustrating
|
||||
//! how to connect to and communicate with the bulk device is also provided.
|
||||
//! Project files are included to allow the examples to be built using
|
||||
//! Microsoft VisualStudio. Source code for this application can be found in
|
||||
//! directory ~/C2000Ware/utilities/tools/{Device}/usb_bulk_example/Release
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usb_structs.h"
|
||||
#include "usblib.h"
|
||||
#include "usb_ids.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdbulk.h"
|
||||
#include "scistdio.h"
|
||||
|
||||
void INT_myUSB0_ISR(void);
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define COMMAND_PACKET_RECEIVED 0x00000001
|
||||
#define COMMAND_STATUS_UPDATE 0x00000002
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Debug-related definitions and declarations.
|
||||
//
|
||||
// Debug output is available via SCIA if DEBUG is defined during build.
|
||||
//
|
||||
//******************************************************************************
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_PRINT SCIprintf // Map all debug print calls to SCIprintf in
|
||||
// debug builds.
|
||||
#else
|
||||
#define DEBUG_PRINT while(0) ((int32_t (*)(char *, ...))0) //Compile out all
|
||||
//debug print calls
|
||||
//in release builds
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile uint32_t g_ui32TxCount = 0;
|
||||
volatile uint32_t g_ui32RxCount = 0;
|
||||
#ifdef DEBUG
|
||||
uint32_t g_ui32SCIRxErrors = 0;
|
||||
#endif
|
||||
tUSBMode g_eCurrentUSBMode; // The current USB operating mode - Host, Device
|
||||
// or unknown.
|
||||
volatile uint32_t g_ui32Flags = 0;
|
||||
char *g_pcStatus;
|
||||
static volatile bool g_bUSBConfigured = false; // Global flag indicating that a
|
||||
// USB configuration has been
|
||||
// set.
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// EchoNewDataToHost - Receive new data and echo it back to the host.
|
||||
//
|
||||
// \param psDevice points to the instance data for the device whose data is to
|
||||
// be processed.
|
||||
// \param pi8Data points to the newly received data in the USB receive buffer.
|
||||
// \param ui32NumBytes is the number of bytes of data available to be processed.
|
||||
//
|
||||
// This function is called whenever we receive a notification that data is
|
||||
// available from the host. We read the data, byte-by-byte and swap the case
|
||||
// of any alphabetical characters found then write it back out to be
|
||||
// transmitted back to the host.
|
||||
//
|
||||
// \return Returns the number of bytes of data processed.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t
|
||||
EchoNewDataToHost(tUSBDBulkDevice *psDevice, uint8_t *pi8Data,
|
||||
uint_fast32_t ui32NumBytes)
|
||||
{
|
||||
uint_fast32_t ui32Loop, ui32Space, ui32Count;
|
||||
uint_fast32_t ui32ReadIndex;
|
||||
uint_fast32_t ui32WriteIndex;
|
||||
tUSBRingBufObject sTxRing;
|
||||
|
||||
//
|
||||
// Get the current buffer information to allow us to write directly to
|
||||
// the transmit buffer (we already have enough information from the
|
||||
// parameters to access the receive buffer directly).
|
||||
//
|
||||
USBBufferInfoGet(&g_sTxBuffer, &sTxRing);
|
||||
|
||||
//
|
||||
// How much space is there in the transmit buffer?
|
||||
//
|
||||
ui32Space = USBBufferSpaceAvailable(&g_sTxBuffer);
|
||||
|
||||
//
|
||||
// How many characters can we process this time round?
|
||||
//
|
||||
ui32Loop = (ui32Space < ui32NumBytes) ? ui32Space : ui32NumBytes;
|
||||
ui32Count = ui32Loop;
|
||||
|
||||
//
|
||||
// Update our receive counter.
|
||||
//
|
||||
g_ui32RxCount += ui32NumBytes;
|
||||
|
||||
//
|
||||
// Dump a debug message.
|
||||
//
|
||||
DEBUG_PRINT("Received %d bytes\n", ui32NumBytes);
|
||||
|
||||
//
|
||||
// Set up to process the characters by directly accessing the USB buffers.
|
||||
//
|
||||
ui32ReadIndex = (uint32_t)(pi8Data - g_pui8USBRxBuffer);
|
||||
ui32WriteIndex = sTxRing.ui32WriteIndex;
|
||||
|
||||
while(ui32Loop)
|
||||
{
|
||||
//
|
||||
// Copy from the receive buffer to the transmit buffer converting
|
||||
// character case on the way.
|
||||
//
|
||||
|
||||
//
|
||||
// Is this a lower case character?
|
||||
//
|
||||
if((g_pui8USBRxBuffer[ui32ReadIndex] >= 'a') &&
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] <= 'z'))
|
||||
{
|
||||
//
|
||||
// Convert to upper case and write to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] - 'a') + 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Is this an upper case character?
|
||||
//
|
||||
if((g_pui8USBRxBuffer[ui32ReadIndex] >= 'A') &&
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] <= 'Z'))
|
||||
{
|
||||
//
|
||||
// Convert to lower case and write to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] - 'Z') + 'z';
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Copy the received character to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
g_pui8USBRxBuffer[ui32ReadIndex];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Move to the next character taking care to adjust the pointer for
|
||||
// the buffer wrap if necessary.
|
||||
//
|
||||
ui32WriteIndex++;
|
||||
ui32WriteIndex =
|
||||
(ui32WriteIndex == myUSB0_LIB_BULK_BUFFER_SIZE) ? 0 : ui32WriteIndex;
|
||||
|
||||
ui32ReadIndex++;
|
||||
ui32ReadIndex = (ui32ReadIndex == myUSB0_LIB_BULK_BUFFER_SIZE) ? 0 : ui32ReadIndex;
|
||||
|
||||
ui32Loop--;
|
||||
}
|
||||
|
||||
//
|
||||
// We've processed the data in place so now send the processed data
|
||||
// back to the host.
|
||||
//
|
||||
USBBufferDataWritten(&g_sTxBuffer, ui32Count);
|
||||
|
||||
DEBUG_PRINT("Wrote %d bytes\n", ui32Count);
|
||||
|
||||
//
|
||||
// We processed as much data as we can directly from the receive buffer so
|
||||
// we need to return the number of bytes to allow the lower layer to
|
||||
// update its read pointer appropriately.
|
||||
//
|
||||
return(ui32Count);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// TxHandler - Handles bulk driver notifications related to the transmit
|
||||
// channel (data to the USB host).
|
||||
//
|
||||
// \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
// \param ui32Event identifies the event we are being notified about.
|
||||
// \param ui32MsgValue is an event-specific value.
|
||||
// \param pvMsgData is an event-specific pointer.
|
||||
//
|
||||
// This function is called by the bulk driver to notify us of any events
|
||||
// related to operation of the transmit data channel (the IN channel carrying
|
||||
// data to the USB host).
|
||||
//
|
||||
// \return The return value is event-specific.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
TxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
|
||||
void *pvMsgData)
|
||||
{
|
||||
//
|
||||
// We are not required to do anything in response to any transmit event
|
||||
// in this example. All we do is update our transmit counter.
|
||||
//
|
||||
if(ui32Event == USB_EVENT_TX_COMPLETE)
|
||||
{
|
||||
g_ui32TxCount += ui32MsgValue;
|
||||
}
|
||||
|
||||
//
|
||||
// Dump a debug message.
|
||||
//
|
||||
DEBUG_PRINT("TX complete %d\n", ui32MsgValue);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Handles bulk driver notifications related to the receive channel (data from
|
||||
// the USB host).
|
||||
//
|
||||
// \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
// \param ui32Event identifies the event we are being notified about.
|
||||
// \param ui32MsgValue is an event-specific value.
|
||||
// \param pvMsgData is an event-specific pointer.
|
||||
//
|
||||
// This function is called by the bulk driver to notify us of any events
|
||||
// related to operation of the receive data channel (the OUT channel carrying
|
||||
// data from the USB host).
|
||||
//
|
||||
// \return The return value is event-specific.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
|
||||
void *pvMsgData)
|
||||
{
|
||||
//
|
||||
// Which event are we being sent?
|
||||
//
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// We are connected to a host and communication is now possible.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
g_bUSBConfigured = true;
|
||||
g_pcStatus = "Host connected.";
|
||||
g_ui32Flags |= COMMAND_STATUS_UPDATE;
|
||||
|
||||
//
|
||||
// Flush our buffers.
|
||||
//
|
||||
USBBufferFlush(&g_sTxBuffer);
|
||||
USBBufferFlush(&g_sRxBuffer);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The host has disconnected.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
g_bUSBConfigured = false;
|
||||
g_pcStatus = "Host disconn.";
|
||||
g_ui32Flags |= COMMAND_STATUS_UPDATE;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// A new packet has been received.
|
||||
//
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
tUSBDBulkDevice *psDevice;
|
||||
|
||||
//
|
||||
// Get a pointer to our instance data from the callback data
|
||||
// parameter.
|
||||
//
|
||||
psDevice = (tUSBDBulkDevice *)pvCBData;
|
||||
|
||||
//
|
||||
// Read the new packet and echo it back to the host.
|
||||
//
|
||||
return(EchoNewDataToHost(psDevice, pvMsgData, ui32MsgValue));
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore SUSPEND and RESUME for now.
|
||||
//
|
||||
case USB_EVENT_SUSPEND:
|
||||
case USB_EVENT_RESUME:
|
||||
break;
|
||||
|
||||
//
|
||||
// Ignore all other events and return 0.
|
||||
//
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called
|
||||
// before DEBUG_PRINT().
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
// ModeCallback - USB Mode callback
|
||||
//
|
||||
// \param ui32Index is the zero-based index of the USB controller making the
|
||||
// callback.
|
||||
// \param eMode indicates the new operating mode.
|
||||
//
|
||||
// This function is called by the USB library whenever an OTG mode change
|
||||
// occurs and, if a connection has been made, informs us of whether we are to
|
||||
// operate as a host or device.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ModeCallback(uint32_t ui32Index, tUSBMode eMode)
|
||||
{
|
||||
//
|
||||
// Save the new mode.
|
||||
//
|
||||
g_eCurrentUSBMode = eMode;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Main
|
||||
//
|
||||
//******************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
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();
|
||||
|
||||
|
||||
//
|
||||
// Initialize the transmit and receive buffers.
|
||||
//
|
||||
USBBufferInit(&g_sTxBuffer);
|
||||
USBBufferInit(&g_sRxBuffer);
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Configure the SCI for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
#endif
|
||||
|
||||
//
|
||||
// Not configured initially.
|
||||
//
|
||||
g_bUSBConfigured = false;
|
||||
|
||||
//
|
||||
// Enable the GPIO peripheral used for USB, and configure the USB
|
||||
// pins.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
|
||||
//
|
||||
// Register the interrupt handler for USB Interrupts.
|
||||
//
|
||||
//Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Show the application name on the display and SCI output.
|
||||
//
|
||||
DEBUG_PRINT("\nC2000 F2837xD Series USB bulk device example\n");
|
||||
DEBUG_PRINT("---------------------------------\n\n");
|
||||
|
||||
//USBStackModeSet(0, eUSBModeForceDevice, ModeCallback);
|
||||
|
||||
//
|
||||
// Pass our device information to the USB library and place the device
|
||||
// on the bus.
|
||||
//
|
||||
//USBDBulkInit(0, &g_sBulkDevice);
|
||||
|
||||
//
|
||||
// Enable global interrupts
|
||||
//
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Main application loop.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Nothing to do...everything happens in the interrupt context.
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Device interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0DeviceIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.deviceClasses = "Bulk";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.pfltQual.$name = "myGPIOQUAL2";
|
||||
usb1.epenQual.$name = "myGPIOQUAL3";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
|
||||
/**
|
||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||
* re-solve from scratch.
|
||||
*/
|
||||
usb1.usb.$suggestSolution = "USB0";
|
||||
@@ -0,0 +1,677 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex5_host_mouse.c
|
||||
//
|
||||
// TITLE: Main application code for the host mouse example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB HID Mouse Host </h1>
|
||||
//!
|
||||
//! This application demonstrates the handling of a USB mouse attached to the
|
||||
//! evaluation kit. Once attached, the position of the mouse pointer and the
|
||||
//! state of the mouse buttons are output to the display.
|
||||
//!
|
||||
//! SCIA, which is connected to the FTDI virtual serial port on the
|
||||
//! controlCARD board, is configured for 115200 bits per second, and 8-N-1
|
||||
//! mode. When a HID compliant mouse is connected to the microUSB port on the
|
||||
//! top of the controlCARD, position and button information will be displayed
|
||||
//! to the console.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhub.h"
|
||||
#include "host/usbhhidmouse.h"
|
||||
#include "scistdio.h"
|
||||
void INT_myUSB0_ISR(void);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The size of the host controller's memory pool in bytes.
|
||||
//
|
||||
//******************************************************************************
|
||||
//#define HCD_MEMORY_SIZE 128
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the Host controller driver.
|
||||
//
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The size of the mouse device interface's memory pool in bytes.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define MOUSE_MEMORY_SIZE 128
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the mouse device.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t g_pui8Buffer[MOUSE_MEMORY_SIZE];
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Declare the USB Events driver interface.
|
||||
//
|
||||
//******************************************************************************
|
||||
DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global that holds all of the host drivers in use in the application.
|
||||
// In this case, only the Mouse class is loaded.
|
||||
//
|
||||
//******************************************************************************
|
||||
static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
|
||||
{
|
||||
&g_sUSBHIDClassDriver,
|
||||
&g_sUSBEventDriver
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This global holds the number of class drivers in the g_ppHostClassDrivers
|
||||
// list.
|
||||
//
|
||||
//******************************************************************************
|
||||
static const uint32_t g_ui32NumHostClassDrivers =
|
||||
sizeof(g_ppHostClassDrivers) / sizeof(tUSBHostClassDriver *);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global value used to store the mouse instance value.
|
||||
//
|
||||
//******************************************************************************
|
||||
static tUSBHMouse *g_psMouseInstance;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global values used to store the mouse state.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t g_ui32Buttons;
|
||||
static int32_t g_i32CursorX;
|
||||
static int32_t g_i32CursorY;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The current USB operating mode - Host, Device or unknown.
|
||||
//
|
||||
//******************************************************************************
|
||||
tUSBMode g_eCurrentUSBMode;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumerated type is used to hold the states of the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
enum
|
||||
{
|
||||
//
|
||||
// No device is present.
|
||||
//
|
||||
STATE_NO_DEVICE,
|
||||
|
||||
//
|
||||
// Mouse has been detected and needs to be initialized in the main
|
||||
// loop.
|
||||
//
|
||||
STATE_MOUSE_INIT,
|
||||
|
||||
//
|
||||
// Mouse is connected and waiting for events.
|
||||
//
|
||||
STATE_MOUSE_CONNECTED,
|
||||
|
||||
//
|
||||
// An unsupported device has been attached.
|
||||
//
|
||||
STATE_UNKNOWN_DEVICE,
|
||||
|
||||
//
|
||||
// A power fault has occurred.
|
||||
//
|
||||
STATE_POWER_FAULT
|
||||
}
|
||||
g_eUSBState;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the generic callback from host stack.
|
||||
//
|
||||
// pvData is actually a pointer to a tEventInfo structure.
|
||||
//
|
||||
// This function will be called to inform the application when a USB event has
|
||||
// occurred that is outside those related to the mouse device. At this
|
||||
// point this is used to detect unsupported devices being inserted and removed.
|
||||
// It is also used to inform the application when a power fault has occurred.
|
||||
// This function is required when the g_USBGenericEventDriver is included in
|
||||
// the host controller driver array that is passed in to the
|
||||
// USBHCDRegisterDrivers() function.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
USBHCDEvents(void *pvData)
|
||||
{
|
||||
tEventInfo *pEventInfo;
|
||||
|
||||
//
|
||||
// Cast this pointer to its actual type.
|
||||
//
|
||||
pEventInfo = (tEventInfo *)pvData;
|
||||
|
||||
switch(pEventInfo->ui32Event)
|
||||
{
|
||||
//
|
||||
// New mouse detected.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// See if this is a HID Mouse.
|
||||
//
|
||||
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HID) &&
|
||||
(USBHCDDevProtocol(pEventInfo->ui32Instance, 0) ==
|
||||
USB_HID_PROTOCOL_MOUSE))
|
||||
{
|
||||
|
||||
//
|
||||
// Proceed to the STATE_MOUSE_INIT state so that the main loop
|
||||
// can finish initialized the mouse since USBHMouseInit()
|
||||
// cannot be called from within a callback.
|
||||
//
|
||||
g_eUSBState = STATE_MOUSE_INIT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Unsupported device detected.
|
||||
//
|
||||
case USB_EVENT_UNKNOWN_CONNECTED:
|
||||
{
|
||||
//
|
||||
// An unknown device was detected.
|
||||
//
|
||||
g_eUSBState = STATE_UNKNOWN_DEVICE;
|
||||
SCIprintf("Unknown Device Connected\n");
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Device has been unplugged.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
|
||||
//
|
||||
// Change the state so that the main loop knows that the device is
|
||||
// no longer present.
|
||||
//
|
||||
g_eUSBState = STATE_NO_DEVICE;
|
||||
SCIprintf("Device Disconnected\n");
|
||||
|
||||
//
|
||||
// Reset the button state.
|
||||
//
|
||||
g_ui32Buttons = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Power Fault has occurred.
|
||||
//
|
||||
case USB_EVENT_POWER_FAULT:
|
||||
{
|
||||
|
||||
//
|
||||
// No power means no device is present.
|
||||
//
|
||||
g_eUSBState = STATE_POWER_FAULT;
|
||||
SCIprintf("Power Fault\n");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// USB Mode callback
|
||||
//
|
||||
// \param ui32Index is the zero-based index of the USB controller making the
|
||||
// callback.
|
||||
// \param eMode indicates the new operating mode.
|
||||
//
|
||||
// This function is called by the USB library whenever an OTG mode change
|
||||
// occurs and, if a connection has been made, informs us of whether we are to
|
||||
// operate as a host or device.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ModeCallback(uint32_t ui32Index, tUSBMode eMode)
|
||||
{
|
||||
//
|
||||
// Save the new mode.
|
||||
//
|
||||
g_eCurrentUSBMode = eMode;
|
||||
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HID mouse handler.
|
||||
//
|
||||
// \param psMsInstance is ignored by this function.
|
||||
// \param ui32Event is one of the valid events for a mouse device.
|
||||
// \param ui32MsgParam is defined by the event that occurs.
|
||||
// \param pvMsgData is a pointer to data that is defined by the event that
|
||||
// occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a mouse has
|
||||
// been plugged in or removed and any time mouse movement or button pressed
|
||||
// is detected.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
MouseCallback(tUSBHMouse *psMsInstance, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
int32_t i32DoUpdate;
|
||||
volatile char pcBuffer[20];
|
||||
|
||||
//
|
||||
// Do an update unless there is no reason to.
|
||||
//
|
||||
i32DoUpdate = 1;
|
||||
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// Mouse button press detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_PRESS:
|
||||
{
|
||||
//
|
||||
// Save the new button that was pressed.
|
||||
//
|
||||
g_ui32Buttons |= ui32MsgParam;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse button release detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_REL:
|
||||
{
|
||||
//
|
||||
// Remove the button from the pressed state.
|
||||
//
|
||||
g_ui32Buttons &= ~ui32MsgParam;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse X movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_X:
|
||||
{
|
||||
//
|
||||
// The mouse returns a 8 bit signed value...check to see if we
|
||||
// need to sign extend
|
||||
//
|
||||
if(ui32MsgParam & 0x80)
|
||||
ui32MsgParam |= 0xFF00;
|
||||
//
|
||||
// Update the cursor X position.
|
||||
//
|
||||
g_i32CursorX += (int16_t)ui32MsgParam ;
|
||||
|
||||
//
|
||||
// Cap the value to not cause an overflow.
|
||||
//
|
||||
if(g_i32CursorX > 9999)
|
||||
{
|
||||
g_i32CursorX = 9999;
|
||||
}
|
||||
|
||||
if(g_i32CursorX < -9999)
|
||||
{
|
||||
g_i32CursorX = -9999;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Y movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_Y:
|
||||
{
|
||||
//
|
||||
// The mouse returns a 8 bit signed value...check to see if we
|
||||
// need to sign extend
|
||||
//
|
||||
if(ui32MsgParam & 0x80)
|
||||
ui32MsgParam |= 0xFF00;
|
||||
|
||||
//
|
||||
// Update the cursor Y position.
|
||||
//
|
||||
g_i32CursorY += (int16_t)ui32MsgParam;
|
||||
|
||||
//
|
||||
// Cap the value to not cause an overflow.
|
||||
//
|
||||
if(g_i32CursorY > 9999)
|
||||
{
|
||||
g_i32CursorY = 9999;
|
||||
}
|
||||
|
||||
if(g_i32CursorY < -9999)
|
||||
{
|
||||
g_i32CursorY = -9999;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//
|
||||
// No reason to update.
|
||||
//
|
||||
i32DoUpdate = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Display the current mouse position and button state if there was an
|
||||
// update.
|
||||
//
|
||||
if(i32DoUpdate)
|
||||
{
|
||||
//
|
||||
// Display the current mouse position and button state.
|
||||
//
|
||||
SCIprintf("\rPos: %l, %l Buttons: %l%l%l ", g_i32CursorX,
|
||||
g_i32CursorY, g_ui32Buttons & 1, (g_ui32Buttons & 2) >> 1,
|
||||
(g_ui32Buttons & 4) >> 2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called
|
||||
// before SCIprintf(). It configures the GPIO and initializes the SCI for
|
||||
// console I/O.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the main loop that runs the application.
|
||||
//
|
||||
//******************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
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();
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Configure the required pins for USB operation.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
|
||||
//
|
||||
// Register the interrupt handler for USB Interrupts.
|
||||
//
|
||||
//Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Configure the SCI for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
|
||||
SCIprintf("\033[2JHost Mouse Application\n");
|
||||
|
||||
//
|
||||
// Initially wait for device connection.
|
||||
//
|
||||
g_eUSBState = STATE_NO_DEVICE;
|
||||
|
||||
//
|
||||
// Initialize the USB stack mode and pass in a mode callback.
|
||||
//
|
||||
//USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
|
||||
|
||||
//
|
||||
// Register the host class drivers.
|
||||
//
|
||||
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
|
||||
|
||||
//
|
||||
// Initialized the cursor.
|
||||
//
|
||||
g_ui32Buttons = 0;
|
||||
g_i32CursorX = 0;
|
||||
g_i32CursorY = 0;
|
||||
|
||||
//
|
||||
// Open an instance of the mouse driver. The mouse does not need
|
||||
// to be present at this time, this just saves a place for it and allows
|
||||
// the applications to be notified when a mouse is present.
|
||||
//
|
||||
g_psMouseInstance =
|
||||
USBHMouseOpen(MouseCallback, g_pui8Buffer, MOUSE_MEMORY_SIZE);
|
||||
|
||||
//
|
||||
// Initialize the power configuration. This sets the power enable signal
|
||||
// to be active high and does not enable the power fault.
|
||||
//
|
||||
//USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
|
||||
|
||||
//
|
||||
// Initialize the USB controller for OTG operation with a 2ms polling
|
||||
// rate.
|
||||
//
|
||||
//USBHCDInit(0, g_pui8HCDPool, HCD_MEMORY_SIZE);
|
||||
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// The main loop for the application.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Run the main routine of the Host controller driver.
|
||||
//
|
||||
USBHCDMain();
|
||||
|
||||
switch(g_eUSBState)
|
||||
{
|
||||
//
|
||||
// This state is entered when the mouse is first detected.
|
||||
//
|
||||
case STATE_MOUSE_INIT:
|
||||
{
|
||||
//
|
||||
// Initialize the newly connected mouse.
|
||||
//
|
||||
USBHMouseInit(g_psMouseInstance);
|
||||
|
||||
//
|
||||
// Proceed to the mouse connected state.
|
||||
//
|
||||
g_eUSBState = STATE_MOUSE_CONNECTED;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_MOUSE_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Nothing is currently done in the main loop when the mouse
|
||||
// is connected.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_NO_DEVICE:
|
||||
{
|
||||
//
|
||||
// The mouse is not connected so nothing needs to be done here.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Host interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0HostIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.$assign = "USB0";
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.usb_mode = "Host";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.pfltQual.$name = "myGPIOQUAL2";
|
||||
usb1.epenQual.$name = "myGPIOQUAL3";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
@@ -0,0 +1,833 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: usb_ex6_host_keyboard.c
|
||||
//
|
||||
// TITLE: Main application code for the host keyboard example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB HID Keyboard Host </h1>
|
||||
//!
|
||||
//! This example application demonstrates how to support a USB keyboard
|
||||
//! attached to the evaluation kit board. The display will show if a keyboard
|
||||
//! is currently connected and the current state of the Caps Lock key on the
|
||||
//! keyboard that is connected on the bottom status area of the screen.
|
||||
//! Pressing any keys on the keyboard will cause them to be sent out the SCI
|
||||
//! at 115200 baud with no parity, 8 bits and 1 stop bit. Any keyboard that
|
||||
//! supports the USB HID BIOS protocol should work with this demo application.
|
||||
//!
|
||||
//! To run the example you should connect a HID compliant keyboard to the
|
||||
//! microUSB port on the top of the controlCARD and open up a serial terminal
|
||||
//! with the above settings to view the characters typed on the keyboard.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhidkeyboard.h"
|
||||
#include "scistdio.h"
|
||||
|
||||
|
||||
void INT_myUSB0_ISR(void);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The ASCII code for a backspace character.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define ASCII_BACKSPACE 0x08
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of the host controller's memory pool in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//#define HCD_MEMORY_SIZE 128
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the Host controller driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//uint8_t g_pui8HCDPool[HCD_MEMORY_SIZE];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of the keyboard device interface's memory pool in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYBOARD_MEMORY_SIZE 128
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the keyboard device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8Buffer[KEYBOARD_MEMORY_SIZE];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Declare the USB Events driver interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The global that holds all of the host drivers in use in the application.
|
||||
// In this case, only the Keyboard class is loaded.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
|
||||
{
|
||||
&g_sUSBHIDClassDriver,
|
||||
&g_sUSBEventDriver
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This global holds the number of class drivers in the g_ppHostClassDrivers
|
||||
// list.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static const uint32_t g_ui32NumHostClassDrivers =
|
||||
sizeof(g_ppHostClassDrivers) / sizeof(tUSBHostClassDriver *);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The global value used to store the keyboard instance value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHKeyboard *g_psKeyboardInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This enumerated type is used to hold the states of the keyboard.
|
||||
//
|
||||
//*****************************************************************************
|
||||
enum
|
||||
{
|
||||
//
|
||||
// No device is present.
|
||||
//
|
||||
STATE_NO_DEVICE,
|
||||
|
||||
//
|
||||
// Keyboard has been detected and needs to be initialized in the main
|
||||
// loop.
|
||||
//
|
||||
STATE_KEYBOARD_INIT,
|
||||
|
||||
//
|
||||
// Keyboard is connected and waiting for events.
|
||||
//
|
||||
STATE_KEYBOARD_CONNECTED,
|
||||
|
||||
//
|
||||
// Keyboard has received a key press that requires updating the keyboard
|
||||
// in the main loop.
|
||||
//
|
||||
STATE_KEYBOARD_UPDATE,
|
||||
|
||||
//
|
||||
// An unsupported device has been attached.
|
||||
//
|
||||
STATE_UNKNOWN_DEVICE,
|
||||
|
||||
//
|
||||
// A power fault has occurred.
|
||||
//
|
||||
STATE_POWER_FAULT
|
||||
}
|
||||
g_eUSBState;
|
||||
|
||||
extern const tHIDKeyboardUsageTable g_sUSKeyboardMap;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The current USB operating mode - Host, Device or unknown.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBMode g_eCurrentUSBMode;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These defines are used to define the screen constraints to the application.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DISPLAY_BANNER_HEIGHT 10
|
||||
#define DISPLAY_BANNER_BG ClrDarkBlue
|
||||
#define DISPLAY_TEXT_BORDER 2
|
||||
#define DISPLAY_TEXT_FG ClrWhite
|
||||
#define DISPLAY_TEXT_BG ClrBlack
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This variable holds the current status of the modifiers keys.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32Modifiers = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the number of characters that will fit on a line in the text area.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32CharsPerLine;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the number of lines that will fit in the text area.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32LinesPerScreen;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the current line for printing in the text area.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32Line = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the current column for printing in the text area.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32Column = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function prints the character out the SCI and into the text area of
|
||||
// the screen.
|
||||
//
|
||||
// \param cChar is the character to print out.
|
||||
//
|
||||
// This function handles all of the detail of printing a character to both the
|
||||
// SCI and to the text area of the screen on the evaluation board. The text
|
||||
// area of the screen will be cleared any time the text goes beyond the end
|
||||
// of the text area.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
PrintChar(const char cChar)
|
||||
{
|
||||
|
||||
//
|
||||
// Send the character to the SCI.
|
||||
//
|
||||
SCIprintf("%c", cChar);
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the generic callback from host stack.
|
||||
//
|
||||
// pvData is actually a pointer to a tEventInfo structure.
|
||||
//
|
||||
// This function will be called to inform the application when a USB event has
|
||||
// occurred that is outside those related to the keyboard device. At this
|
||||
// point this is used to detect unsupported devices being inserted and removed.
|
||||
// It is also used to inform the application when a power fault has occurred.
|
||||
// This function is required when the g_USBGenericEventDriver is included in
|
||||
// the host controller driver array that is passed in to the
|
||||
// USBHCDRegisterDrivers() function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBHCDEvents(void *pvData)
|
||||
{
|
||||
tEventInfo *pEventInfo;
|
||||
|
||||
//
|
||||
// Cast this pointer to its actual type.
|
||||
//
|
||||
pEventInfo = (tEventInfo *)pvData;
|
||||
|
||||
switch(pEventInfo->ui32Event)
|
||||
{
|
||||
//
|
||||
// New keyboard detected.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// See if this is a HID Keyboard.
|
||||
//
|
||||
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HID) &&
|
||||
(USBHCDDevProtocol(pEventInfo->ui32Instance, 0) ==
|
||||
USB_HID_PROTOCOL_KEYB))
|
||||
{
|
||||
//
|
||||
// Indicate that the keyboard has been detected.
|
||||
//
|
||||
SCIprintf("Keyboard Connected\n");
|
||||
|
||||
//
|
||||
// Proceed to the STATE_KEYBOARD_INIT state so that the main
|
||||
// loop can finish initialized the mouse since
|
||||
// USBHKeyboardInit() cannot be called from within a callback.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_INIT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Unsupported device detected.
|
||||
//
|
||||
case USB_EVENT_UNKNOWN_CONNECTED:
|
||||
{
|
||||
SCIprintf("Unsupported Device Class (0x%02x) Connected.\n",
|
||||
pEventInfo->ui32Instance);
|
||||
|
||||
//
|
||||
// An unknown device was detected.
|
||||
//
|
||||
g_eUSBState = STATE_UNKNOWN_DEVICE;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Device has been unplugged.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// Indicate that the device has been disconnected.
|
||||
//
|
||||
SCIprintf("Device Disconnected\n");
|
||||
|
||||
//
|
||||
// Change the state so that the main loop knows that the device
|
||||
// is no longer present.
|
||||
//
|
||||
g_eUSBState = STATE_NO_DEVICE;
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Power Fault occurred.
|
||||
//
|
||||
case USB_EVENT_POWER_FAULT:
|
||||
{
|
||||
SCIprintf("Power Fault\n");
|
||||
|
||||
//
|
||||
// No power means no device is present.
|
||||
//
|
||||
g_eUSBState = STATE_POWER_FAULT;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB Mode callback
|
||||
//
|
||||
// \param ui32Index is the zero-based index of the USB controller making the
|
||||
// callback.
|
||||
// \param eMode indicates the new operating mode.
|
||||
//
|
||||
// This function is called by the USB library whenever an OTG mode change
|
||||
// occurs and, if a connection has been made, informs us of whether we are to
|
||||
// operate as a host or device.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
ModeCallback(uint32_t ui32Index, tUSBMode eMode)
|
||||
{
|
||||
//
|
||||
// Save the new mode.
|
||||
//
|
||||
g_eCurrentUSBMode = eMode;
|
||||
|
||||
switch(eMode)
|
||||
{
|
||||
case eUSBModeHost:
|
||||
{
|
||||
SCIprintf("\nHost Mode.\n");
|
||||
break;
|
||||
}
|
||||
case eUSBModeDevice:
|
||||
{
|
||||
SCIprintf("\nDevice Mode.\n");
|
||||
break;
|
||||
}
|
||||
case eUSBModeNone:
|
||||
{
|
||||
SCIprintf("\nIdle Mode.\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
SCIprintf("ERROR: Bad Mode!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HID keyboard handler.
|
||||
//
|
||||
// \param psKbInstance is ignored by this function.
|
||||
// \param ui32Event is one of the valid events for a keyboard device.
|
||||
// \param ui32MsgParam is defined by the event that occurs.
|
||||
// \param pvMsgData is a pointer to data that is defined by the event that
|
||||
// occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a keyboard has
|
||||
// been plugged in or removed and any time a key is pressed or released.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
KeyboardCallback(tUSBHKeyboard *psKbInstance, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
char cChar;
|
||||
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// New Key press detected.
|
||||
//
|
||||
case USBH_EVENT_HID_KB_PRESS:
|
||||
{
|
||||
//
|
||||
// If this was a Caps Lock key then update the Caps Lock state.
|
||||
//
|
||||
if(ui32MsgParam == HID_KEYB_USAGE_CAPSLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Caps Lock
|
||||
// state.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_UPDATE;
|
||||
|
||||
//
|
||||
// Toggle the current Caps Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_CAPS_LOCK;
|
||||
|
||||
}
|
||||
else if(ui32MsgParam == HID_KEYB_USAGE_SCROLLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Scroll Lock
|
||||
// state.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_UPDATE;
|
||||
|
||||
//
|
||||
// Toggle the current Scroll Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_SCROLL_LOCK;
|
||||
}
|
||||
else if(ui32MsgParam == HID_KEYB_USAGE_NUMLOCK)
|
||||
{
|
||||
//
|
||||
// The main loop needs to update the keyboard's Scroll Lock
|
||||
// state.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_UPDATE;
|
||||
|
||||
//
|
||||
// Toggle the current Num Lock state.
|
||||
//
|
||||
g_ui32Modifiers ^= HID_KEYB_NUM_LOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Was this the backspace key?
|
||||
//
|
||||
if((uint8_t)ui32MsgParam == HID_KEYB_USAGE_BACKSPACE)
|
||||
{
|
||||
//
|
||||
// Yes - set the ASCII code for a backspace key. This is
|
||||
// not returned by USBHKeyboardUsageToChar since this only
|
||||
// returns printable characters.
|
||||
//
|
||||
cChar = ASCII_BACKSPACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// This is not backspace so try to map the usage code to a
|
||||
// printable ASCII character.
|
||||
//
|
||||
cChar = (char)
|
||||
USBHKeyboardUsageToChar(g_psKeyboardInstance,
|
||||
&g_sUSKeyboardMap,
|
||||
(uint8_t)ui32MsgParam);
|
||||
}
|
||||
|
||||
//
|
||||
// A zero value indicates there was no textual mapping of this
|
||||
// usage code.
|
||||
//
|
||||
if(cChar != 0)
|
||||
{
|
||||
PrintChar(cChar);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_HID_KB_MOD:
|
||||
{
|
||||
//
|
||||
// This application ignores the state of the shift or control
|
||||
// and other special keys.
|
||||
//
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_HID_KB_REL:
|
||||
{
|
||||
//
|
||||
// This applications ignores the release of keys as well.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore any other events.
|
||||
//
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called
|
||||
// before SCIprintf(). It configures the GPIO and initializes the SCI for
|
||||
// console I/O.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the main loop that runs the application.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
tUSBMode eLastMode;
|
||||
char *pcString;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
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();
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Initially wait for device connection.
|
||||
//
|
||||
g_eUSBState = STATE_NO_DEVICE;
|
||||
eLastMode = eUSBModeHost;
|
||||
g_eCurrentUSBMode = eUSBModeHost;
|
||||
|
||||
//
|
||||
// Configure the required pins for USB operation.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
|
||||
//
|
||||
// Register the interrupt handler for USB Interrupts.
|
||||
//
|
||||
//Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Enable Interrupts
|
||||
//
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Configure SCIA for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
|
||||
//
|
||||
// Initialize the USB stack mode and pass in a mode callback.
|
||||
//
|
||||
//USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
|
||||
|
||||
//
|
||||
// Register the host class drivers.
|
||||
//
|
||||
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
|
||||
|
||||
//
|
||||
// Open an instance of the keyboard driver. The keyboard does not need
|
||||
// to be present at this time, this just save a place for it and allows
|
||||
// the applications to be notified when a keyboard is present.
|
||||
//
|
||||
g_psKeyboardInstance = USBHKeyboardOpen(KeyboardCallback, g_pui8Buffer,
|
||||
KEYBOARD_MEMORY_SIZE);
|
||||
|
||||
//
|
||||
// Initialize the power configuration. This sets the power enable signal
|
||||
// to be active high and does not enable the power fault.
|
||||
//
|
||||
//USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
|
||||
|
||||
//
|
||||
// Initialize the USB controller for OTG operation with a 2ms polling
|
||||
// rate.
|
||||
//
|
||||
//USBHCDInit(0, g_pui8HCDPool, HCD_MEMORY_SIZE);
|
||||
|
||||
//
|
||||
// Open and instance of the keyboard class driver.
|
||||
//
|
||||
SCIprintf("Host Keyboard Application\n");
|
||||
|
||||
//
|
||||
// The main loop for the application.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Run the main routine of the Host controller driver.
|
||||
//
|
||||
USBHCDMain();
|
||||
|
||||
//
|
||||
// Has the USB mode changed since last time we checked?
|
||||
//
|
||||
if(g_eCurrentUSBMode != eLastMode)
|
||||
{
|
||||
//
|
||||
// Remember the new mode.
|
||||
//
|
||||
eLastMode = g_eCurrentUSBMode;
|
||||
|
||||
switch(eLastMode)
|
||||
{
|
||||
case eUSBModeHost:
|
||||
pcString = "HOST";
|
||||
break;
|
||||
|
||||
case eUSBModeDevice:
|
||||
pcString = "DEVICE";
|
||||
break;
|
||||
|
||||
case eUSBModeNone:
|
||||
pcString = "NONE";
|
||||
break;
|
||||
|
||||
default:
|
||||
pcString = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
SCIprintf("USB mode changed to %s\n", pcString);
|
||||
}
|
||||
|
||||
switch(g_eUSBState)
|
||||
{
|
||||
//
|
||||
// This state is entered when they keyboard is first detected.
|
||||
//
|
||||
case STATE_KEYBOARD_INIT:
|
||||
{
|
||||
//
|
||||
// Initialized the newly connected keyboard.
|
||||
//
|
||||
USBHKeyboardInit(g_psKeyboardInstance);
|
||||
|
||||
//
|
||||
// Proceed to the keyboard connected state.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_CONNECTED;
|
||||
|
||||
|
||||
|
||||
USBHKeyboardModifierSet(g_psKeyboardInstance, g_ui32Modifiers);
|
||||
|
||||
break;
|
||||
}
|
||||
case STATE_KEYBOARD_UPDATE:
|
||||
{
|
||||
//
|
||||
// If the application detected a change that required an
|
||||
// update to be sent to the keyboard to change the modifier
|
||||
// state then call it and return to the connected state.
|
||||
//
|
||||
g_eUSBState = STATE_KEYBOARD_CONNECTED;
|
||||
|
||||
USBHKeyboardModifierSet(g_psKeyboardInstance, g_ui32Modifiers);
|
||||
|
||||
break;
|
||||
}
|
||||
case STATE_KEYBOARD_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Nothing is currently done in the main loop when the keyboard
|
||||
// is connected.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_UNKNOWN_DEVICE:
|
||||
{
|
||||
//
|
||||
// Nothing to do as the device is unknown.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_NO_DEVICE:
|
||||
{
|
||||
//
|
||||
// Nothing is currently done in the main loop when the keyboard
|
||||
// is not connected.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore the other events.
|
||||
//
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Host interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0HostIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.$assign = "USB0";
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.usb_mode = "Host";
|
||||
usb1.usbLib.hostApplication = "Keyboard";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.$assign = "USB0";
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.usb_mode = "Host";
|
||||
usb1.usbLib.hostApplication = "Mass Storage";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
@@ -0,0 +1,68 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex8_descriptors.h
|
||||
//
|
||||
// TITLE: The USB descriptor information for this project.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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.
|
||||
// $
|
||||
//##############################################################################
|
||||
|
||||
#ifndef USB_EX8_DESCRIPTORS_H
|
||||
#define USB_EX8_DESCRIPTORS_H
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern uint32_t const g_ui32ReportDescriptorSize;
|
||||
extern uint8_t const g_pucReportDescriptor[];
|
||||
extern tDeviceInfo g_sMouseDeviceInfo;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern void HandleHIDDescriptor(uint32_t ui32Index,
|
||||
tUSBRequest *pUSBRequest);
|
||||
extern void HandleRequests(uint32_t ui32Index, tUSBRequest *pUSBRequest);
|
||||
extern void ConfigurationChange(uint32_t ui32Index, uint32_t ui32Info);
|
||||
extern void EP1Handler(uint32_t ui32Index, uint32_t ui32Status);
|
||||
extern void HandleReset(uint32_t ui32Index);
|
||||
extern void HandleDisconnect(uint32_t ui32Index);
|
||||
|
||||
#endif // USB_EX8_DESCRIPTORS_H
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,173 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex8_dev_mouse.c
|
||||
//
|
||||
// TITLE: Main routines for the mouse device.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "usb_structs.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "usb_ids.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidmouse.h"
|
||||
#include "scistdio.h"
|
||||
//#include "usb_ex8_mouse_structs.h"
|
||||
#include "usb_ex8_dual_detect.h"
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The incremental update for the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define MOUSE_MOVE_INC ((char)4)
|
||||
#define MOUSE_MOVE_DEC ((char)-4)
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Holds command bits used to signal the main loop to perform various tasks.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile uint32_t g_ui32Commands;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// A flag used to indicate whether or not we are currently connected to the USB
|
||||
// host.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile bool g_bConnected;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumeration holds the various states that the mouse can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
MOUSE_STATE_UNCONFIGURED,
|
||||
|
||||
//
|
||||
// No keys to send and not waiting on data.
|
||||
//
|
||||
MOUSE_STATE_IDLE,
|
||||
|
||||
//
|
||||
// Waiting on data to be sent out.
|
||||
//
|
||||
MOUSE_STATE_SENDING
|
||||
}
|
||||
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// MouseHandler - This function handles notification messages from the
|
||||
// mouse device driver.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
MouseHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
|
||||
void *pvMsgData)
|
||||
{
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// The USB host has connected to and configured the device.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
DEBUG_PRINT("Host connected.\n");
|
||||
g_eMouseState = MOUSE_STATE_IDLE;
|
||||
g_bConnected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The USB host has disconnected from the device.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
DEBUG_PRINT("Host disconnected.\n");
|
||||
g_bConnected = false;
|
||||
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// A report was sent to the host. We are now free to send another.
|
||||
//
|
||||
case USB_EVENT_TX_COMPLETE:
|
||||
{
|
||||
DEBUG_PRINT("TX complete.\n");
|
||||
g_eMouseState = MOUSE_STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This function initializes the mouse in device mode.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
DeviceStackInit(void)
|
||||
{
|
||||
//
|
||||
// Pass the USB library our device information, initialize the USB
|
||||
// controller and connect the device to the bus.
|
||||
//
|
||||
USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,315 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex8_dual_detect.c
|
||||
//
|
||||
// TITLE: Example to show how to switch USB operating modes on the fly.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> USB Dual Detect </h1>
|
||||
//!
|
||||
//! This program uses a GPIO to do ID detection. If a host is connected to
|
||||
//! the device's USB port, the stack will switch to device mode and enumerate
|
||||
//! as mouse. If a mouse device is connected to the device's USB port, the
|
||||
//! stack will switch to host mode and display the mouses movement and button
|
||||
//! press information in a serial terminal.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usb_structs.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidmouse.h"
|
||||
#include "host/usbhost.h"
|
||||
#ifdef DEBUG
|
||||
#include "scistdio.h"
|
||||
#endif
|
||||
#include "usb_ex8_descriptors.h"
|
||||
#include "usb_ex8_dual_detect.h"
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The current state of the USB in the system based on the detected mode.
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile tUSBMode g_eCurrentUSBMode = eUSBModeNone;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The saved number of clock ticks per millisecond.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t g_ui32ClockMS;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The size of the host controller's memory pool in bytes.
|
||||
//
|
||||
//******************************************************************************
|
||||
//#define HCD_MEMORY_SIZE 128
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the Host controller driver.
|
||||
//
|
||||
//******************************************************************************
|
||||
//unsigned char g_pHCDPool[HCD_MEMORY_SIZE];
|
||||
extern uint8_t g_pui8HCDPool[myUSB0_LIB_HCD_MEMORY_SIZE];
|
||||
//******************************************************************************
|
||||
//
|
||||
// This global is used to indicate to the main loop that a mode change has
|
||||
// occurred.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t g_ui32NewState;
|
||||
|
||||
extern tUSBDHIDMouseDevice g_sMouseDevice;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Callback function for mode changes.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ModeCallback(uint32_t ui32Index, tUSBMode eMode)
|
||||
{
|
||||
//
|
||||
// Save the new mode.
|
||||
//
|
||||
|
||||
g_eCurrentUSBMode = eMode;
|
||||
|
||||
switch(eMode)
|
||||
{
|
||||
case eUSBModeHost:
|
||||
{
|
||||
DEBUG_PRINT("\nHost Mode.\n");
|
||||
break;
|
||||
}
|
||||
case eUSBModeDevice:
|
||||
{
|
||||
DEBUG_PRINT("\nDevice Mode.\n");
|
||||
break;
|
||||
}
|
||||
case eUSBModeNone:
|
||||
{
|
||||
DEBUG_PRINT("\nIdle Mode.\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG_PRINT("ERROR: Bad Mode!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_ui32NewState = 1;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Configure the UART and its pins. This must be called before UARTprintf().
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI Rx pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI Tx pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200, SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Capture one sequence of DEVCTL register values during a session request.
|
||||
//
|
||||
//******************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uint8_t oldID = 2;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
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();
|
||||
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Configure the required pins for USB operation.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
Interrupt_register(INT_USBA, f28x_USB0DualModeIntHandler);
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Configure SCIA for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
SCIprintf("\033[2JDual Mode Detection Application\n");
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Determine the number of SysCtlDelay loops required to delay 1mS.
|
||||
//
|
||||
g_ui32ClockMS = SysCtl_getClock(DEVICE_OSCSRC_FREQ) / (3 * 1000);
|
||||
|
||||
//
|
||||
// Initialize the host stack.
|
||||
//
|
||||
HostStackInit();
|
||||
|
||||
//
|
||||
// Initialize the device stack.
|
||||
//
|
||||
DeviceStackInit();
|
||||
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Set the new state so that the screen updates on the first
|
||||
// pass.
|
||||
//
|
||||
g_ui32NewState = 1;
|
||||
|
||||
//
|
||||
// Loop forever.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
if(GPIO_readPin(47) != oldID)
|
||||
{
|
||||
oldID = GPIO_readPin(47);
|
||||
if(GPIO_readPin(47))
|
||||
{
|
||||
//
|
||||
// Device Mode
|
||||
// Kill the host mode
|
||||
//
|
||||
USBHCDTerm(0);
|
||||
|
||||
//
|
||||
// Force device and re-initialize the stack
|
||||
//
|
||||
USBStackModeSet(0, eUSBModeForceDevice, ModeCallback);
|
||||
|
||||
DeviceStackInit();
|
||||
g_eCurrentUSBMode = eUSBModeForceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Host Mode
|
||||
// Kill the Device mode
|
||||
//
|
||||
USBDHIDMouseTerm((tUSBDHIDMouseDevice *)&g_sMouseDevice);
|
||||
USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
|
||||
HostStackInit();
|
||||
USBHCDInit(0, g_pui8HCDPool, myUSB0_LIB_HCD_MEMORY_SIZE);
|
||||
g_eCurrentUSBMode = eUSBModeForceHost;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_eCurrentUSBMode == eUSBModeForceHost)
|
||||
{
|
||||
HostMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,83 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex8_dual_detect.h
|
||||
//
|
||||
// TITLE: The dual example application common definitions.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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.
|
||||
// $
|
||||
//##############################################################################
|
||||
|
||||
#ifndef USB_EX8_DUAL_DETECT_H
|
||||
#define USB_EX8_DUAL_DETECT_H
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Debug-related definitions and declarations.
|
||||
//
|
||||
// Debug output is available via SCIA if DEBUG is defined during build.
|
||||
//
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Map all debug print calls to SCIprintf in debug builds.
|
||||
//
|
||||
#define DEBUG_PRINT SCIprintf
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Compile out all debug print calls in release builds.
|
||||
//
|
||||
#define DEBUG_PRINT while(0) ((int (*)(char *, ...))0)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void HostStackInit(void);
|
||||
void HostMain(void);
|
||||
void DeviceStackInit(void);
|
||||
void DeviceMain(void);
|
||||
void UpdateStatus(char *pcString, uint32_t ui32Buttons, bool bClrGBg);
|
||||
void ClearMainWindow(void);
|
||||
|
||||
#endif // USB_EX8_DUAL_DETECT_H
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.$assign = "USB0";
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.usb_mode = "Dual";
|
||||
usb1.usbLib.deviceClasses = "Mouse";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
usb1.USBInt.interruptHandler = "f28x_USB0DualModeIntHandler";
|
||||
@@ -0,0 +1,438 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex8_host_mouse.c
|
||||
//
|
||||
// TITLE: Main application code for the host mouse example.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhhid.h"
|
||||
#include "host/usbhhidmouse.h"
|
||||
#ifdef DEBUG
|
||||
#include "scistdio.h"
|
||||
#endif
|
||||
#include "usb_ex8_dual_detect.h"
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The size of the mouse device interface's memory pool in bytes.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define MOUSE_MEMORY_SIZE 128
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The memory pool to provide to the mouse device.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t g_pui8Buffer[MOUSE_MEMORY_SIZE];
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Declare the USB Events driver interface.
|
||||
//
|
||||
//******************************************************************************
|
||||
DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global that holds all of the host drivers in use in the application.
|
||||
// In this case, only the Mouse class is loaded.
|
||||
//
|
||||
//******************************************************************************
|
||||
static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
|
||||
{
|
||||
&g_sUSBHIDClassDriver,
|
||||
&g_sUSBEventDriver
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This global holds the number of class drivers in the g_ppHostClassDrivers
|
||||
// list.
|
||||
//
|
||||
//******************************************************************************
|
||||
static const uint32_t g_ui32NumHostClassDrivers =
|
||||
sizeof(g_ppHostClassDrivers) / sizeof(tUSBHostClassDriver *);
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global value used to store the mouse instance value.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t g_ui32MouseInstance;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The global values used to store the mouse state.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t g_ui32Buttons;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This enumerated type is used to hold the states of the mouse.
|
||||
//
|
||||
//******************************************************************************
|
||||
enum
|
||||
{
|
||||
//
|
||||
// No device is present.
|
||||
//
|
||||
STATE_NO_DEVICE,
|
||||
|
||||
//
|
||||
// Mouse has been detected and needs to be initialized in the main
|
||||
// loop.
|
||||
//
|
||||
STATE_MOUSE_INIT,
|
||||
|
||||
//
|
||||
// Mouse is connected and waiting for events.
|
||||
//
|
||||
STATE_MOUSE_CONNECTED,
|
||||
|
||||
//
|
||||
// An unsupported device has been attached.
|
||||
//
|
||||
STATE_UNKNOWN_DEVICE,
|
||||
|
||||
//
|
||||
// A power fault has occurred.
|
||||
//
|
||||
STATE_POWER_FAULT
|
||||
}
|
||||
eUSBState;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the generic callback from host stack.
|
||||
//
|
||||
// \param pvData is actually a pointer to a tEventInfo structure.
|
||||
//
|
||||
// This function will be called to inform the application when a USB event has
|
||||
// occurred that is outside those related to the mouse device. At this
|
||||
// point this is used to detect unsupported devices being inserted and removed.
|
||||
// It is also used to inform the application when a power fault has occurred.
|
||||
// This function is required when the g_USBGenericEventDriver is included in
|
||||
// the host controller driver array that is passed in to the
|
||||
// USBHCDRegisterDrivers() function.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
USBHCDEvents(void *pvData)
|
||||
{
|
||||
tEventInfo *pEventInfo;
|
||||
|
||||
//
|
||||
// Cast this pointer to its actual type.
|
||||
//
|
||||
pEventInfo = (tEventInfo *)pvData;
|
||||
|
||||
switch(pEventInfo->ui32Event)
|
||||
{
|
||||
//
|
||||
// New mouse detected.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// See if this is a HID Mouse.
|
||||
//
|
||||
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HID) &&
|
||||
(USBHCDDevProtocol(pEventInfo->ui32Instance, 0) ==
|
||||
USB_HID_PROTOCOL_MOUSE))
|
||||
{
|
||||
//
|
||||
// Indicate that the mouse has been detected.
|
||||
//
|
||||
DEBUG_PRINT("Mouse Connected\n");
|
||||
|
||||
//
|
||||
// Proceed to the STATE_MOUSE_INIT state so that the main loop
|
||||
// can finish initialized the mouse since USBHMouseInit()
|
||||
// cannot be called from within a callback.
|
||||
//
|
||||
eUSBState = STATE_MOUSE_INIT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Unsupported detected.
|
||||
//
|
||||
case USB_EVENT_UNKNOWN_CONNECTED:
|
||||
{
|
||||
DEBUG_PRINT("Unsupported Device Connected\n");
|
||||
|
||||
//
|
||||
// An unknown device was detected.
|
||||
//
|
||||
eUSBState = STATE_UNKNOWN_DEVICE;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Device has been unplugged.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// Indicate that the mouse has been disconnected.
|
||||
//
|
||||
DEBUG_PRINT("Device Disconnected\n");
|
||||
|
||||
//
|
||||
// Change the state so that the main loop knows that the mouse is
|
||||
// no longer present.
|
||||
//
|
||||
eUSBState = STATE_NO_DEVICE;
|
||||
|
||||
//
|
||||
// Reset the button state.
|
||||
//
|
||||
g_ui32Buttons = 0;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Power Fault occurred.
|
||||
//
|
||||
case USB_EVENT_POWER_FAULT:
|
||||
{
|
||||
DEBUG_PRINT("Power Fault\n");
|
||||
|
||||
//
|
||||
// No power means no device is present.
|
||||
//
|
||||
eUSBState = STATE_POWER_FAULT;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the callback from the USB HID mouse handler.
|
||||
//
|
||||
// \param pvCBData is ignored by this function.
|
||||
// \param ui32Event is one of the valid events for a mouse device.
|
||||
// \param ui32MsgParam is defined by the event that occurs.
|
||||
// \param pvMsgData is a pointer to data that is defined by the event that
|
||||
// occurs.
|
||||
//
|
||||
// This function will be called to inform the application when a mouse has
|
||||
// been plugged in or removed and any time mouse movement or button pressed
|
||||
// is detected.
|
||||
//
|
||||
// \return This function will return 0.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
MouseCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam,
|
||||
void *pvMsgData)
|
||||
{
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// Mouse button press detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_PRESS:
|
||||
{
|
||||
DEBUG_PRINT("Button Pressed %02x\n", ui32MsgParam);
|
||||
|
||||
//
|
||||
// Save the new button that was pressed.
|
||||
//
|
||||
g_ui32Buttons |= ui32MsgParam;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse button release detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_REL:
|
||||
{
|
||||
DEBUG_PRINT("Button Released %02x\n", ui32MsgParam);
|
||||
|
||||
//
|
||||
// Remove the button from the pressed state.
|
||||
//
|
||||
g_ui32Buttons &= ~ui32MsgParam;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse X movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_X:
|
||||
{
|
||||
DEBUG_PRINT("X:%02d.\n", (uint8_t)ui32MsgParam);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Y movement detected.
|
||||
//
|
||||
case USBH_EVENT_HID_MS_Y:
|
||||
{
|
||||
DEBUG_PRINT("Y:%02d.\n", (uint8_t)ui32MsgParam);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Initialize the host mode stack.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
HostStackInit(void)
|
||||
{
|
||||
//
|
||||
// Register the host class drivers.
|
||||
//
|
||||
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);
|
||||
|
||||
//
|
||||
// Initialize the button states.
|
||||
//
|
||||
g_ui32Buttons = 0;
|
||||
|
||||
//
|
||||
// Open an instance of the mouse driver. The mouse does not need
|
||||
// to be present at this time, this just saves a place for it and allows
|
||||
// the applications to be notified when a mouse is present.
|
||||
//
|
||||
g_ui32MouseInstance =
|
||||
(uint32_t)USBHMouseOpen((tUSBHIDMouseCallback)MouseCallback,
|
||||
(uint8_t *)g_pui8Buffer,
|
||||
MOUSE_MEMORY_SIZE);
|
||||
|
||||
//
|
||||
// Initialize the power configuration. This sets the power enable signal
|
||||
// to be active high and does not enable the power fault.
|
||||
//
|
||||
USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
|
||||
|
||||
//
|
||||
// Call the main loop for the Host controller driver.
|
||||
//
|
||||
eUSBState = STATE_NO_DEVICE;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// This is the main loop that runs the application.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
HostMain(void)
|
||||
{
|
||||
switch(eUSBState)
|
||||
{
|
||||
//
|
||||
// This state is entered when the mouse is first detected.
|
||||
//
|
||||
case STATE_MOUSE_INIT:
|
||||
{
|
||||
//
|
||||
// Initialize the newly connected mouse.
|
||||
//
|
||||
USBHMouseInit((tUSBHMouse *)g_ui32MouseInstance);
|
||||
|
||||
//
|
||||
// Proceed to the mouse connected state.
|
||||
//
|
||||
eUSBState = STATE_MOUSE_CONNECTED;
|
||||
|
||||
break;
|
||||
}
|
||||
case STATE_MOUSE_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Nothing is currently done in the main loop when the mouse
|
||||
// is connected.
|
||||
//
|
||||
break;
|
||||
}
|
||||
case STATE_NO_DEVICE:
|
||||
{
|
||||
//
|
||||
// The mouse is not connected so nothing needs to be done here.
|
||||
//
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Periodically call the main loop for the Host controller driver.
|
||||
//
|
||||
USBHCDMain();
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,659 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_ex9_dev_bulk_throughput.c
|
||||
//
|
||||
// TITLE: Main routines for the generic bulk device example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>USB Throughput Bulk Device Example (usb_ex9_throughput_dev_bulk)</h1>
|
||||
//!
|
||||
//! This example provides a throughput numbers of bulk data transfer to and
|
||||
//! from the host. The device uses a vendor-specific class ID and supports
|
||||
//! a single bulk IN Endpoint and a single bulk OUT Endpoint.
|
||||
//!
|
||||
//! SCIA, connected to the FTDI virtual COM port and running at 115200,
|
||||
//! 8-N-1, is used to display messages from this application.
|
||||
//!
|
||||
//! A Windows INF file for the device is provided under the windows drivers
|
||||
//! directory. This INF contains information required to install the WinUSB
|
||||
//! subsystem on WindowsXP, Windows 7 and Windows 10. This is present in
|
||||
//! utilities/windows_drivers.
|
||||
//!
|
||||
//! A sample Windows command-line application, usb_throughput_bulk_example,
|
||||
//! illustrating how to connect to and communicate with the bulk device is
|
||||
//! also provided. Project files are included to allow the examples to be
|
||||
//! built using Microsoft VisualStudio. Source code for this application can
|
||||
//! be found in directory
|
||||
//! ~/C2000Ware/utilities/tools/usb_throughput_bulk_example/Release.
|
||||
//!
|
||||
//! After running the example in CCS Connect the USB Micro to the PC. Then the
|
||||
//! example will wait to receive data from the application. Run the
|
||||
//! usb_throughput_bulk example, the throughput and Data Packets Transferred.
|
||||
//!
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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 "usb_hal.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "usb_structs.h"
|
||||
#include "usblib.h"
|
||||
#include "usb_ids.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdbulk.h"
|
||||
#include "scistdio.h"
|
||||
//#include "usb_ex9_bulk_structs.h"
|
||||
|
||||
void INT_myUSB0_ISR(void);
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// The system tick rate expressed both as ticks per second and a millisecond
|
||||
// period.
|
||||
//
|
||||
#define TICKS_PER_SECOND 1000
|
||||
|
||||
#define COMMAND_PACKET_RECEIVED 0x00000001
|
||||
#define COMMAND_STATUS_UPDATE 0x00000002
|
||||
|
||||
//
|
||||
// Debug-related definitions and declarations.
|
||||
//
|
||||
// Debug output is available via SCIA if DEBUG is defined during build.
|
||||
//
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_PRINT SCIprintf // Map all debug print calls to SCIprintf in
|
||||
// debug builds.
|
||||
#else
|
||||
#define DEBUG_PRINT while(0) ((int32_t (*)(char *, ...))0) // Compile out all
|
||||
// debug print calls
|
||||
// in release builds
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//******************************************************************************
|
||||
volatile uint32_t g_ui32TickCount = 0; // The global system tick counter.
|
||||
volatile uint32_t g_ui32TxCount = 0;
|
||||
volatile uint32_t g_ui32RxCount = 0;
|
||||
tUSBMode g_eCurrentUSBMode; // The current USB operating mode - Host, Device
|
||||
// or unknown.
|
||||
volatile uint32_t g_ui32Flags = 0;
|
||||
char *g_pcStatus;
|
||||
static volatile bool g_bUSBConfigured = false; // Global flag indicating that a
|
||||
// USB configuration has been
|
||||
// set.
|
||||
|
||||
uint8_t g_bConnected = 0;
|
||||
uint8_t buffer[256];
|
||||
volatile uint32_t globalCounter = 0UL;
|
||||
volatile uint32_t idleCycles = 0UL;
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// CPUTimerIntHandler - Interrupt handler for the CPU Timer.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
CPUTimerIntHandler(void)
|
||||
{
|
||||
idleCycles = globalCounter * 100U;
|
||||
|
||||
globalCounter = 0UL;
|
||||
|
||||
//
|
||||
// Update our system tick counter.
|
||||
//
|
||||
g_ui32TickCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// EchoNewDataToHost - Receive new data and echo it back to the host.
|
||||
//
|
||||
// \param psDevice points to the instance data for the device whose data is to
|
||||
// be processed.
|
||||
// \param pi8Data points to the newly received data in the USB receive buffer.
|
||||
// \param ui32NumBytes is the number of bytes of data available to be processed.
|
||||
//
|
||||
// This function is called whenever we receive a notification that data is
|
||||
// available from the host. We read the data, byte-by-byte and swap the case
|
||||
// of any alphabetical characters found then write it back out to be
|
||||
// transmitted back to the host.
|
||||
//
|
||||
// \return Returns the number of bytes of data processed.
|
||||
//
|
||||
//******************************************************************************
|
||||
static uint32_t
|
||||
EchoNewDataToHost(tUSBDBulkDevice *psDevice, uint8_t *pi8Data,
|
||||
uint_fast32_t ui32NumBytes)
|
||||
{
|
||||
uint_fast32_t ui32Loop, ui32Space, ui32Count;
|
||||
uint_fast32_t ui32ReadIndex;
|
||||
uint_fast32_t ui32WriteIndex;
|
||||
tUSBRingBufObject sTxRing;
|
||||
|
||||
//
|
||||
// Get the current buffer information to allow us to write directly to
|
||||
// the transmit buffer (we already have enough information from the
|
||||
// parameters to access the receive buffer directly).
|
||||
//
|
||||
USBBufferInfoGet(&g_sTxBuffer, &sTxRing);
|
||||
|
||||
//
|
||||
// How much space is there in the transmit buffer?
|
||||
//
|
||||
ui32Space = USBBufferSpaceAvailable(&g_sTxBuffer);
|
||||
|
||||
//
|
||||
// How many characters can we process this time round?
|
||||
//
|
||||
ui32Loop = (ui32Space < ui32NumBytes) ? ui32Space : ui32NumBytes;
|
||||
ui32Count = ui32Loop;
|
||||
|
||||
//
|
||||
// Update our receive counter.
|
||||
//
|
||||
g_ui32RxCount += ui32NumBytes;
|
||||
|
||||
//
|
||||
// Dump a debug message.
|
||||
//
|
||||
DEBUG_PRINT("Received %d bytes\n", ui32NumBytes);
|
||||
|
||||
//
|
||||
// Set up to process the characters by directly accessing the USB buffers.
|
||||
//
|
||||
ui32ReadIndex = (uint32_t)(pi8Data - g_pui8USBRxBuffer);
|
||||
ui32WriteIndex = sTxRing.ui32WriteIndex;
|
||||
|
||||
while(ui32Loop)
|
||||
{
|
||||
//
|
||||
// Copy from the receive buffer to the transmit buffer converting
|
||||
// character case on the way.
|
||||
//
|
||||
|
||||
//
|
||||
// Is this a lower case character?
|
||||
//
|
||||
if((g_pui8USBRxBuffer[ui32ReadIndex] >= 'a') &&
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] <= 'z'))
|
||||
{
|
||||
//
|
||||
// Convert to upper case and write to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] - 'a') + 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Is this an upper case character?
|
||||
//
|
||||
if((g_pui8USBRxBuffer[ui32ReadIndex] >= 'A') &&
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] <= 'Z'))
|
||||
{
|
||||
//
|
||||
// Convert to lower case and write to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
(g_pui8USBRxBuffer[ui32ReadIndex] - 'Z') + 'z';
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Copy the received character to the transmit buffer.
|
||||
//
|
||||
g_pui8USBTxBuffer[ui32WriteIndex] =
|
||||
g_pui8USBRxBuffer[ui32ReadIndex];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Move to the next character taking care to adjust the pointer for
|
||||
// the buffer wrap if necessary.
|
||||
//
|
||||
ui32WriteIndex++;
|
||||
ui32WriteIndex =
|
||||
(ui32WriteIndex == myUSB0_LIB_BULK_BUFFER_SIZE) ? 0 : ui32WriteIndex;
|
||||
|
||||
ui32ReadIndex++;
|
||||
ui32ReadIndex = (ui32ReadIndex == myUSB0_LIB_BULK_BUFFER_SIZE) ? 0 : ui32ReadIndex;
|
||||
|
||||
ui32Loop--;
|
||||
}
|
||||
|
||||
//
|
||||
// We've processed the data in place so now send the processed data
|
||||
// back to the host.
|
||||
//
|
||||
USBBufferDataWritten(&g_sTxBuffer, ui32Count);
|
||||
|
||||
//
|
||||
// We processed as much data as we can directly from the receive buffer so
|
||||
// we need to return the number of bytes to allow the lower layer to
|
||||
// update its read pointer appropriately.
|
||||
//
|
||||
return(ui32Count);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// TxHandler - Handles bulk driver notifications related to the transmit
|
||||
// channel (data to the USB host).
|
||||
//
|
||||
// \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
// \param ui32Event identifies the event we are being notified about.
|
||||
// \param ui32MsgValue is an event-specific value.
|
||||
// \param pvMsgData is an event-specific pointer.
|
||||
//
|
||||
// This function is called by the bulk driver to notify us of any events
|
||||
// related to operation of the transmit data channel (the IN channel carrying
|
||||
// data to the USB host).
|
||||
//
|
||||
// \return The return value is event-specific.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
TxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
|
||||
void *pvMsgData)
|
||||
{
|
||||
//
|
||||
// Update the transmit counter.
|
||||
// Write the USB Bulk Data.
|
||||
//
|
||||
if(ui32Event == USB_EVENT_TX_COMPLETE)
|
||||
{
|
||||
g_ui32TxCount += ui32MsgValue;
|
||||
|
||||
uint32_t ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);
|
||||
if(ui32Space)
|
||||
{
|
||||
USBDBulkPacketWrite(&g_sBulkDevice, buffer, ui32Space, true);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Handles bulk driver notifications related to the receive channel (data from
|
||||
// the USB host).
|
||||
//
|
||||
// \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
// \param ui32Event identifies the event we are being notified about.
|
||||
// \param ui32MsgValue is an event-specific value.
|
||||
// \param pvMsgData is an event-specific pointer.
|
||||
//
|
||||
// This function is called by the bulk driver to notify us of any events
|
||||
// related to operation of the receive data channel (the OUT channel carrying
|
||||
// data from the USB host).
|
||||
//
|
||||
// \return The return value is event-specific.
|
||||
//
|
||||
//******************************************************************************
|
||||
uint32_t
|
||||
RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
|
||||
void *pvMsgData)
|
||||
{
|
||||
//
|
||||
// Which event are we being sent?
|
||||
//
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// We are connected to a host and communication is now possible.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
g_bUSBConfigured = true;
|
||||
g_pcStatus = "Host Connected.";
|
||||
g_ui32Flags |= COMMAND_STATUS_UPDATE;
|
||||
|
||||
//
|
||||
// Flush our buffers.
|
||||
//
|
||||
USBBufferFlush(&g_sTxBuffer);
|
||||
USBBufferFlush(&g_sRxBuffer);
|
||||
|
||||
g_bConnected = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The host has disconnected.
|
||||
//
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
g_bUSBConfigured = false;
|
||||
g_pcStatus = "Host Disconnected.";
|
||||
g_ui32Flags |= COMMAND_STATUS_UPDATE;
|
||||
g_bConnected = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// A new packet has been received.
|
||||
//
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
tUSBDBulkDevice *psDevice;
|
||||
|
||||
//
|
||||
// Get a pointer to our instance data from the callback data
|
||||
// parameter.
|
||||
//
|
||||
psDevice = (tUSBDBulkDevice *)pvCBData;
|
||||
|
||||
//
|
||||
// Read the new packet and echo it back to the host.
|
||||
//
|
||||
return(EchoNewDataToHost(psDevice, pvMsgData, ui32MsgValue));
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore SUSPEND and RESUME for now.
|
||||
//
|
||||
case USB_EVENT_SUSPEND:
|
||||
case USB_EVENT_RESUME:
|
||||
break;
|
||||
|
||||
//
|
||||
// Ignore all other events and return 0.
|
||||
//
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
//******************************************************************************
|
||||
//
|
||||
// ConfigureSCI - Configure the SCI and its pins. This must be called before
|
||||
// DEBUG_PRINT(). It configures the SCI GPIOs and the Console I/O.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ConfigureSCI(void)
|
||||
{
|
||||
//
|
||||
// GPIO28 is the SCI RX pin.
|
||||
//
|
||||
GPIO_setMasterCore(28, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_28_SCIRXDA);
|
||||
GPIO_setDirectionMode(28, GPIO_DIR_MODE_IN);
|
||||
GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// GPIO29 is the SCI TX pin.
|
||||
//
|
||||
GPIO_setMasterCore(29, GPIO_CORE_CPU1);
|
||||
GPIO_setPinConfig(GPIO_29_SCITXDA);
|
||||
GPIO_setDirectionMode(29, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(29, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setQualificationMode(29, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Initialize the SCI for console I/O.
|
||||
//
|
||||
SCIStdioConfig(SCIA_BASE, 115200,
|
||||
SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ));
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// ModeCallback - USB Mode callback
|
||||
//
|
||||
// \param ui32Index is the zero-based index of the USB controller making the
|
||||
// callback.
|
||||
// \param eMode indicates the new operating mode.
|
||||
//
|
||||
// This function is called by the USB library whenever an OTG mode change
|
||||
// occurs and, if a connection has been made, informs us of whether we are to
|
||||
// operate as a host or device.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//******************************************************************************
|
||||
void
|
||||
ModeCallback(uint32_t ui32Index, tUSBMode eMode)
|
||||
{
|
||||
//
|
||||
// Save the new mode.
|
||||
//
|
||||
g_eCurrentUSBMode = eMode;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Main
|
||||
//
|
||||
//******************************************************************************
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uint8_t index;
|
||||
volatile uint16_t firstPacket;
|
||||
unsigned long ui32Space;
|
||||
firstPacket = 1;
|
||||
|
||||
for(index = 0; index < 256; index++)
|
||||
{
|
||||
buffer[index] = index;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for USB.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize the transmit and receive buffers.
|
||||
//
|
||||
USBBufferInit(&g_sTxBuffer);
|
||||
USBBufferInit(&g_sRxBuffer);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set the clocking to run from the PLL at 60MHz
|
||||
//
|
||||
//SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
|
||||
Board_init();
|
||||
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Configure the SCI for debug output.
|
||||
//
|
||||
ConfigureSCI();
|
||||
#endif
|
||||
|
||||
//
|
||||
// Not configured initially.
|
||||
//
|
||||
g_bUSBConfigured = false;
|
||||
|
||||
//
|
||||
// Enable the GPIO peripheral used for USB, and configure the USB
|
||||
// pins.
|
||||
//
|
||||
USBGPIOEnable();
|
||||
Interrupt_register(INT_USBA, INT_myUSB0_ISR);
|
||||
|
||||
//
|
||||
// Register the CPU Timer interrupt handler.
|
||||
// This is used to calculate the CPU Utilization.
|
||||
//
|
||||
Interrupt_register(INT_TIMER0, &CPUTimerIntHandler);
|
||||
|
||||
CPUTimerInit();
|
||||
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE,
|
||||
(SysCtl_getClock(DEVICE_OSCSRC_FREQ) / TICKS_PER_SECOND));
|
||||
|
||||
//
|
||||
// Enable the CPU Timer interrupt.
|
||||
//
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Show the application name on the display and SCI output.
|
||||
//
|
||||
DEBUG_PRINT("\nC2000 F2837xD Series USB Throughput bulk device example\n");
|
||||
DEBUG_PRINT("---------------------------------\n\n");
|
||||
|
||||
|
||||
|
||||
//USBStackModeSet(0, eUSBModeForceDevice, ModeCallback);
|
||||
|
||||
//
|
||||
// Pass our device information to the USB library and place the device
|
||||
// on the bus.
|
||||
//
|
||||
//USBDBulkInit(0, &g_sBulkDevice);
|
||||
|
||||
//
|
||||
// Enable global interrupts
|
||||
//
|
||||
Interrupt_enableMaster();
|
||||
|
||||
//
|
||||
// Wait for the first packet to be received.
|
||||
//
|
||||
while(firstPacket)
|
||||
{
|
||||
if(g_bConnected)
|
||||
{
|
||||
//
|
||||
// How much space is there in the transmit buffer?
|
||||
//
|
||||
ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);
|
||||
|
||||
if(ui32Space)
|
||||
{
|
||||
USBDBulkPacketWrite(&g_sBulkDevice, buffer, ui32Space,
|
||||
true);
|
||||
}
|
||||
|
||||
firstPacket = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This is where USB interrupts will be taken.
|
||||
// Set up CPUTimer for 1ms with interrupt.
|
||||
// Count Number of cycles per loop iteration.
|
||||
// In CPUTimer interrupt multiply cycle count by counter to find Number
|
||||
// cycles idle in 1ms.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
|
||||
//
|
||||
// Loop iteration should be 100 cycles
|
||||
//
|
||||
globalCounter++;
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
__asm(" RPT #10 || NOP");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Device interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
INT_myUSB0_ISR(void)
|
||||
{
|
||||
USB0DeviceIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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 "F2837xD" --package "F2837xD_100PTP" --part "F2837xD_100PTP" --product "C2000WARE@4.02.00.00"
|
||||
* @versions {"tool":"1.13.0+2411"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const usb = scripting.addModule("/driverlib/usb.js", {}, false);
|
||||
const usb1 = usb.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
usb1.$name = "myUSB0";
|
||||
usb1.registerInterrupts = true;
|
||||
usb1.usb.usbdmPin.$assign = "ball.73";
|
||||
usb1.usb.usbdpPin.$assign = "ball.74";
|
||||
usb1.usbLib.deviceClasses = "Bulk";
|
||||
usb1.dmQual.$name = "myGPIOQUAL0";
|
||||
usb1.dpQual.$name = "myGPIOQUAL1";
|
||||
usb1.USBInt.enableInterrupt = true;
|
||||
|
||||
/**
|
||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||
* re-solve from scratch.
|
||||
*/
|
||||
usb1.usb.$suggestSolution = "USB0";
|
||||
@@ -0,0 +1,158 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_hal.c
|
||||
//
|
||||
// TITLE: Wrapper for interrupt functions and USB support pins.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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.
|
||||
// $
|
||||
//##############################################################################
|
||||
|
||||
//
|
||||
// Include Files.
|
||||
//
|
||||
#include "usb_hal.h"
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! \addtogroup c2000_specific
|
||||
//! @{
|
||||
//
|
||||
//******************************************************************************
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Enables USB related GPIOs to perform their USB function.
|
||||
//
|
||||
//******************************************************************************
|
||||
void USBGPIOEnable(void)
|
||||
{
|
||||
//
|
||||
// Set the USB DM and DP.
|
||||
//
|
||||
GPIO_setMasterCore(42, GPIO_CORE_CPU1);
|
||||
GPIO_setAnalogMode(42, GPIO_ANALOG_ENABLED);
|
||||
GPIO_setMasterCore(43, GPIO_CORE_CPU1);
|
||||
GPIO_setAnalogMode(43, GPIO_ANALOG_ENABLED);
|
||||
|
||||
//
|
||||
// Set the direction for VBUS.
|
||||
//
|
||||
GPIO_setMasterCore(46, GPIO_CORE_CPU1);
|
||||
GPIO_setDirectionMode(46, GPIO_DIR_MODE_IN);
|
||||
|
||||
//
|
||||
// Set the direction for ID.
|
||||
//
|
||||
GPIO_setMasterCore(47, GPIO_CORE_CPU1);
|
||||
GPIO_setDirectionMode(47, GPIO_DIR_MODE_IN);
|
||||
|
||||
GPIO_setMasterCore(120, GPIO_CORE_CPU1);
|
||||
GPIO_setDirectionMode(120, GPIO_DIR_MODE_IN);
|
||||
|
||||
GPIO_setMasterCore(121, GPIO_CORE_CPU1);
|
||||
GPIO_setDirectionMode(121, GPIO_DIR_MODE_OUT);
|
||||
GPIO_writePin(121, 1);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Configure the CPU Timer.
|
||||
//
|
||||
//******************************************************************************
|
||||
void CPUTimerInit(void)
|
||||
{
|
||||
//
|
||||
// Initialize timer period to maximum.
|
||||
//
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE,0xFFFFFFFF);
|
||||
|
||||
//
|
||||
// Initialize Pre-scale counter to divide by 1.
|
||||
//
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0U);
|
||||
|
||||
//
|
||||
// Make sure timer is stopped.
|
||||
//
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Reload all counter register with period value:
|
||||
//
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
}
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Wrapper function to implement mS based delay for USB functions
|
||||
//
|
||||
//******************************************************************************
|
||||
void USBDelay(uint32_t ui32Delay)
|
||||
{
|
||||
DEVICE_DELAY_US(ui32Delay*1000);
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Dual mode interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
f28x_USB0DualModeIntHandler(void)
|
||||
{
|
||||
USB0DualModeIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
//! Dual mode interrupt service routine wrapper to make ISR compatible with
|
||||
//! C2000 PIE controller.
|
||||
//
|
||||
//******************************************************************************
|
||||
__interrupt void
|
||||
f28x_USB0OTGModeIntHandler(void)
|
||||
{
|
||||
USB0OTGModeIntHandler();
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Close the c2000_specific Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//******************************************************************************
|
||||
@@ -0,0 +1,101 @@
|
||||
//##############################################################################
|
||||
//
|
||||
// FILE: usb_hal.h
|
||||
//
|
||||
// TITLE: Compatability layer for ported software.
|
||||
//
|
||||
//##############################################################################
|
||||
//
|
||||
//
|
||||
// $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.
|
||||
// $
|
||||
//##############################################################################
|
||||
|
||||
#ifndef USB_HAL_H
|
||||
#define USB_HAL_H
|
||||
|
||||
//******************************************************************************
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//******************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "usblib.h"
|
||||
#include "usblibpriv.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhostpriv.h"
|
||||
#include "usblibpriv.h"
|
||||
|
||||
//
|
||||
// Defines.
|
||||
//
|
||||
|
||||
//
|
||||
// Define to pass to SysCtl_setAuxClock(). Will configure the clock as follows:
|
||||
// AUXPLLCLK =
|
||||
// 20MHz (XTAL_OSC) * 12 (IMULT) / (4 (SYSDIV) )
|
||||
//
|
||||
#define DEVICE_AUXSETCLOCK_CFG_USB (SYSCTL_OSCSRC_XTAL | SYSCTL_PLL_ENABLE |\
|
||||
SYSCTL_IMULT(12) | SYSCTL_SYSDIV(4))
|
||||
|
||||
//******************************************************************************
|
||||
//! \addtogroup c2000_specific
|
||||
//! @{
|
||||
//******************************************************************************
|
||||
extern void USBGPIOEnable(void);
|
||||
extern void CPUTimerInit(void);
|
||||
extern void USBDelay(uint32_t ui32Delay);
|
||||
extern void f28x_USB0DualModeIntHandler(void);
|
||||
extern void f28x_USB0OTGModeIntHandler(void);
|
||||
|
||||
//******************************************************************************
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//******************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//******************************************************************************
|
||||
|
||||
#endif // USB_HAL_H
|
||||
Reference in new issue
Block a user