From 9d28ed19595b839aa98d7e5d85ca99dbbbdd18e3 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Fri, 20 Dec 2019 08:09:08 -0800 Subject: [PATCH 01/13] added usb test project for seed. --- .../seed/tests/SeedUSB_CDC/Makefile | 14 + .../SeedUSB_CDC-Debug.vgdbsettings | 130 +++ .../SeedUSB_CDC-Release.vgdbsettings | 124 +++ .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 43 + .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.sln | 39 + .../tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj | 319 +++++++ .../SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters | 796 ++++++++++++++++++ .../seed/tests/SeedUSB_CDC/stm32.props | 34 + .../seed/tests/SeedUSB_CDC/stm32.xml | 53 ++ .../tests/SeedUSB_CDC/stm32h7xx_hal_conf.h | 465 ++++++++++ .../seed/tests/SeedUSB_CDC/system_stm32h7xx.c | 365 ++++++++ 11 files changed, 2382 insertions(+) create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/Makefile create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Release.vgdbsettings create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.sln create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h create mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/Makefile b/hardware_platforms/seed/tests/SeedUSB_CDC/Makefile new file mode 100644 index 000000000..2eb53a3c9 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/Makefile @@ -0,0 +1,14 @@ +# Project Name +TARGET = ex_SeedUSB_CDC + +# Sources +CPP_SOURCES = SeedUSB_CDC.cpp + +# Library Locations +LIBDAISY_DIR = ../../../../libdaisy +DAISYSP_DIR = ../../../../daisysp + +# Core location, and generic makefile. +SYSTEM_FILES_DIR = ../../../../core +include $(SYSTEM_FILES_DIR)/Makefile + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings new file mode 100644 index 000000000..6e526c42e --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings @@ -0,0 +1,130 @@ + + + Debug + + + + MinGWUnixSlash + $(ToolchainDir) + + $(ProjectDir) + false + stm32.xml + + + + + 0 + + + SeedUSB_CDC.vcxproj + + + + 1 + true + + + + + + + + + + + + + Default + + + + true + + + + + Unknown + + true + true + true + + + + false + + + VisualGDB\VisualGDBCache + + + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + main + true + false + false + false + 0 + + + com.sysprogs.arm.openocd + + -f interface/stlink.cfg -f target/stm32h7x.cfg -c init -c "reset init" + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon halt + mon reset init + load + + false + 0 + 0 + + + true + Auto + 0 + false + false + true + false + false + + _estack + 0 + false + true + + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Release.vgdbsettings b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Release.vgdbsettings new file mode 100644 index 000000000..43c4ab3a3 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Release.vgdbsettings @@ -0,0 +1,124 @@ + + + Release + + + + MinGWUnixSlash + $(ToolchainDir) + + $(ProjectDir) + false + stm32.xml + + + + + 0 + + + SeedUSB_CDC.vcxproj + 0 + true + + + + + + + + + + + + + Default + + + + true + + + + Unknown + + true + true + true + + + + false + + + VisualGDB\VisualGDBCache + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + main + true + false + false + false + 0 + + + com.sysprogs.arm.openocd + + -f interface/stlink.cfg -f target/stm32h7x.cfg -c init -c "reset init" + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon halt + mon reset init + load + + false + 0 + 0 + + + true + Auto + 0 + false + false + true + false + false + + _estack + 0 + false + true + + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp new file mode 100644 index 000000000..dd64baa46 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -0,0 +1,43 @@ +#include +#include "daisy_seed.h" +#include "daisysp.h" +#include + +// 1MB test +#define TEST_BUFF_SIZE (1024 * 1024) + +using namespace daisy; +using namespace daisysp; + +static uint32_t DSY_SDRAM_BSS test_buff[TEST_BUFF_SIZE]; + +static daisy_handle hw; +static uint32_t start, end, dur; + + +void passthru(float *in, float *out, size_t size) +{ + memcpy(out, in, sizeof(float) * size); +} + +int main(void) +{ + // Initialize Hardware + daisy_seed_init(&hw); + for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + { + test_buff[i] = i; + } + for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + { + if(test_buff[i] != i) + { + asm("bkpt 255"); + } + } + dsy_tim_start(); + dsy_audio_set_callback(DSY_AUDIO_INTERNAL, passthru); + dsy_audio_start(DSY_AUDIO_INTERNAL); + while(1) {} +} + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.sln b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.sln new file mode 100644 index 000000000..fd9087fca --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29102.190 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SeedUSB_CDC", "SeedUSB_CDC.vcxproj", "{EA625EAA-7C64-4842-AE4B-E618D4BD7D8F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B41DDCEC-68B1-473A-BD7B-774476F0115A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdaisy", "..\..\..\..\libdaisy\libdaisy.vcxproj", "{1B07A9D3-1E1B-488A-9817-4B13EECA191C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "daisysp", "..\..\..\..\daisysp\daisysp.vcxproj", "{44F4AEA3-A6B2-4F03-9C28-34B2336BDF57}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|VisualGDB = Debug|VisualGDB + Release|VisualGDB = Release|VisualGDB + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EA625EAA-7C64-4842-AE4B-E618D4BD7D8F}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {EA625EAA-7C64-4842-AE4B-E618D4BD7D8F}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {EA625EAA-7C64-4842-AE4B-E618D4BD7D8F}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {EA625EAA-7C64-4842-AE4B-E618D4BD7D8F}.Release|VisualGDB.Build.0 = Release|VisualGDB + {1B07A9D3-1E1B-488A-9817-4B13EECA191C}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {1B07A9D3-1E1B-488A-9817-4B13EECA191C}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {1B07A9D3-1E1B-488A-9817-4B13EECA191C}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {1B07A9D3-1E1B-488A-9817-4B13EECA191C}.Release|VisualGDB.Build.0 = Release|VisualGDB + {44F4AEA3-A6B2-4F03-9C28-34B2336BDF57}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {44F4AEA3-A6B2-4F03-9C28-34B2336BDF57}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {44F4AEA3-A6B2-4F03-9C28-34B2336BDF57}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {44F4AEA3-A6B2-4F03-9C28-34B2336BDF57}.Release|VisualGDB.Build.0 = Release|VisualGDB + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5ACB48A9-9162-4D61-926D-FF1C67B99779} + EndGlobalSection +EndGlobal diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj new file mode 100644 index 000000000..03fceb154 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj @@ -0,0 +1,319 @@ + + + + + Debug + VisualGDB + + + Release + VisualGDB + + + + 16.0 + {EA625EAA-7C64-4842-AE4B-E618D4BD7D8F} + com.sysprogs.arm.stm32 + 2019.06 + + + + + $(ProjectDir)stm32.props + + + $(ProjectDir)stm32.props + + + + + + + + + Debug + com.sysprogs.gnuarm.arm-eabi + 8.3.1/8.0/r1 + + + com.sysprogs.gnuarm.arm-eabi + 8.3.1/8.0/r1 + + + + ../../../../libdaisy/src;../../../../daisysp;%(ClCompile.AdditionalIncludeDirectories) + DEBUG=1;%(ClCompile.PreprocessorDefinitions) + + + ;%(Link.AdditionalLinkerInputs) + ;%(Link.LibrarySearchDirectories) + ;%(Link.AdditionalLibraryNames) + ../../../../core/STM32H750IB_flash.lds + + + + + {44f4aea3-a6b2-4f03-9c28-34b2336bdf57} + + + {1b07a9d3-1e1b-488a-9817-4b13eeca191c} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters new file mode 100644 index 000000000..52cb0a607 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters @@ -0,0 +1,796 @@ + + + + + {5deeb07d-87af-49cb-9aad-48fb1cfc98ab} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {bf198600-7ecf-4ab6-a1e7-4d6600362747} + h;hpp;hxx;hm;inl;inc;xsd + + + {2ebd8dd6-d993-40a7-8a64-4bfb52493486} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {a721619a-0742-48a6-b0ef-ae86a7abbed8} + + + {7886524c-98a2-4b06-b7f3-09467f97bd96} + + + {5bf0492d-4c24-4d9b-9d32-6194517f3979} + + + {9e5cbf8d-b54b-4d86-973a-a227ce867304} + + + {21e62c5f-c549-4eda-acbd-f865c43893bf} + + + {29c145a4-ef83-48c0-bee3-e479c05df77e} + + + {7bea5beb-13d9-430e-94ad-356e88ca36b3} + + + + + Source files + + + Source files + + + Source files\Device-specific files + + + Source files\Device-specific files + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\HAL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Source files\Device-specific files\LL + + + Header files + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\HAL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + Header files\Device-specific files\LL + + + VisualGDB settings + + + VisualGDB settings + + + VisualGDB settings + + + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props new file mode 100644 index 000000000..aedc4146b --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props @@ -0,0 +1,34 @@ + + + + + + + ARM_MATH_CM7;flash_layout;CORE_CM7;STM32H750IB;STM32H750xx;%(ClCompile.PreprocessorDefinitions) + %(ClCompile.AdditionalIncludeDirectories);$(ProjectDir);$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc;$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc/Legacy;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Device/ST/STM32H7xx/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/RTOS2/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Core/Include + + + + + $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds + --specs=nano.specs --specs=nosys.specs %(Link.AdditionalOptions) + + + + $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds + + + + + cortex-m7 + THUMB + fpv4-sp-d16 + hard + + + diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml new file mode 100644 index 000000000..862470b64 --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml @@ -0,0 +1,53 @@ + + + com.sysprogs.gnuarm.arm-eabi + + 8.3.1 + 8.0 + 1 + + com.sysprogs.arm.stm32 + 2019.06 + STM32H750IB + STM32H7xxxx/DeviceDefinitions/stm32h750xx.xml + + + + com.sysprogs.bspoptions.primary_memory + flash + + + com.sysprogs.bspoptions.arm.floatmode + -mfloat-abi=hard + + + com.sysprogs.mcuoptions.ignore_startup_file + + + com.sysprogs.toolchainoptions.arm.libctype + --specs=nano.specs + + + com.sysprogs.toolchainoptions.arm.syscallspecs + --specs=nosys.specs + + + + Device-specific files + stm32.mak + + com.sysprogs.arm.stm32.hal + com.sysprogs.arm.stm32.ll + + + + + com.sysprogs.bspoptions.stm32.ll_driver + + + + + + + + \ No newline at end of file diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h new file mode 100644 index 000000000..72ea21cde --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h @@ -0,0 +1,465 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32h7xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_CONF_H +#define STM32H7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_COMP_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FDCAN_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_HRTIM_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_OPAMP_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RAMECC_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SWPMI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */ + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 ((uint8_t)0x02) +#define ETH_MAC_ADDR1 ((uint8_t)0x00) +#define ETH_MAC_ADDR2 ((uint8_t)0x00) +#define ETH_MAC_ADDR3 ((uint8_t)0x00) +#define ETH_MAC_ADDR4 ((uint8_t)0x00) +#define ETH_MAC_ADDR5 ((uint8_t)0x00) + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED + #include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED + #include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED + #include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED + #include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED + #include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED + #include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c b/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c new file mode 100644 index 000000000..9daeefbaa --- /dev/null +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c @@ -0,0 +1,365 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32h7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** @addtogroup STM32H7xx_System_Private_Includes + * @{ + */ + +#include "stm32h7xx.h" +#include +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ +/* #define DATA_IN_D2_SRAM */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 64000000; + uint32_t SystemD2Clock = 64000000; + const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting and vector table location + * configuration. + * @param None + * @retval None + */ +void SystemInit (void) +{ +#if defined (DATA_IN_D2_SRAM) + __IO uint32_t tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= RCC_CR_HSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON , CSION,RC48ON, CSIKERON PLL1ON, PLL2ON and PLL3ON bits */ + RCC->CR &= 0xEAF6ED7FU; + + /* Reset D1CFGR register */ + RCC->D1CFGR = 0x00000000; + + /* Reset D2CFGR register */ + RCC->D2CFGR = 0x00000000; + + /* Reset D3CFGR register */ + RCC->D3CFGR = 0x00000000; + + /* Reset PLLCKSELR register */ + RCC->PLLCKSELR = 0x00000000; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x00000000; + /* Reset PLL1DIVR register */ + RCC->PLL1DIVR = 0x00000000; + /* Reset PLL1FRACR register */ + RCC->PLL1FRACR = 0x00000000; + + /* Reset PLL2DIVR register */ + RCC->PLL2DIVR = 0x00000000; + + /* Reset PLL2FRACR register */ + + RCC->PLL2FRACR = 0x00000000; + /* Reset PLL3DIVR register */ + RCC->PLL3DIVR = 0x00000000; + + /* Reset PLL3FRACR register */ + RCC->PLL3FRACR = 0x00000000; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000; + +#if defined (DATA_IN_D2_SRAM) + /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock ((AHB SRAM clock) */ +#if defined(RCC_AHB2ENR_D2SRAM1EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); +#else + RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); +#endif /* RCC_AHB2ENR_D2SRAM1EN */ + + tmpreg = RCC->AHB2ENR; + (void) tmpreg; +#endif /* DATA_IN_D2_SRAM */ + +#if defined(DUAL_CORE) && defined(CORE_CM4) + /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = D2_AHBSRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif /* VECT_TAB_SRAM */ + +#else + /* dual core CM7 or single core line */ + if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) + { + /* if stm32h7 revY*/ + /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ + *((__IO uint32_t*)0x51008108) = 0x000000001U; + } + + /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D1 AXI-RAM */ +#else + SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif + +#endif /*DUAL_CORE && CORE_CM4*/ + +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock , it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), + * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. + * + * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 64 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; + float_t fracn1, pllvco; + + /* Get SYSCLK source -------------------------------------------------------*/ + + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ + SystemCoreClock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + + case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ + SystemCoreClock = CSI_VALUE; + break; + + case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); + pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; + pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); + fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); + + if (pllm != 0U) + { + switch (pllsource) + { + case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ + + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + + break; + + case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ + pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + default: + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + } + pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; + SystemCoreClock = (uint32_t)(float_t)(pllvco/(float_t)pllp); + } + else + { + SystemCoreClock = 0U; + } + break; + + default: + SystemCoreClock = CSI_VALUE; + break; + } + + /* Compute SystemClock frequency --------------------------------------------------*/ + tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; + + /* SystemCoreClock frequency : CM7 CPU frequency */ + SystemCoreClock >>= tmp; + + /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ + SystemD2Clock = (SystemCoreClock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); + +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 21c160fe7bf55a193444c776b039b51c5957bedc Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Fri, 20 Dec 2019 09:56:31 -0800 Subject: [PATCH 02/13] added files for USB, and made an usb handle class --- .clang-format | 15 +- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 18 +- libdaisy/libdaisy.vcxproj | 23 +- libdaisy/libdaisy.vcxproj.filters | 45 ++ libdaisy/src/hid_usb.cpp | 89 ++ libdaisy/src/hid_usb.h | 68 ++ libdaisy/src/usbd_cdc_if.c | 475 +++++++++++ libdaisy/src/usbd_cdc_if.h | 133 +++ libdaisy/src/usbd_conf.c | 758 ++++++++++++++++++ libdaisy/src/usbd_conf.h | 170 ++++ libdaisy/src/usbd_desc.c | 598 ++++++++++++++ libdaisy/src/usbd_desc.h | 147 ++++ 12 files changed, 2521 insertions(+), 18 deletions(-) create mode 100644 libdaisy/src/hid_usb.cpp create mode 100644 libdaisy/src/hid_usb.h create mode 100644 libdaisy/src/usbd_cdc_if.c create mode 100644 libdaisy/src/usbd_cdc_if.h create mode 100644 libdaisy/src/usbd_conf.c create mode 100644 libdaisy/src/usbd_conf.h create mode 100644 libdaisy/src/usbd_desc.c create mode 100644 libdaisy/src/usbd_desc.h diff --git a/.clang-format b/.clang-format index 7ee7fa5a8..0b35236be 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,10 @@ --- AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: 'true' -AlignConsecutiveDeclarations: 'true' +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true AlignEscapedNewlinesLeft: 'true' -AlignOperands: 'true' -AlignTrailingComments: 'true' +AlignOperands: true +AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: 'false' AllowShortBlocksOnASingleLine: 'true' AllowShortCaseLabelsOnASingleLine: 'true' @@ -29,7 +29,7 @@ IndentWrappedFunctionNames: 'false' KeepEmptyLinesAtTheStartOfBlocks: 'false' Language: Cpp MaxEmptyLinesToKeep: '2' -NamespaceIndentation: All +NamespaceIndentation: Inner ReflowComments: 'false' SpaceAfterCStyleCast: 'false' SpaceBeforeAssignmentOperators: 'true' @@ -40,7 +40,7 @@ SpacesInContainerLiterals: 'false' SpacesInParentheses: 'false' SpacesInSquareBrackets: 'false' Standard: Cpp11 -UseTab: Always +UseTab: Never TabWidth: 4 SortIncludes: false AccessModifierOffset: -2 @@ -61,6 +61,5 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyNamespace: false SplitEmptyRecord: false -BreakBeforeBraces: Custom +BreakBeforeBraces: Allman BreakBeforeBinaryOperators: All -... diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index dd64baa46..ac03469f5 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -12,7 +12,7 @@ using namespace daisysp; static uint32_t DSY_SDRAM_BSS test_buff[TEST_BUFF_SIZE]; static daisy_handle hw; -static uint32_t start, end, dur; +static uint32_t start, end, dur; void passthru(float *in, float *out, size_t size) @@ -24,13 +24,14 @@ int main(void) { // Initialize Hardware daisy_seed_init(&hw); - for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + // Test RAM + for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) { test_buff[i] = i; } - for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) { - if(test_buff[i] != i) + if(test_buff[i] != i) { asm("bkpt 255"); } @@ -38,6 +39,11 @@ int main(void) dsy_tim_start(); dsy_audio_set_callback(DSY_AUDIO_INTERNAL, passthru); dsy_audio_start(DSY_AUDIO_INTERNAL); - while(1) {} -} + uint32_t hello_count = 0; + while(1) + { + dsy_tim_delay_ms(500); + + } +} diff --git a/libdaisy/libdaisy.vcxproj b/libdaisy/libdaisy.vcxproj index cf4a4727b..b63661216 100644 --- a/libdaisy/libdaisy.vcxproj +++ b/libdaisy/libdaisy.vcxproj @@ -43,7 +43,7 @@ - src;%(ClCompile.AdditionalIncludeDirectories) + src;Middlewares/ST/STM32_USB_Device_Library/Core/Inc;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;%(ClCompile.AdditionalIncludeDirectories) DEBUG=1;__FPU_PRESENT=1;%(ClCompile.PreprocessorDefinitions) Og @@ -51,9 +51,9 @@ - ;%(Link.AdditionalLinkerInputs) - ;%(Link.LibrarySearchDirectories) - ;%(Link.AdditionalLibraryNames) + %(Link.AdditionalLinkerInputs) + %(Link.LibrarySearchDirectories) + %(Link.AdditionalLibraryNames) ../core/STM32H750IB_flash.lds @@ -74,6 +74,9 @@ + + + @@ -83,6 +86,7 @@ + @@ -93,6 +97,13 @@ + + + + + + + @@ -112,6 +123,7 @@ + @@ -123,6 +135,9 @@ + + + diff --git a/libdaisy/libdaisy.vcxproj.filters b/libdaisy/libdaisy.vcxproj.filters index 9d3300b03..63531b69a 100644 --- a/libdaisy/libdaisy.vcxproj.filters +++ b/libdaisy/libdaisy.vcxproj.filters @@ -875,6 +875,30 @@ Header files + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + @@ -934,6 +958,27 @@ Source files + + Source files + + + Source files + + + Source files + + + Source files + + + Source files + + + Source files + + + Source files + diff --git a/libdaisy/src/hid_usb.cpp b/libdaisy/src/hid_usb.cpp new file mode 100644 index 000000000..ed7b80556 --- /dev/null +++ b/libdaisy/src/hid_usb.cpp @@ -0,0 +1,89 @@ +#include "hid_usb.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_cdc.h" +#include "usbd_cdc_if.h" + +using namespace daisy; + +static void UsbErrorHandler(); + +// Globals from Cube generated version: +USBD_HandleTypeDef hUsbDeviceHS; +USBD_HandleTypeDef hUsbDeviceFS; + +static void InitFS() +{ + if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) + != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + UsbErrorHandler(); + } +} + +static void InitHS() +{ + // HS as FS + if(USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_RegisterClass(&hUsbDeviceHS, &USBD_CDC) != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_CDC_RegisterInterface(&hUsbDeviceHS, &USBD_Interface_fops_HS) + != USBD_OK) + { + UsbErrorHandler(); + } + if(USBD_Start(&hUsbDeviceHS) != USBD_OK) + { + UsbErrorHandler(); + } +} + + +void UsbHandle::Init(UsbPeriph dev) +{ + switch(dev) + { + case FS_INTERNAL: InitFS(); break; + case FS_EXTERNAL: InitHS(); break; + case FS_BOTH: + InitFS(); + InitHS(); + break; + default: break; + } + // Enable USB Regulator + HAL_PWREx_EnableUSBVoltageDetector(); +} + +void UsbHandle::TransmitInternal(uint8_t* buff, size_t size) +{ + CDC_Transmit_FS(buff, size); +} +void UsbHandle::TransmitExternal(uint8_t* buff, size_t size) +{ + CDC_Transmit_HS(buff, size); +} + + +// Static Function Implementation +static void UsbErrorHandler() +{ + while(1) {} +} diff --git a/libdaisy/src/hid_usb.h b/libdaisy/src/hid_usb.h new file mode 100644 index 000000000..2db086981 --- /dev/null +++ b/libdaisy/src/hid_usb.h @@ -0,0 +1,68 @@ +// # hid_usb +// ## Description +// Interface for initializing and using the USB Peripherals on the daisy +// ## Credits +// +// **Author:** Stephen Hensley +// +// **Date Added:** December 2019 +// +#pragma once +#ifndef DSY_HID_USB_H +#define DSY_HID_USB_H +#include +#include +namespace daisy +{ +class UsbHandle +{ + public: +// ## Data Types +// ### UsbPeriph +// Specified which of the two USB Peripherals to initialize. +// +// FS External D- pin is Pin 37 (GPIO31) +// +// FS External D+ pin is Pin 38 (GPIO32) +// + enum UsbPeriph + { +// ~~~~ + FS_INTERNAL, + FS_EXTERNAL, + FS_BOTH, +// ~~~~ + }; + + UsbHandle() {} + + ~UsbHandle() {} + +// ## General Functions +// ### Init +// Initializes the specified peripheral(s) as USB CDC Devices +// ~~~~ + void Init(UsbPeriph dev); +// ~~~~ + +// ### TransmitInternal +// Transmits a buffer of 'size' bytes from the on board USB FS port. +// ~~~~ + void TransmitInternal(uint8_t* buff, size_t size); +// ~~~~ + +// ### Init +// Transmits a buffer of 'size' bytes from a USB port connected to the +// external USB Pins of the daisy seed. +// ~~~~ + void TransmitExternal(uint8_t* buff, size_t size); +// ~~~~ + + private: +}; + +} // namespace daisy +#endif + +// TODO: +// - Add Support for other USB classes (currently only CDC is supported) diff --git a/libdaisy/src/usbd_cdc_if.c b/libdaisy/src/usbd_cdc_if.c new file mode 100644 index 000000000..d30e87db0 --- /dev/null +++ b/libdaisy/src/usbd_cdc_if.c @@ -0,0 +1,475 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_cdc_if.c + * @version : v1.0_Cube + * @brief : Usb device for Virtual Com Port. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_cdc_if.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @brief Usb device library. + * @{ + */ + +/** @addtogroup USBD_CDC_IF + * @{ + */ + +/** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines + * @brief Private defines. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_DEFINES */ +/* Define size for the receive and transmit buffer over CDC */ +/* It's up to user to redefine and/or remove those define */ +#define APP_RX_DATA_SIZE 2048 +#define APP_TX_DATA_SIZE 2048 +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables + * @brief Private variables. + * @{ + */ +/* Create buffer for reception and transmission */ +/* It's up to user to redefine and/or remove those define */ +/** Received data over USB are stored in this buffer */ +uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; + +/** Data to send over USB CDC are stored in this buffer */ +uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; + +/* Create buffer for reception and transmission */ +/* It's up to user to redefine and/or remove those define */ +/** Received data over USB are stored in this buffer */ +uint8_t UserRxBufferHS[APP_RX_DATA_SIZE]; + +/** Data to send over USB CDC are stored in this buffer */ +uint8_t UserTxBufferHS[APP_TX_DATA_SIZE]; + +/* USER CODE BEGIN PRIVATE_VARIABLES */ + +/* USER CODE END PRIVATE_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables + * @brief Public variables. + * @{ + */ + +extern USBD_HandleTypeDef hUsbDeviceFS; + +extern USBD_HandleTypeDef hUsbDeviceHS; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static int8_t CDC_Init_FS(void); +static int8_t CDC_DeInit_FS(void); +static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); +static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); + +static int8_t CDC_Init_HS(void); +static int8_t CDC_DeInit_HS(void); +static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length); +static int8_t CDC_Receive_HS(uint8_t* pbuf, uint32_t *Len); + +/* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ + +/* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */ + +/** + * @} + */ + +USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = +{ + CDC_Init_FS, + CDC_DeInit_FS, + CDC_Control_FS, + CDC_Receive_FS +}; + +USBD_CDC_ItfTypeDef USBD_Interface_fops_HS = +{ + CDC_Init_HS, + CDC_DeInit_HS, + CDC_Control_HS, + CDC_Receive_HS +}; + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Initializes the CDC media low layer over the FS USB IP + * @retval USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Init_FS(void) +{ + /* USER CODE BEGIN 3 */ + /* Set Application Buffers */ + USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); + USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); + return (USBD_OK); + /* USER CODE END 3 */ +} + +/** + * @brief DeInitializes the CDC media low layer + * @retval USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_DeInit_FS(void) +{ + /* USER CODE BEGIN 4 */ + return (USBD_OK); + /* USER CODE END 4 */ +} + +/** + * @brief Manage the CDC class requests + * @param cmd: Command code + * @param pbuf: Buffer containing command data (request parameters) + * @param length: Number of data to be sent (in bytes) + * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) +{ + /* USER CODE BEGIN 5 */ + switch(cmd) + { + case CDC_SEND_ENCAPSULATED_COMMAND: + + break; + + case CDC_GET_ENCAPSULATED_RESPONSE: + + break; + + case CDC_SET_COMM_FEATURE: + + break; + + case CDC_GET_COMM_FEATURE: + + break; + + case CDC_CLEAR_COMM_FEATURE: + + break; + + /*******************************************************************************/ + /* Line Coding Structure */ + /*-----------------------------------------------------------------------------*/ + /* Offset | Field | Size | Value | Description */ + /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ + /* 4 | bCharFormat | 1 | Number | Stop bits */ + /* 0 - 1 Stop bit */ + /* 1 - 1.5 Stop bits */ + /* 2 - 2 Stop bits */ + /* 5 | bParityType | 1 | Number | Parity */ + /* 0 - None */ + /* 1 - Odd */ + /* 2 - Even */ + /* 3 - Mark */ + /* 4 - Space */ + /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ + /*******************************************************************************/ + case CDC_SET_LINE_CODING: + + break; + + case CDC_GET_LINE_CODING: + + break; + + case CDC_SET_CONTROL_LINE_STATE: + + break; + + case CDC_SEND_BREAK: + + break; + + default: + break; + } + + return (USBD_OK); + /* USER CODE END 5 */ +} + +/** + * @brief Data received over USB OUT endpoint are sent over CDC interface + * through this function. + * + * @note + * This function will block any OUT packet reception on USB endpoint + * untill exiting this function. If you exit this function before transfer + * is complete on CDC interface (ie. using DMA controller) it will result + * in receiving more data while previous ones are still not sent. + * + * @param Buf: Buffer of data to be received + * @param Len: Number of data received (in bytes) + * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) +{ + /* USER CODE BEGIN 6 */ + USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); + USBD_CDC_ReceivePacket(&hUsbDeviceFS); + return (USBD_OK); + /* USER CODE END 6 */ +} + +/** + * @brief CDC_Transmit_FS + * Data to send over USB IN endpoint are sent over CDC interface + * through this function. + * @note + * + * + * @param Buf: Buffer of data to be sent + * @param Len: Number of data to be sent (in bytes) + * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY + */ +uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) +{ + uint8_t result = USBD_OK; + /* USER CODE BEGIN 7 */ + USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; + if (hcdc->TxState != 0){ + return USBD_BUSY; + } + USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); + result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); + /* USER CODE END 7 */ + return result; +} + +/** + * @brief Initializes the CDC media low layer over the USB HS IP + * @retval USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Init_HS(void) +{ + /* USER CODE BEGIN 8 */ + /* Set Application Buffers */ + USBD_CDC_SetTxBuffer(&hUsbDeviceHS, UserTxBufferHS, 0); + USBD_CDC_SetRxBuffer(&hUsbDeviceHS, UserRxBufferHS); + return (USBD_OK); + /* USER CODE END 8 */ +} + +/** + * @brief DeInitializes the CDC media low layer + * @param None + * @retval USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_DeInit_HS(void) +{ + /* USER CODE BEGIN 9 */ + return (USBD_OK); + /* USER CODE END 9 */ +} + +/** + * @brief Manage the CDC class requests + * @param cmd: Command code + * @param pbuf: Buffer containing command data (request parameters) + * @param length: Number of data to be sent (in bytes) + * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length) +{ + /* USER CODE BEGIN 10 */ + switch(cmd) + { + case CDC_SEND_ENCAPSULATED_COMMAND: + + break; + + case CDC_GET_ENCAPSULATED_RESPONSE: + + break; + + case CDC_SET_COMM_FEATURE: + + break; + + case CDC_GET_COMM_FEATURE: + + break; + + case CDC_CLEAR_COMM_FEATURE: + + break; + + /*******************************************************************************/ + /* Line Coding Structure */ + /*-----------------------------------------------------------------------------*/ + /* Offset | Field | Size | Value | Description */ + /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ + /* 4 | bCharFormat | 1 | Number | Stop bits */ + /* 0 - 1 Stop bit */ + /* 1 - 1.5 Stop bits */ + /* 2 - 2 Stop bits */ + /* 5 | bParityType | 1 | Number | Parity */ + /* 0 - None */ + /* 1 - Odd */ + /* 2 - Even */ + /* 3 - Mark */ + /* 4 - Space */ + /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ + /*******************************************************************************/ + case CDC_SET_LINE_CODING: + + break; + + case CDC_GET_LINE_CODING: + + break; + + case CDC_SET_CONTROL_LINE_STATE: + + break; + + case CDC_SEND_BREAK: + + break; + + default: + break; + } + + return (USBD_OK); + /* USER CODE END 10 */ +} + +/** + * @brief Data received over USB OUT endpoint are sent over CDC interface + * through this function. + * + * @note + * This function will block any OUT packet reception on USB endpoint + * untill exiting this function. If you exit this function before transfer + * is complete on CDC interface (ie. using DMA controller) it will result + * in receiving more data while previous ones are still not sent. + * + * @param Buf: Buffer of data to be received + * @param Len: Number of data received (in bytes) + * @retval USBD_OK if all operations are OK else USBD_FAIL + */ +static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len) +{ + /* USER CODE BEGIN 11 */ + USBD_CDC_SetRxBuffer(&hUsbDeviceHS, &Buf[0]); + USBD_CDC_ReceivePacket(&hUsbDeviceHS); + return (USBD_OK); + /* USER CODE END 11 */ +} + +/** + * @brief Data to send over USB IN endpoint are sent over CDC interface + * through this function. + * @param Buf: Buffer of data to be sent + * @param Len: Number of data to be sent (in bytes) + * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY + */ +uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len) +{ + uint8_t result = USBD_OK; + /* USER CODE BEGIN 12 */ + USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceHS.pClassData; + if (hcdc->TxState != 0){ + return USBD_BUSY; + } + USBD_CDC_SetTxBuffer(&hUsbDeviceHS, Buf, Len); + result = USBD_CDC_TransmitPacket(&hUsbDeviceHS); + /* USER CODE END 12 */ + return result; +} + +/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ + +/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/src/usbd_cdc_if.h b/libdaisy/src/usbd_cdc_if.h new file mode 100644 index 000000000..af0e5a084 --- /dev/null +++ b/libdaisy/src/usbd_cdc_if.h @@ -0,0 +1,133 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_cdc_if.h + * @version : v1.0_Cube + * @brief : Header for usbd_cdc_if.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CDC_IF_H__ +#define __USBD_CDC_IF_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_cdc.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @brief For Usb device. + * @{ + */ + +/** @defgroup USBD_CDC_IF USBD_CDC_IF + * @brief Usb VCP device module + * @{ + */ + +/** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines + * @brief Defines. + * @{ + */ +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** CDC Interface callback. */ +extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; +/** CDC Interface callback. */ +extern USBD_CDC_ItfTypeDef USBD_Interface_fops_HS; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); +uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len); + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CDC_IF_H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/src/usbd_conf.c b/libdaisy/src/usbd_conf.c new file mode 100644 index 000000000..a5ab99851 --- /dev/null +++ b/libdaisy/src/usbd_conf.c @@ -0,0 +1,758 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +PCD_HandleTypeDef hpcd_USB_OTG_HS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_EP1_OUT_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_FS_EP1_OUT_IRQn); + HAL_NVIC_SetPriority(OTG_FS_EP1_IN_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_FS_EP1_IN_IRQn); + HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } + else if(pcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_HS_EP1_OUT_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_HS_EP1_OUT_IRQn); + HAL_NVIC_SetPriority(OTG_HS_EP1_IN_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_HS_EP1_IN_IRQn); + HAL_NVIC_SetPriority(OTG_HS_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_EP1_OUT_IRQn); + + HAL_NVIC_DisableIRQ(OTG_FS_EP1_IN_IRQn); + + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } + else if(pcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_HS_EP1_OUT_IRQn); + + HAL_NVIC_DisableIRQ(OTG_HS_EP1_IN_IRQn); + + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 9; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); + } + if (pdev->id == DEVICE_HS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; + + hpcd_USB_OTG_HS.Instance = USB_OTG_HS; + hpcd_USB_OTG_HS.Init.dev_endpoints = 9; + hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_HS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE; + hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; + hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_HS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_HS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} + +/** + * @brief Delays routine for the USB device library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/src/usbd_conf.h b/libdaisy/src/usbd_conf.h new file mode 100644 index 000000000..a4dc56dd1 --- /dev/null +++ b/libdaisy/src/usbd_conf.h @@ -0,0 +1,170 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 1U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_SUPPORT_USER_STRING 0U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros */ + +/** Alias for memory allocation. */ +#define USBD_malloc malloc + +/** Alias for memory release. */ +#define USBD_free free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/src/usbd_desc.c b/libdaisy/src/usbd_desc.c new file mode 100644 index 000000000..91ca84780 --- /dev/null +++ b/libdaisy/src/usbd_desc.c @@ -0,0 +1,598 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 1155 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Electrosmith" +#define USBD_PID_HS 22336 +#define USBD_PRODUCT_STRING_HS "Daisy Seed Virtual ComPort" +#define USBD_CONFIGURATION_STRING_HS "CDC Config" +#define USBD_INTERFACE_STRING_HS "CDC Interface" +#define USBD_PID_FS 22336 +#define USBD_PRODUCT_STRING_FS "Daisy Seed Virtual ComPort" +#define USBD_CONFIGURATION_STRING_FS "CDC Config" +#define USBD_INTERFACE_STRING_FS "CDC Interface" + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +#ifdef USBD_SUPPORT_USER_STRING_DESC +uint8_t * USBD_FS_USRStringDesc(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length); +#endif /* USBD_SUPPORT_USER_STRING_DESC */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x02, /*bDeviceClass*/ + 0x02, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for HS. + * @{ + */ + +uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +#ifdef USBD_SUPPORT_USER_STRING_DESC +uint8_t * USBD_HS_USRStringDesc(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length); +#endif /* USBD_SUPPORT_USER_STRING_DESC */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef HS_Desc = +{ + USBD_HS_DeviceDescriptor +, USBD_HS_LangIDStrDescriptor +, USBD_HS_ManufacturerStrDescriptor +, USBD_HS_ProductStrDescriptor +, USBD_HS_SerialStrDescriptor +, USBD_HS_ConfigStrDescriptor +, USBD_HS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + + 0x02, + 0x02, /*bDeviceClass*/ + 0x02, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_HS), /*idProduct*/ + HIBYTE(USBD_PID_HS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_HS_DeviceDesc); + return USBD_HS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer + */ +uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +#if (USBD_LPM_ENABLED == 1) +/** + * @brief Return the BOS descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_HS_BOSDesc); + return (uint8_t*)USBD_HS_BOSDesc; +} +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/src/usbd_desc.h b/libdaisy/src/usbd_desc.h new file mode 100644 index 000000000..255f6d250 --- /dev/null +++ b/libdaisy/src/usbd_desc.h @@ -0,0 +1,147 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef HS_Desc; +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 38d087075ee83013b3df6532f0af44ec62d2fe8e Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Fri, 20 Dec 2019 14:08:16 -0800 Subject: [PATCH 03/13] usb shows up correctly with Makefile, but not with VS. And I can't get a serial console to open for either --- .../SeedUSB_CDC-Debug.vgdbsettings | 82 +- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 192 ++- .../tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj | 250 +--- .../SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters | 746 +----------- .../seed/tests/SeedUSB_CDC/stm32.props | 6 +- .../seed/tests/SeedUSB_CDC/stm32.xml | 7 +- libdaisy/Makefile | 12 + .../Class/CDC/Src/usbd_cdc.c | 2 +- libdaisy/libdaisy.vcxproj | 367 ++---- libdaisy/libdaisy.vcxproj.filters | 1083 ++++++----------- libdaisy/src/daisy.h | 1 + libdaisy/src/daisy_seed.h | 9 +- libdaisy/src/hid_usb.cpp | 43 +- libdaisy/src/stm32h7xx_hal_conf.h | 4 +- libdaisy/src/sys_system.c | 369 +++--- libdaisy/src/usbd_conf.c | 8 +- libdaisy/src/usbd_conf.h | 2 +- libdaisy/src/usbd_desc.c | 34 +- libdaisy/stm32.props | 6 +- libdaisy/stm32.xml | 7 +- 20 files changed, 983 insertions(+), 2247 deletions(-) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings index 6e526c42e..f5c792fac 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings @@ -20,6 +20,7 @@ SeedUSB_CDC.vcxproj + 1 true @@ -37,6 +38,67 @@ Default + + + COM20 + + 115200 + 8 + None + One + None + + + 0 + false + false + false + ASCII + + + 255 + 0 + 0 + 0 + + + 255 + 169 + 169 + 169 + + + 255 + 211 + 211 + 211 + + + 255 + 144 + 238 + 144 + + + 255 + 169 + 169 + 169 + + + + 16 + true + true + true + true + 0 + + LF + false + true + false + true @@ -63,14 +125,14 @@ false - false - false - false - false - false - false - false - false + true + true + true + true + true + true + true + true false false @@ -82,7 +144,7 @@ false None false - false + true main true false @@ -127,4 +189,4 @@ false true - + \ No newline at end of file diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index ac03469f5..ab963b91c 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -1,49 +1,179 @@ #include #include "daisy_seed.h" -#include "daisysp.h" +//#include "daisysp.h" #include +#include +#include // 1MB test #define TEST_BUFF_SIZE (1024 * 1024) using namespace daisy; -using namespace daisysp; +//using namespace daisysp; -static uint32_t DSY_SDRAM_BSS test_buff[TEST_BUFF_SIZE]; - -static daisy_handle hw; -static uint32_t start, end, dur; +//void SystemClock_Config(void); +//void Error_Handler(); +//extern "C" +//{ +//void SysTick_Handler(void) +//{ +// HAL_IncTick(); +// HAL_SYSTICK_IRQHandler(); +//} +// +//void HardFault_Handler() +//{ +// asm("bkpt 255"); +//} +//} +//static uint32_t DSY_SDRAM_BSS test_buff[TEST_BUFF_SIZE]; -void passthru(float *in, float *out, size_t size) -{ - memcpy(out, in, sizeof(float) * size); -} +static daisy_handle hw; +UsbHandle usb_handle; int main(void) { - // Initialize Hardware - daisy_seed_init(&hw); - // Test RAM - for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) - { - test_buff[i] = i; - } - for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) - { - if(test_buff[i] != i) - { - asm("bkpt 255"); - } - } - dsy_tim_start(); - dsy_audio_set_callback(DSY_AUDIO_INTERNAL, passthru); - dsy_audio_start(DSY_AUDIO_INTERNAL); - uint32_t hello_count = 0; + // Initialize Hardware + + daisy_seed_init(&hw); + hw.usb_handle.Init(UsbHandle::FS_BOTH); + + // // Test RAM + // for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + // { + // test_buff[i] = i; + // } + // for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) + // { + // if(test_buff[i] != i) + // { + // asm("bkpt 255"); + // } + // } + // dsy_tim_start(); + int hello_count = 0; + char buff[512]; + char* dynbuff; + dynbuff = (char*)malloc(sizeof(char) * 32); while(1) { - dsy_tim_delay_ms(500); - - + //dsy_tim_delay_ms(500); + HAL_Delay(500); +// dsy_gpio_toggle(&hw.led); +// dsy_gpio_toggle(&hw.testpoint); + sprintf(buff, "Tick:\t%d\n", hello_count); + hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); } } + +//void SystemClock_Config(void) +//{ +// RCC_OscInitTypeDef RCC_OscInitStruct = {0}; +// RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; +// RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; +// +// /** Supply configuration update enable +// */ +// HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); +// /** Configure the main internal regulator output voltage +// */ +// __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); +// +// while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} +// /** Macro to configure the PLL clock source +// */ +// __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); +// /** Initializes the CPU, AHB and APB busses clocks +// */ +// RCC_OscInitStruct.OscillatorType +// = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; +// RCC_OscInitStruct.HSEState = RCC_HSE_ON; +// RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; +// RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; +// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; +// RCC_OscInitStruct.PLL.PLLM = 4; +// RCC_OscInitStruct.PLL.PLLN = 200; +// RCC_OscInitStruct.PLL.PLLP = 2; +// RCC_OscInitStruct.PLL.PLLQ = 5; +// RCC_OscInitStruct.PLL.PLLR = 2; +// RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; +// RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; +// RCC_OscInitStruct.PLL.PLLFRACN = 0; +// if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) +// { +// Error_Handler(); +// } +// /** Initializes the CPU, AHB and APB busses clocks +// */ +// RCC_ClkInitStruct.ClockType +// = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 +// | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1; +// RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; +// RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; +// RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; +// RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; +// RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; +// RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; +// RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; +// +// if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) +// { +// Error_Handler(); +// } +// PeriphClkInitStruct.PeriphClockSelection +// = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SPI1 +// | RCC_PERIPHCLK_SAI2 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SDMMC +// | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_I2C1 +// | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_QSPI | RCC_PERIPHCLK_FMC; +// PeriphClkInitStruct.PLL2.PLL2M = 4; +// PeriphClkInitStruct.PLL2.PLL2N = 100; +// PeriphClkInitStruct.PLL2.PLL2P = 1; +// PeriphClkInitStruct.PLL2.PLL2Q = 2; +// PeriphClkInitStruct.PLL2.PLL2R = 2; +// PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2; +// PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; +// PeriphClkInitStruct.PLL2.PLL2FRACN = 0; +// PeriphClkInitStruct.PLL3.PLL3M = 6; +// PeriphClkInitStruct.PLL3.PLL3N = 295; +// PeriphClkInitStruct.PLL3.PLL3P = 64; +// PeriphClkInitStruct.PLL3.PLL3Q = 2; +// PeriphClkInitStruct.PLL3.PLL3R = 1; +// PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_1; +// PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; +// PeriphClkInitStruct.PLL3.PLL3FRACN = 0; +// PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; +// PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; +// PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; +// PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; +// PeriphClkInitStruct.Sai23ClockSelection = RCC_SAI23CLKSOURCE_PLL3; +// PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; +// PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; +// PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48; +// PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; +// PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; +// PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; +// if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) +// { +// Error_Handler(); +// } +// /** Enable USB Voltage detector +// */ +// HAL_PWREx_EnableUSBVoltageDetector(); +//} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +//void Error_Handler(void) +//{ +// /* USER CODE BEGIN Error_Handler_Debug */ +// /* User can add his own implementation to report the HAL error return state */ +// +// /* USER CODE END Error_Handler_Debug */ +//} diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj index 03fceb154..0214cc14d 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj @@ -41,8 +41,8 @@ - ../../../../libdaisy/src;../../../../daisysp;%(ClCompile.AdditionalIncludeDirectories) - DEBUG=1;%(ClCompile.PreprocessorDefinitions) + ../../../../libdaisy/src;../../../../daisysp;../../../../libdaisy/Drivers/CMSIS/Device/ST/STM32H7xx/Include;../../../../libdaisy/Drivers/STM32H7xx_HAL_Driver/Inc;../../../../libdaisy/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;../../../../libdaisy/Drivers/CMSIS/Include;%(ClCompile.AdditionalIncludeDirectories) + DEBUG=1;STM32H750xx;%(ClCompile.PreprocessorDefinitions) ;%(Link.AdditionalLinkerInputs) @@ -67,253 +67,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- + \ No newline at end of file diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters index 52cb0a607..2f910cb13 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters @@ -16,21 +16,9 @@ {a721619a-0742-48a6-b0ef-ae86a7abbed8} - - {7886524c-98a2-4b06-b7f3-09467f97bd96} - - - {5bf0492d-4c24-4d9b-9d32-6194517f3979} - {9e5cbf8d-b54b-4d86-973a-a227ce867304} - - {21e62c5f-c549-4eda-acbd-f865c43893bf} - - - {29c145a4-ef83-48c0-bee3-e479c05df77e} - {7bea5beb-13d9-430e-94ad-356e88ca36b3} @@ -48,741 +36,9 @@ Source files\Device-specific files - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - Header files - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - VisualGDB settings @@ -793,4 +49,4 @@ VisualGDB settings - + \ No newline at end of file diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props index aedc4146b..e8819c6d8 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props @@ -9,14 +9,14 @@ - ARM_MATH_CM7;flash_layout;CORE_CM7;STM32H750IB;STM32H750xx;%(ClCompile.PreprocessorDefinitions) - %(ClCompile.AdditionalIncludeDirectories);$(ProjectDir);$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc;$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc/Legacy;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Device/ST/STM32H7xx/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/RTOS2/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Core/Include + ARM_MATH_CM7;flash_layout;CORE_CM7;STM32H750IB;%(ClCompile.PreprocessorDefinitions) + %(ClCompile.AdditionalIncludeDirectories);$(ProjectDir) $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds - --specs=nano.specs --specs=nosys.specs %(Link.AdditionalOptions) + --specs=nano.specs --specs=rdimon.specs %(Link.AdditionalOptions) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml index 862470b64..e5a72f838 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml @@ -29,16 +29,13 @@ com.sysprogs.toolchainoptions.arm.syscallspecs - --specs=nosys.specs + --specs=rdimon.specs Device-specific files stm32.mak - - com.sysprogs.arm.stm32.hal - com.sysprogs.arm.stm32.ll - + diff --git a/libdaisy/Makefile b/libdaisy/Makefile index cdbcfdb38..808db6c77 100644 --- a/libdaisy/Makefile +++ b/libdaisy/Makefile @@ -19,6 +19,7 @@ per_tim \ hid_switch \ hid_encoder \ hid_ctrl \ +hid_usb \ dev_sr_4021 \ system_stm32h7xx \ @@ -36,6 +37,8 @@ CHIPSET = stm32f7x SOURCES_DIR = \ Drivers/CMSIS \ Drivers/STM32H7xx_HAL_Driver \ +Middlewares/ST/STM32_USB_Device_Library/Core/Src \ +Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src \ #Middlewares/FatFs \ # Build path @@ -93,6 +96,13 @@ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c \ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c \ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c \ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \ +Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \ +Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \ +Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \ +Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \ +src/usbd_conf.c \ +src/usbd_desc.c \ +src/usbd_cdc_if.c \ STARTUP_PATH = Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc @@ -157,6 +167,8 @@ C_INCLUDES = \ -IDrivers/CMSIS/Include \ -IDrivers/CMSIS/Device/ST/STM32H7xx/Include \ -IDrivers/STM32H7xx_HAL_Driver/Inc \ +-IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \ +-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \ -I. \ # compile gcc flags diff --git a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 7f94e6c12..7ecd7c216 100644 --- a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -507,7 +507,7 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) pdev->ep_in[CDC_CMD_EP & 0xFU].is_used = 1U; pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); - + USBD_memset(pdev->pClassData, 0, sizeof(USBD_CDC_HandleTypeDef)); if(pdev->pClassData == NULL) { ret = 1U; diff --git a/libdaisy/libdaisy.vcxproj b/libdaisy/libdaisy.vcxproj index b63661216..e88fb80e6 100644 --- a/libdaisy/libdaisy.vcxproj +++ b/libdaisy/libdaisy.vcxproj @@ -43,17 +43,17 @@ - src;Middlewares/ST/STM32_USB_Device_Library/Core/Inc;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;%(ClCompile.AdditionalIncludeDirectories) - DEBUG=1;__FPU_PRESENT=1;%(ClCompile.PreprocessorDefinitions) + src;Middlewares/ST/STM32_USB_Device_Library/Core/Inc;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;Drivers/STM32H7xx_HAL_Driver/Inc;Drivers/CMSIS/Device/ST/STM32H7xx/Include;Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;Drivers/CMSIS/Include;%(ClCompile.AdditionalIncludeDirectories) + DEBUG=1;flash_layout;STM32H750xx;%(ClCompile.PreprocessorDefinitions) Og - %(Link.AdditionalLinkerInputs) - %(Link.LibrarySearchDirectories) - %(Link.AdditionalLibraryNames) + ;%(Link.AdditionalLinkerInputs) + ;%(Link.LibrarySearchDirectories) + ;%(Link.AdditionalLibraryNames) ../core/STM32H750IB_flash.lds @@ -62,6 +62,7 @@ src;%(ClCompile.AdditionalIncludeDirectories) NDEBUG=1;RELEASE=1;%(ClCompile.PreprocessorDefinitions) + Og ;%(Link.AdditionalLinkerInputs) @@ -74,6 +75,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -140,250 +253,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libdaisy/libdaisy.vcxproj.filters b/libdaisy/libdaisy.vcxproj.filters index 63531b69a..80961a995 100644 --- a/libdaisy/libdaisy.vcxproj.filters +++ b/libdaisy/libdaisy.vcxproj.filters @@ -16,24 +16,15 @@ {dc7152e9-ed42-402a-b255-30fc9227e423} - - {db0aac9d-5500-49fb-a2f8-ab5474bd443c} - - - {8d314a77-7e66-4851-8a0b-6c3db517f11f} - {91fe0048-9069-4aa5-8a1a-a78904333b2d} - - {4a5eeb89-ffe5-4023-9b4e-0ed16a0f1f74} - - - {62aa12cb-caee-4180-b462-51106c94bdc8} - {d804b7fb-bc78-40ec-98ce-9bea7733d09b} + + {0bf89a2c-f0cf-4d5b-b6c2-5a8dc5db0260} + @@ -42,738 +33,6 @@ Source files\Device-specific files - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\HAL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Source files\Device-specific files\LL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\HAL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - - - Header files\Device-specific files\LL - VisualGDB settings @@ -979,6 +238,342 @@ Source files + + Source files + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + + + HAL + diff --git a/libdaisy/src/daisy.h b/libdaisy/src/daisy.h index 64245ea4b..f88edd1a0 100644 --- a/libdaisy/src/daisy.h +++ b/libdaisy/src/daisy.h @@ -69,5 +69,6 @@ FORCE_INLINE float cube(float x) #ifdef __cplusplus #include "hid_ctrl.h" #include "parameter.h" +#include "hid_usb.h" #endif #endif diff --git a/libdaisy/src/daisy_seed.h b/libdaisy/src/daisy_seed.h index 4fb499986..2cc188651 100644 --- a/libdaisy/src/daisy_seed.h +++ b/libdaisy/src/daisy_seed.h @@ -58,6 +58,7 @@ typedef struct dsy_adc_handle adc_handle; dsy_dac_handle dac_handle; dsy_gpio led, testpoint; + daisy::UsbHandle usb_handle; } daisy_handle; @@ -194,14 +195,16 @@ inline void daisy_seed_init(daisy_handle *daisy_seed) daisy_seed->audio_handle.dev1_i2c = &daisy_seed->i2c1_handle; daisy_seed->audio_handle.block_size = 48; - // System Initialization (optional) + + // System Initialization (optional) #ifndef DSY_SEED_NO_INIT dsy_system_init(); - dsy_sdram_init(&daisy_seed->sdram_handle); - dsy_qspi_init(&daisy_seed->qspi_handle); +// dsy_sdram_init(&daisy_seed->sdram_handle); +// dsy_qspi_init(&daisy_seed->qspi_handle); dsy_gpio_init(&daisy_seed->led); dsy_gpio_init(&daisy_seed->testpoint); dsy_audio_init(&daisy_seed->audio_handle); + daisy_seed->usb_handle.Init(daisy::UsbHandle::FS_BOTH); dsy_tim_init(); #endif // DSY_SEED_NO_INIT } diff --git a/libdaisy/src/hid_usb.cpp b/libdaisy/src/hid_usb.cpp index ed7b80556..ebe1c2a5a 100644 --- a/libdaisy/src/hid_usb.cpp +++ b/libdaisy/src/hid_usb.cpp @@ -8,9 +8,16 @@ using namespace daisy; static void UsbErrorHandler(); +// Externs for IRQ Handlers +extern "C" +{ // Globals from Cube generated version: USBD_HandleTypeDef hUsbDeviceHS; USBD_HandleTypeDef hUsbDeviceFS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +} + static void InitFS() { @@ -63,8 +70,8 @@ void UsbHandle::Init(UsbPeriph dev) case FS_INTERNAL: InitFS(); break; case FS_EXTERNAL: InitHS(); break; case FS_BOTH: - InitFS(); InitHS(); + InitFS(); break; default: break; } @@ -87,3 +94,37 @@ static void UsbErrorHandler() { while(1) {} } + +// IRQ Handler +extern "C" +{ +void OTG_HS_EP1_OUT_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); +} + +void OTG_HS_EP1_IN_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); +} + +void OTG_HS_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); +} + +void OTG_FS_EP1_OUT_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); +} + +void OTG_FS_EP1_IN_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); +} + +void OTG_FS_IRQHandler(void) +{ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); +} +} diff --git a/libdaisy/src/stm32h7xx_hal_conf.h b/libdaisy/src/stm32h7xx_hal_conf.h index 7ba8a6a1d..6a4e26ad9 100644 --- a/libdaisy/src/stm32h7xx_hal_conf.h +++ b/libdaisy/src/stm32h7xx_hal_conf.h @@ -97,11 +97,11 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) -#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#define HSE_VALUE ((uint32_t)16000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** diff --git a/libdaisy/src/sys_system.c b/libdaisy/src/sys_system.c index adad84a73..2cd76c8d7 100644 --- a/libdaisy/src/sys_system.c +++ b/libdaisy/src/sys_system.c @@ -4,48 +4,53 @@ // Jump related stuff -#define u32 uint32_t +#define u32 uint32_t #define vu32 volatile uint32_t -#define SET_REG(addr,val) do { *(vu32*)(addr)=val; } while(0) -#define GET_REG(addr) (*(vu32*)(addr)) - -#define RCC_CR RCC -#define RCC_CFGR (RCC + 0x04) -#define RCC_CIR (RCC + 0x08) -#define RCC_AHBENR (RCC + 0x14) +#define SET_REG(addr, val) \ + do \ + { \ + *(vu32*)(addr) = val; \ + } while(0) +#define GET_REG(addr) (*(vu32*)(addr)) + +#define RCC_CR RCC +#define RCC_CFGR (RCC + 0x04) +#define RCC_CIR (RCC + 0x08) +#define RCC_AHBENR (RCC + 0x14) #define RCC_APB2ENR (RCC + 0x18) #define RCC_APB1ENR (RCC + 0x1C) -#define SCS 0xE000E000 -#define STK (SCS+0x10) -#define STK_CTRL (STK+0x00) -#define RCC_CR RCC - -typedef struct { - vu32 ISER[2]; - u32 RESERVED0[30]; - vu32 ICER[2]; - u32 RSERVED1[30]; - vu32 ISPR[2]; - u32 RESERVED2[30]; - vu32 ICPR[2]; - u32 RESERVED3[30]; - vu32 IABR[2]; - u32 RESERVED4[62]; - vu32 IPR[15]; +#define SCS 0xE000E000 +#define STK (SCS + 0x10) +#define STK_CTRL (STK + 0x00) +#define RCC_CR RCC + +typedef struct +{ + vu32 ISER[2]; + u32 RESERVED0[30]; + vu32 ICER[2]; + u32 RSERVED1[30]; + vu32 ISPR[2]; + u32 RESERVED2[30]; + vu32 ICPR[2]; + u32 RESERVED3[30]; + vu32 IABR[2]; + u32 RESERVED4[62]; + vu32 IPR[15]; } NVIC_TypeDef; __attribute__((always_inline)) static inline void __JUMPTOQSPI() { - __asm("LDR R1, =0xE000ED00;"); // SCB - __asm("LDR R0, =0x90000000;"); // APP BASE - __asm("STR R0, [R1, #8]"); // VTOR - __asm("LDR SP, [R0, #0]"); // SP @ +0 - __asm("LDR R0, [R0, #4]"); // PC @ +4 - __asm("BX R0"); + __asm("LDR R1, =0xE000ED00;"); // SCB + __asm("LDR R0, =0x90000000;"); // APP BASE + __asm("STR R0, [R1, #8]"); // VTOR + __asm("LDR SP, [R0, #0]"); // SP @ +0 + __asm("LDR R0, [R0, #4]"); // PC @ +4 + __asm("BX R0"); } -typedef void(*EntryPoint)(void); +typedef void (*EntryPoint)(void); // Static Function Declaration static void SystemClock_Config(); @@ -54,35 +59,29 @@ static void Error_Handler(void); void SysTick_Handler(void) { - HAL_IncTick(); - HAL_SYSTICK_IRQHandler(); + HAL_IncTick(); + HAL_SYSTICK_IRQHandler(); } -void HardFault_Handler() +void HardFault_Handler() { - asm("bkpt 255"); + asm("bkpt 255"); } void dsy_system_init() { - // For now we won't use the board parameter since all three supported boards use the same 16MHz HSE. - // That said, 2hp Audio BB had a bit different setup, and actually a more accurate sample rate for audio iirc. - SystemClock_Config(); - MPU_Config(); - dsy_dma_init(); // - SCB_EnableICache(); - SCB_EnableDCache(); - //SCB_EnableDCache(); // This will require relocation of DMA buffers, or Cache Maintence. Performance is almost doubled, though. - HAL_Init(); + HAL_Init(); + SystemClock_Config(); + MPU_Config(); + dsy_dma_init(); + SCB_EnableICache(); + SCB_EnableDCache(); } void dsy_system_jumptoqspi() { - __JUMPTOQSPI(); - while (1) - { - - } + __JUMPTOQSPI(); + while(1) {} } uint32_t dsy_system_getnow() @@ -97,152 +96,156 @@ void dsy_system_delay(uint32_t delay_ms) void SystemClock_Config() { - // HOLD THISSSS - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + // HOLD THISSSS + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - /** Supply configuration update enable + /** Supply configuration update enable */ - HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); - /** Configure the main internal regulator output voltage + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage */ - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} - /** Macro to configure the PLL clock source + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source */ - __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); - /** Initializes the CPU, AHB and APB busses clocks + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); + /** Initializes the CPU, AHB and APB busses clocks */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 4; - RCC_OscInitStruct.PLL.PLLN = 200; - RCC_OscInitStruct.PLL.PLLP = 2; - RCC_OscInitStruct.PLL.PLLQ = 5; - RCC_OscInitStruct.PLL.PLLR = 2; - RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; - RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; - RCC_OscInitStruct.PLL.PLLFRACN = 0; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Initializes the CPU, AHB and APB busses clocks + RCC_OscInitStruct.OscillatorType + = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 4; + RCC_OscInitStruct.PLL.PLLN = 200; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 5; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB busses clocks */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 - |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; - RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; - RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) - { - Error_Handler(); - } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_RNG - |RCC_PERIPHCLK_SPI1|RCC_PERIPHCLK_SAI2 - |RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_SDMMC - |RCC_PERIPHCLK_I2C2|RCC_PERIPHCLK_ADC - |RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_USB - |RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC; - // PLL 2 - PeriphClkInitStruct.PLL2.PLL2M = 4; - PeriphClkInitStruct.PLL2.PLL2N = 115; - PeriphClkInitStruct.PLL2.PLL2P = 8; // 57.5 - PeriphClkInitStruct.PLL2.PLL2Q = 10; // 46 - PeriphClkInitStruct.PLL2.PLL2R = 2; // 115Mhz - PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2; - PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; - PeriphClkInitStruct.PLL2.PLL2FRACN = 0; - // PLL 3 - PeriphClkInitStruct.PLL3.PLL3M = 6; - PeriphClkInitStruct.PLL3.PLL3N = 295; - PeriphClkInitStruct.PLL3.PLL3P = 64; // 12.29Mhz - PeriphClkInitStruct.PLL3.PLL3Q = 4; - PeriphClkInitStruct.PLL3.PLL3R = 32; // 24.xMhz - PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_1; - PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; - PeriphClkInitStruct.PLL3.PLL3FRACN = 0; - PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2; - //PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_PLL2; - PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; - PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; - PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; - PeriphClkInitStruct.Sai23ClockSelection = RCC_SAI23CLKSOURCE_PLL3; - PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; - PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; - PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; - //PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3; - PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; - PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PLL3; - //PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_D3PCLK1; - PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; - //PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL3; - PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL3; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Enable USB Voltage detector + RCC_ClkInitStruct.ClockType + = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 + | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) + { + Error_Handler(); + } + PeriphClkInitStruct.PeriphClockSelection + = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SPI1 + | RCC_PERIPHCLK_SAI2 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SDMMC + | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_I2C1 + | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_QSPI | RCC_PERIPHCLK_FMC; + // PLL 2 + PeriphClkInitStruct.PLL2.PLL2M = 4; + PeriphClkInitStruct.PLL2.PLL2N = 115; + PeriphClkInitStruct.PLL2.PLL2P = 8; // 57.5 + PeriphClkInitStruct.PLL2.PLL2Q = 10; // 46 + PeriphClkInitStruct.PLL2.PLL2R = 2; // 115Mhz + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; + PeriphClkInitStruct.PLL2.PLL2FRACN = 0; + // PLL 3 + PeriphClkInitStruct.PLL3.PLL3M = 6; + PeriphClkInitStruct.PLL3.PLL3N = 295; + PeriphClkInitStruct.PLL3.PLL3P = 64; // 12.29Mhz + PeriphClkInitStruct.PLL3.PLL3Q = 4; + PeriphClkInitStruct.PLL3.PLL3R = 32; // 24.xMhz + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_1; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2; + //PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_PLL2; + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; + PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; + PeriphClkInitStruct.Sai23ClockSelection = RCC_SAI23CLKSOURCE_PLL3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + PeriphClkInitStruct.Usart234578ClockSelection + = RCC_USART234578CLKSOURCE_D2PCLK1; + PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; + //PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3; + PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; + PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PLL3; + //PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_D3PCLK1; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + //PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL3; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL3; + if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector */ - HAL_PWREx_EnableUSBVoltageDetector(); + HAL_PWREx_EnableUSBVoltageDetector(); +} + +static void MPU_Config() +{ + MPU_Region_InitTypeDef MPU_InitStruct; + HAL_MPU_Disable(); + // Configure RAM D2 (SRAM1) as non cacheable + MPU_InitStruct.Enable = MPU_REGION_ENABLE; + MPU_InitStruct.BaseAddress = 0x30000000; + MPU_InitStruct.Size = MPU_REGION_SIZE_16KB; + MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; + MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; + MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; + MPU_InitStruct.Number = MPU_REGION_NUMBER0; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1; + MPU_InitStruct.SubRegionDisable = 0x00; + MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; + HAL_MPU_ConfigRegion(&MPU_InitStruct); + + MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE; + MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; + MPU_InitStruct.Number = MPU_REGION_NUMBER1; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; + MPU_InitStruct.Size = MPU_REGION_SIZE_64MB; + MPU_InitStruct.BaseAddress = 0xC0000000; + HAL_MPU_ConfigRegion(&MPU_InitStruct); + + // uint32_t enable_bit = (1 << 0); + // uint32_t privdefena = (1 << 2); + // uint32_t rasr_enable = (1 << 0); + + + // MPU->CTRL = enable_bit | privdefena; + // MPU->RNR = 0x00; + // MPU->RBAR = 0x30000000; + // MPU->RASR = rasr_enable; + + + HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } -static void MPU_Config() +void HAL_MspInit() { - MPU_Region_InitTypeDef MPU_InitStruct; - HAL_MPU_Disable(); - // Configure RAM D2 (SRAM1) as non cacheable - MPU_InitStruct.Enable = MPU_REGION_ENABLE; - MPU_InitStruct.BaseAddress = 0x30000000; - MPU_InitStruct.Size = MPU_REGION_SIZE_16KB; - MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; - MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; - MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; - MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; - MPU_InitStruct.Number = MPU_REGION_NUMBER0; - MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1; - MPU_InitStruct.SubRegionDisable = 0x00; - MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; - HAL_MPU_ConfigRegion(&MPU_InitStruct); - - MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE; - MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; - MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; - MPU_InitStruct.Number = MPU_REGION_NUMBER1; - MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; - MPU_InitStruct.Size = MPU_REGION_SIZE_64MB; - MPU_InitStruct.BaseAddress = 0xC0000000; - HAL_MPU_ConfigRegion(&MPU_InitStruct); - - // uint32_t enable_bit = (1 << 0); - // uint32_t privdefena = (1 << 2); - // uint32_t rasr_enable = (1 << 0); - - - // MPU->CTRL = enable_bit | privdefena; - // MPU->RNR = 0x00; - // MPU->RBAR = 0x30000000; - // MPU->RASR = rasr_enable; - - - HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + __HAL_RCC_SYSCFG_CLK_ENABLE(); } static void Error_Handler() { - // Insert code to handle errors here. - while(1) - { - } + // Insert code to handle errors here. + while(1) {} } diff --git a/libdaisy/src/usbd_conf.c b/libdaisy/src/usbd_conf.c index a5ab99851..d2e44d136 100644 --- a/libdaisy/src/usbd_conf.c +++ b/libdaisy/src/usbd_conf.c @@ -39,10 +39,12 @@ /* USER CODE END PV */ PCD_HandleTypeDef hpcd_USB_OTG_FS; -void Error_Handler(void); - PCD_HandleTypeDef hpcd_USB_OTG_HS; -void Error_Handler(void); + +void Error_Handler(void) +{ + while(1) {} +} /* External functions --------------------------------------------------------*/ diff --git a/libdaisy/src/usbd_conf.h b/libdaisy/src/usbd_conf.h index a4dc56dd1..e85b765f5 100644 --- a/libdaisy/src/usbd_conf.h +++ b/libdaisy/src/usbd_conf.h @@ -66,7 +66,7 @@ /*---------- -----------*/ #define USBD_SUPPORT_USER_STRING 0U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL 3U /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ diff --git a/libdaisy/src/usbd_desc.c b/libdaisy/src/usbd_desc.c index 91ca84780..420ba922c 100644 --- a/libdaisy/src/usbd_desc.c +++ b/libdaisy/src/usbd_desc.c @@ -63,17 +63,29 @@ * @{ */ -#define USBD_VID 1155 -#define USBD_LANGID_STRING 1033 -#define USBD_MANUFACTURER_STRING "Electrosmith" -#define USBD_PID_HS 22336 -#define USBD_PRODUCT_STRING_HS "Daisy Seed Virtual ComPort" -#define USBD_CONFIGURATION_STRING_HS "CDC Config" -#define USBD_INTERFACE_STRING_HS "CDC Interface" -#define USBD_PID_FS 22336 -#define USBD_PRODUCT_STRING_FS "Daisy Seed Virtual ComPort" -#define USBD_CONFIGURATION_STRING_FS "CDC Config" -#define USBD_INTERFACE_STRING_FS "CDC Interface" +//#define USBD_VID 1155 +//#define USBD_LANGID_STRING 1033 +//#define USBD_MANUFACTURER_STRING "Electrosmith" +//#define USBD_PID_HS 22336 +//#define USBD_PRODUCT_STRING_HS "Daisy Seed Virtual ComPort" +//#define USBD_CONFIGURATION_STRING_HS "CDC Config" +//#define USBD_INTERFACE_STRING_HS "CDC Interface" +//#define USBD_PID_FS 22336 +//#define USBD_PRODUCT_STRING_FS "Daisy Seed Virtual ComPort" +//#define USBD_CONFIGURATION_STRING_FS "CDC Config" +//#define USBD_INTERFACE_STRING_FS "CDC Interface" + +#define USBD_VID 1155 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "STMicroelectronics" +#define USBD_PID_HS 22336 +#define USBD_PRODUCT_STRING_HS "STM32 Virtual ComPort" +#define USBD_CONFIGURATION_STRING_HS "CDC Config" +#define USBD_INTERFACE_STRING_HS "CDC Interface" +#define USBD_PID_FS 22336 +#define USBD_PRODUCT_STRING_FS "STM32 Virtual ComPort" +#define USBD_CONFIGURATION_STRING_FS "CDC Config" +#define USBD_INTERFACE_STRING_FS "CDC Interface" /* USER CODE BEGIN PRIVATE_DEFINES */ diff --git a/libdaisy/stm32.props b/libdaisy/stm32.props index 873111c44..e8819c6d8 100644 --- a/libdaisy/stm32.props +++ b/libdaisy/stm32.props @@ -9,14 +9,14 @@ - ARM_MATH_CM7;flash_layout;CORE_CM7;STM32H750IB;STM32H750xx;USE_FULL_LL_DRIVER;%(ClCompile.PreprocessorDefinitions) - %(ClCompile.AdditionalIncludeDirectories);$(ProjectDir);$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc;$(BSP_ROOT)/STM32H7xxxx/STM32H7xx_HAL_Driver/Inc/Legacy;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Device/ST/STM32H7xx/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/RTOS2/Include;$(BSP_ROOT)/STM32H7xxxx/CMSIS_HAL/Core/Include + ARM_MATH_CM7;flash_layout;CORE_CM7;STM32H750IB;%(ClCompile.PreprocessorDefinitions) + %(ClCompile.AdditionalIncludeDirectories);$(ProjectDir) $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds - --specs=nano.specs --specs=nosys.specs %(Link.AdditionalOptions) + --specs=nano.specs --specs=rdimon.specs %(Link.AdditionalOptions) diff --git a/libdaisy/stm32.xml b/libdaisy/stm32.xml index 878473eb7..7117d90a3 100644 --- a/libdaisy/stm32.xml +++ b/libdaisy/stm32.xml @@ -29,16 +29,13 @@ com.sysprogs.toolchainoptions.arm.syscallspecs - --specs=nosys.specs + --specs=rdimon.specs Device-specific files stm32.mak - - com.sysprogs.arm.stm32.hal - com.sysprogs.arm.stm32.ll - + From 768a1b6ab04ae0353fac9f81256ef147f3d229c5 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Fri, 20 Dec 2019 16:48:27 -0800 Subject: [PATCH 04/13] changes -- to no avail --- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 168 +----------------- libdaisy/src/hid_usb.cpp | 3 +- libdaisy/src/sys_system.c | 4 +- 3 files changed, 11 insertions(+), 164 deletions(-) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index ab963b91c..5e7c9456b 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -1,33 +1,8 @@ +#include #include #include "daisy_seed.h" -//#include "daisysp.h" -#include -#include -#include - -// 1MB test -#define TEST_BUFF_SIZE (1024 * 1024) using namespace daisy; -//using namespace daisysp; - -//void SystemClock_Config(void); -//void Error_Handler(); -//extern "C" -//{ -//void SysTick_Handler(void) -//{ -// HAL_IncTick(); -// HAL_SYSTICK_IRQHandler(); -//} -// -//void HardFault_Handler() -//{ -// asm("bkpt 255"); -//} -//} - -//static uint32_t DSY_SDRAM_BSS test_buff[TEST_BUFF_SIZE]; static daisy_handle hw; @@ -35,145 +10,16 @@ UsbHandle usb_handle; int main(void) { // Initialize Hardware - daisy_seed_init(&hw); - hw.usb_handle.Init(UsbHandle::FS_BOTH); - - // // Test RAM - // for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) - // { - // test_buff[i] = i; - // } - // for(uint32_t i = 0; i < TEST_BUFF_SIZE; i++) - // { - // if(test_buff[i] != i) - // { - // asm("bkpt 255"); - // } - // } // dsy_tim_start(); - int hello_count = 0; - char buff[512]; - char* dynbuff; - dynbuff = (char*)malloc(sizeof(char) * 32); - while(1) + int hello_count = 0; + char buff[512]; + while(1) { - //dsy_tim_delay_ms(500); - HAL_Delay(500); -// dsy_gpio_toggle(&hw.led); -// dsy_gpio_toggle(&hw.testpoint); + dsy_system_delay(500); + dsy_gpio_toggle(&hw.led); + dsy_gpio_toggle(&hw.testpoint); sprintf(buff, "Tick:\t%d\n", hello_count); hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); } } - -//void SystemClock_Config(void) -//{ -// RCC_OscInitTypeDef RCC_OscInitStruct = {0}; -// RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; -// RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; -// -// /** Supply configuration update enable -// */ -// HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); -// /** Configure the main internal regulator output voltage -// */ -// __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); -// -// while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} -// /** Macro to configure the PLL clock source -// */ -// __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); -// /** Initializes the CPU, AHB and APB busses clocks -// */ -// RCC_OscInitStruct.OscillatorType -// = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; -// RCC_OscInitStruct.HSEState = RCC_HSE_ON; -// RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; -// RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; -// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; -// RCC_OscInitStruct.PLL.PLLM = 4; -// RCC_OscInitStruct.PLL.PLLN = 200; -// RCC_OscInitStruct.PLL.PLLP = 2; -// RCC_OscInitStruct.PLL.PLLQ = 5; -// RCC_OscInitStruct.PLL.PLLR = 2; -// RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; -// RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; -// RCC_OscInitStruct.PLL.PLLFRACN = 0; -// if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) -// { -// Error_Handler(); -// } -// /** Initializes the CPU, AHB and APB busses clocks -// */ -// RCC_ClkInitStruct.ClockType -// = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 -// | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1; -// RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; -// RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; -// RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; -// RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; -// RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; -// RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; -// RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; -// -// if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) -// { -// Error_Handler(); -// } -// PeriphClkInitStruct.PeriphClockSelection -// = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SPI1 -// | RCC_PERIPHCLK_SAI2 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SDMMC -// | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_I2C1 -// | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_QSPI | RCC_PERIPHCLK_FMC; -// PeriphClkInitStruct.PLL2.PLL2M = 4; -// PeriphClkInitStruct.PLL2.PLL2N = 100; -// PeriphClkInitStruct.PLL2.PLL2P = 1; -// PeriphClkInitStruct.PLL2.PLL2Q = 2; -// PeriphClkInitStruct.PLL2.PLL2R = 2; -// PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2; -// PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; -// PeriphClkInitStruct.PLL2.PLL2FRACN = 0; -// PeriphClkInitStruct.PLL3.PLL3M = 6; -// PeriphClkInitStruct.PLL3.PLL3N = 295; -// PeriphClkInitStruct.PLL3.PLL3P = 64; -// PeriphClkInitStruct.PLL3.PLL3Q = 2; -// PeriphClkInitStruct.PLL3.PLL3R = 1; -// PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_1; -// PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; -// PeriphClkInitStruct.PLL3.PLL3FRACN = 0; -// PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; -// PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; -// PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; -// PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; -// PeriphClkInitStruct.Sai23ClockSelection = RCC_SAI23CLKSOURCE_PLL3; -// PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; -// PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; -// PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48; -// PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; -// PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; -// PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; -// if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) -// { -// Error_Handler(); -// } -// /** Enable USB Voltage detector -// */ -// HAL_PWREx_EnableUSBVoltageDetector(); -//} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -//void Error_Handler(void) -//{ -// /* USER CODE BEGIN Error_Handler_Debug */ -// /* User can add his own implementation to report the HAL error return state */ -// -// /* USER CODE END Error_Handler_Debug */ -//} diff --git a/libdaisy/src/hid_usb.cpp b/libdaisy/src/hid_usb.cpp index ebe1c2a5a..b2ef7c636 100644 --- a/libdaisy/src/hid_usb.cpp +++ b/libdaisy/src/hid_usb.cpp @@ -16,7 +16,6 @@ USBD_HandleTypeDef hUsbDeviceHS; USBD_HandleTypeDef hUsbDeviceFS; extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern PCD_HandleTypeDef hpcd_USB_OTG_HS; -} static void InitFS() @@ -62,6 +61,8 @@ static void InitHS() } } +} + void UsbHandle::Init(UsbPeriph dev) { diff --git a/libdaisy/src/sys_system.c b/libdaisy/src/sys_system.c index 2cd76c8d7..e37216226 100644 --- a/libdaisy/src/sys_system.c +++ b/libdaisy/src/sys_system.c @@ -74,8 +74,8 @@ void dsy_system_init() SystemClock_Config(); MPU_Config(); dsy_dma_init(); - SCB_EnableICache(); - SCB_EnableDCache(); +// SCB_EnableICache(); +// SCB_EnableDCache(); } void dsy_system_jumptoqspi() From d386ef0c75a4b218f2dfb61ddf6a918cc61e6237 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 09:15:44 -0700 Subject: [PATCH 05/13] jumped sys_system back to master (i didn't handle all of the merge conflics. --- libdaisy/src/sys_system.c | 61 --------------------------------------- 1 file changed, 61 deletions(-) diff --git a/libdaisy/src/sys_system.c b/libdaisy/src/sys_system.c index 609daae54..f2aa4206f 100644 --- a/libdaisy/src/sys_system.c +++ b/libdaisy/src/sys_system.c @@ -127,11 +127,7 @@ void SystemClock_Config() RCC_OscInitStruct.PLL.PLLM = 4; RCC_OscInitStruct.PLL.PLLN = 200; RCC_OscInitStruct.PLL.PLLP = 2; -<<<<<<< HEAD - RCC_OscInitStruct.PLL.PLLQ = 5; -======= RCC_OscInitStruct.PLL.PLLQ = 5; // was 4 in cube ->>>>>>> master RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; @@ -163,14 +159,9 @@ void SystemClock_Config() | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_QSPI | RCC_PERIPHCLK_FMC; // PLL 2 -<<<<<<< HEAD - PeriphClkInitStruct.PLL2.PLL2M = 4; - PeriphClkInitStruct.PLL2.PLL2N = 115; -======= PeriphClkInitStruct.PLL2.PLL2M = 4; // PeriphClkInitStruct.PLL2.PLL2N = 115; // Max Freq @ 3v3 PeriphClkInitStruct.PLL2.PLL2N = 84; // Max Freq @ 1V9 ->>>>>>> master PeriphClkInitStruct.PLL2.PLL2P = 8; // 57.5 PeriphClkInitStruct.PLL2.PLL2Q = 10; // 46 PeriphClkInitStruct.PLL2.PLL2R = 2; // 115Mhz @@ -195,11 +186,8 @@ void SystemClock_Config() PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; -<<<<<<< HEAD -======= //PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; //PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_PLL2; ->>>>>>> master PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2; //PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3; PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; @@ -215,7 +203,6 @@ void SystemClock_Config() /** Enable USB Voltage detector */ HAL_PWREx_EnableUSBVoltageDetector(); -<<<<<<< HEAD } static void MPU_Config() @@ -259,54 +246,6 @@ static void MPU_Config() HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } -void HAL_MspInit() -{ - __HAL_RCC_SYSCFG_CLK_ENABLE(); -======= -} - -static void MPU_Config() -{ - MPU_Region_InitTypeDef MPU_InitStruct; - HAL_MPU_Disable(); - // Configure RAM D2 (SRAM1) as non cacheable - MPU_InitStruct.Enable = MPU_REGION_ENABLE; - MPU_InitStruct.BaseAddress = 0x30000000; - MPU_InitStruct.Size = MPU_REGION_SIZE_16KB; - MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; - MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; - MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; - MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; - MPU_InitStruct.Number = MPU_REGION_NUMBER0; - MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1; - MPU_InitStruct.SubRegionDisable = 0x00; - MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; - HAL_MPU_ConfigRegion(&MPU_InitStruct); - - MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE; - MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; - MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; - MPU_InitStruct.Number = MPU_REGION_NUMBER1; - MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; - MPU_InitStruct.Size = MPU_REGION_SIZE_64MB; - MPU_InitStruct.BaseAddress = 0xC0000000; - HAL_MPU_ConfigRegion(&MPU_InitStruct); - - // uint32_t enable_bit = (1 << 0); - // uint32_t privdefena = (1 << 2); - // uint32_t rasr_enable = (1 << 0); - - - // MPU->CTRL = enable_bit | privdefena; - // MPU->RNR = 0x00; - // MPU->RBAR = 0x30000000; - // MPU->RASR = rasr_enable; - - - HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); ->>>>>>> master -} - static void Error_Handler() { // Insert code to handle errors here. From 9564cc1f85cec4b179a2eaa3271d0639b3094635 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 10:43:27 -0700 Subject: [PATCH 06/13] added line coding info to USB CDC interface, and replaced non-functioning malloc call for USB class with static version. --- .../SeedUSB_CDC-Debug.vgdbsettings | 2 +- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 5 +- .../tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj | 4 +- .../SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters | 6 - .../tests/SeedUSB_CDC/stm32h7xx_hal_conf.h | 465 ------------------ .../seed/tests/SeedUSB_CDC/system_stm32h7xx.c | 365 -------------- .../Class/CDC/Src/usbd_cdc.c | 8 +- libdaisy/libdaisy.vcxproj | 19 +- libdaisy/libdaisy.vcxproj.filters | 54 ++ libdaisy/src/hid_usb.cpp | 2 +- libdaisy/src/usbd_cdc_if.c | 7 +- 11 files changed, 90 insertions(+), 847 deletions(-) delete mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h delete mode 100644 hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings index f5c792fac..aa3486752 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings @@ -40,7 +40,7 @@ - COM20 + COM3 115200 8 diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index 5e7c9456b..e7b902f5a 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -14,12 +14,15 @@ int main(void) // dsy_tim_start(); int hello_count = 0; char buff[512]; + while(1) { dsy_system_delay(500); dsy_gpio_toggle(&hw.led); dsy_gpio_toggle(&hw.testpoint); - sprintf(buff, "Tick:\t%d\n", hello_count); + sprintf(buff, "Tick:\t%d\r\n", hello_count); + hello_count = (hello_count + 1) % 100; hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); + } } diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj index 0214cc14d..a7c2577ad 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj @@ -41,7 +41,7 @@ - ../../../../libdaisy/src;../../../../daisysp;../../../../libdaisy/Drivers/CMSIS/Device/ST/STM32H7xx/Include;../../../../libdaisy/Drivers/STM32H7xx_HAL_Driver/Inc;../../../../libdaisy/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;../../../../libdaisy/Drivers/CMSIS/Include;%(ClCompile.AdditionalIncludeDirectories) + ../../../../libdaisy/src;../../../../daisysp;%(ClCompile.AdditionalIncludeDirectories) DEBUG=1;STM32H750xx;%(ClCompile.PreprocessorDefinitions) @@ -64,10 +64,8 @@ - - diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters index 2f910cb13..2ecaddaa4 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.vcxproj.filters @@ -27,18 +27,12 @@ Source files - - Source files - Source files\Device-specific files Source files\Device-specific files - - Header files - VisualGDB settings diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h deleted file mode 100644 index 72ea21cde..000000000 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32h7xx_hal_conf.h +++ /dev/null @@ -1,465 +0,0 @@ -/** - ****************************************************************************** - * @file stm32h7xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32h7xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef STM32H7xx_HAL_CONF_H -#define STM32H7xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED -#define HAL_ADC_MODULE_ENABLED -#define HAL_CEC_MODULE_ENABLED -#define HAL_COMP_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -#define HAL_CRC_MODULE_ENABLED -#define HAL_CRYP_MODULE_ENABLED -#define HAL_DAC_MODULE_ENABLED -#define HAL_DCMI_MODULE_ENABLED -#define HAL_DFSDM_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_DMA2D_MODULE_ENABLED -#define HAL_DSI_MODULE_ENABLED -#define HAL_ETH_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_FDCAN_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED -#define HAL_HASH_MODULE_ENABLED -#define HAL_HCD_MODULE_ENABLED -#define HAL_HRTIM_MODULE_ENABLED -#define HAL_HSEM_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -#define HAL_IRDA_MODULE_ENABLED -#define HAL_IWDG_MODULE_ENABLED -#define HAL_JPEG_MODULE_ENABLED -#define HAL_LPTIM_MODULE_ENABLED -#define HAL_LTDC_MODULE_ENABLED -#define HAL_MDIOS_MODULE_ENABLED -#define HAL_MDMA_MODULE_ENABLED -#define HAL_MMC_MODULE_ENABLED -#define HAL_NAND_MODULE_ENABLED -#define HAL_NOR_MODULE_ENABLED -#define HAL_OPAMP_MODULE_ENABLED -#define HAL_PCD_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_QSPI_MODULE_ENABLED -#define HAL_RAMECC_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_RNG_MODULE_ENABLED -#define HAL_RTC_MODULE_ENABLED -#define HAL_SAI_MODULE_ENABLED -#define HAL_SD_MODULE_ENABLED -#define HAL_SDRAM_MODULE_ENABLED -#define HAL_SMARTCARD_MODULE_ENABLED -#define HAL_SMBUS_MODULE_ENABLED -#define HAL_SPDIFRX_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_SRAM_MODULE_ENABLED -#define HAL_SWPMI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -#define HAL_WWDG_MODULE_ENABLED - -/* ########################## Oscillator Values adaptation ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) -#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal oscillator (CSI) default value. - * This value is the default CSI value after Reset. - */ -#if !defined (CSI_VALUE) - #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* CSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system frequency - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/ -#endif /* LSE_VALUE */ - - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature.*/ - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */ -#define USE_RTOS 0 -#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */ - -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ -#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ -#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ -#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ -#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ -#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ -#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ -#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ -#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ -#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ -#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ -#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ -#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ -#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ -#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ - -/* ########################### Ethernet Configuration ######################### */ -#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ -#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ - -#define ETH_MAC_ADDR0 ((uint8_t)0x02) -#define ETH_MAC_ADDR1 ((uint8_t)0x00) -#define ETH_MAC_ADDR2 ((uint8_t)0x00) -#define ETH_MAC_ADDR3 ((uint8_t)0x00) -#define ETH_MAC_ADDR4 ((uint8_t)0x00) -#define ETH_MAC_ADDR5 ((uint8_t)0x00) - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1 */ - - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32h7xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32h7xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32h7xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_MDMA_MODULE_ENABLED - #include "stm32h7xx_hal_mdma.h" -#endif /* HAL_MDMA_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32h7xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32h7xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32h7xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32h7xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32h7xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32h7xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32h7xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32h7xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32h7xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED - #include "stm32h7xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32h7xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED - #include "stm32h7xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32h7xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32h7xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32h7xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32h7xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED - #include "stm32h7xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_HSEM_MODULE_ENABLED - #include "stm32h7xx_hal_hsem.h" -#endif /* HAL_HSEM_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32h7xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32h7xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32h7xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32h7xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32h7xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32h7xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_JPEG_MODULE_ENABLED - #include "stm32h7xx_hal_jpeg.h" -#endif /* HAL_JPEG_MODULE_ENABLED */ - -#ifdef HAL_MDIOS_MODULE_ENABLED - #include "stm32h7xx_hal_mdios.h" -#endif /* HAL_MDIOS_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32h7xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32h7xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED -#include "stm32h7xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32h7xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32h7xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32h7xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RAMECC_MODULE_ENABLED - #include "stm32h7xx_hal_ramecc.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32h7xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32h7xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32h7xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32h7xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32h7xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32h7xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32h7xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_SWPMI_MODULE_ENABLED - #include "stm32h7xx_hal_swpmi.h" -#endif /* HAL_SWPMI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32h7xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32h7xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32h7xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32h7xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32h7xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED - #include "stm32h7xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32h7xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32h7xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32h7xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t *file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32H7xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c b/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c deleted file mode 100644 index 9daeefbaa..000000000 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/system_stm32h7xx.c +++ /dev/null @@ -1,365 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32h7xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32h7xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32h7xx_system - * @{ - */ - -/** @addtogroup STM32H7xx_System_Private_Includes - * @{ - */ - -#include "stm32h7xx.h" -#include -#if !defined (HSE_VALUE) -#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (CSI_VALUE) - #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* CSI_VALUE */ - -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ -/* #define DATA_IN_D2_SRAM */ - -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -/******************************************************************************/ - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_Variables - * @{ - */ - /* This variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = 64000000; - uint32_t SystemD2Clock = 64000000; - const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32H7xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system - * Initialize the FPU setting and vector table location - * configuration. - * @param None - * @retval None - */ -void SystemInit (void) -{ -#if defined (DATA_IN_D2_SRAM) - __IO uint32_t tmpreg; -#endif /* DATA_IN_D2_SRAM */ - - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ - #endif - /* Reset the RCC clock configuration to the default reset state ------------*/ - /* Set HSION bit */ - RCC->CR |= RCC_CR_HSION; - - /* Reset CFGR register */ - RCC->CFGR = 0x00000000; - - /* Reset HSEON, CSSON , CSION,RC48ON, CSIKERON PLL1ON, PLL2ON and PLL3ON bits */ - RCC->CR &= 0xEAF6ED7FU; - - /* Reset D1CFGR register */ - RCC->D1CFGR = 0x00000000; - - /* Reset D2CFGR register */ - RCC->D2CFGR = 0x00000000; - - /* Reset D3CFGR register */ - RCC->D3CFGR = 0x00000000; - - /* Reset PLLCKSELR register */ - RCC->PLLCKSELR = 0x00000000; - - /* Reset PLLCFGR register */ - RCC->PLLCFGR = 0x00000000; - /* Reset PLL1DIVR register */ - RCC->PLL1DIVR = 0x00000000; - /* Reset PLL1FRACR register */ - RCC->PLL1FRACR = 0x00000000; - - /* Reset PLL2DIVR register */ - RCC->PLL2DIVR = 0x00000000; - - /* Reset PLL2FRACR register */ - - RCC->PLL2FRACR = 0x00000000; - /* Reset PLL3DIVR register */ - RCC->PLL3DIVR = 0x00000000; - - /* Reset PLL3FRACR register */ - RCC->PLL3FRACR = 0x00000000; - - /* Reset HSEBYP bit */ - RCC->CR &= 0xFFFBFFFFU; - - /* Disable all interrupts */ - RCC->CIER = 0x00000000; - -#if defined (DATA_IN_D2_SRAM) - /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock ((AHB SRAM clock) */ -#if defined(RCC_AHB2ENR_D2SRAM1EN) - RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); -#else - RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); -#endif /* RCC_AHB2ENR_D2SRAM1EN */ - - tmpreg = RCC->AHB2ENR; - (void) tmpreg; -#endif /* DATA_IN_D2_SRAM */ - -#if defined(DUAL_CORE) && defined(CORE_CM4) - /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = D2_AHBSRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif /* VECT_TAB_SRAM */ - -#else - /* dual core CM7 or single core line */ - if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) - { - /* if stm32h7 revY*/ - /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ - *((__IO uint32_t*)0x51008108) = 0x000000001U; - } - - /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D1 AXI-RAM */ -#else - SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif - -#endif /*DUAL_CORE && CORE_CM4*/ - -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock , it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), - * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. - * - * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value - * 4 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value - * 64 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value - * 25 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * @param None - * @retval None - */ -void SystemCoreClockUpdate (void) -{ - uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; - float_t fracn1, pllvco; - - /* Get SYSCLK source -------------------------------------------------------*/ - - switch (RCC->CFGR & RCC_CFGR_SWS) - { - case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ - SystemCoreClock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); - break; - - case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ - SystemCoreClock = CSI_VALUE; - break; - - case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ - - /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); - pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; - pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); - fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); - - if (pllm != 0U) - { - switch (pllsource) - { - case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ - - hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; - pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); - - break; - - case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ - pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); - break; - - case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ - pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); - break; - - default: - pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); - break; - } - pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; - SystemCoreClock = (uint32_t)(float_t)(pllvco/(float_t)pllp); - } - else - { - SystemCoreClock = 0U; - } - break; - - default: - SystemCoreClock = CSI_VALUE; - break; - } - - /* Compute SystemClock frequency --------------------------------------------------*/ - tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; - - /* SystemCoreClock frequency : CM7 CPU frequency */ - SystemCoreClock >>= tmp; - - /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ - SystemD2Clock = (SystemCoreClock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); - -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 7ecd7c216..6ab5d3cb7 100644 --- a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -94,6 +94,9 @@ * @} */ +// TESTING WITH STATIC USB CDC +static USBD_CDC_HandleTypeDef h_cdc; + /** @defgroup USBD_CDC_Private_FunctionPrototypes * @{ @@ -506,8 +509,9 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_LL_OpenEP(pdev, CDC_CMD_EP, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE); pdev->ep_in[CDC_CMD_EP & 0xFU].is_used = 1U; - pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); - USBD_memset(pdev->pClassData, 0, sizeof(USBD_CDC_HandleTypeDef)); + //pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); + pdev->pClassData = &h_cdc; + // USBD_memset(pdev->pClassData, 0, sizeof(USBD_CDC_HandleTypeDef)); if(pdev->pClassData == NULL) { ret = 1U; diff --git a/libdaisy/libdaisy.vcxproj b/libdaisy/libdaisy.vcxproj index db8428f6e..07a44156f 100644 --- a/libdaisy/libdaisy.vcxproj +++ b/libdaisy/libdaisy.vcxproj @@ -43,7 +43,7 @@ - src;Drivers/CMSIS/Device/ST/STM32H7xx/Include;Drivers/STM32H7xx_HAL_Driver/Inc;Drivers/CMSIS/Include;Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;;%(ClCompile.AdditionalIncludeDirectories) + src;Drivers/CMSIS/Device/ST/STM32H7xx/Include;Drivers/STM32H7xx_HAL_Driver/Inc;Drivers/CMSIS/Include;Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;Middlewares/ST/STM32_USB_Device_Library/Core/Inc;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;%(ClCompile.AdditionalIncludeDirectories) DEBUG=1;__FPU_PRESENT=1;STM32H750xx;%(ClCompile.PreprocessorDefinitions) Og @@ -185,6 +185,10 @@ + + + + @@ -196,6 +200,7 @@ + @@ -207,6 +212,9 @@ + + + @@ -346,6 +354,11 @@ + + + + + @@ -366,6 +379,7 @@ + @@ -378,6 +392,9 @@ + + + diff --git a/libdaisy/libdaisy.vcxproj.filters b/libdaisy/libdaisy.vcxproj.filters index 253b84729..ff0e9ce18 100644 --- a/libdaisy/libdaisy.vcxproj.filters +++ b/libdaisy/libdaisy.vcxproj.filters @@ -28,6 +28,9 @@ {d09b4563-3bcf-452d-a23a-b147a545005b} + + {23cd5738-10d6-4357-bb0b-f9a24c84f81e} +
@@ -563,6 +566,33 @@ Header files + + USB Middleware + + + USB Middleware + + + USB Middleware + + + USB Middleware + + + Header files + + + Header files + + + Header files + + + Header files + + + USB Middleware + @@ -967,6 +997,30 @@ Source files + + USB Middleware + + + USB Middleware + + + USB Middleware + + + Source files + + + Source files + + + Source files + + + Source files + + + USB Middleware + diff --git a/libdaisy/src/hid_usb.cpp b/libdaisy/src/hid_usb.cpp index b2ef7c636..57bebdb07 100644 --- a/libdaisy/src/hid_usb.cpp +++ b/libdaisy/src/hid_usb.cpp @@ -18,6 +18,7 @@ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +} static void InitFS() { if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) @@ -61,7 +62,6 @@ static void InitHS() } } -} void UsbHandle::Init(UsbPeriph dev) diff --git a/libdaisy/src/usbd_cdc_if.c b/libdaisy/src/usbd_cdc_if.c index d30e87db0..ae38a48d2 100644 --- a/libdaisy/src/usbd_cdc_if.c +++ b/libdaisy/src/usbd_cdc_if.c @@ -203,6 +203,9 @@ static int8_t CDC_DeInit_FS(void) * @param length: Number of data to be sent (in bytes) * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL */ +// line coding: 115200 bps, 1 stop, no parity, 8-bit +static uint8_t line_coding[7] = {0x00, 0xC2, 0x01, 0x00, 0x00, 0x00, 0x08}; + static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { /* USER CODE BEGIN 5 */ @@ -246,11 +249,11 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ /*******************************************************************************/ case CDC_SET_LINE_CODING: - + memcpy(line_coding, pbuf, sizeof(line_coding)); break; case CDC_GET_LINE_CODING: - + memcpy(pbuf, line_coding, sizeof(line_coding)); break; case CDC_SET_CONTROL_LINE_STATE: From a02177d77ff58ec986814448a06b6466ff52ae07 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 11:12:23 -0700 Subject: [PATCH 07/13] fixed static class data for usb, and rebuilt. --- hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 4 +++- hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props | 2 +- hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml | 2 +- .../ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c | 6 +++--- libdaisy/libdaisy-Debug.vgdbsettings | 1 + libdaisy/stm32.props | 2 +- libdaisy/stm32.xml | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index e7b902f5a..3e1de327f 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -15,6 +15,9 @@ int main(void) int hello_count = 0; char buff[512]; + uint8_t *mbuff; + mbuff = (uint8_t*)malloc(8); + while(1) { dsy_system_delay(500); @@ -23,6 +26,5 @@ int main(void) sprintf(buff, "Tick:\t%d\r\n", hello_count); hello_count = (hello_count + 1) % 100; hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); - } } diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props index e8819c6d8..b3823ae68 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.props @@ -16,7 +16,7 @@ $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds - --specs=nano.specs --specs=rdimon.specs %(Link.AdditionalOptions) + --specs=nano.specs --specs=nosys.specs %(Link.AdditionalOptions) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml index e5a72f838..58151f69d 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/stm32.xml @@ -29,7 +29,7 @@ com.sysprogs.toolchainoptions.arm.syscallspecs - --specs=rdimon.specs + --specs=nosys.specs diff --git a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 6ab5d3cb7..95ef1b25c 100644 --- a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -95,7 +95,7 @@ */ // TESTING WITH STATIC USB CDC -static USBD_CDC_HandleTypeDef h_cdc; +static USBD_CDC_HandleTypeDef h_cdc; /** @defgroup USBD_CDC_Private_FunctionPrototypes @@ -509,9 +509,9 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_LL_OpenEP(pdev, CDC_CMD_EP, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE); pdev->ep_in[CDC_CMD_EP & 0xFU].is_used = 1U; - //pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); - pdev->pClassData = &h_cdc; + // pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); // USBD_memset(pdev->pClassData, 0, sizeof(USBD_CDC_HandleTypeDef)); + pdev->pClassData = &h_cdc; if(pdev->pClassData == NULL) { ret = 1U; diff --git a/libdaisy/libdaisy-Debug.vgdbsettings b/libdaisy/libdaisy-Debug.vgdbsettings index cbafe01d6..cfb426b04 100644 --- a/libdaisy/libdaisy-Debug.vgdbsettings +++ b/libdaisy/libdaisy-Debug.vgdbsettings @@ -20,6 +20,7 @@ libdaisy.vcxproj + 1 true diff --git a/libdaisy/stm32.props b/libdaisy/stm32.props index e8819c6d8..b3823ae68 100644 --- a/libdaisy/stm32.props +++ b/libdaisy/stm32.props @@ -16,7 +16,7 @@ $(BSP_ROOT)/STM32H7xxxx/LinkerScripts/STM32H750IB_flash.lds - --specs=nano.specs --specs=rdimon.specs %(Link.AdditionalOptions) + --specs=nano.specs --specs=nosys.specs %(Link.AdditionalOptions) diff --git a/libdaisy/stm32.xml b/libdaisy/stm32.xml index 7117d90a3..8eae5f306 100644 --- a/libdaisy/stm32.xml +++ b/libdaisy/stm32.xml @@ -29,7 +29,7 @@ com.sysprogs.toolchainoptions.arm.syscallspecs - --specs=rdimon.specs + --specs=nosys.specs From dc27dbd16bb6c77238d3b824761cf05be95e9437 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 11:19:26 -0700 Subject: [PATCH 08/13] updated Makefile for missing midi. --- libdaisy/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdaisy/Makefile b/libdaisy/Makefile index c38c755ca..2f91f2e4e 100644 --- a/libdaisy/Makefile +++ b/libdaisy/Makefile @@ -18,10 +18,11 @@ per_gpio \ per_dac \ per_tim \ per_uart \ -hid_switch \ -hid_encoder \ hid_ctrl \ +hid_encoder \ hid_gatein \ +hid_midi \ +hid_switch \ hid_usb \ dev_sr_4021 \ util_hal_map \ From 7a9bfbc83b45b2c6b018ee7f7ade9373773de324 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 12:13:12 -0700 Subject: [PATCH 09/13] added another static classdata for hs so each can run simultaneously without issue, and updated class desc --- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 9 +--- .../Class/CDC/Src/usbd_cdc.c | 7 ++- libdaisy/libdaisy-Debug.vgdbsettings | 6 ++- libdaisy/libdaisy.vcxproj | 4 +- libdaisy/src/usbd_desc.c | 49 ++++++++++--------- libdaisy/stm32.xml | 10 ++-- 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index 3e1de327f..efa264299 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -5,9 +5,7 @@ using namespace daisy; static daisy_handle hw; - -UsbHandle usb_handle; -int main(void) +int main(void) { // Initialize Hardware daisy_seed_init(&hw); @@ -15,9 +13,6 @@ int main(void) int hello_count = 0; char buff[512]; - uint8_t *mbuff; - mbuff = (uint8_t*)malloc(8); - while(1) { dsy_system_delay(500); @@ -25,6 +20,6 @@ int main(void) dsy_gpio_toggle(&hw.testpoint); sprintf(buff, "Tick:\t%d\r\n", hello_count); hello_count = (hello_count + 1) % 100; - hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); + hw.usb_handle.TransmitExternal((uint8_t*)buff, strlen(buff)); } } diff --git a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 95ef1b25c..9bd216ddb 100644 --- a/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/libdaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -95,7 +95,7 @@ */ // TESTING WITH STATIC USB CDC -static USBD_CDC_HandleTypeDef h_cdc; +static USBD_CDC_HandleTypeDef h_cdc_fs, h_cdc_hs; /** @defgroup USBD_CDC_Private_FunctionPrototypes @@ -490,6 +490,8 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; + // Set pClassData + pdev->pClassData = &h_cdc_hs; } else { @@ -504,6 +506,8 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) CDC_DATA_FS_OUT_PACKET_SIZE); pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; + // Set pClassData + pdev->pClassData = &h_cdc_fs; } /* Open Command IN EP */ USBD_LL_OpenEP(pdev, CDC_CMD_EP, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE); @@ -511,7 +515,6 @@ static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx) // pdev->pClassData = USBD_malloc(sizeof (USBD_CDC_HandleTypeDef)); // USBD_memset(pdev->pClassData, 0, sizeof(USBD_CDC_HandleTypeDef)); - pdev->pClassData = &h_cdc; if(pdev->pClassData == NULL) { ret = 1U; diff --git a/libdaisy/libdaisy-Debug.vgdbsettings b/libdaisy/libdaisy-Debug.vgdbsettings index cfb426b04..17d63fd5c 100644 --- a/libdaisy/libdaisy-Debug.vgdbsettings +++ b/libdaisy/libdaisy-Debug.vgdbsettings @@ -13,14 +13,16 @@ + com.visualgdb.arm-eabi - 0 + 7.2.0 + 8.0.1 + 3 libdaisy.vcxproj - 1 true diff --git a/libdaisy/libdaisy.vcxproj b/libdaisy/libdaisy.vcxproj index 07a44156f..9363a0a49 100644 --- a/libdaisy/libdaisy.vcxproj +++ b/libdaisy/libdaisy.vcxproj @@ -32,8 +32,8 @@ Debug - com.sysprogs.gnuarm.arm-eabi - 8.3.1/8.0/r1 + com.visualgdb.arm-eabi + 7.2.0/8.0.1/r3 StaticLibrary diff --git a/libdaisy/src/usbd_desc.c b/libdaisy/src/usbd_desc.c index 420ba922c..04089efd1 100644 --- a/libdaisy/src/usbd_desc.c +++ b/libdaisy/src/usbd_desc.c @@ -63,29 +63,32 @@ * @{ */ -//#define USBD_VID 1155 -//#define USBD_LANGID_STRING 1033 -//#define USBD_MANUFACTURER_STRING "Electrosmith" -//#define USBD_PID_HS 22336 -//#define USBD_PRODUCT_STRING_HS "Daisy Seed Virtual ComPort" -//#define USBD_CONFIGURATION_STRING_HS "CDC Config" -//#define USBD_INTERFACE_STRING_HS "CDC Interface" -//#define USBD_PID_FS 22336 -//#define USBD_PRODUCT_STRING_FS "Daisy Seed Virtual ComPort" -//#define USBD_CONFIGURATION_STRING_FS "CDC Config" -//#define USBD_INTERFACE_STRING_FS "CDC Interface" - -#define USBD_VID 1155 -#define USBD_LANGID_STRING 1033 -#define USBD_MANUFACTURER_STRING "STMicroelectronics" -#define USBD_PID_HS 22336 -#define USBD_PRODUCT_STRING_HS "STM32 Virtual ComPort" -#define USBD_CONFIGURATION_STRING_HS "CDC Config" -#define USBD_INTERFACE_STRING_HS "CDC Interface" -#define USBD_PID_FS 22336 -#define USBD_PRODUCT_STRING_FS "STM32 Virtual ComPort" -#define USBD_CONFIGURATION_STRING_FS "CDC Config" -#define USBD_INTERFACE_STRING_FS "CDC Interface" +// BOTH +#define USBD_VID 1155 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Electrosmith" +// HS +#define USBD_PID_HS 22336 +#define USBD_PRODUCT_STRING_HS "Daisy Seed External Virtual ComPort" +#define USBD_CONFIGURATION_STRING_HS "CDC Config" +#define USBD_INTERFACE_STRING_HS "CDC Interface" +// FS +#define USBD_PID_FS 22336 +#define USBD_PRODUCT_STRING_FS "Daisy Seed Built In Virtual ComPort" +#define USBD_CONFIGURATION_STRING_FS "CDC Config" +#define USBD_INTERFACE_STRING_FS "CDC Interface" + +//#define USBD_VID 1155 +//#define USBD_LANGID_STRING 1033 +//#define USBD_MANUFACTURER_STRING "STMicroelectronics" +//#define USBD_PID_HS 22336 +//#define USBD_PRODUCT_STRING_HS "STM32 Virtual ComPort" +//#define USBD_CONFIGURATION_STRING_HS "CDC Config" +//#define USBD_INTERFACE_STRING_HS "CDC Interface" +//#define USBD_PID_FS 22336 +//#define USBD_PRODUCT_STRING_FS "STM32 Virtual ComPort" +//#define USBD_CONFIGURATION_STRING_FS "CDC Config" +//#define USBD_INTERFACE_STRING_FS "CDC Interface" /* USER CODE BEGIN PRIVATE_DEFINES */ diff --git a/libdaisy/stm32.xml b/libdaisy/stm32.xml index 8eae5f306..3c46e3627 100644 --- a/libdaisy/stm32.xml +++ b/libdaisy/stm32.xml @@ -1,10 +1,10 @@ - com.sysprogs.gnuarm.arm-eabi + com.visualgdb.arm-eabi - 8.3.1 - 8.0 - 1 + 7.2.0 + 8.0.1 + 3 com.sysprogs.arm.stm32 2019.06 @@ -29,7 +29,7 @@ com.sysprogs.toolchainoptions.arm.syscallspecs - --specs=nosys.specs + --specs=rdimon.specs From ae25928420bb43837a64af5d680f4b1a7856bf5a Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 12:19:27 -0700 Subject: [PATCH 10/13] comments for desc --- libdaisy/src/usbd_desc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libdaisy/src/usbd_desc.c b/libdaisy/src/usbd_desc.c index 04089efd1..ad1464cc7 100644 --- a/libdaisy/src/usbd_desc.c +++ b/libdaisy/src/usbd_desc.c @@ -68,13 +68,13 @@ #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Electrosmith" // HS -#define USBD_PID_HS 22336 -#define USBD_PRODUCT_STRING_HS "Daisy Seed External Virtual ComPort" +#define USBD_PID_HS 22336 // replace with our PID when we have one. +#define USBD_PRODUCT_STRING_HS "Daisy Seed External" #define USBD_CONFIGURATION_STRING_HS "CDC Config" #define USBD_INTERFACE_STRING_HS "CDC Interface" // FS -#define USBD_PID_FS 22336 -#define USBD_PRODUCT_STRING_FS "Daisy Seed Built In Virtual ComPort" +#define USBD_PID_FS 22336 // replace with our PID when we have one. +#define USBD_PRODUCT_STRING_FS "Daisy Seed Built In" #define USBD_CONFIGURATION_STRING_FS "CDC Config" #define USBD_INTERFACE_STRING_FS "CDC Interface" From 17623e78a98c909bf6861a3a5282c58345115be6 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 12:24:39 -0700 Subject: [PATCH 11/13] comments. --- libdaisy/src/usbd_desc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdaisy/src/usbd_desc.c b/libdaisy/src/usbd_desc.c index ad1464cc7..7715f734b 100644 --- a/libdaisy/src/usbd_desc.c +++ b/libdaisy/src/usbd_desc.c @@ -78,6 +78,7 @@ #define USBD_CONFIGURATION_STRING_FS "CDC Config" #define USBD_INTERFACE_STRING_FS "CDC Interface" +// Previous defines. //#define USBD_VID 1155 //#define USBD_LANGID_STRING 1033 //#define USBD_MANUFACTURER_STRING "STMicroelectronics" From 36d69ed4152f0dd46173c456f21ebb3be66471d4 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 13:11:46 -0700 Subject: [PATCH 12/13] removed receive functions for now. --- .../SeedUSB_CDC-Debug.vgdbsettings | 2 +- .../seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp | 20 +++---- libdaisy/src/hid_usb.cpp | 1 - libdaisy/src/hid_usb.h | 57 ++++++++++--------- libdaisy/src/usbd_cdc_if.c | 2 + 5 files changed, 39 insertions(+), 43 deletions(-) diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings index aa3486752..692376b21 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC-Debug.vgdbsettings @@ -40,7 +40,7 @@ - COM3 + COM4 115200 8 diff --git a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp index efa264299..f00eae878 100644 --- a/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp +++ b/hardware_platforms/seed/tests/SeedUSB_CDC/SeedUSB_CDC.cpp @@ -2,24 +2,18 @@ #include #include "daisy_seed.h" -using namespace daisy; - static daisy_handle hw; -int main(void) + +int main(void) { - // Initialize Hardware daisy_seed_init(&hw); - // dsy_tim_start(); - int hello_count = 0; - char buff[512]; - + int tick_cnt = 0; + char buff[512]; while(1) { dsy_system_delay(500); - dsy_gpio_toggle(&hw.led); - dsy_gpio_toggle(&hw.testpoint); - sprintf(buff, "Tick:\t%d\r\n", hello_count); - hello_count = (hello_count + 1) % 100; - hw.usb_handle.TransmitExternal((uint8_t*)buff, strlen(buff)); + sprintf(buff, "Tick:\t%d\r\n", tick_cnt); + hw.usb_handle.TransmitInternal((uint8_t*)buff, strlen(buff)); + tick_cnt = (tick_cnt + 1) % 100; } } diff --git a/libdaisy/src/hid_usb.cpp b/libdaisy/src/hid_usb.cpp index 57bebdb07..97e1e47a3 100644 --- a/libdaisy/src/hid_usb.cpp +++ b/libdaisy/src/hid_usb.cpp @@ -89,7 +89,6 @@ void UsbHandle::TransmitExternal(uint8_t* buff, size_t size) CDC_Transmit_HS(buff, size); } - // Static Function Implementation static void UsbErrorHandler() { diff --git a/libdaisy/src/hid_usb.h b/libdaisy/src/hid_usb.h index 2db086981..24f930af0 100644 --- a/libdaisy/src/hid_usb.h +++ b/libdaisy/src/hid_usb.h @@ -17,46 +17,45 @@ namespace daisy class UsbHandle { public: -// ## Data Types -// ### UsbPeriph -// Specified which of the two USB Peripherals to initialize. -// -// FS External D- pin is Pin 37 (GPIO31) -// -// FS External D+ pin is Pin 38 (GPIO32) -// + // ## Data Types + // ### UsbPeriph + // Specified which of the two USB Peripherals to initialize. + // + // FS External D- pin is Pin 37 (GPIO31) + // + // FS External D+ pin is Pin 38 (GPIO32) + // enum UsbPeriph { -// ~~~~ + // ~~~~ FS_INTERNAL, - FS_EXTERNAL, - FS_BOTH, -// ~~~~ + FS_EXTERNAL, + FS_BOTH, + // ~~~~ }; UsbHandle() {} ~UsbHandle() {} -// ## General Functions -// ### Init -// Initializes the specified peripheral(s) as USB CDC Devices -// ~~~~ + // ## General Functions + // ### Init + // Initializes the specified peripheral(s) as USB CDC Devices + // ~~~~ void Init(UsbPeriph dev); -// ~~~~ + // ~~~~ -// ### TransmitInternal -// Transmits a buffer of 'size' bytes from the on board USB FS port. -// ~~~~ + // ### TransmitInternal + // Transmits a buffer of 'size' bytes from the on board USB FS port. + // ~~~~ void TransmitInternal(uint8_t* buff, size_t size); -// ~~~~ - -// ### Init -// Transmits a buffer of 'size' bytes from a USB port connected to the -// external USB Pins of the daisy seed. -// ~~~~ + // ~~~~ + // ### TransmitExternal + // Transmits a buffer of 'size' bytes from a USB port connected to the + // external USB Pins of the daisy seed. + // ~~~~ void TransmitExternal(uint8_t* buff, size_t size); -// ~~~~ + // ~~~~ private: }; @@ -65,4 +64,6 @@ class UsbHandle #endif // TODO: -// - Add Support for other USB classes (currently only CDC is supported) +// - Add support for other USB classes (currently only CDC is supported) +// - Add support for Receiving data (currently it is handled and tested, +// but there is no access to the rx buffer) diff --git a/libdaisy/src/usbd_cdc_if.c b/libdaisy/src/usbd_cdc_if.c index ae38a48d2..8117a492a 100644 --- a/libdaisy/src/usbd_cdc_if.c +++ b/libdaisy/src/usbd_cdc_if.c @@ -289,6 +289,7 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) { /* USER CODE BEGIN 6 */ +// CDC_Transmit_FS(Buf, *Len); USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); USBD_CDC_ReceivePacket(&hUsbDeviceFS); return (USBD_OK); @@ -436,6 +437,7 @@ static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length) static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len) { /* USER CODE BEGIN 11 */ + //CDC_Transmit_HS(Buf, *Len); USBD_CDC_SetRxBuffer(&hUsbDeviceHS, &Buf[0]); USBD_CDC_ReceivePacket(&hUsbDeviceHS); return (USBD_OK); From 2a2ff6cac47a4fab6d0fbfb34f8f5031dadd8e86 Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 12 Mar 2020 13:20:29 -0700 Subject: [PATCH 13/13] added seed/tests to rebuild examples --- rebuild_examples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebuild_examples.sh b/rebuild_examples.sh index a050cd8fe..76eab0c90 100755 --- a/rebuild_examples.sh +++ b/rebuild_examples.sh @@ -2,7 +2,7 @@ echo "rebuilding examples:" start_dir=$PWD HW=hardware_platforms -example_dirs=( daisysp/examples $HW/field/examples $HW/patch/examples $HW/petal/examples $HW/pod/examples ) +example_dirs=( daisysp/examples $HW/field/examples $HW/patch/examples $HW/petal/examples $HW/pod/examples $HW/seed/tests ) for e in ${example_dirs[@]}; do for d in $e/*/; do echo "rebuilding $d"