From 6d57ce69d24fd6aa7a32ca39b58cde6f3d5a8488 Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Fri, 15 Sep 2023 18:51:17 +0200 Subject: [PATCH] Porting `legacy` tests to new integration-test infra (part 4...) (#2315) * ported SketchThatIncludesArduinoH from legacy into integration test * ported SketchWithStaticAsserts from legacy into integration test * ported SketchWithEnumClass from legacy into integration test * ported SketchWithExternC from legacy into integration test * ported testBuilderSketchWithMultilinePrototypes from legacy into integration test * ported SketchWithExternCMultiline from legacy into integration test * ported SketchWithMultilineTemplate from legacy into integration test * ported SketchWithFakeFunctionPointer from legacy into integration test * fix wrong templating * ported SketchWithMinMaxDefinitions from legacy into integration test * ported SketchWithFastledsLibrary from legacy into integration test * ported sketch with merged sketch and bootloader from legacy into integration test * temporary disable legacy test, before porting them to the new infra * update .gitignore * ported CheckBuildOptionsFile from legacy into integration test * ported SketchClassFunction from legacy into integration test * ported SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet from legacy into integration test * remove legacy builder test folder * remove unsued fields from context --- .gitignore | 1 + .../integrationtest/compile_4/compile_test.go | 273 +++ .../SketchClassFunction.ino | 0 .../SketchClassFunction.preprocessed.txt | 17 + ...TransactionsAndIncludesMissingEthernet.ino | 0 .../SketchThatIncludesArduinoH.ino | 0 ...ketchThatIncludesArduinoH.preprocessed.txt | 21 + .../SketchWithEnumClass.ino | 0 .../SketchWithEnumClass.preprocessed.txt | 31 + .../SketchWithExternC/SketchWithExternC.ino | 0 .../SketchWithExternC.preprocessed.txt | 20 + .../SketchWithExternCMultiline.ino | 0 ...ketchWithExternCMultiline.preprocessed.txt | 51 + .../SketchWithFakeFunctionPointer.ino | 0 ...chWithFakeFunctionPointer.preprocessed.txt | 27 + .../SketchWithFastledsLibrary.ino | 2 +- ...SketchWithFastledsLibrary.preprocessed.txt | 37 + .../SketchWithMergedSketchAndBootloader.ino | 2 +- .../doc.txt | 0 .../header.h | 1 + .../merged_sketch.txt | 0 .../old.pde | 0 .../other.ino | 2 +- .../s_file.S | 0 .../src/helper.h | 0 .../SketchWithMinMaxDefinitions.ino | 0 ...etchWithMinMaxDefinitions.preprocessed.txt | 26 + .../SketchWithMultilinePrototypes.ino | 0 ...chWithMultilinePrototypes.preprocessed.txt | 76 + .../SketchWithMultilineTemplate.ino | 0 ...etchWithMultilineTemplate.preprocessed.txt | 20 + .../SketchWithStaticAsserts.ino | 0 .../SketchWithStaticAsserts.preprocessed.txt | 26 + legacy/builder/builder.go | 2 - legacy/builder/test/.gitignore | 1 - legacy/builder/test/builder_test.go | 141 -- .../test/hardware/watterott/avr/boards.txt | 130 -- .../test/hardware/watterott/avr/platform.txt | 146 -- .../hardware/watterott/avr/programmers.txt | 0 legacy/builder/test/helper.go | 37 - .../builder/test/helper_tools_downloader.go | 726 -------- .../ANewLibrary-master/anewlibrary.h | 0 .../test/libraries/Balanduino/Balanduino.h | 0 .../test/libraries/Balanduino/Kalman.h | 0 .../builder/test/libraries/Balanduino/PS3BT.h | 0 .../builder/test/libraries/Balanduino/SPP.h | 0 .../builder/test/libraries/Balanduino/Wii.h | 0 .../test/libraries/Balanduino/XBOXRECV.h | 0 .../builder/test/libraries/Balanduino/adk.h | 0 .../test/libraries/Balanduino/usbhub.h | 0 .../builder/test/libraries/FakeAudio/Audio.h | 0 .../test/libraries/FakeAudio/FakeAudio.h | 0 .../test/libraries/IRremote/IRremote.h | 1 - .../test/libraries/IRremote/IRremoteInt.h | 0 legacy/builder/test/libraries/SPI/SPI.cpp | 201 --- legacy/builder/test/libraries/SPI/SPI.h | 324 ---- .../builder/test/libraries/SPI/keywords.txt | 36 - .../test/libraries/SPI/library.properties | 11 - .../ShouldNotRecurseWithOldLibs.cpp | 0 .../ShouldNotRecurseWithOldLibs.h | 0 .../ShouldNotRecurseWithOldLibs/doc/error.cpp | 1 - .../utility/utils.cpp | 0 .../utility/utils.h | 0 .../test/libraries/USBHost/keywords.txt | 35 - .../test/libraries/USBHost/library.properties | 9 - .../USBHost/src/KeyboardController.cpp | 40 - .../USBHost/src/KeyboardController.h | 54 - .../libraries/USBHost/src/MouseController.cpp | 83 - .../libraries/USBHost/src/MouseController.h | 57 - .../test/libraries/USBHost/src/Usb.cpp | 857 --------- .../builder/test/libraries/USBHost/src/Usb.h | 48 - .../test/libraries/USBHost/src/UsbCore.h | 291 --- .../test/libraries/USBHost/src/address.h | 280 --- .../test/libraries/USBHost/src/adk.cpp | 410 ----- .../builder/test/libraries/USBHost/src/adk.h | 148 -- .../libraries/USBHost/src/confdescparser.h | 223 --- .../test/libraries/USBHost/src/hexdump.h | 61 - .../test/libraries/USBHost/src/hid.cpp | 112 -- .../builder/test/libraries/USBHost/src/hid.h | 183 -- .../test/libraries/USBHost/src/hidboot.cpp | 223 --- .../test/libraries/USBHost/src/hidboot.h | 609 ------- .../USBHost/src/hidescriptorparser.cpp | 1599 ----------------- .../USBHost/src/hidescriptorparser.h | 173 -- .../libraries/USBHost/src/hiduniversal.cpp | 421 ----- .../test/libraries/USBHost/src/hiduniversal.h | 105 -- .../test/libraries/USBHost/src/hidusagestr.h | 977 ---------- .../test/libraries/USBHost/src/macros.h | 82 - .../test/libraries/USBHost/src/message.cpp | 116 -- .../test/libraries/USBHost/src/message.h | 78 - .../test/libraries/USBHost/src/parsetools.cpp | 67 - .../test/libraries/USBHost/src/parsetools.h | 143 -- .../test/libraries/USBHost/src/printhex.h | 84 - .../test/libraries/USBHost/src/sink_parser.h | 41 - .../test/libraries/USBHost/src/usb_ch9.h | 174 -- .../test/libraries/USBHost/src/usbhub.cpp | 426 ----- .../test/libraries/USBHost/src/usbhub.h | 252 --- .../test/libraries/testlib1/testlib1.h | 0 .../test/libraries/testlib2/testlib2.h | 0 .../test/libraries/testlib3/testlib3.h | 0 .../test/libraries/testlib4/testlib4.h | 0 .../libraries/wronglib/library.properties | 9 - .../test/libraries/wronglib/src/.gitkeep | 0 .../test/libraries/wronglib/utility/.gitkeep | 0 .../test/merge_sketch_with_bootloader_test.go | 208 --- .../test/setup_build_properties_test.go | 156 -- legacy/builder/test/sketch1/header.h | 1 - .../test/store_build_options_map_test.go | 131 -- .../avr/builtin_tools_versions.txt | 2 - legacy/builder/test/tools_loader_test.go | 39 - .../try_build_of_problematic_sketch_test.go | 93 - .../test/user_hardware/arduino/avr/.gitkeep | 0 .../my_avr_platform/avr/boards.txt | 89 - .../stk500v2/stk500boot_v2_mega2560.hex | 469 ----- .../my_avr_platform/avr/libraries/SPI/SPI.cpp | 201 --- .../my_avr_platform/avr/libraries/SPI/SPI.h | 324 ---- .../BarometricPressureSensor.ino | 143 -- .../DigitalPotControl/DigitalPotControl.ino | 71 - .../avr/libraries/SPI/keywords.txt | 36 - .../avr/libraries/SPI/library.properties | 10 - .../my_avr_platform/avr/platform.txt | 9 - .../user_hardware/my_symlinked_avr_platform | 1 - legacy/builder/types/context.go | 9 - 122 files changed, 630 insertions(+), 12222 deletions(-) rename legacy/builder/test/sketch_class_function/sketch_class_function.ino => internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.preprocessed.txt rename legacy/builder/test/sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet/sketch.ino => internal/integrationtest/compile_4/testdata/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet.ino (100%) rename legacy/builder/test/sketch_that_includes_arduino_h/sketch_that_includes_arduino_h.ino => internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.preprocessed.txt rename legacy/builder/test/sketch_with_enum_class/sketch_with_enum_class.ino => internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.preprocessed.txt rename legacy/builder/test/sketch_with_externC/sketch_with_externC.ino => internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.preprocessed.txt rename legacy/builder/test/sketch_with_externC_multiline/sketch_with_externC_multiline.ino => internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.preprocessed.txt rename legacy/builder/test/sketch_with_fake_function_pointer/sketch_with_fake_function_pointer.ino => internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.preprocessed.txt rename legacy/builder/test/sketch_fastleds/sketch_fastleds.ino => internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.ino (99%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.preprocessed.txt rename legacy/builder/test/sketch1/sketch1.ino => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/SketchWithMergedSketchAndBootloader.ino (94%) rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/doc.txt (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/header.h rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/merged_sketch.txt (100%) rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/old.pde (100%) rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/other.ino (94%) rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/s_file.S (100%) rename {legacy/builder/test/sketch1 => internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader}/src/helper.h (100%) rename legacy/builder/test/sketch12/sketch12.ino => internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.preprocessed.txt rename legacy/builder/test/sketch_with_multiline_prototypes/sketch_with_multiline_prototypes.ino => internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt rename legacy/builder/test/sketch_with_multiline_template/sketch_with_multiline_template.ino => internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.preprocessed.txt rename legacy/builder/test/sketch_with_static_asserts/sketch_with_static_asserts.ino => internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino (100%) create mode 100644 internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.preprocessed.txt delete mode 100644 legacy/builder/test/.gitignore delete mode 100644 legacy/builder/test/builder_test.go delete mode 100644 legacy/builder/test/hardware/watterott/avr/boards.txt delete mode 100644 legacy/builder/test/hardware/watterott/avr/platform.txt delete mode 100644 legacy/builder/test/hardware/watterott/avr/programmers.txt delete mode 100644 legacy/builder/test/helper.go delete mode 100644 legacy/builder/test/helper_tools_downloader.go delete mode 100644 legacy/builder/test/libraries/ANewLibrary-master/anewlibrary.h delete mode 100644 legacy/builder/test/libraries/Balanduino/Balanduino.h delete mode 100644 legacy/builder/test/libraries/Balanduino/Kalman.h delete mode 100644 legacy/builder/test/libraries/Balanduino/PS3BT.h delete mode 100644 legacy/builder/test/libraries/Balanduino/SPP.h delete mode 100644 legacy/builder/test/libraries/Balanduino/Wii.h delete mode 100644 legacy/builder/test/libraries/Balanduino/XBOXRECV.h delete mode 100644 legacy/builder/test/libraries/Balanduino/adk.h delete mode 100644 legacy/builder/test/libraries/Balanduino/usbhub.h delete mode 100644 legacy/builder/test/libraries/FakeAudio/Audio.h delete mode 100644 legacy/builder/test/libraries/FakeAudio/FakeAudio.h delete mode 100644 legacy/builder/test/libraries/IRremote/IRremote.h delete mode 100644 legacy/builder/test/libraries/IRremote/IRremoteInt.h delete mode 100644 legacy/builder/test/libraries/SPI/SPI.cpp delete mode 100644 legacy/builder/test/libraries/SPI/SPI.h delete mode 100644 legacy/builder/test/libraries/SPI/keywords.txt delete mode 100644 legacy/builder/test/libraries/SPI/library.properties delete mode 100644 legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.cpp delete mode 100644 legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.h delete mode 100644 legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/doc/error.cpp delete mode 100644 legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.cpp delete mode 100644 legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.h delete mode 100644 legacy/builder/test/libraries/USBHost/keywords.txt delete mode 100644 legacy/builder/test/libraries/USBHost/library.properties delete mode 100644 legacy/builder/test/libraries/USBHost/src/KeyboardController.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/KeyboardController.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/MouseController.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/MouseController.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/Usb.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/Usb.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/UsbCore.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/address.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/adk.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/adk.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/confdescparser.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hexdump.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hid.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/hid.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hidboot.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/hidboot.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hidescriptorparser.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/hidescriptorparser.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hiduniversal.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/hiduniversal.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/hidusagestr.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/macros.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/message.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/message.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/parsetools.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/parsetools.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/printhex.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/sink_parser.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/usb_ch9.h delete mode 100644 legacy/builder/test/libraries/USBHost/src/usbhub.cpp delete mode 100644 legacy/builder/test/libraries/USBHost/src/usbhub.h delete mode 100644 legacy/builder/test/libraries/testlib1/testlib1.h delete mode 100644 legacy/builder/test/libraries/testlib2/testlib2.h delete mode 100644 legacy/builder/test/libraries/testlib3/testlib3.h delete mode 100644 legacy/builder/test/libraries/testlib4/testlib4.h delete mode 100644 legacy/builder/test/libraries/wronglib/library.properties delete mode 100644 legacy/builder/test/libraries/wronglib/src/.gitkeep delete mode 100644 legacy/builder/test/libraries/wronglib/utility/.gitkeep delete mode 100644 legacy/builder/test/merge_sketch_with_bootloader_test.go delete mode 100644 legacy/builder/test/setup_build_properties_test.go delete mode 100644 legacy/builder/test/sketch1/header.h delete mode 100644 legacy/builder/test/store_build_options_map_test.go delete mode 100644 legacy/builder/test/tools_builtin/avr/builtin_tools_versions.txt delete mode 100644 legacy/builder/test/tools_loader_test.go delete mode 100644 legacy/builder/test/try_build_of_problematic_sketch_test.go delete mode 100644 legacy/builder/test/user_hardware/arduino/avr/.gitkeep delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/boards.txt delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/bootloaders/stk500v2/stk500boot_v2_mega2560.hex delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/SPI.cpp delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/SPI.h delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/keywords.txt delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/library.properties delete mode 100644 legacy/builder/test/user_hardware/my_avr_platform/avr/platform.txt delete mode 120000 legacy/builder/test/user_hardware/my_symlinked_avr_platform diff --git a/.gitignore b/.gitignore index e3e93deba51..15f5060d5da 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ venv /dist /.pytest-tmp-dir /node_modules/ +__debug_bin* # gRPC client example folder /client_example/client_example diff --git a/internal/integrationtest/compile_4/compile_test.go b/internal/integrationtest/compile_4/compile_test.go index 4210eaa931f..07ba1f8e931 100644 --- a/internal/integrationtest/compile_4/compile_test.go +++ b/internal/integrationtest/compile_4/compile_test.go @@ -28,6 +28,7 @@ import ( "github.com/arduino/arduino-cli/internal/integrationtest" "github.com/arduino/go-paths-helper" "github.com/stretchr/testify/require" + "go.bug.st/testifyjson/requirejson" "golang.org/x/exp/slices" ) @@ -63,6 +64,8 @@ func TestCompileOfProblematicSketches(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "install", "CapacitiveSensor@0.5") require.NoError(t, err) + _, _, err = cli.Run("lib", "install", "FastLED@3.1.0") + require.NoError(t, err) // Install custom hardware required for tests customHwDir, err := paths.New("..", "testdata", "user_hardware").Abs() @@ -99,12 +102,24 @@ func TestCompileOfProblematicSketches(t *testing.T) { {"SketchNoFunctionsTwoFiles", testBuilderSketchNoFunctionsTwoFiles}, {"SketchWithClassAndMethodSubstring", testBuilderSketchWithClassAndMethodSubstring}, {"SketchThatChecksIfSPIHasTransactions", tryBuildAvrLeonardo}, + {"SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet", testBuilderSketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet}, {"SketchWithDependendLibraries", tryBuildAvrLeonardo}, {"SketchWithFunctionPointer", tryBuildAvrLeonardo}, {"USBHostExample", testBuilderUSBHostExample}, {"SketchWithConflictingLibraries", testBuilderSketchWithConflictingLibraries}, {"SketchLibraryProvidesAllIncludes", testBuilderSketchLibraryProvidesAllIncludes}, {"UserHardware", testBuilderWithUserHardware}, + {"SketchThatIncludesArduinoH", testBuilderSketchThatIncludesArduinoH}, + {"SketchWithStaticAsserts", testBuilderSketchWithStaticAsserts}, + {"SketchWithEnumClass", testBuilderSketchWithEnumClass}, + {"SketchWithExternC", testBuilderSketchWithExternC}, + {"SketchWithMultilinePrototypes", testBuilderSketchWithMultilinePrototypes}, + {"SketchWithExternCMultiline", testBuilderSketchWithExternCMultiline}, + {"SketchWithMultilineTemplate", testBuilderSketchWithMultilineTemplate}, + {"SketchWithFakeFunctionPointer", testBuilderSketchWithFakeFunctionPointer}, + {"SketchWithMinMaxDefinitions", testBuilderSketchWithMinMaxDefinitions}, + {"SketchWithFastledsLibrary", testBuilderSketchWithFastledsLibrary}, + {"SketchClassFunction", testBuilderSketchClassFunction}, }.Run(t, env, cli) } @@ -613,6 +628,179 @@ func tryBuildAvrLeonardo(t *testing.T, env *integrationtest.Environment, cli *in require.NoError(t, err) } +func testBuilderSketchThatIncludesArduinoH(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithStaticAsserts(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithEnumClass(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithExternC(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithMultilinePrototypes(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithExternCMultiline(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithMultilineTemplate(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithFakeFunctionPointer(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithMinMaxDefinitions(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:samd:arduino_zero_native") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:samd:arduino_zero_native") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchWithFastledsLibrary(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:samd:arduino_zero_native") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:samd:arduino_zero_native") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchClassFunction(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + }) + + t.Run("Preprocess", func(t *testing.T) { + // Preprocess + sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo") + require.NoError(t, err) + comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch) + }) +} + +func testBuilderSketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + t.Run("Build", func(t *testing.T) { + // Build + _, err := tryBuild(t, env, cli, "arduino:avr:leonardo") + require.Error(t, err) + }) +} + type builderOutput struct { CompilerOut string `json:"compiler_out"` CompilerErr string `json:"compiler_err"` @@ -765,3 +953,88 @@ func TestCoreCaching(t *testing.T) { require.NoError(t, err) require.NotEqual(t, coreStatBefore.ModTime(), coreStatAfterTouch.ModTime()) } + +func TestMergeSketchWithBootloader(t *testing.T) { + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + sketchPath, err := paths.New("testdata", "SketchWithMergedSketchAndBootloader").Abs() + require.NoError(t, err) + + // Install Arduino AVR Boards + _, _, err = cli.Run("core", "install", "arduino:avr@1.8.6") + require.NoError(t, err) + + buildPath, err := paths.MkTempDir("", "arduino-integration-test") + require.NoError(t, err) + defer buildPath.RemoveAll() + + // Build first time + _, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), sketchPath.String()) + require.NoError(t, err) + + bytes, err := buildPath.Join("SketchWithMergedSketchAndBootloader.ino.with_bootloader.hex").ReadFile() + require.NoError(t, err) + mergedSketchHex := string(bytes) + + require.Contains(t, mergedSketchHex, ":100000000C9434000C9446000C9446000C9446006A\n") + require.True(t, strings.HasSuffix(mergedSketchHex, ":00000001FF\n")) +} + +func TestBuildOptionsFile(t *testing.T) { + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + sketchPath := cli.CopySketch("sketch_simple") + defer sketchPath.RemoveAll() + + _, _, err := cli.Run("core", "install", "arduino:avr@1.8.6") + require.NoError(t, err) + + buildPath, err := paths.MkTempDir("", "arduino-integration-test") + require.NoError(t, err) + defer buildPath.RemoveAll() + + // Build first time + _, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), sketchPath.String()) + require.NoError(t, err) + + exist, err := buildPath.Join("build.options.json").ExistCheck() + require.NoError(t, err) + require.True(t, exist) + + buildOptionsBytes, err := buildPath.Join("build.options.json").ReadFile() + require.NoError(t, err) + + requirejson.Query(t, buildOptionsBytes, "keys", `[ + "additionalFiles", + "builtInToolsFolders", + "compiler.optimization_flags", + "customBuildProperties", + "fqbn", + "hardwareFolders", + "otherLibrariesFolders", + "sketchLocation" + ]`) + requirejson.Query(t, buildOptionsBytes, ".fqbn", `"arduino:avr:uno"`) + requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"build.warn_data_percentage=75"`) + + // Recompiling a second time should provide the same result + _, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), sketchPath.String()) + require.NoError(t, err) + + buildOptionsBytes, err = buildPath.Join("build.options.json").ReadFile() + require.NoError(t, err) + requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"build.warn_data_percentage=75"`) + + // Recompiling with a new build option must produce a new `build.options.json` + _, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), + "--build-property", "custom=prop", + sketchPath.String(), + ) + require.NoError(t, err) + + buildOptionsBytes, err = buildPath.Join("build.options.json").ReadFile() + require.NoError(t, err) + requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"custom=prop,build.warn_data_percentage=75"`) +} diff --git a/legacy/builder/test/sketch_class_function/sketch_class_function.ino b/internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.ino similarity index 100% rename from legacy/builder/test/sketch_class_function/sketch_class_function.ino rename to internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.preprocessed.txt new file mode 100644 index 00000000000..a49a869b9fe --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchClassFunction/SketchClassFunction.preprocessed.txt @@ -0,0 +1,17 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +class test { + void asdf() {} +}; +#line 4 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 7 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 8 {{QuoteCppString .sketchMainFile}} +void asdf(); +#line 4 {{QuoteCppString .sketchMainFile}} +void setup() { + asdf(); +} +void loop() {} +void asdf() {} diff --git a/legacy/builder/test/sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet/sketch.ino b/internal/integrationtest/compile_4/testdata/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet.ino similarity index 100% rename from legacy/builder/test/sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet/sketch.ino rename to internal/integrationtest/compile_4/testdata/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet/SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet.ino diff --git a/legacy/builder/test/sketch_that_includes_arduino_h/sketch_that_includes_arduino_h.ino b/internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.ino similarity index 100% rename from legacy/builder/test/sketch_that_includes_arduino_h/sketch_that_includes_arduino_h.ino rename to internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.preprocessed.txt new file mode 100644 index 00000000000..574062c29d2 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchThatIncludesArduinoH/SketchThatIncludesArduinoH.preprocessed.txt @@ -0,0 +1,21 @@ +#line 1 {{QuoteCppString .sketchMainFile}} +// Arduino.h should not be automatically included by the Arduino +// preprocessor before the explicit include line in this sketch. + +#if defined(HIGH) +#error Arduino.h seems to be automatically included +#endif + + # include + +#line 10 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 13 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 10 {{QuoteCppString .sketchMainFile}} +void setup() { +} + +void loop() { +} + diff --git a/legacy/builder/test/sketch_with_enum_class/sketch_with_enum_class.ino b/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino similarity index 100% rename from legacy/builder/test/sketch_with_enum_class/sketch_with_enum_class.ino rename to internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.preprocessed.txt new file mode 100644 index 00000000000..5aaae6f52ad --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.preprocessed.txt @@ -0,0 +1,31 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +#line 1 {{QuoteCppString .sketchMainFile}} +void test(); +#line 11 {{QuoteCppString .sketchMainFile}} +void test2(); +#line 14 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 17 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 1 {{QuoteCppString .sketchMainFile}} +void test() { + test2(); +} + +enum class MyEnum +{ + AValue = 0, + AnotherValue = 1 +}; + +void test2() { +} + +void setup() { +} + +void loop() { +} + + diff --git a/legacy/builder/test/sketch_with_externC/sketch_with_externC.ino b/internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.ino similarity index 100% rename from legacy/builder/test/sketch_with_externC/sketch_with_externC.ino rename to internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.preprocessed.txt new file mode 100644 index 00000000000..c067a742cdd --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithExternC/SketchWithExternC.preprocessed.txt @@ -0,0 +1,20 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +#line 1 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 6 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 11 {{QuoteCppString .sketchMainFile}} + extern "C" void test(); +#line 1 {{QuoteCppString .sketchMainFile}} +void setup() { + // put your setup code here, to run once: + test(); +} + +void loop() { + // put your main code here, to run repeatedly: + +} + +extern "C" void test() {} diff --git a/legacy/builder/test/sketch_with_externC_multiline/sketch_with_externC_multiline.ino b/internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.ino similarity index 100% rename from legacy/builder/test/sketch_with_externC_multiline/sketch_with_externC_multiline.ino rename to internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.preprocessed.txt new file mode 100644 index 00000000000..f40f61fe921 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.preprocessed.txt @@ -0,0 +1,51 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +#line 1 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 5 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 15 {{QuoteCppString .sketchMainFile}} + extern "C" void test2(); +#line 20 {{QuoteCppString .sketchMainFile}} + extern "C" void test4(); +#line 26 {{QuoteCppString .sketchMainFile}} + extern "C" void test6(); +#line 30 {{QuoteCppString .sketchMainFile}} +void test7(); +#line 32 {{QuoteCppString .sketchMainFile}} + extern "C" void test10(); +#line 1 {{QuoteCppString .sketchMainFile}} +void setup() { + // put your setup code here, to run once: + } + + void loop() { + // put your main code here, to run repeatedly: + test2(); + test4(); + test6(); + test7(); + test10(); + } + + extern "C" { + void test2() {} + } + + extern "C" + { + void test4() {} + } + + extern "C" + + { + void test6() {} + } + + // this function should not have C linkage + void test7() {} + + extern "C" void test10() { + + }; diff --git a/legacy/builder/test/sketch_with_fake_function_pointer/sketch_with_fake_function_pointer.ino b/internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.ino similarity index 100% rename from legacy/builder/test/sketch_with_fake_function_pointer/sketch_with_fake_function_pointer.ino rename to internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.preprocessed.txt new file mode 100644 index 00000000000..4fb3e3e61f1 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.preprocessed.txt @@ -0,0 +1,27 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +template< uint16_t nBuffSize > + class Foo{ + public: + + template< uint16_t N > + Foo &operator +=( const Foo &ref ){ + //... + return *this; + } +}; + +Foo<64> a; +Foo<32> b; + +#line 15 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 19 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 15 {{QuoteCppString .sketchMainFile}} +void setup(){ + a += b; +} + +void loop(){} + diff --git a/legacy/builder/test/sketch_fastleds/sketch_fastleds.ino b/internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.ino similarity index 99% rename from legacy/builder/test/sketch_fastleds/sketch_fastleds.ino rename to internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.ino index eba4f5265cf..82c208e69c0 100644 --- a/legacy/builder/test/sketch_fastleds/sketch_fastleds.ino +++ b/internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.ino @@ -24,4 +24,4 @@ SimplePatternList gPatterns = {sinelon}; void sinelon() { -} \ No newline at end of file +} diff --git a/internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.preprocessed.txt new file mode 100644 index 00000000000..e770d0c709b --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithFastledsLibrary/SketchWithFastledsLibrary.preprocessed.txt @@ -0,0 +1,37 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +#include "FastLED.h" + +#define DATA_PIN 7 +#define CLK_PIN 6 +#define LED_TYPE APA102 +#define COLOR_ORDER GRB +#define NUM_LEDS 79 +CRGB leds[NUM_LEDS]; + +#define BRIGHTNESS 96 +#define FRAMES_PER_SECOND 120 +#line 12 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 17 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 25 {{QuoteCppString .sketchMainFile}} +void sinelon(); +#line 12 {{QuoteCppString .sketchMainFile}} +void setup() { + + FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); +} + +void loop() { + +} + +typedef void (*SimplePatternList[])(); +//SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; +SimplePatternList gPatterns = {sinelon}; + +void sinelon() +{ +} + diff --git a/legacy/builder/test/sketch1/sketch1.ino b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/SketchWithMergedSketchAndBootloader.ino similarity index 94% rename from legacy/builder/test/sketch1/sketch1.ino rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/SketchWithMergedSketchAndBootloader.ino index 0d5e0f5ceb9..32f56baab79 100644 --- a/legacy/builder/test/sketch1/sketch1.ino +++ b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/SketchWithMergedSketchAndBootloader.ino @@ -4,4 +4,4 @@ void setup() { void loop() { -} \ No newline at end of file +} diff --git a/legacy/builder/test/sketch1/doc.txt b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/doc.txt similarity index 100% rename from legacy/builder/test/sketch1/doc.txt rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/doc.txt diff --git a/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/header.h b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/header.h new file mode 100644 index 00000000000..eb6f60040f0 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/header.h @@ -0,0 +1 @@ +#define TRUE FALSE diff --git a/legacy/builder/test/sketch1/merged_sketch.txt b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/merged_sketch.txt similarity index 100% rename from legacy/builder/test/sketch1/merged_sketch.txt rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/merged_sketch.txt diff --git a/legacy/builder/test/sketch1/old.pde b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/old.pde similarity index 100% rename from legacy/builder/test/sketch1/old.pde rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/old.pde diff --git a/legacy/builder/test/sketch1/other.ino b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/other.ino similarity index 94% rename from legacy/builder/test/sketch1/other.ino rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/other.ino index c426196c017..b0f732c3f50 100644 --- a/legacy/builder/test/sketch1/other.ino +++ b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/other.ino @@ -1,3 +1,3 @@ String hello() { return "world"; -} \ No newline at end of file +} diff --git a/legacy/builder/test/sketch1/s_file.S b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/s_file.S similarity index 100% rename from legacy/builder/test/sketch1/s_file.S rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/s_file.S diff --git a/legacy/builder/test/sketch1/src/helper.h b/internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/src/helper.h similarity index 100% rename from legacy/builder/test/sketch1/src/helper.h rename to internal/integrationtest/compile_4/testdata/SketchWithMergedSketchAndBootloader/src/helper.h diff --git a/legacy/builder/test/sketch12/sketch12.ino b/internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.ino similarity index 100% rename from legacy/builder/test/sketch12/sketch12.ino rename to internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.preprocessed.txt new file mode 100644 index 00000000000..140c8f2b30a --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithMinMaxDefinitions/SketchWithMinMaxDefinitions.preprocessed.txt @@ -0,0 +1,26 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +// See: https://github.com/arduino/arduino-builder/issues/68 + +// The following avoid duplicate definitions of min and max +#undef min +#undef max + +#include + +#line 9 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 13 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 15 {{QuoteCppString .sketchMainFile}} +void test(); +#line 9 {{QuoteCppString .sketchMainFile}} +void setup() { + test(); +} + +void loop() {} + +void test() {} + + diff --git a/legacy/builder/test/sketch_with_multiline_prototypes/sketch_with_multiline_prototypes.ino b/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.ino similarity index 100% rename from legacy/builder/test/sketch_with_multiline_prototypes/sketch_with_multiline_prototypes.ino rename to internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt new file mode 100644 index 00000000000..513eea23055 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt @@ -0,0 +1,76 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +#line 1 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 12 {{QuoteCppString .sketchMainFile}} +void myctagstestfunc(int a, int b, int c, int d); +#line 17 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 18 {{QuoteCppString .sketchMainFile}} +void test(); +#line 21 {{QuoteCppString .sketchMainFile}} +void test3(); +#line 25 {{QuoteCppString .sketchMainFile}} +void test5(int a, int b, int c); +#line 33 {{QuoteCppString .sketchMainFile}} +void test7(); +#line 36 {{QuoteCppString .sketchMainFile}} +void test8(); +#line 44 {{QuoteCppString .sketchMainFile}} +void test9(int a, int b); +#line 50 {{QuoteCppString .sketchMainFile}} +void test10(int a, int b, int c ); +#line 1 {{QuoteCppString .sketchMainFile}} +void setup() { + myctagstestfunc(1,2,3,4); + test(); + test3(); + test5(1,2,3); + test7(); + test8(); + test9(42, 42); + test10(0,0,0); +} + +void myctagstestfunc(int a, +int b, +int c, +int d) { } + +void loop() {} + +void +test() {} + +void +// comment +test3() {} + +void +test5(int a, + int b, + int c) +{ + +} + +void /* comment */ +test7() {} + +void +/* +multi +line +comment +*/ +test8() {} + + void + /* comment */ + test9(int a, + int b) {} + +void test10(int a, // this + int b, // doesn't + int c // work + ) {} diff --git a/legacy/builder/test/sketch_with_multiline_template/sketch_with_multiline_template.ino b/internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.ino similarity index 100% rename from legacy/builder/test/sketch_with_multiline_template/sketch_with_multiline_template.ino rename to internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.preprocessed.txt new file mode 100644 index 00000000000..bf3b3ae2e32 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithMultilineTemplate/SketchWithMultilineTemplate.preprocessed.txt @@ -0,0 +1,20 @@ +#include +#line 0 {{QuoteCppString .sketchMainFile}} +template< typename T > T func(T t); +#line 6 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 10 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 0 {{QuoteCppString .sketchMainFile}} +#line 1 {{QuoteCppString .sketchMainFile}} +template< typename T > +T func(T t){ + return t * t; +} + +void setup() { + func( 12.34f ); +} + +void loop() {} + diff --git a/legacy/builder/test/sketch_with_static_asserts/sketch_with_static_asserts.ino b/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino similarity index 100% rename from legacy/builder/test/sketch_with_static_asserts/sketch_with_static_asserts.ino rename to internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino diff --git a/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.preprocessed.txt b/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.preprocessed.txt new file mode 100644 index 00000000000..87c352443c5 --- /dev/null +++ b/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.preprocessed.txt @@ -0,0 +1,26 @@ +#include +#line 1 {{QuoteCppString .sketchMainFile}} +// https://github.com/arduino/arduino-builder/issues/68 + +const int a = 10; +const int b = 20; + +static_assert(a < b, "bar"); + +#line 8 {{QuoteCppString .sketchMainFile}} +void setup(); +#line 12 {{QuoteCppString .sketchMainFile}} +void loop(); +#line 15 {{QuoteCppString .sketchMainFile}} +void test(); +#line 8 {{QuoteCppString .sketchMainFile}} +void setup() { + test(); +} + +void loop() { +} + +void test() { +} + diff --git a/legacy/builder/builder.go b/legacy/builder/builder.go index cf9551b0d99..e7fa77fc7f4 100644 --- a/legacy/builder/builder.go +++ b/legacy/builder/builder.go @@ -27,8 +27,6 @@ import ( var tr = i18n.Tr -const DEFAULT_DEBUG_LEVEL = 5 - type Builder struct{} func (s *Builder) Run(ctx *types.Context) error { diff --git a/legacy/builder/test/.gitignore b/legacy/builder/test/.gitignore deleted file mode 100644 index c49bbb5b804..00000000000 --- a/legacy/builder/test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -downloaded_* diff --git a/legacy/builder/test/builder_test.go b/legacy/builder/test/builder_test.go deleted file mode 100644 index 25df800ff5e..00000000000 --- a/legacy/builder/test/builder_test.go +++ /dev/null @@ -1,141 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "fmt" - "os" - "path/filepath" - "testing" - - bldr "github.com/arduino/arduino-cli/arduino/builder" - "github.com/arduino/arduino-cli/arduino/builder/detector" - "github.com/arduino/arduino-cli/arduino/builder/logger" - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/sketch" - "github.com/arduino/arduino-cli/legacy/builder/types" - "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -func cleanUpBuilderTestContext(t *testing.T, ctx *types.Context) { - if ctx.Builder.GetBuildPath() != nil { - require.NoError(t, ctx.Builder.GetBuildPath().RemoveAll()) - } -} - -func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *paths.Path, fqbnString string) *types.Context { - DownloadCoresAndToolsAndLibraries(t) - - if ctx == nil { - ctx = &types.Context{} - } - if ctx.HardwareDirs.Len() == 0 { - ctx.HardwareDirs = paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware") - ctx.BuiltInToolsDirs = paths.NewPathList("downloaded_tools") - ctx.BuiltInLibrariesDirs = paths.New("downloaded_libraries") - ctx.OtherLibrariesDirs = paths.NewPathList("libraries") - } - - buildPath, err := paths.MkTempDir("", "test_build_path") - require.NoError(t, err) - require.NotNil(t, buildPath) - - // Create a Package Manager from the given context - // This should happen only on legacy arduino-builder. - // Hopefully this piece will be removed once the legacy package will be cleanedup. - pmb := packagemanager.NewBuilder(nil, nil, nil, nil, "arduino-builder") - for _, err := range pmb.LoadHardwareFromDirectories(ctx.HardwareDirs) { - // NoError(t, err) - fmt.Println(err) - } - if ctx.BuiltInToolsDirs != nil { - pmb.LoadToolsFromBundleDirectories(ctx.BuiltInToolsDirs) - } - pm := pmb.Build() - pme, _ /* never release... */ := pm.NewExplorer() - ctx.PackageManager = pme - - var sk *sketch.Sketch - if sketchPath != nil { - s, err := sketch.New(sketchPath) - require.NoError(t, err) - sk = s - } - - // This is an hack to avoid panic when the `NewBuilder` assert a condition on sketch path. - // Since the test will be migrated soon in an E2E manner we temporary set the sketch to be empty. - // so this assertion inside the Builder: - // buildPath().Canonical().EqualsTo(sk.FullPath.Canonical())` - // Doesn't fail - if sk == nil { - sk = &sketch.Sketch{ - MainFile: &paths.Path{}, - FullPath: paths.New(os.TempDir()), - OtherSketchFiles: []*paths.Path{}, - AdditionalFiles: []*paths.Path{}, - RootFolderFiles: []*paths.Path{}, - Project: &sketch.Project{}, - } - } - - builderLogger := logger.New(nil, nil, false, "") - ctx.BuilderLogger = builderLogger - ctx.Builder, err = bldr.NewBuilder( - sk, nil, buildPath, false, nil, 0, nil, - ctx.HardwareDirs, ctx.BuiltInToolsDirs, ctx.OtherLibrariesDirs, - ctx.BuiltInLibrariesDirs, parseFQBN(t, "a:b:c"), false, nil, false, - nil, nil, builderLogger, nil, - ) - require.NoError(t, err) - - var actualPlatform, targetPlatform *cores.PlatformRelease - if fqbnString != "" { - fqbn := parseFQBN(t, fqbnString) - _, targetPlatfrm, _, boardBuildProperties, buildPlatform, err := pme.ResolveFQBN(fqbn) - require.NoError(t, err) - targetPlatform = targetPlatfrm - actualPlatform = buildPlatform - - _, err = pme.FindToolsRequiredForBuild(targetPlatform, buildPlatform) - require.NoError(t, err) - - ctx.Builder, err = bldr.NewBuilder( - sk, boardBuildProperties, buildPath, false, nil, 0, nil, - ctx.HardwareDirs, ctx.BuiltInToolsDirs, ctx.OtherLibrariesDirs, - ctx.BuiltInLibrariesDirs, fqbn, false, nil, false, targetPlatform, - actualPlatform, builderLogger, nil) - require.NoError(t, err) - ctx.PackageManager = pme - } - - lm, libsResolver, _, err := detector.LibrariesLoader( - false, nil, - ctx.BuiltInLibrariesDirs, nil, ctx.OtherLibrariesDirs, - actualPlatform, targetPlatform, - ) - require.NoError(t, err) - - ctx.SketchLibrariesDetector = detector.NewSketchLibrariesDetector( - lm, libsResolver, - false, - false, - builderLogger, - ) - - return ctx -} diff --git a/legacy/builder/test/hardware/watterott/avr/boards.txt b/legacy/builder/test/hardware/watterott/avr/boards.txt deleted file mode 100644 index be844787844..00000000000 --- a/legacy/builder/test/hardware/watterott/avr/boards.txt +++ /dev/null @@ -1,130 +0,0 @@ -# VID 0x6666 is a prototype product Vendor ID -# http://www.linux-usb.org/usb.ids - -menu.speed=Speed -menu.core=Core -menu.info=Info - - -# ATmega32u4 @ 16 MHz -atmega32u4.name=ATmega32u4 -atmega32u4.menu.speed.16mhz=16 MHz -atmega32u4.menu.speed.16mhz.build.f_cpu=16000000L -atmega32u4.menu.speed.16mhz.bootloader.file=caterina_16mhz.hex -atmega32u4.menu.speed.8mhz=8 MHz -atmega32u4.menu.speed.8mhz.build.f_cpu=8000000L -atmega32u4.menu.speed.8mhz.bootloader.file=caterina_8mhz.hex -atmega32u4.vid.0=0x1D50 -atmega32u4.pid.0=0x60B0 -atmega32u4.vid.1=0x6666 -atmega32u4.pid.1=0x60B0 -atmega32u4.vid.2=0x2341 -atmega32u4.pid.2=0x0036 -atmega32u4.vid.3=0x2341 -atmega32u4.pid.3=0x8036 -atmega32u4.vid.4=0x2A03 -atmega32u4.pid.4=0x0036 -atmega32u4.vid.5=0x2A03 -atmega32u4.pid.5=0x8036 -atmega32u4.bootloader.tool=avrdude -atmega32u4.bootloader.low_fuses=0xff -atmega32u4.bootloader.high_fuses=0xd8 -atmega32u4.bootloader.extended_fuses=0xcb -#atmega32u4.bootloader.file=caterina_16mhz.hex -atmega32u4.bootloader.unlock_bits=0x3F -atmega32u4.bootloader.lock_bits=0x2F -atmega32u4.upload.tool=avrdude -atmega32u4.upload.protocol=avr109 -atmega32u4.upload.maximum_size=28672 -atmega32u4.upload.maximum_data_size=2560 -atmega32u4.upload.speed=57600 -atmega32u4.upload.disable_flushing=true -atmega32u4.upload.use_1200bps_touch=true -atmega32u4.upload.wait_for_upload_port=true -atmega32u4.build.mcu=atmega32u4 -#atmega32u4.build.f_cpu=16000000L -atmega32u4.build.vid=0x6666 -atmega32u4.build.pid=0x60B0 -atmega32u4.build.usb_product="USB IO Board" -atmega32u4.build.usb_manufacturer="ATmega32u4" -atmega32u4.build.board=AVR_LEONARDO -atmega32u4.build.core=arduino:arduino -atmega32u4.build.variant=leonardo -atmega32u4.build.extra_flags={build.usb_flags} -DMOUSE_ABS_ENABLED - - -# ATtiny841 @ internal 8 MHz -attiny841.name=ATtiny841 (8 MHz) -# use Standard Arduino Core -attiny841.menu.core.arduino=Standard Arduino -attiny841.menu.core.arduino.build.core=arduino:arduino -attiny841.menu.core.arduino.build.variant=tiny14 -# use Spence Konde Core: https://github.com/SpenceKonde/arduino-tiny-841/ -attiny841.menu.core.spencekonde=ATtiny841 (by Spence Konde) -#attiny841.menu.core.spencekonde.build.core=arduino-tiny-841:tiny -attiny841.menu.core.spencekonde.build.core=tiny841 -attiny841.menu.core.spencekonde.build.variant=tiny14 -# info menu item -attiny841.menu.info.info=Press Reset, when Uploading is shown. -attiny841.vid.0=0x16D0 -attiny841.pid.0=0x0753 -attiny841.bootloader.tool=avrdude -attiny841.bootloader.low_fuses=0xE2 -attiny841.bootloader.high_fuses=0xDD -attiny841.bootloader.extended_fuses=0xFE -attiny841.bootloader.unlock_bits=0xFF -attiny841.bootloader.lock_bits=0xFF -attiny841.bootloader.file=micronucleus-t841.hex -attiny841.upload.tool=micronucleus -attiny841.upload.protocol=usb -attiny841.upload.wait_for_upload_port=false -attiny841.upload.use_1200bps_touch=false -attiny841.upload.disable_flushing=false -attiny841.upload.maximum_size=6500 -attiny841.build.mcu=attiny841 -attiny841.build.f_cpu=8000000L -attiny841.build.board=AVR_ATTINY841 -#attiny841.build.core=arduino:arduino -#attiny841.build.variant=tiny14 - - -# ATtiny85 @ internal 16.5 MHz -attiny85.name=ATtiny85 (16.5 MHz) -# use Standard Arduino Core -attiny85.menu.core.arduino=Standard Arduino -attiny85.menu.core.arduino.build.board=AVR_ATTINY85 -attiny85.menu.core.arduino.build.core=arduino:arduino -attiny85.menu.core.arduino.build.variant=tiny8 -# use Spence Konde Core: https://github.com/SpenceKonde/ATTinyCore -attiny85.menu.core.spencekonde=ATtiny85 (by Spence Konde) -attiny85.menu.core.spencekonde.build.board=AVR_ATTINY85 -#attiny85.menu.core.spencekonde.build.core=ATTinyCore:tiny -attiny85.menu.core.spencekonde.build.core=tiny85 -attiny85.menu.core.spencekonde.build.variant=tiny8 -# use Digistump Core: https://github.com/digistump/DigistumpArduino -attiny85.menu.core.digistump=Digistump/Digispark -attiny85.menu.core.digistump.build.board=AVR_DIGISPARK -attiny85.menu.core.digistump.build.core=digistump:tiny -attiny85.menu.core.digistump.build.variant=digispark -# info menu item -attiny85.menu.info.info=Press Reset, when Uploading is shown. -attiny85.vid.0=0x16D0 -attiny85.pid.0=0x0753 -attiny85.bootloader.tool=avrdude -attiny85.bootloader.low_fuses=0xE1 -attiny85.bootloader.high_fuses=0xDD -attiny85.bootloader.extended_fuses=0xFE -attiny85.bootloader.unlock_bits=0xFF -attiny85.bootloader.lock_bits=0xFF -attiny85.bootloader.file=micronucleus-t85.hex -attiny85.upload.tool=micronucleus -attiny85.upload.protocol=usb -attiny85.upload.wait_for_upload_port=false -attiny85.upload.use_1200bps_touch=false -attiny85.upload.disable_flushing=false -attiny85.upload.maximum_size=6300 -attiny85.build.mcu=attiny85 -attiny85.build.f_cpu=16500000L -attiny85.build.board=AVR_ATTINY85 -#attiny85.build.core=arduino:arduino -#attiny85.build.variant=tiny8 diff --git a/legacy/builder/test/hardware/watterott/avr/platform.txt b/legacy/builder/test/hardware/watterott/avr/platform.txt deleted file mode 100644 index 13d46ceae1e..00000000000 --- a/legacy/builder/test/hardware/watterott/avr/platform.txt +++ /dev/null @@ -1,146 +0,0 @@ - -# Watterott AVR Core and platform. -# ------------------------------ -# -# For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification - -name=Watterott AVR Boards -version=1.0.0 - -# AVR compile variables -# --------------------- - -compiler.warning_flags=-w -compiler.warning_flags.none=-w -compiler.warning_flags.default= -compiler.warning_flags.more=-Wall -compiler.warning_flags.all=-Wall -Wextra - -# Default "compiler.path" is correct, change only if you want to overidde the initial value -#compiler.path={runtime.ide.path}/hardware/tools/avr/bin/ -compiler.path={runtime.tools.avr-gcc.path}/bin/ -compiler.c.cmd=avr-gcc -compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD -# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396 -# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain -compiler.c.elf.flags=-Os {compiler.warning_flags} -Wl,--gc-sections -compiler.c.elf.cmd=avr-gcc -compiler.S.flags=-c -g -x assembler-with-cpp -compiler.cpp.cmd=avr-g++ -compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -compiler.ar.cmd=avr-ar -compiler.ar.flags=rcs -compiler.objcopy.cmd=avr-objcopy -compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 -compiler.elf2hex.flags=-O ihex -R .eeprom -compiler.elf2hex.cmd=avr-objcopy -compiler.ldflags= -compiler.size.cmd=avr-size - -# This can be overriden in boards.txt -build.extra_flags= - -# These can be overridden in platform.local.txt -compiler.c.extra_flags= -compiler.c.elf.extra_flags= -compiler.S.extra_flags= -compiler.cpp.extra_flags= -compiler.ar.extra_flags= -compiler.objcopy.eep.extra_flags= -compiler.elf2hex.extra_flags= - -# AVR compile patterns -# -------------------- - -## Compile c files -recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" - -## Compile c++ files -recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" - -## Compile S files -recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" - -## Create archives -recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}" - -## Combine gc-sections, archives, and objects -recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm - -## Create output files (.eep and .hex) -recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep" -recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" - -## Save hex -recipe.output.tmp_file={build.project_name}.hex -recipe.output.save_file={build.project_name}.{build.variant}.hex - -## Compute size -recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" -recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).* -recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).* -recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).* - -## Preprocessor -preproc.includes.flags=-w -x c++ -M -MG -MP -recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -preproc.macros.flags=-w -x c++ -E -CC -recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" - - -# AVR Uploader/Programmers tools -# ------------------------------ - -## AVRdude -#tools.avrdude.path={runtime.ide.path}/hardware/tools/avr/ -tools.avrdude.path={runtime.tools.avrdude.path} -tools.avrdude.cmd.path={path}/bin/avrdude -#tools.avrdude.config.path={path}/etc/avrdude.conf -tools.avrdude.config.path={runtime.platform.path}/tools/avrdude.conf - -tools.avrdude.upload.params.verbose=-v -tools.avrdude.upload.params.quiet=-q -q -tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i" - -tools.avrdude.program.params.verbose=-v -tools.avrdude.program.params.quiet=-q -q -tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i" - -tools.avrdude.erase.params.verbose=-v -tools.avrdude.erase.params.quiet=-q -q -tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m - -tools.avrdude.bootloader.params.verbose=-v -tools.avrdude.bootloader.params.quiet=-q -q -tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m - -## Micronucleus -tools.micronucleus.path={runtime.tools.micronucleus.path} -tools.micronucleus.cmd=micronucleus -tools.micronucleus.cmd.windows=micronucleus.exe - -tools.micronucleus.upload.params.verbose= -tools.micronucleus.upload.params.quiet= -tools.micronucleus.upload.pattern="{path}/{cmd}" --run --timeout 60 "{build.path}/{build.project_name}.hex" - -tools.micronucleus.program.params.verbose= -tools.micronucleus.program.params.quiet= -tools.micronucleus.program.pattern="{path}/{cmd}" --run --timeout 60 "{build.path}/{build.project_name}.hex" - -tools.micronucleus.erase.params.verbose= -tools.micronucleus.erase.params.quiet= -tools.micronucleus.erase.pattern= -#tools.micronucleus.erase.pattern="{path}/{cmd}" --erase-only --timeout 60 - -tools.micronucleus.bootloader.params.verbose= -tools.micronucleus.bootloader.params.quiet= -tools.micronucleus.bootloader.pattern="{path}/{cmd}" --run --timeout 60 "{runtime.platform.path}/bootloaders/{bootloader.file}" - - -# USB Default Flags -# Default blank usb manufacturer will be filled it at compile time -# - from numeric vendor ID, set to Unknown otherwise -build.usb_manufacturer="Unknown" -build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' - diff --git a/legacy/builder/test/hardware/watterott/avr/programmers.txt b/legacy/builder/test/hardware/watterott/avr/programmers.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/helper.go b/legacy/builder/test/helper.go deleted file mode 100644 index 746096c473f..00000000000 --- a/legacy/builder/test/helper.go +++ /dev/null @@ -1,37 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// Copyright 2015 Matthijs Kooijman -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "testing" - - "github.com/arduino/arduino-cli/arduino/cores" - paths "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -func SetupBuildPath(t *testing.T) *paths.Path { - buildPath, err := paths.MkTempDir("", "test_build_path") - require.NoError(t, err) - return buildPath -} - -func parseFQBN(t *testing.T, fqbnIn string) *cores.FQBN { - fqbn, err := cores.ParseFQBN(fqbnIn) - require.NoError(t, err) - return fqbn -} diff --git a/legacy/builder/test/helper_tools_downloader.go b/legacy/builder/test/helper_tools_downloader.go deleted file mode 100644 index ee4b60df572..00000000000 --- a/legacy/builder/test/helper_tools_downloader.go +++ /dev/null @@ -1,726 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "os" - "os/exec" - "runtime" - "strings" - "testing" - - "github.com/arduino/go-paths-helper" - "github.com/arduino/go-properties-orderedmap" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" -) - -var hardwareFolder = paths.New("downloaded_hardware") -var boardManagerFolder = paths.New("downloaded_board_manager_stuff") -var toolsFolder = paths.New("downloaded_tools") -var librariesFolder = paths.New("downloaded_libraries") -var patchesFolder = paths.New("downloaded_stuff_patches") - -type Tool struct { - Name string - Package string - Version string - OsUrls []OsUrl -} - -type OsUrl struct { - Os string - Url string -} - -type Library struct { - Name string - Version string - VersionInLibProperties string - Url string -} - -type Core struct { - Maintainer string - Arch string - Version string - Url string -} - -func DownloadCoresAndToolsAndLibraries(t *testing.T) { - cores := []Core{ - {Maintainer: "arduino", Arch: "avr", Version: "1.6.10"}, - {Maintainer: "arduino", Arch: "sam", Version: "1.6.7"}, - } - - boardsManagerCores := []Core{ - {Maintainer: "arduino", Arch: "samd", Version: "1.6.5"}, - } - - boardsManagerRedBearCores := []Core{ - {Maintainer: "RedBearLab", Arch: "avr", Version: "1.0.0", Url: "https://redbearlab.github.io/arduino/Blend/blend_boards.zip"}, - } - - toolsMultipleVersions := []Tool{ - {Name: "bossac", Version: "1.6.1-arduino"}, - {Name: "bossac", Version: "1.5-arduino"}, - } - - tools := []Tool{ - {Name: "avrdude", Version: "6.0.1-arduino5"}, - {Name: "avr-gcc", Version: "4.8.1-arduino5"}, - {Name: "arm-none-eabi-gcc", Version: "4.8.3-2014q1"}, - {Name: "ctags", Version: "5.8-arduino11", - OsUrls: []OsUrl{ - {Os: "i686-pc-linux-gnu", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-i686-pc-linux-gnu.tar.bz2"}, - {Os: "x86_64-pc-linux-gnu", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-x86_64-pc-linux-gnu.tar.bz2"}, - {Os: "i686-mingw32", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-i686-mingw32.zip"}, - {Os: "x86_64-apple-darwin", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-x86_64-apple-darwin.zip"}, - {Os: "arm-linux-gnueabihf", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-armv6-linux-gnueabihf.tar.bz2"}, - {Os: "aarch64-linux-gnu", Url: "http://downloads.arduino.cc/tools/ctags-5.8-arduino11-aarch64-linux-gnu.tar.bz2"}, - }, - }, - {Name: "arduino-preprocessor", Version: "0.1.5", - OsUrls: []OsUrl{ - {Os: "i686-pc-linux-gnu", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-i686-pc-linux-gnu.tar.bz2"}, - {Os: "x86_64-pc-linux-gnu", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-x86_64-pc-linux-gnu.tar.bz2"}, - {Os: "i686-mingw32", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-i686-w64-mingw32.tar.bz2"}, - {Os: "x86_64-apple-darwin", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-x86_64-apple-darwin11.tar.bz2"}, - {Os: "arm-linux-gnueabihf", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-arm-linux-gnueabihf.tar.bz2"}, - {Os: "aarch64-linux-gnu", Url: "https://github.com/arduino/arduino-preprocessor/releases/download/0.1.5/arduino-preprocessor-0.1.5-aarch64-linux-gnu.tar.bz2"}, - }, - }, - } - - boardsManagerTools := []Tool{ - {Name: "openocd", Version: "0.9.0-arduino", Package: "arduino"}, - {Name: "CMSIS", Version: "4.0.0-atmel", Package: "arduino"}, - } - - boardsManagerRFduinoTools := []Tool{ - {Name: "arm-none-eabi-gcc", Version: "4.8.3-2014q1", Package: "RFduino"}, - } - - libraries := []Library{ - {Name: "Audio", Version: "1.0.4"}, - {Name: "Adafruit PN532", Version: "1.0.0"}, - {Name: "Bridge", Version: "1.6.1"}, - {Name: "CapacitiveSensor", Version: "0.5.0", VersionInLibProperties: "0.5"}, - {Name: "Ethernet", Version: "1.1.1"}, - {Name: "Robot IR Remote", Version: "2.0.0"}, - {Name: "FastLED", Version: "3.1.0"}, - } - - download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools, libraries) - - patchFiles(t) -} - -func patchFiles(t *testing.T) { - err := patchesFolder.MkdirAll() - require.NoError(t, err) - files, err := patchesFolder.ReadDir() - require.NoError(t, err) - - for _, file := range files { - if file.Ext() == ".patch" { - panic("Patching for downloaded tools is not available! (see https://github.com/arduino/arduino-builder/issues/147)") - // XXX: find an alternative to x/codereview/patch - // https://github.com/arduino/arduino-builder/issues/147 - /* - data, err := ioutil.ReadFile(Abs(t, filepath.Join(PATCHES_FOLDER, file.Name()))) - require.NoError(t, err) - patchSet, err := patch.Parse(data) - require.NoError(t, err) - operations, err := patchSet.Apply(ioutil.ReadFile) - for _, op := range operations { - utils.WriteFileBytes(op.Dst, op.Data) - } - */ - } - } -} - -func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores []Core, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools []Tool, libraries []Library) { - allCoresDownloaded, err := allCoresAlreadyDownloadedAndUnpacked(hardwareFolder, cores) - require.NoError(t, err) - if allCoresDownloaded && - allBoardsManagerCoresAlreadyDownloadedAndUnpacked(boardManagerFolder, boardsManagerCores) && - allBoardsManagerCoresAlreadyDownloadedAndUnpacked(boardManagerFolder, boardsManagerRedBearCores) && - allBoardsManagerToolsAlreadyDownloadedAndUnpacked(boardManagerFolder, boardsManagerTools) && - allBoardsManagerToolsAlreadyDownloadedAndUnpacked(boardManagerFolder, boardsManagerRFduinoTools) && - allToolsAlreadyDownloadedAndUnpacked(toolsFolder, tools) && - allToolsAlreadyDownloadedAndUnpacked(toolsFolder, toolsMultipleVersions) && - allLibrariesAlreadyDownloadedAndUnpacked(librariesFolder, libraries) { - return - } - - index, err := downloadIndex("http://downloads.arduino.cc/packages/package_index.json") - require.NoError(t, err) - - err = downloadCores(cores, index) - require.NoError(t, err) - - err = downloadBoardManagerCores(boardsManagerCores, index) - require.NoError(t, err) - - err = downloadTools(tools, index) - require.NoError(t, err) - - err = downloadToolsMultipleVersions(toolsMultipleVersions, index) - require.NoError(t, err) - - err = downloadBoardsManagerTools(boardsManagerTools, index) - require.NoError(t, err) - - rfduinoIndex, err := downloadIndex("http://downloads.arduino.cc/packages/test_package_rfduino_index.json") - require.NoError(t, err) - - err = downloadBoardsManagerTools(boardsManagerRFduinoTools, rfduinoIndex) - require.NoError(t, err) - - err = downloadBoardManagerCores(boardsManagerRedBearCores, nil) - require.NoError(t, err) - - librariesIndex, err := downloadIndex("http://downloads.arduino.cc/libraries/library_index.json") - require.NoError(t, err) - - err = downloadLibraries(libraries, librariesIndex) - require.NoError(t, err) -} - -func downloadIndex(url string) (map[string]interface{}, error) { - res, err := http.Get(url) - if err != nil { - return nil, err - } - - bytes, err := io.ReadAll(res.Body) - if err != nil { - return nil, err - } - res.Body.Close() - - index := make(map[string]interface{}) - err = json.Unmarshal(bytes, &index) - if err != nil { - return nil, err - } - - return index, nil -} - -func downloadCores(cores []Core, index map[string]interface{}) error { - for _, core := range cores { - url, err := findCoreUrl(index, core) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackCore(core, url, hardwareFolder) - if err != nil { - return errors.WithStack(err) - } - } - return nil -} - -func downloadBoardManagerCores(cores []Core, index map[string]interface{}) error { - for _, core := range cores { - url, err := findCoreUrl(index, core) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackBoardManagerCore(core, url, boardManagerFolder) - if err != nil { - return errors.WithStack(err) - } - } - return nil -} - -func findCoreUrl(index map[string]interface{}, core Core) (string, error) { - if core.Url != "" { - return core.Url, nil - } - packages := index["packages"].([]interface{}) - for _, p := range packages { - pack := p.(map[string]interface{}) - if pack["name"].(string) == core.Maintainer { - packagePlatforms := pack["platforms"].([]interface{}) - for _, pt := range packagePlatforms { - packagePlatform := pt.(map[string]interface{}) - if packagePlatform["architecture"] == core.Arch && packagePlatform["version"] == core.Version { - return packagePlatform["url"].(string), nil - } - } - } - } - - return "", errors.Errorf("Unable to find tool " + core.Maintainer + " " + core.Arch + " " + core.Version) -} - -func downloadTools(tools []Tool, index map[string]interface{}) error { - host := translateGOOSGOARCHToPackageIndexValue() - - for _, tool := range tools { - url, err := findToolUrl(index, tool, host) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackTool(tool, url, toolsFolder, true) - if err != nil { - return errors.WithStack(err) - } - } - - return nil -} - -func downloadToolsMultipleVersions(tools []Tool, index map[string]interface{}) error { - host := translateGOOSGOARCHToPackageIndexValue() - - for _, tool := range tools { - if !toolAlreadyDownloadedAndUnpacked(toolsFolder, tool) { - if toolsFolder.Join(tool.Name).Exist() { - if err := toolsFolder.Join(tool.Name).RemoveAll(); err != nil { - return errors.WithStack(err) - } - } - } - } - - for _, tool := range tools { - url, err := findToolUrl(index, tool, host) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackTool(tool, url, toolsFolder, false) - if err != nil { - return errors.WithStack(err) - } - } - - return nil -} - -func downloadBoardsManagerTools(tools []Tool, index map[string]interface{}) error { - host := translateGOOSGOARCHToPackageIndexValue() - - for _, tool := range tools { - url, err := findToolUrl(index, tool, host) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackBoardsManagerTool(tool, url, boardManagerFolder) - if err != nil { - return errors.WithStack(err) - } - } - - return nil -} - -func allBoardsManagerCoresAlreadyDownloadedAndUnpacked(targetPath *paths.Path, cores []Core) bool { - for _, core := range cores { - if !boardManagerCoreAlreadyDownloadedAndUnpacked(targetPath, core) { - return false - } - } - return true -} - -func boardManagerCoreAlreadyDownloadedAndUnpacked(targetPath *paths.Path, core Core) bool { - return targetPath.Join(core.Maintainer, "hardware", core.Arch, core.Version).Exist() -} - -func allCoresAlreadyDownloadedAndUnpacked(targetPath *paths.Path, cores []Core) (bool, error) { - for _, core := range cores { - alreadyDownloaded, err := coreAlreadyDownloadedAndUnpacked(targetPath, core) - if err != nil { - return false, errors.WithStack(err) - } - if !alreadyDownloaded { - return false, nil - } - } - return true, nil -} - -func coreAlreadyDownloadedAndUnpacked(targetPath *paths.Path, core Core) (bool, error) { - corePath := targetPath.Join(core.Maintainer, core.Arch) - - if corePath.NotExist() { - return false, nil - } - platform, err := properties.LoadFromPath(corePath.Join("platform.txt")) - if err != nil { - return false, errors.WithStack(err) - } - - if core.Version != platform.Get("version") { - err := corePath.RemoveAll() - return false, errors.WithStack(err) - } - - return true, nil -} - -func allBoardsManagerToolsAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tools []Tool) bool { - for _, tool := range tools { - if !boardManagerToolAlreadyDownloadedAndUnpacked(targetPath, tool) { - return false - } - } - return true -} - -func boardManagerToolAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tool Tool) bool { - return targetPath.Join(tool.Package, "tools", tool.Name, tool.Version).Exist() -} - -func allToolsAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tools []Tool) bool { - for _, tool := range tools { - if !toolAlreadyDownloadedAndUnpacked(targetPath, tool) { - return false - } - } - return true -} - -func toolAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tool Tool) bool { - return targetPath.Join(tool.Name, tool.Version).Exist() -} - -func allLibrariesAlreadyDownloadedAndUnpacked(targetPath *paths.Path, libraries []Library) bool { - for _, library := range libraries { - if !libraryAlreadyDownloadedAndUnpacked(targetPath, library) { - return false - } - } - return true -} - -func libraryAlreadyDownloadedAndUnpacked(targetPath *paths.Path, library Library) bool { - libPath := targetPath.Join(strings.Replace(library.Name, " ", "_", -1)) - if !libPath.Exist() { - return false - } - - libProps, err := properties.LoadFromPath(libPath.Join("library.properties")) - if err != nil { - return false - } - return libProps.Get("version") == library.Version || libProps.Get("version") == library.VersionInLibProperties -} - -func downloadAndUnpackCore(core Core, url string, targetPath *paths.Path) error { - alreadyDownloaded, err := coreAlreadyDownloadedAndUnpacked(targetPath, core) - if err != nil { - return errors.WithStack(err) - } - if alreadyDownloaded { - return nil - } - - if err := targetPath.ToAbs(); err != nil { - return errors.WithStack(err) - } - - unpackFolder, files, err := downloadAndUnpack(url) - if err != nil { - return errors.WithStack(err) - } - defer unpackFolder.RemoveAll() - - packagerPath := targetPath.Join(core.Maintainer) - corePath := targetPath.Join(core.Maintainer, core.Arch) - - if err := packagerPath.MkdirAll(); err != nil { - return errors.WithStack(err) - } - if corePath.Exist() { - if err := corePath.RemoveAll(); err != nil { - return errors.WithStack(err) - } - } - if err := unpackFolder.Join(files[0].Base()).CopyDirTo(corePath); err != nil { - return errors.WithStack(err) - } - return nil -} - -func downloadAndUnpackBoardManagerCore(core Core, url string, targetPath *paths.Path) error { - if boardManagerCoreAlreadyDownloadedAndUnpacked(targetPath, core) { - return nil - } - - if err := targetPath.ToAbs(); err != nil { - return errors.WithStack(err) - } - - unpackFolder, files, err := downloadAndUnpack(url) - if err != nil { - return errors.WithStack(err) - } - defer unpackFolder.RemoveAll() - - corePath := targetPath.Join(core.Maintainer, "hardware", core.Arch) - if corePath.Exist() { - if err := corePath.RemoveAll(); err != nil { - return errors.WithStack(err) - } - } - if err := corePath.MkdirAll(); err != nil { - return errors.WithStack(err) - } - if err := unpackFolder.Join(files[0].Base()).CopyDirTo(corePath.Join(core.Version)); err != nil { - return errors.WithStack(err) - } - return nil -} - -func downloadAndUnpackBoardsManagerTool(tool Tool, url string, targetPath *paths.Path) error { - if boardManagerToolAlreadyDownloadedAndUnpacked(targetPath, tool) { - return nil - } - - if err := targetPath.ToAbs(); err != nil { - return errors.WithStack(err) - } - - unpackFolder, files, err := downloadAndUnpack(url) - if err != nil { - return errors.WithStack(err) - } - defer unpackFolder.RemoveAll() - - if err := targetPath.Join(tool.Package, "tools", tool.Name).MkdirAll(); err != nil { - return errors.WithStack(err) - } - if err := unpackFolder.Join(files[0].Base()).CopyDirTo(targetPath.Join(tool.Package, "tools", tool.Name, tool.Version)); err != nil { - return errors.WithStack(err) - } - return nil -} - -func downloadAndUnpackTool(tool Tool, url string, targetPath *paths.Path, deleteIfMissing bool) error { - if toolAlreadyDownloadedAndUnpacked(targetPath, tool) { - return nil - } - - if err := targetPath.ToAbs(); err != nil { - return errors.WithStack(err) - } - - unpackFolder, files, err := downloadAndUnpack(url) - if err != nil { - return errors.WithStack(err) - } - defer unpackFolder.RemoveAll() - - toolPath := targetPath.Join(tool.Name) - if deleteIfMissing { - if toolPath.Exist() { - if err := toolPath.MkdirAll(); err != nil { - return errors.WithStack(err) - } - } - } - if err := toolPath.MkdirAll(); err != nil { - return errors.WithStack(err) - } - destDir := toolPath.Join(tool.Version) - if len(files) == 1 && files[0].IsDir() { - if err := unpackFolder.Join(files[0].Base()).CopyDirTo(destDir); err != nil { - return errors.WithStack(err) - } - } else { - unpackFolder.CopyDirTo(destDir) - } - - return nil -} - -func downloadAndUnpack(url string) (*paths.Path, paths.PathList, error) { - fmt.Fprintln(os.Stderr, "Downloading "+url) - - unpackFolder, err := paths.MkTempDir("", "arduino-builder-tool") - if err != nil { - return nil, nil, errors.WithStack(err) - } - - urlParts := strings.Split(url, "/") - archiveFileName := urlParts[len(urlParts)-1] - archiveFilePath := unpackFolder.Join(archiveFileName) - - res, err := http.Get(url) - if err != nil { - return nil, nil, errors.WithStack(err) - } - - bytes, err := io.ReadAll(res.Body) - if err != nil { - return nil, nil, errors.WithStack(err) - } - res.Body.Close() - - archiveFilePath.WriteFile(bytes) - - cmd := buildUnpackCmd(archiveFilePath) - out, err := cmd.CombinedOutput() - if err != nil { - fmt.Println(string(out)) - return nil, nil, errors.WithStack(err) - } - if len(out) > 0 { - fmt.Println(string(out)) - } - - archiveFilePath.Remove() - - files, err := unpackFolder.ReadDir() - if err != nil { - return nil, nil, errors.WithStack(err) - } - - return unpackFolder, files, nil -} - -func buildUnpackCmd(file *paths.Path) *exec.Cmd { - var cmd *exec.Cmd - if file.Ext() == ".zip" { - cmd = exec.Command("unzip", "-qq", file.Base()) - } else { - cmd = exec.Command("tar", "xf", file.Base()) - } - cmd.Dir = file.Parent().String() - return cmd -} - -func translateGOOSGOARCHToPackageIndexValue() []string { - switch value := runtime.GOOS + "-" + runtime.GOARCH; value { - case "linux-amd64": - return []string{"x86_64-pc-linux-gnu", "x86_64-linux-gnu"} - case "linux-386": - return []string{"i686-pc-linux-gnu", "i686-linux-gnu"} - case "windows-amd64": - return []string{"i686-mingw32", "i686-cygwin"} - case "windows-386": - return []string{"i686-mingw32", "i686-cygwin"} - case "darwin-amd64": - return []string{"i386-apple-darwin11", "x86_64-apple-darwin"} - case "linux-arm": - return []string{"arm-linux-gnueabihf"} - default: - panic("Unknown OS: " + value) - } -} - -func findToolUrl(index map[string]interface{}, tool Tool, host []string) (string, error) { - if len(tool.OsUrls) > 0 { - for _, osUrl := range tool.OsUrls { - if slices.Contains(host, osUrl.Os) { - return osUrl.Url, nil - } - } - } else { - packages := index["packages"].([]interface{}) - for _, p := range packages { - pack := p.(map[string]interface{}) - packageTools := pack["tools"].([]interface{}) - for _, pt := range packageTools { - packageTool := pt.(map[string]interface{}) - name := packageTool["name"].(string) - version := packageTool["version"].(string) - if name == tool.Name && version == tool.Version { - systems := packageTool["systems"].([]interface{}) - for _, s := range systems { - system := s.(map[string]interface{}) - if slices.Contains(host, system["host"].(string)) { - return system["url"].(string), nil - } - } - } - } - } - } - - return "", errors.Errorf("Unable to find tool " + tool.Name + " " + tool.Version) -} - -func downloadLibraries(libraries []Library, index map[string]interface{}) error { - for _, library := range libraries { - url, err := findLibraryUrl(index, library) - if err != nil { - return errors.WithStack(err) - } - err = downloadAndUnpackLibrary(library, url, librariesFolder) - if err != nil { - return errors.WithStack(err) - } - } - - return nil -} - -func findLibraryUrl(index map[string]interface{}, library Library) (string, error) { - if library.Url != "" { - return library.Url, nil - } - libs := index["libraries"].([]interface{}) - for _, l := range libs { - lib := l.(map[string]interface{}) - if library.Name == lib["name"].(string) && library.Version == lib["version"].(string) { - return lib["url"].(string), nil - } - } - - return "", errors.Errorf("Unable to find library " + library.Name + " " + library.Version) -} - -func downloadAndUnpackLibrary(library Library, url string, targetPath *paths.Path) error { - if libraryAlreadyDownloadedAndUnpacked(targetPath, library) { - return nil - } - - if err := targetPath.ToAbs(); err != nil { - return errors.WithStack(err) - } - - unpackFolder, files, err := downloadAndUnpack(url) - if err != nil { - return errors.WithStack(err) - } - defer unpackFolder.RemoveAll() - - libPath := targetPath.Join(strings.Replace(library.Name, " ", "_", -1)) - if libPath.Exist() { - if err := libPath.RemoveAll(); err != nil { - return errors.WithStack(err) - } - } - - if err := unpackFolder.Join(files[0].Base()).CopyDirTo(libPath); err != nil { - return errors.WithStack(err) - } - - return nil -} diff --git a/legacy/builder/test/libraries/ANewLibrary-master/anewlibrary.h b/legacy/builder/test/libraries/ANewLibrary-master/anewlibrary.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/Balanduino.h b/legacy/builder/test/libraries/Balanduino/Balanduino.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/Kalman.h b/legacy/builder/test/libraries/Balanduino/Kalman.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/PS3BT.h b/legacy/builder/test/libraries/Balanduino/PS3BT.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/SPP.h b/legacy/builder/test/libraries/Balanduino/SPP.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/Wii.h b/legacy/builder/test/libraries/Balanduino/Wii.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/XBOXRECV.h b/legacy/builder/test/libraries/Balanduino/XBOXRECV.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/adk.h b/legacy/builder/test/libraries/Balanduino/adk.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/Balanduino/usbhub.h b/legacy/builder/test/libraries/Balanduino/usbhub.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/FakeAudio/Audio.h b/legacy/builder/test/libraries/FakeAudio/Audio.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/FakeAudio/FakeAudio.h b/legacy/builder/test/libraries/FakeAudio/FakeAudio.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/IRremote/IRremote.h b/legacy/builder/test/libraries/IRremote/IRremote.h deleted file mode 100644 index 5497fbd7255..00000000000 --- a/legacy/builder/test/libraries/IRremote/IRremote.h +++ /dev/null @@ -1 +0,0 @@ -#warning IRRemote included! \ No newline at end of file diff --git a/legacy/builder/test/libraries/IRremote/IRremoteInt.h b/legacy/builder/test/libraries/IRremote/IRremoteInt.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/SPI/SPI.cpp b/legacy/builder/test/libraries/SPI/SPI.cpp deleted file mode 100644 index af14e07b12f..00000000000 --- a/legacy/builder/test/libraries/SPI/SPI.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2010 by Cristian Maglie - * Copyright (c) 2014 by Paul Stoffregen (Transaction API) - * Copyright (c) 2014 by Matthijs Kooijman (SPISettings AVR) - * Copyright (c) 2014 by Andrew J. Kroll (atomicity fixes) - * SPI Master library for arduino. - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of either the GNU General Public License version 2 - * or the GNU Lesser General Public License version 2.1, both as - * published by the Free Software Foundation. - */ - -#include "SPI.h" - -SPIClass SPI; - -uint8_t SPIClass::initialized = 0; -uint8_t SPIClass::interruptMode = 0; -uint8_t SPIClass::interruptMask = 0; -uint8_t SPIClass::interruptSave = 0; -#ifdef SPI_TRANSACTION_MISMATCH_LED -uint8_t SPIClass::inTransactionFlag = 0; -#endif - -void SPIClass::begin() -{ - uint8_t sreg = SREG; - noInterrupts(); // Protect from a scheduler and prevent transactionBegin - if (!initialized) { - // Set SS to high so a connected chip will be "deselected" by default - uint8_t port = digitalPinToPort(SS); - uint8_t bit = digitalPinToBitMask(SS); - volatile uint8_t *reg = portModeRegister(port); - - // if the SS pin is not already configured as an output - // then set it high (to enable the internal pull-up resistor) - if(!(*reg & bit)){ - digitalWrite(SS, HIGH); - } - - // When the SS pin is set as OUTPUT, it can be used as - // a general purpose output port (it doesn't influence - // SPI operations). - pinMode(SS, OUTPUT); - - // Warning: if the SS pin ever becomes a LOW INPUT then SPI - // automatically switches to Slave, so the data direction of - // the SS pin MUST be kept as OUTPUT. - SPCR |= _BV(MSTR); - SPCR |= _BV(SPE); - - // Set direction register for SCK and MOSI pin. - // MISO pin automatically overrides to INPUT. - // By doing this AFTER enabling SPI, we avoid accidentally - // clocking in a single bit since the lines go directly - // from "input" to SPI control. - // http://code.google.com/p/arduino/issues/detail?id=888 - pinMode(SCK, OUTPUT); - pinMode(MOSI, OUTPUT); - } - initialized++; // reference count - SREG = sreg; -} - -void SPIClass::end() { - uint8_t sreg = SREG; - noInterrupts(); // Protect from a scheduler and prevent transactionBegin - // Decrease the reference counter - if (initialized) - initialized--; - // If there are no more references disable SPI - if (!initialized) { - SPCR &= ~_BV(SPE); - interruptMode = 0; - #ifdef SPI_TRANSACTION_MISMATCH_LED - inTransactionFlag = 0; - #endif - } - SREG = sreg; -} - -// mapping of interrupt numbers to bits within SPI_AVR_EIMSK -#if defined(__AVR_ATmega32U4__) - #define SPI_INT0_MASK (1< - * Copyright (c) 2014 by Paul Stoffregen (Transaction API) - * Copyright (c) 2014 by Matthijs Kooijman (SPISettings AVR) - * Copyright (c) 2014 by Andrew J. Kroll (atomicity fixes) - * SPI Master library for arduino. - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of either the GNU General Public License version 2 - * or the GNU Lesser General Public License version 2.1, both as - * published by the Free Software Foundation. - */ - -#ifndef _SPI_H_INCLUDED -#define _SPI_H_INCLUDED - -#include - -// SPI_HAS_TRANSACTION means SPI has beginTransaction(), endTransaction(), -// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode) -#define SPI_HAS_TRANSACTION 1 - -// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method -#define SPI_HAS_NOTUSINGINTERRUPT 1 - -// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version. -// This way when there is a bug fix you can check this define to alert users -// of your code if it uses better version of this library. -// This also implies everything that SPI_HAS_TRANSACTION as documented above is -// available too. -#define SPI_ATOMIC_VERSION 1 - -// Uncomment this line to add detection of mismatched begin/end transactions. -// A mismatch occurs if other libraries fail to use SPI.endTransaction() for -// each SPI.beginTransaction(). Connect an LED to this pin. The LED will turn -// on if any mismatch is ever detected. -//#define SPI_TRANSACTION_MISMATCH_LED 5 - -#ifndef LSBFIRST -#define LSBFIRST 0 -#endif -#ifndef MSBFIRST -#define MSBFIRST 1 -#endif - -#define SPI_CLOCK_DIV4 0x00 -#define SPI_CLOCK_DIV16 0x01 -#define SPI_CLOCK_DIV64 0x02 -#define SPI_CLOCK_DIV128 0x03 -#define SPI_CLOCK_DIV2 0x04 -#define SPI_CLOCK_DIV8 0x05 -#define SPI_CLOCK_DIV32 0x06 - -#define SPI_MODE0 0x00 -#define SPI_MODE1 0x04 -#define SPI_MODE2 0x08 -#define SPI_MODE3 0x0C - -#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR -#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR -#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR - -// define SPI_AVR_EIMSK for AVR boards with external interrupt pins -#if defined(EIMSK) - #define SPI_AVR_EIMSK EIMSK -#elif defined(GICR) - #define SPI_AVR_EIMSK GICR -#elif defined(GIMSK) - #define SPI_AVR_EIMSK GIMSK -#endif - -class SPISettings { -public: - SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) { - if (__builtin_constant_p(clock)) { - init_AlwaysInline(clock, bitOrder, dataMode); - } else { - init_MightInline(clock, bitOrder, dataMode); - } - } - SPISettings() { - init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); - } -private: - void init_MightInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) { - init_AlwaysInline(clock, bitOrder, dataMode); - } - void init_AlwaysInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) - __attribute__((__always_inline__)) { - // Clock settings are defined as follows. Note that this shows SPI2X - // inverted, so the bits form increasing numbers. Also note that - // fosc/64 appears twice - // SPR1 SPR0 ~SPI2X Freq - // 0 0 0 fosc/2 - // 0 0 1 fosc/4 - // 0 1 0 fosc/8 - // 0 1 1 fosc/16 - // 1 0 0 fosc/32 - // 1 0 1 fosc/64 - // 1 1 0 fosc/64 - // 1 1 1 fosc/128 - - // We find the fastest clock that is less than or equal to the - // given clock rate. The clock divider that results in clock_setting - // is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the - // slowest (128 == 2 ^^ 7, so clock_div = 6). - uint8_t clockDiv; - - // When the clock is known at compiletime, use this if-then-else - // cascade, which the compiler knows how to completely optimize - // away. When clock is not known, use a loop instead, which generates - // shorter code. - if (__builtin_constant_p(clock)) { - if (clock >= F_CPU / 2) { - clockDiv = 0; - } else if (clock >= F_CPU / 4) { - clockDiv = 1; - } else if (clock >= F_CPU / 8) { - clockDiv = 2; - } else if (clock >= F_CPU / 16) { - clockDiv = 3; - } else if (clock >= F_CPU / 32) { - clockDiv = 4; - } else if (clock >= F_CPU / 64) { - clockDiv = 5; - } else { - clockDiv = 6; - } - } else { - uint32_t clockSetting = F_CPU / 2; - clockDiv = 0; - while (clockDiv < 6 && clock < clockSetting) { - clockSetting /= 2; - clockDiv++; - } - } - - // Compensate for the duplicate fosc/64 - if (clockDiv == 6) - clockDiv = 7; - - // Invert the SPI2X bit - clockDiv ^= 0x1; - - // Pack into the SPISettings class - spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) | - (dataMode & SPI_MODE_MASK) | ((clockDiv >> 1) & SPI_CLOCK_MASK); - spsr = clockDiv & SPI_2XCLOCK_MASK; - } - uint8_t spcr; - uint8_t spsr; - friend class SPIClass; -}; - - -class SPIClass { -public: - // Initialize the SPI library - static void begin(); - - // If SPI is used from within an interrupt, this function registers - // that interrupt with the SPI library, so beginTransaction() can - // prevent conflicts. The input interruptNumber is the number used - // with attachInterrupt. If SPI is used from a different interrupt - // (eg, a timer), interruptNumber should be 255. - static void usingInterrupt(uint8_t interruptNumber); - // And this does the opposite. - static void notUsingInterrupt(uint8_t interruptNumber); - // Note: the usingInterrupt and notUsingInterrupt functions should - // not to be called from ISR context or inside a transaction. - // For details see: - // https://github.com/arduino/Arduino/pull/2381 - // https://github.com/arduino/Arduino/pull/2449 - - // Before using SPI.transfer() or asserting chip select pins, - // this function is used to gain exclusive access to the SPI bus - // and configure the correct settings. - inline static void beginTransaction(SPISettings settings) { - if (interruptMode > 0) { - uint8_t sreg = SREG; - noInterrupts(); - - #ifdef SPI_AVR_EIMSK - if (interruptMode == 1) { - interruptSave = SPI_AVR_EIMSK; - SPI_AVR_EIMSK &= ~interruptMask; - SREG = sreg; - } else - #endif - { - interruptSave = sreg; - } - } - - #ifdef SPI_TRANSACTION_MISMATCH_LED - if (inTransactionFlag) { - pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); - digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); - } - inTransactionFlag = 1; - #endif - - SPCR = settings.spcr; - SPSR = settings.spsr; - } - - // Write to the SPI bus (MOSI pin) and also receive (MISO pin) - inline static uint8_t transfer(uint8_t data) { - SPDR = data; - /* - * The following NOP introduces a small delay that can prevent the wait - * loop form iterating when running at the maximum speed. This gives - * about 10% more speed, even if it seems counter-intuitive. At lower - * speeds it is unnoticed. - */ - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; // wait - return SPDR; - } - inline static uint16_t transfer16(uint16_t data) { - union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out; - in.val = data; - if (!(SPCR & _BV(DORD))) { - SPDR = in.msb; - asm volatile("nop"); // See transfer(uint8_t) function - while (!(SPSR & _BV(SPIF))) ; - out.msb = SPDR; - SPDR = in.lsb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.lsb = SPDR; - } else { - SPDR = in.lsb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.lsb = SPDR; - SPDR = in.msb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.msb = SPDR; - } - return out.val; - } - inline static void transfer(void *buf, size_t count) { - if (count == 0) return; - uint8_t *p = (uint8_t *)buf; - SPDR = *p; - while (--count > 0) { - uint8_t out = *(p + 1); - while (!(SPSR & _BV(SPIF))) ; - uint8_t in = SPDR; - SPDR = out; - *p++ = in; - } - while (!(SPSR & _BV(SPIF))) ; - *p = SPDR; - } - // After performing a group of transfers and releasing the chip select - // signal, this function allows others to access the SPI bus - inline static void endTransaction(void) { - #ifdef SPI_TRANSACTION_MISMATCH_LED - if (!inTransactionFlag) { - pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); - digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); - } - inTransactionFlag = 0; - #endif - - if (interruptMode > 0) { - #ifdef SPI_AVR_EIMSK - uint8_t sreg = SREG; - #endif - noInterrupts(); - #ifdef SPI_AVR_EIMSK - if (interruptMode == 1) { - SPI_AVR_EIMSK = interruptSave; - SREG = sreg; - } else - #endif - { - SREG = interruptSave; - } - } - } - - // Disable the SPI bus - static void end(); - - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setBitOrder(uint8_t bitOrder) { - if (bitOrder == LSBFIRST) SPCR |= _BV(DORD); - else SPCR &= ~(_BV(DORD)); - } - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setDataMode(uint8_t dataMode) { - SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode; - } - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setClockDivider(uint8_t clockDiv) { - SPCR = (SPCR & ~SPI_CLOCK_MASK) | (clockDiv & SPI_CLOCK_MASK); - SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK); - } - // These undocumented functions should not be used. SPI.transfer() - // polls the hardware flag which is automatically cleared as the - // AVR responds to SPI's interrupt - inline static void attachInterrupt() { SPCR |= _BV(SPIE); } - inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); } - -private: - static uint8_t initialized; - static uint8_t interruptMode; // 0=none, 1=mask, 2=global - static uint8_t interruptMask; // which interrupts to mask - static uint8_t interruptSave; // temp storage, to restore state - #ifdef SPI_TRANSACTION_MISMATCH_LED - static uint8_t inTransactionFlag; - #endif -}; - -extern SPIClass SPI; - -#endif diff --git a/legacy/builder/test/libraries/SPI/keywords.txt b/legacy/builder/test/libraries/SPI/keywords.txt deleted file mode 100644 index fa7616581aa..00000000000 --- a/legacy/builder/test/libraries/SPI/keywords.txt +++ /dev/null @@ -1,36 +0,0 @@ -####################################### -# Syntax Coloring Map SPI -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SPI KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -begin KEYWORD2 -end KEYWORD2 -transfer KEYWORD2 -setBitOrder KEYWORD2 -setDataMode KEYWORD2 -setClockDivider KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### -SPI_CLOCK_DIV4 LITERAL1 -SPI_CLOCK_DIV16 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_CLOCK_DIV128 LITERAL1 -SPI_CLOCK_DIV2 LITERAL1 -SPI_CLOCK_DIV8 LITERAL1 -SPI_CLOCK_DIV32 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_MODE0 LITERAL1 -SPI_MODE1 LITERAL1 -SPI_MODE2 LITERAL1 -SPI_MODE3 LITERAL1 \ No newline at end of file diff --git a/legacy/builder/test/libraries/SPI/library.properties b/legacy/builder/test/libraries/SPI/library.properties deleted file mode 100644 index 7e55b100497..00000000000 --- a/legacy/builder/test/libraries/SPI/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=SPI -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE. -paragraph= -url=http://arduino.cc/en/Reference/SPI -architectures=avr -types=Arduino -category=Other - diff --git a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.cpp b/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.cpp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.h b/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/ShouldNotRecurseWithOldLibs.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/doc/error.cpp b/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/doc/error.cpp deleted file mode 100644 index 28fe130ceb5..00000000000 --- a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/doc/error.cpp +++ /dev/null @@ -1 +0,0 @@ - #error "This file is never supposed to be compiled" diff --git a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.cpp b/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.cpp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.h b/legacy/builder/test/libraries/ShouldNotRecurseWithOldLibs/utility/utils.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/USBHost/keywords.txt b/legacy/builder/test/libraries/USBHost/keywords.txt deleted file mode 100644 index dded4dcf729..00000000000 --- a/legacy/builder/test/libraries/USBHost/keywords.txt +++ /dev/null @@ -1,35 +0,0 @@ -####################################### -# Syntax Coloring Map For USBHost -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -MouseController KEYWORD1 -USBHost KEYWORD1 -KeyboardController KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -Task KEYWORD2 -mouseMoved KEYWORD2 -mouseDragged KEYWORD2 -mousePressed KEYWORD2 -mouseReleased KEYWORD2 -getXChange KEYWORD2 -getYChange KEYWORD2 -getButton KEYWORD2 -keyPressed KEYWORD2 -keyReleased KEYWORD2 -getModifiers KEYWORD2 -getKey KEYWORD2 -getOemKey KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/legacy/builder/test/libraries/USBHost/library.properties b/legacy/builder/test/libraries/USBHost/library.properties deleted file mode 100644 index b6bdce97f49..00000000000 --- a/legacy/builder/test/libraries/USBHost/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=USBHost -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Allows the communication with USB peripherals like mice, keyboards, and thumbdrives. For Arduino Due and Zero. -paragraph=The USBHost library allows the board to appear as a USB host, enabling it to communicate with peripherals like USB mice and keyboards. USBHost does not support devices that are connected through USB hubs. This includes some keyboards that have an internal hub. -url=http://arduino.cc/en/Reference/USBHost -architectures=samd -category=Other diff --git a/legacy/builder/test/libraries/USBHost/src/KeyboardController.cpp b/legacy/builder/test/libraries/USBHost/src/KeyboardController.cpp deleted file mode 100644 index 70c769f64e0..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/KeyboardController.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (c) 2012 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -extern "C" { -void __keyboardControllerEmptyCallback() { } -} - -void keyPressed() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback"))); -void keyReleased() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback"))); - -void KeyboardController::OnKeyDown(uint8_t _mod, uint8_t _oemKey) { - modifiers = _mod; - keyOem = _oemKey; - key = OemToAscii(_mod, _oemKey); - keyPressed(); -} - -void KeyboardController::OnKeyUp(uint8_t _mod, uint8_t _oemKey) { - modifiers = _mod; - keyOem = _oemKey; - key = OemToAscii(_mod, _oemKey); - keyReleased(); -} diff --git a/legacy/builder/test/libraries/USBHost/src/KeyboardController.h b/legacy/builder/test/libraries/USBHost/src/KeyboardController.h deleted file mode 100644 index e1b891bff8a..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/KeyboardController.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (c) 2012 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef KEYBOARD_CONTROLLER_H -#define KEYBOARD_CONTROLLER_H - -#include - -enum KeyboardModifiers { - LeftCtrl = 1, - LeftShift = 2, - Alt = 4, - LeftCmd = 8, - RightCtrl = 16, - RightShift = 32, - AltGr = 64, - RightCmd = 128 -}; - -class KeyboardController : public KeyboardReportParser { -public: - KeyboardController(USBHost &usb) : hostKeyboard(&usb), key(0), keyOem(0), modifiers(0) { - hostKeyboard.SetReportParser(0, this); - }; - - uint8_t getKey() { return key; }; - uint8_t getModifiers() { return modifiers; }; - uint8_t getOemKey() { return keyOem; }; - -protected: - virtual void OnKeyDown(uint8_t mod, uint8_t key); - virtual void OnKeyUp(uint8_t mod, uint8_t key); - -private: - HIDBoot hostKeyboard; - uint8_t key, keyOem, modifiers; -}; - -#endif diff --git a/legacy/builder/test/libraries/USBHost/src/MouseController.cpp b/legacy/builder/test/libraries/USBHost/src/MouseController.cpp deleted file mode 100644 index 3d528bc3785..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/MouseController.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (c) 2012 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -extern "C" { -void __mouseControllerEmptyCallback() { } -} - -void mouseClicked() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); -void mouseDragged() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); -void mouseMoved() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); -void mousePressed() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); -void mouseReleased() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); - -int MouseController::getXChange() { - int r = dx; - dx = 0; - return r; -} - -int MouseController::getYChange() { - int r = dy; - dy = 0; - return r; -} - -void MouseController::OnMouseMove(MOUSEINFO *mi) { - dx += mi->dX; - dy += mi->dY; - if (buttons != 0) - mouseDragged(); - else - mouseMoved(); -} - -void MouseController::OnLeftButtonUp(MOUSEINFO *mi) { - buttons &= ~LEFT_BUTTON; - mouseReleased(); - mouseClicked(); -} - -void MouseController::OnLeftButtonDown(MOUSEINFO *mi) { - buttons |= LEFT_BUTTON; - mousePressed(); -} - -void MouseController::OnMiddleButtonUp(MOUSEINFO *mi) { - buttons &= ~MIDDLE_BUTTON; - mouseReleased(); - mouseClicked(); -} - -void MouseController::OnMiddleButtonDown(MOUSEINFO *mi) { - buttons |= MIDDLE_BUTTON; - mousePressed(); -} - -void MouseController::OnRightButtonUp(MOUSEINFO *mi) { - buttons &= ~RIGHT_BUTTON; - mouseReleased(); - mouseClicked(); -} - -void MouseController::OnRightButtonDown(MOUSEINFO *mi) { - buttons |= RIGHT_BUTTON; - mousePressed(); -} diff --git a/legacy/builder/test/libraries/USBHost/src/MouseController.h b/legacy/builder/test/libraries/USBHost/src/MouseController.h deleted file mode 100644 index 4c8c65e9ce9..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/MouseController.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (c) 2012 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef MOUSE_CONTROLLER_H -#define MOUSE_CONTROLLER_H - -#include - -enum MouseButton { - LEFT_BUTTON = 0x01, - MIDDLE_BUTTON = 0x02, - RIGHT_BUTTON = 0x04 -}; - -class MouseController : public MouseReportParser -{ -public: - MouseController(USBHost &usb) : hostMouse(&usb), dx(0), dy(0), buttons(0) { - hostMouse.SetReportParser(0, this); - }; - - bool getButton(MouseButton button) { return (buttons & button) == button; }; - int getXChange(); - int getYChange(); - // int getWheelChange(); // Not implemented - -protected: - virtual void OnMouseMove(MOUSEINFO *mi); - virtual void OnLeftButtonUp(MOUSEINFO *mi); - virtual void OnLeftButtonDown(MOUSEINFO *mi); - virtual void OnMiddleButtonUp(MOUSEINFO *mi); - virtual void OnMiddleButtonDown(MOUSEINFO *mi); - virtual void OnRightButtonUp(MOUSEINFO *mi); - virtual void OnRightButtonDown(MOUSEINFO *mi); - -private: - HIDBoot hostMouse; - int dx, dy; - int buttons; -}; - -#endif diff --git a/legacy/builder/test/libraries/USBHost/src/Usb.cpp b/legacy/builder/test/libraries/USBHost/src/Usb.cpp deleted file mode 100644 index bc821bb1fb4..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/Usb.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -/* USB functions */ - -#include -#include "Arduino.h" -#include "Usb.h" - - -#ifdef ARDUINO_SAMD_ZERO - -static uint32_t usb_error = 0; -static uint32_t usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; - -/* constructor */ -USBHost::USBHost() : bmHubPre(0) { - // Set up state machine - usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine -} - -/* Initialize data structures */ -uint32_t USBHost::Init() { - //devConfigIndex = 0; - // Init host stack - init(); - bmHubPre = 0; - UHD_Init(); - return 0; -} - -uint32_t USBHost::getUsbTaskState(void) { - return (usb_task_state); -} - -void USBHost::setUsbTaskState(uint32_t state) { - usb_task_state = state; -} - -EpInfo* USBHost::getEpInfoEntry(uint32_t addr, uint32_t ep) { - UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); - - if(!p || !p->epinfo) - return NULL; - - EpInfo *pep = p->epinfo; - - for (uint32_t i = 0; i < p->epcount; i++) { - if(pep->epAddr == ep) - return pep; - - pep++; - } - return NULL; -} - -/* set device table entry */ - -/* each device is different and has different number of endpoints. This function plugs endpoint record structure, defined in application, to devtable */ -uint32_t USBHost::setEpInfoEntry(uint32_t addr, uint32_t epcount, EpInfo* eprecord_ptr) { - if (!eprecord_ptr) - return USB_ERROR_INVALID_ARGUMENT; - - UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->address.devAddress = addr; - p->epinfo = eprecord_ptr; - p->epcount = epcount; - - return 0; -} - -uint32_t USBHost::SetPipeAddress(uint32_t addr, uint32_t ep, EpInfo **ppep, uint32_t &nak_limit) { - UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - *ppep = getEpInfoEntry(addr, ep); - - if(!*ppep) - return USB_ERROR_EP_NOT_FOUND_IN_TBL; - - nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER ) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); - nak_limit--; - TRACE_USBHOST(printf(" => SetPipeAddress deviceEP=%lu configued as hostPIPE=%lu sending to address=%lu\r\n", ep, (*ppep)->epAddr, addr);) - /* - USBTRACE2("\r\nAddress: ", addr); - USBTRACE2(" EP: ", ep); - USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); - USBTRACE2(" NAK Limit: ", nak_limit); - USBTRACE("\r\n"); - */ - - // CTRL_PIPE.PDADDR: usb_pipe_table[pipe_num].HostDescBank[0].CTRL_PIPE.bit.PDADDR = addr - uhd_configure_address((*ppep)->epAddr, addr); // Set peripheral address - - return 0; -} - -/* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */ -/* depending on request. Actual requests are defined as inlines */ -/* return codes: */ -/* 00 = success */ -/* 01-0f = non-zero HRSLT */ -uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint32_t nbytes, uint8_t* dataptr, USBReadParser *p) { - - uint32_t direction = 0; // Request direction, IN or OUT - uint32_t rcode; - SETUP_PKT setup_pkt; - - EpInfo *pep = NULL; - uint32_t nak_limit = 0; - - TRACE_USBHOST(printf(" => ctrlReq\r\n");) - - rcode = SetPipeAddress(addr, ep, &pep, nak_limit); - if(rcode) - return rcode; - - // Allocate Pipe0 with default 64 bytes size if not already initialized - rcode = UHD_Pipe0_Alloc(0, 64); - if (rcode) - { - TRACE_USBHOST(printf("/!\\ USBHost::ctrlReq : EP0 allocation error: %lu\r\n", rcode);) - //USBTRACE2("\n\rUSBHost::ctrlReq : EP0 allocation error: ", rcode"); - return rcode; - } - - // Determine request direction - direction = ((bmReqType & 0x80 ) > 0); - - /* fill in setup packet */ - setup_pkt.ReqType_u.bmRequestType = bmReqType; - setup_pkt.bRequest = bRequest; - setup_pkt.wVal_u.wValueLo = wValLo; - setup_pkt.wVal_u.wValueHi = wValHi; - setup_pkt.wIndex = wInd; - setup_pkt.wLength = total; - - UHD_Pipe_Write(pep->epAddr, sizeof(setup_pkt), (uint8_t *)&setup_pkt); //transfer to setup packet FIFO - - rcode = dispatchPkt(tokSETUP, ep, nak_limit); // Dispatch packet - - if (rcode) //return HRSLT if not zero - return ( rcode); - - if (dataptr != NULL) //data stage, if present - { - if (direction) // IN transfer - { - uint32_t left = total; - TRACE_USBHOST(printf(" => ctrlData IN\r\n");) - - pep->bmRcvToggle = 1; //bmRCVTOG1; - - // Bytes read into buffer - uint32_t read = nbytes; - - rcode = InTransfer(pep, nak_limit, (uint8_t*)&read, dataptr); - - if((rcode&USB_ERROR_DATATOGGLE) == USB_ERROR_DATATOGGLE) { - // yes, we flip it wrong here so that next time it is actually correct! - //pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - pep->bmRcvToggle = USB_HOST_DTGL(pep->epAddr); - //continue; - } - - if(rcode) { - //USBTRACE2("\n\rUSBHost::ctrlReq : in transfer: ", rcode"); - return rcode; - } - // Invoke callback function if inTransfer completed successfully and callback function pointer is specified - if(!rcode && p) - ((USBReadParser*)p)->Parse(read, dataptr, total - left); - } - else // OUT transfer - { - pep->bmSndToggle = 1; //bmSNDTOG1; - rcode = OutTransfer(pep, nak_limit, nbytes, dataptr); - } - if(rcode) //return error - return (rcode); - } - - // Status stage - UHD_Pipe_CountZero(pep->epAddr); - USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL; - return dispatchPkt((direction) ? tokOUTHS : tokINHS, pep->epAddr, nak_limit); //GET if direction -} - -/* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */ -/* Keep sending INs and writes data to memory area pointed by 'data' */ - -/* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, - fe USB xfer timeout */ -uint32_t USBHost::inTransfer(uint32_t addr, uint32_t ep, uint8_t *nbytesptr, uint8_t* data) { - EpInfo *pep = NULL; - uint32_t nak_limit = 0; - - uint32_t rcode = SetPipeAddress(addr, ep, &pep, nak_limit); - - if(rcode) { - USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); - USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); - USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); - return rcode; - } - return InTransfer(pep, nak_limit, nbytesptr, data); -} - -uint32_t USBHost::InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr, uint8_t* data) { - uint32_t rcode = 0; - uint32_t pktsize = 0; - - uint32_t nbytes = *nbytesptr; - uint32_t maxpktsize = pep->maxPktSize; - - *nbytesptr = 0; - //set toggle value - if(pep->bmRcvToggle) - USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL; - else - USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_DTGL; - - usb_pipe_table[pep->epAddr].HostDescBank[0].ADDR.reg = (uint32_t)data; - - // use a 'break' to exit this loop - while (1) { - /* get pipe config from setting register */ - usb_pipe_table[pep->epAddr].HostDescBank[0].ADDR.reg += pktsize; - - rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS. - if(rcode == USB_ERROR_DATATOGGLE) { - // yes, we flip it wrong here so that next time it is actually correct! - //pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - pep->bmRcvToggle = USB_HOST_DTGL(pep->epAddr); - //set toggle value - if(pep->bmRcvToggle) - USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL; - else - USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_DTGL; - continue; - } - if(rcode) { - //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode); - return(rcode);// break; //should be 0, indicating ACK. Else return error code. - } - /* check for RCVDAVIRQ and generate error if not present */ - /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ - - pktsize = uhd_byte_count(pep->epAddr); // Number of received bytes - - USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_BK0RDY; - - //printf("Got %i bytes \r\n", pktsize); - // This would be OK, but... - //assert(pktsize <= nbytes); - if(pktsize > nbytes) { - // This can happen. Use of assert on Arduino locks up the Arduino. - // So I will trim the value, and hope for the best. - //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize); - pktsize = nbytes; - } - - int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); - - if(mem_left < 0) - mem_left = 0; - - //data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); - - //regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer - *nbytesptr += pktsize;// add this packet's byte count to total transfer length - - /* The transfer is complete under two conditions: */ - /* 1. The device sent a short packet (L.T. maxPacketSize) */ - /* 2. 'nbytes' have been transferred. */ - if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes? - { - // Save toggle value - pep->bmRcvToggle = USB_HOST_DTGL(pep->epAddr); - //printf("\r\n"); - rcode = 0; - break; - } // if - } //while( 1 ) - return ( rcode); -} - -/* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */ -/* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */ - -/* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ -uint32_t USBHost::outTransfer(uint32_t addr, uint32_t ep, uint32_t nbytes, uint8_t* data) { - EpInfo *pep = NULL; - uint32_t nak_limit = 0; - - uint32_t rcode = SetPipeAddress(addr, ep, &pep, nak_limit); - - if(rcode) - return rcode; - - return OutTransfer(pep, nak_limit, nbytes, data); -} - -uint32_t USBHost::OutTransfer(EpInfo *pep, uint32_t nak_limit, uint32_t nbytes, uint8_t *data) { - uint32_t rcode = 0, retry_count; - uint8_t *data_p = data; //local copy of the data pointer - uint32_t bytes_tosend, nak_count; - uint32_t bytes_left = nbytes; - uint8_t buf[64]; - uint8_t i; - - uint32_t maxpktsize = pep->maxPktSize; - - if(maxpktsize < 1 || maxpktsize > 64) - return USB_ERROR_INVALID_MAX_PKT_SIZE; - - for( i=0; ibmSndToggle) - USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL; - else - USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_DTGL; - - while(bytes_left) { - retry_count = 0; - nak_count = 0; - bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; - UHD_Pipe_Write(pep->epAddr, bytes_tosend, buf); //filling output FIFO - - //set number of bytes - //dispatch packet - //wait for the completion IRQ - //clear IRQ - - rcode = dispatchPkt(tokOUT, pep->epAddr, nak_limit); - if (rcode) - { - switch(rcode) { - case USB_ERRORFLOW: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - goto breakout; - return ( rcode); - break; - case USB_ERRORTIMEOUT: - retry_count++; - if(retry_count == USB_RETRY_LIMIT) - goto breakout; - return ( rcode); - break; - case USB_ERROR_DATATOGGLE: - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmSndToggle = USB_HOST_DTGL(pep->epAddr); - //set toggle value - if(pep->bmSndToggle) - USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL; - else - USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_DTGL; - break; - default: - goto breakout; - }//switch( rcode - } - - bytes_left -= bytes_tosend; - data_p += bytes_tosend; - }//while( bytes_left... -breakout: - - pep->bmSndToggle = USB_HOST_DTGL(pep->epAddr); - return ( rcode); //should be 0 in all cases -} - -/* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */ -/* If NAK, tries to re-send up to nak_limit times */ -/* If nak_limit == 0, do not count NAKs, exit after timeout */ -/* If bus timeout, re-sends up to USB_RETRY_LIMIT times */ - -/* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */ -uint32_t USBHost::dispatchPkt(uint32_t token, uint32_t epAddr, uint32_t nak_limit) { - uint32_t timeout = millis() + USB_XFER_TIMEOUT; - uint32_t nak_count = 0, retry_count=0; - uint32_t rcode = USB_ERROR_TRANSFER_TIMEOUT; - - TRACE_USBHOST(printf(" => dispatchPkt token=%lu pipe=%lu nak_limit=%lu\r\n", token, epAddr, nak_limit);) - - UHD_Pipe_Send(epAddr, token); //launch the transfer - - // Check timeout but don't hold timeout if VBUS is lost - while ((timeout > millis()) && (UHD_GetVBUSState() == UHD_STATE_CONNECTED)) - { - // Wait for transfer completion - if (UHD_Pipe_Is_Transfer_Complete(epAddr, token)) - { - return 0; - } - - //case hrNAK: - if( (usb_pipe_table[epAddr].HostDescBank[0].STATUS_BK.reg & USB_ERRORFLOW ) ) { - nak_count++; - if(nak_limit && (nak_count == nak_limit)) { - rcode = USB_ERRORFLOW; - return (rcode); - } - } - - //case hrTIMEOUT: - if(usb_pipe_table[epAddr].HostDescBank[0].STATUS_PIPE.reg & USB_ERRORTIMEOUT) { - retry_count++; - if(retry_count == USB_RETRY_LIMIT) { - rcode = USB_ERRORTIMEOUT; - return (rcode); - } - } - - if( (usb_pipe_table[epAddr].HostDescBank[0].STATUS_PIPE.reg & USB_ERROR_DATATOGGLE ) ) { - rcode = USB_ERROR_DATATOGGLE; - return (rcode); - } - } - - return rcode; -} - -/* USB main task. Performs enumeration/cleanup */ -void USBHost::Task(void) //USB state machine -{ - uint32_t rcode = 0; - volatile uint32_t tmpdata = 0; - static uint32_t delay = 0; - //USB_DEVICE_DESCRIPTOR buf; - uint32_t lowspeed = 0; - - // Update USB task state on Vbus change - tmpdata = UHD_GetVBUSState(); - - /* modify USB task state if Vbus changed */ - switch (tmpdata) - { - case UHD_STATE_ERROR: //illegal state - usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL; - lowspeed = 0; - break; - - case UHD_STATE_DISCONNECTED: // Disconnected state - if ((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED) - usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; - lowspeed = 0; - break; - - case UHD_STATE_CONNECTED: // Attached state - if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) { - delay = millis() + USB_SETTLE_DELAY; - usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE; - } - break; - }// switch( tmpdata - - // Poll connected devices (if required) - for (uint32_t i = 0; i < USB_NUMDEVICES; ++i) - if (devConfig[i]) - rcode = devConfig[i]->Poll(); - - // Perform USB enumeration stage and clean up - switch (usb_task_state) { - case USB_DETACHED_SUBSTATE_INITIALIZE: - TRACE_USBHOST(printf(" + USB_DETACHED_SUBSTATE_INITIALIZE\r\n");) - - // Init USB stack and driver - UHD_Init(); - init(); - - // Free all USB resources - for (uint32_t i = 0; i < USB_NUMDEVICES; ++i) - if (devConfig[i]) - rcode = devConfig[i]->Release(); - - usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE; - break; - case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here - // Nothing to do - break; - case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here - // Nothing to do - break; - case USB_ATTACHED_SUBSTATE_SETTLE: // Settle time for just attached device - if((long)(millis() - delay) >= 0L) - usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE; - break; - case USB_ATTACHED_SUBSTATE_RESET_DEVICE: - TRACE_USBHOST(printf(" + USB_ATTACHED_SUBSTATE_RESET_DEVICE\r\n");) - UHD_BusReset(); //issue bus reset - usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE; - break; - case USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE: - if (Is_uhd_reset_sent()) - { - TRACE_USBHOST(printf(" + USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE\r\n");) - - // Clear Bus Reset flag - uhd_ack_reset_sent(); - - // Enable Start Of Frame generation - uhd_enable_sof(); - - usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF; - - // Wait 20ms after Bus Reset (USB spec) - delay = millis() + 20; - } - break; - case USB_ATTACHED_SUBSTATE_WAIT_SOF: - // Wait for SOF received first - if (Is_uhd_sof()) - { - if (delay < millis()) - { - TRACE_USBHOST(printf(" + USB_ATTACHED_SUBSTATE_WAIT_SOF\r\n");) - - // 20ms waiting elapsed - usb_task_state = USB_STATE_CONFIGURING; - } - } - break; - case USB_STATE_CONFIGURING: - TRACE_USBHOST(printf(" + USB_STATE_CONFIGURING\r\n");) - rcode = Configuring(0, 0, lowspeed); - - if (rcode) { - TRACE_USBHOST(printf("/!\\ USBHost::Task : USB_STATE_CONFIGURING failed with code: %lu\r\n", rcode);) - if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) { - usb_error = rcode; - usb_task_state = USB_STATE_ERROR; - } - } - else { - usb_task_state = USB_STATE_RUNNING; - TRACE_USBHOST(printf(" + USB_STATE_RUNNING\r\n");) - } - break; - case USB_STATE_RUNNING: - break; - case USB_STATE_ERROR: - break; - } // switch( usb_task_state ) -} - -uint32_t USBHost::DefaultAddressing(uint32_t parent, uint32_t port, uint32_t lowspeed) { - //uint8_t buf[12]; - uint32_t rcode = 0; - UsbDeviceDefinition *p0 = NULL, *p = NULL; - - // Get pointer to pseudo device with address 0 assigned - p0 = addrPool.GetUsbDevicePtr(0); - - if(!p0) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p0->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - p0->lowspeed = (lowspeed) ? 1 : 0; - - // Allocate new address according to device class - uint32_t bAddress = addrPool.AllocAddress(parent, 0, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign new address to the device - rcode = setAddr(0, 0, bAddress); - - if(rcode) { - TRACE_USBHOST(printf("/!\\ USBHost::DefaultAddressing : Set address failed with code: %lu\r\n", rcode);) - addrPool.FreeAddress(bAddress); - bAddress = 0; - return rcode; - } - return 0; -} - -uint32_t USBHost::AttemptConfig(uint32_t driver, uint32_t parent, uint32_t port, uint32_t lowspeed) { - //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port); - uint8_t retries = 0; - -again: - uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed); - if(rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) { - if(parent == 0) { - // Send a bus reset on the root interface. - //regWr(rHCTL, bmBUSRST); //issue bus reset - UHD_BusReset(); - delay(102); // delay 102ms, compensate for clock inaccuracy. - } else { - // reset parent port - devConfig[parent]->ResetHubPort(port); - } - } else if(rcode != 0x00/*hrJERR*/ && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works - delay(100); - retries++; - goto again; - } else if(rcode) - return rcode; - - rcode = devConfig[driver]->Init(parent, port, lowspeed); - if(rcode != 0x00/*hrJERR*/ && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works - delay(100); - retries++; - goto again; - } - if(rcode) { - // Issue a bus reset, because the device may be in a limbo state - if(parent == 0) { - // Send a bus reset on the root interface. - //regWr(rHCTL, bmBUSRST); //issue bus reset - UHD_BusReset(); - delay(102); // delay 102ms, compensate for clock inaccuracy. - } else { - // reset parent port - devConfig[parent]->ResetHubPort(port); - } - } - return rcode; -} - -/* - * This is broken. We need to enumerate differently. - * It causes major problems with several devices if detected in an unexpected order. - * - * - * Oleg - I wouldn't do anything before the newly connected device is considered sane. - * i.e.(delays are not indicated for brevity): - * 1. reset - * 2. GetDevDescr(); - * 3a. If ACK, continue with allocating address, addressing, etc. - * 3b. Else reset again, count resets, stop at some number (5?). - * 4. When max.number of resets is reached, toggle power/fail - * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD() - * it doesn't need to be reset again - * New steps proposal: - * 1: get address pool instance. exit on fail - * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail. - * 3: bus reset, 100ms delay - * 4: set address - * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail - * 6: while (configurations) { - * for(each configuration) { - * for (each driver) { - * 6a: Ask device if it likes configuration. Returns 0 on OK. - * If successful, the driver configured device. - * The driver now owns the endpoints, and takes over managing them. - * The following will need codes: - * Everything went well, instance consumed, exit with success. - * Instance already in use, ignore it, try next driver. - * Not a supported device, ignore it, try next driver. - * Not a supported configuration for this device, ignore it, try next driver. - * Could not configure device, fatal, exit with fail. - * } - * } - * } - * 7: for(each driver) { - * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID - * 8: if we get here, no driver likes the device plugged in, so exit failure. - * - */ -uint32_t USBHost::Configuring(uint32_t parent, uint32_t port, uint32_t lowspeed) { - //uint32_t bAddress = 0; - //printf("Configuring: parent = %i, port = %i\r\n", parent, port); - uint32_t devConfigIndex; - uint32_t rcode = 0; - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); - UsbDeviceDefinition *p = NULL; - EpInfo *oldep_ptr = NULL; - EpInfo epInfo; - - epInfo.epAddr = 0; - epInfo.maxPktSize = 8; - epInfo.epAttribs = 0; - epInfo.bmNakPower = USB_NAK_MAX_POWER; - - //delay(2000); - AddressPool &addrPool = GetAddressPool(); - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - if(!p) { - //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n"); - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to - // avoid toggle inconsistence - - p->epinfo = &epInfo; - - p->lowspeed = lowspeed; - // Get device descriptor - rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - // The first GetDescriptor give us the endpoint 0 max packet size. - epInfo.maxPktSize = buf[7]; - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) { - //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n"); - return rcode; - } - - // to-do? - // Allocate new address according to device class - //bAddress = addrPool.AllocAddress(parent, false, port); - - //if (!bAddress) - // return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - uint16_t vid = udd->idVendor; - uint16_t pid = udd->idProduct; - uint8_t klass = udd->bDeviceClass; - - // Attempt to configure if VID/PID or device class matches with a driver - for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { - if(!devConfig[devConfigIndex]) continue; // no driver - if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) { - rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); - if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED) - break; - } - } - - if(devConfigIndex < USB_NUMDEVICES) { - return rcode; - } - - - // blindly attempt to configure - for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { - if(!devConfig[devConfigIndex]) continue; - if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above - rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); - - //printf("ERROR ENUMERATING %2.2x\r\n", rcode); - if(!(rcode == USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED || rcode == USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE)) { - // in case of an error dev_index should be reset to 0 - // in order to start from the very beginning the - // next time the program gets here - //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) - // devConfigIndex = 0; - return rcode; - } - } - // if we get here that means that the device class is not supported by any of registered classes - rcode = DefaultAddressing(parent, port, lowspeed); - - return rcode; -} - -uint32_t USBHost::ReleaseDevice(uint32_t addr) { - if(!addr) - return 0; - - for(uint32_t i = 0; i < USB_NUMDEVICES; i++) { - if(!devConfig[i]) continue; - if(devConfig[i]->GetAddress() == addr) - return devConfig[i]->Release(); - } - return 0; -} - -//get device descriptor - -uint32_t USBHost::getDevDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint8_t* dataptr) { - return (ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, 0)); -} -//get configuration descriptor - -uint32_t USBHost::getConfDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint32_t conf, uint8_t* dataptr) { - return (ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, 0)); -} - -/* Requests Configuration Descriptor. Sends two Get Conf Descr requests. The first one gets the total length of all descriptors, then the second one requests this - total length. The length of the first request can be shorter ( 4 bytes ), however, there are devices which won't work unless this length is set to 9 */ -uint32_t USBHost::getConfDescr(uint32_t addr, uint32_t ep, uint32_t conf, USBReadParser *p) { - const uint32_t bufSize = 64; - uint8_t buf[bufSize]; - USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); - - uint32_t ret = getConfDescr(addr, ep, 9, conf, buf); - - if(ret) - return ret; - - uint32_t total = ucd->wTotalLength; - - //USBTRACE2("\r\ntotal conf.size:", total); - - return (ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p)); -} - -//get string descriptor - -uint32_t USBHost::getStrDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint32_t index, uint32_t langid, uint8_t* dataptr) { - return (ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nbytes, nbytes, dataptr, 0)); -} -//set address - -uint32_t USBHost::setAddr(uint32_t oldaddr, uint32_t ep, uint32_t newaddr) { - uint32_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL); - //delay(2); //per USB 2.0 sect.9.2.6.3 - delay(300); // Older spec says you should wait at least 200ms - return rcode; - //return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL)); -} -//set configuration - -uint32_t USBHost::setConf(uint32_t addr, uint32_t ep, uint32_t conf_value) { - return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL)); -} - -#endif //ARDUINO_SAMD_ZERO diff --git a/legacy/builder/test/libraries/USBHost/src/Usb.h b/legacy/builder/test/libraries/USBHost/src/Usb.h deleted file mode 100644 index e95ebc0528b..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/Usb.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -/* USB functions */ - -#ifndef USB_H_INCLUDED -#define USB_H_INCLUDED -#define _usb_h_ - -#include - -#define ARDUINO 101 - -//#include "Arduino.h" -#include "macros.h" -// None of these should ever be included by a driver, or a user's sketch. - -#include "variant.h" -#define USB_HOST_SERIAL SERIAL_PORT_MONITOR -#include "Print.h" -#include "printhex.h" -#include "message.h" -#include "hexdump.h" -#include "sink_parser.h" - -#include "address.h" - -#include "usb_ch9.h" -//#include "usbhost.h" -#include "UsbCore.h" -#include "parsetools.h" - -#include "confdescparser.h" - -#endif /* USB_H_INCLUDED */ diff --git a/legacy/builder/test/libraries/USBHost/src/UsbCore.h b/legacy/builder/test/libraries/USBHost/src/UsbCore.h deleted file mode 100644 index fdb14c1c14a..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/UsbCore.h +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(USBCORE_H) -#error "Never include UsbCore.h directly; include Usb.h instead" -#else -#define USBCORE_H - -// Not used anymore? If anyone uses this, please let us know so that this may be -// moved to the proper place, settings.h. -//#define USB_METHODS_INLINE - -/* shield pins. First parameter - SS pin, second parameter - INT pin */ -#ifdef BOARD_BLACK_WIDDOW -typedef MAX3421e MAX3421E; // Black Widow -#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) -#if EXT_RAM -typedef MAX3421e MAX3421E; // Teensy++ 2.0 with XMEM2 -#else -typedef MAX3421e MAX3421E; // Teensy++ 1.0 and 2.0 -#endif -#elif defined(BOARD_MEGA_ADK) -typedef MAX3421e MAX3421E; // Arduino Mega ADK -#elif defined(ARDUINO_AVR_BALANDUINO) -typedef MAX3421e MAX3421E; // Balanduino -#else -//typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.) or Teensy 2.0 and 3.0 -#endif - -/* Common setup data constant combinations */ -#define bmREQ_GET_DESCR USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //get descriptor request type -#define bmREQ_SET USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //set request type for all but 'set feature' and 'set interface' -#define bmREQ_CL_GET_INTF USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE //get interface request type - -// D7 data transfer direction (0 - host-to-device, 1 - device-to-host) -// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved) -// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved) - -// USB Device Classes -#define USB_CLASS_USE_CLASS_INFO 0x00 // Use Class Info in the Interface Descriptors -#define USB_CLASS_AUDIO 0x01 // Audio -#define USB_CLASS_COM_AND_CDC_CTRL 0x02 // Communications and CDC Control -#define USB_CLASS_HID 0x03 // HID -#define USB_CLASS_PHYSICAL 0x05 // Physical -#define USB_CLASS_IMAGE 0x06 // Image -#define USB_CLASS_PRINTER 0x07 // Printer -#define USB_CLASS_MASS_STORAGE 0x08 // Mass Storage -#define USB_CLASS_HUB 0x09 // Hub -#define USB_CLASS_CDC_DATA 0x0a // CDC-Data -#define USB_CLASS_SMART_CARD 0x0b // Smart-Card -#define USB_CLASS_CONTENT_SECURITY 0x0d // Content Security -#define USB_CLASS_VIDEO 0x0e // Video -#define USB_CLASS_PERSONAL_HEALTH 0x0f // Personal Healthcare -#define USB_CLASS_DIAGNOSTIC_DEVICE 0xdc // Diagnostic Device -#define USB_CLASS_WIRELESS_CTRL 0xe0 // Wireless Controller -#define USB_CLASS_MISC 0xef // Miscellaneous -#define USB_CLASS_APP_SPECIFIC 0xfe // Application Specific -#define USB_CLASS_VENDOR_SPECIFIC 0xff // Vendor Specific - -// Additional Error Codes -#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED 0xD1 -#define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2 -#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3 -#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4 -#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5 -#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6 -#define USB_ERROR_EPINFO_IS_NULL 0xD7 -#define USB_ERROR_INVALID_ARGUMENT 0xD8 -#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9 -#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA -#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB -#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET 0xE0 -#define USB_ERROR_FailGetDevDescr 0xE1 -#define USB_ERROR_FailSetDevTblEntry 0xE2 -#define USB_ERROR_FailGetConfDescr 0xE3 -#define USB_ERROR_TRANSFER_TIMEOUT 0xFF - -#define USB_XFER_TIMEOUT 10000 //30000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec -//#define USB_NAK_LIMIT 32000 //NAK limit for a transfer. 0 means NAKs are not counted -#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer -#define USB_SETTLE_DELAY 200 //settle delay in milliseconds - -#define USB_NUMDEVICES 16 //number of USB devices -//#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller -#define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recomended, can be up to 20 ms - -/* USB state machine states */ -#define USB_STATE_MASK 0xf0 - -#define USB_STATE_DETACHED 0x10 -#define USB_DETACHED_SUBSTATE_INITIALIZE 0x11 -#define USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE 0x12 -#define USB_DETACHED_SUBSTATE_ILLEGAL 0x13 -#define USB_ATTACHED_SUBSTATE_SETTLE 0x20 -#define USB_ATTACHED_SUBSTATE_RESET_DEVICE 0x30 -#define USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE 0x40 -#define USB_ATTACHED_SUBSTATE_WAIT_SOF 0x50 -#define USB_ATTACHED_SUBSTATE_WAIT_RESET 0x51 -#define USB_ATTACHED_SUBSTATE_GET_DEVICE_DESCRIPTOR_SIZE 0x60 -#define USB_STATE_ADDRESSING 0x70 -#define USB_STATE_CONFIGURING 0x80 -#define USB_STATE_RUNNING 0x90 -#define USB_STATE_ERROR 0xa0 - -class USBDeviceConfig { -public: - - virtual uint32_t Init(uint32_t parent, uint32_t port, uint32_t lowspeed) { - return 0; - } - - virtual uint32_t ConfigureDevice(uint32_t parent, uint32_t port, uint32_t lowspeed) { - return 0; - } - - virtual uint32_t Release() { - return 0; - } - - virtual uint32_t Poll() { - return 0; - } - - virtual uint32_t GetAddress() { - return 0; - } - - virtual void ResetHubPort(uint32_t port) { - return; - } // Note used for hubs only! - - virtual uint32_t VIDPIDOK(uint32_t vid, uint32_t pid) { - return false; - } - - virtual uint32_t DEVCLASSOK(uint32_t klass) { - return false; - } -}; - -/* USB Setup Packet Structure */ -typedef struct { - - union { // offset description - uint8_t bmRequestType; // 0 Bit-map of request type - - struct { - uint8_t recipient : 5; // Recipient of the request - uint8_t type : 2; // Type of request - uint8_t direction : 1; // Direction of data X-fer - }; - } ReqType_u; - uint8_t bRequest; // 1 Request - - union { - uint16_t wValue; // 2 Depends on bRequest - - struct { - uint8_t wValueLo; - uint8_t wValueHi; - }; - } wVal_u; - uint16_t wIndex; // 4 Depends on bRequest - uint16_t wLength; // 6 Depends on bRequest -} SETUP_PKT, *PSETUP_PKT; - - - -// Base class for incoming data parser - -class USBReadParser { -public: - virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset) = 0; -}; - -class USBHost { - AddressPoolImpl addrPool; - USBDeviceConfig* devConfig[USB_NUMDEVICES]; - uint8_t bmHubPre; - -public: - USBHost(void); - - void SetHubPreMask() { - //bmHubPre |= bmHUBPRE; - }; - - void ResetHubPreMask() { - //bmHubPre &= (~bmHUBPRE); - }; - - AddressPool& GetAddressPool() { - return (AddressPool&)addrPool; - }; - - uint32_t RegisterDeviceClass(USBDeviceConfig *pdev) { - for(uint8_t i = 0; i < USB_NUMDEVICES; i++) { - if(!devConfig[i]) { - devConfig[i] = pdev; - return 0; - } - } - return USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS; - }; - - void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { - addrPool.ForEachUsbDevice(pfunc); - }; - uint32_t getUsbTaskState(void); - void setUsbTaskState(uint32_t state); - - EpInfo* getEpInfoEntry(uint32_t addr, uint32_t ep); - uint32_t setEpInfoEntry(uint32_t addr, uint32_t epcount, EpInfo* eprecord_ptr); - - /* Control requests */ - uint32_t getDevDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint8_t* dataptr); - uint32_t getConfDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint32_t conf, uint8_t* dataptr); - - uint32_t getConfDescr(uint32_t addr, uint32_t ep, uint32_t conf, USBReadParser *p); - - uint32_t getStrDescr(uint32_t addr, uint32_t ep, uint32_t nbytes, uint32_t index, uint32_t langid, uint8_t* dataptr); - uint32_t setAddr(uint32_t oldaddr, uint32_t ep, uint32_t newaddr); - uint32_t setConf(uint32_t addr, uint32_t ep, uint32_t conf_value); - /**/ - uint32_t ctrlData(uint32_t addr, uint32_t ep, uint32_t nbytes, uint8_t* dataptr, uint32_t direction); - uint32_t ctrlStatus(uint32_t ep, uint32_t direction, uint32_t nak_limit); - uint32_t inTransfer(uint32_t addr, uint32_t ep, uint8_t *nbytesptr, uint8_t* data); - uint32_t outTransfer(uint32_t addr, uint32_t ep, uint32_t nbytes, uint8_t* data); - uint32_t dispatchPkt(uint32_t token, uint32_t ep, uint32_t nak_limit); - - void Task(void); - - uint32_t DefaultAddressing(uint32_t parent, uint32_t port, uint32_t lowspeed); - uint32_t Configuring(uint32_t parent, uint32_t port, uint32_t lowspeed); - uint32_t ReleaseDevice(uint32_t addr); - - uint32_t ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint32_t nbytes, uint8_t* dataptr, USBReadParser *p); - - uint32_t Init(); -private: - uint32_t SetPipeAddress(uint32_t addr, uint32_t ep, EpInfo **ppep, uint32_t &nak_limit); - uint32_t OutTransfer(EpInfo *pep, uint32_t nak_limit, uint32_t nbytes, uint8_t *data); - uint32_t InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr, uint8_t *data); - uint32_t AttemptConfig(uint32_t driver, uint32_t parent, uint32_t port, uint32_t lowspeed); -}; - -#if 0 //defined(USB_METHODS_INLINE) -//get device descriptor - -inline uint8_t USBHost::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr)); -} -//get configuration descriptor - -inline uint8_t USBHost::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr)); -} -//get string descriptor - -inline uint8_t USBHost::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr)); -} -//set address - -inline uint8_t USBHost::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { - return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL)); -} -//set configuration - -inline uint8_t USBHost::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { - return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL)); -} - -#endif // defined(USB_METHODS_INLINE) - -#endif /* USBCORE_H */ diff --git a/legacy/builder/test/libraries/USBHost/src/address.h b/legacy/builder/test/libraries/USBHost/src/address.h deleted file mode 100644 index a96108224f8..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/address.h +++ /dev/null @@ -1,280 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -#if !defined(_usb_h_) || defined(ADDRESS_H_INCLUDED) -#error "Never include address.h directly; include Usb.h instead" -#else -#define ADDRESS_H_INCLUDED - -#include -#include - -/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */ -/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */ -#define USB_NAK_MAX_POWER 15 //NAK binary order maximum value -#define USB_NAK_DEFAULT 14 //default 32K-1 NAKs before giving up -#define USB_NAK_NOWAIT 1 //Single NAK stops transfer -#define USB_NAK_NONAK 0 //Do not count NAKs, stop retrying after USB Timeout - -struct EpInfo { - uint32_t epAddr; // Endpoint address - uint32_t maxPktSize; // Maximum packet size - union { - uint8_t epAttribs; - - struct { - uint8_t bmSndToggle : 1; // Send toggle, when zero bmSNDTOG0, bmSNDTOG1 otherwise - uint8_t bmRcvToggle : 1; // Send toggle, when zero bmRCVTOG0, bmRCVTOG1 otherwise - uint8_t bmNakPower : 6; // Binary order for NAK_LIMIT value - }; - }; -}; - -// 7 6 5 4 3 2 1 0 -// --------------------------------- -// | | H | P | P | P | A | A | A | -// --------------------------------- -// -// H - if 1 the address is a hub address -// P - parent hub address -// A - device address / port number in case of hub -// - -struct UsbDeviceAddress { - union { - struct { - uint32_t bmAddress : 3; // device address/port number - uint32_t bmParent : 3; // parent hub address - uint32_t bmHub : 1; // hub flag - uint32_t bmReserved : 25; // reserved, must be zerro - }; - uint32_t devAddress; - }; -}; - -#define bmUSB_DEV_ADDR_ADDRESS 0x07 -#define bmUSB_DEV_ADDR_PARENT 0x38 -#define bmUSB_DEV_ADDR_HUB 0x40 - -struct UsbDeviceDefinition { - EpInfo *epinfo; // endpoint info pointer - UsbDeviceAddress address; - uint32_t epcount; // number of endpoints - uint32_t lowspeed; // indicates if a device is the low speed one - // uint8_t devclass; // device class -}; - -class AddressPool { -public: - virtual UsbDeviceDefinition* GetUsbDevicePtr(uint32_t addr) = 0; - virtual uint32_t AllocAddress(uint32_t parent, uint32_t is_hub = 0, uint32_t port = 0) = 0; - virtual void FreeAddress(uint32_t addr) = 0; -}; - -typedef void (*UsbDeviceHandleFunc)(UsbDeviceDefinition *pdev); - -#define ADDR_ERROR_INVALID_INDEX 0xFF -#define ADDR_ERROR_INVALID_ADDRESS 0xFF - -template -class AddressPoolImpl : public AddressPool { - EpInfo dev0ep; //Endpoint data structure used during enumeration for uninitialized device - - uint32_t hubCounter; // hub counter is kept - // in order to avoid hub address duplication - - UsbDeviceDefinition thePool[MAX_DEVICES_ALLOWED]; - - // Initializes address pool entry - - void InitEntry(uint32_t index) { - thePool[index].address.devAddress = 0; - thePool[index].epcount = 1; - thePool[index].lowspeed = 0; - thePool[index].epinfo = &dev0ep; - }; - - // Returns thePool index for a given address - - uint32_t FindAddressIndex(uint32_t address = 0) { - for (uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) { - if(thePool[i].address.devAddress == address) - return i; - } - return 0; - }; - - // Returns thePool child index for a given parent - - uint32_t FindChildIndex(UsbDeviceAddress addr, uint32_t start = 1) { - for (uint32_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) { - if(thePool[i].address.bmParent == addr.bmAddress) - return i; - } - return 0; - }; - - // Frees address entry specified by index parameter - - void FreeAddressByIndex(uint32_t index) { - // Zero field is reserved and should not be affected - if(index == 0) - return; - - UsbDeviceAddress uda = thePool[index].address; - // If a hub was switched off all port addresses should be freed - if(uda.bmHub == 1) { - for (uint32_t i = 1; (i = FindChildIndex(uda, i));) - FreeAddressByIndex(i); - - // If the hub had the last allocated address, hubCounter should be decremented - if(hubCounter == uda.bmAddress) - hubCounter--; - } - InitEntry(index); - } - - // Initializes the whole address pool at once - - void InitAllAddresses() { - for (uint32_t i = 1; i < MAX_DEVICES_ALLOWED; i++) - InitEntry(i); - - hubCounter = 0; - }; - -public: - - AddressPoolImpl() : hubCounter(0) { - // Zero address is reserved - InitEntry(0); - - thePool[0].address.devAddress = 0; - thePool[0].epinfo = &dev0ep; - dev0ep.epAddr = 0; - dev0ep.maxPktSize = 8; - dev0ep.epAttribs = 0; //set DATA0/1 toggles to 0 - dev0ep.bmNakPower = USB_NAK_MAX_POWER; - - InitAllAddresses(); - }; - - // Returns a pointer to a specified address entry - - virtual UsbDeviceDefinition* GetUsbDevicePtr(uint32_t addr) { - if(!addr) - return thePool; - - uint32_t index = FindAddressIndex(addr); - - return (!index) ? NULL : thePool + index; - }; - - // Performs an operation specified by pfunc for each addressed device - - void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { - if(!pfunc) - return; - - for (uint32_t i = 1; i < MAX_DEVICES_ALLOWED; i++) - if(thePool[i].address.devAddress) - pfunc(thePool + i); - }; - - // Allocates new address - - virtual uint32_t AllocAddress(uint32_t parent, uint32_t is_hub = 0, uint32_t port = 0) { - /* if (parent != 0 && port == 0) - USB_HOST_SERIAL.println("PRT:0"); */ - UsbDeviceAddress _parent; - _parent.devAddress = parent; - if(_parent.bmReserved || port > 7) - //if(parent > 127 || port > 7) - return 0; - - if(is_hub && hubCounter == 7) - return 0; - - // finds first empty address entry starting from one - uint32_t index = FindAddressIndex(0); - - if(!index) // if empty entry is not found - return 0; - - if(_parent.devAddress == 0) { - if(is_hub) { - thePool[index].address.devAddress = 0x41; - hubCounter++; - } else - thePool[index].address.devAddress = 1; - - return thePool[index].address.devAddress; - } - - UsbDeviceAddress addr; - addr.devAddress = 0; // Ensure all bits are zero - addr.bmParent = _parent.bmAddress; - if(is_hub) { - addr.bmHub = 1; - addr.bmAddress = ++hubCounter; - } else { - addr.bmHub = 0; - addr.bmAddress = port; - } - thePool[index].address = addr; - /* - USB_HOST_SERIAL.print("Addr:"); - USB_HOST_SERIAL.print(addr.bmHub, HEX); - USB_HOST_SERIAL.print("."); - USB_HOST_SERIAL.print(addr.bmParent, HEX); - USB_HOST_SERIAL.print("."); - USB_HOST_SERIAL.println(addr.bmAddress, HEX); - */ - return thePool[index].address.devAddress; - }; - - // Empties pool entry - - virtual void FreeAddress(uint32_t addr) { - // if the root hub is disconnected all the addresses should be initialized - if(addr == 0x41) { - InitAllAddresses(); - return; - } - uint32_t index = FindAddressIndex(addr); - FreeAddressByIndex(index); - }; - - // Returns number of hubs attached - // It can be rather helpfull to find out if there are hubs attached than getting the exact number of hubs. - //uint32_t GetNumHubs() - //{ - // return hubCounter; - //}; - //uint32_t GetNumDevices() - //{ - // uint32_t counter = 0; - - // for (uint32_t i=1; iRegisterDeviceClass(this); //set devConfig[] entry - } -} - -uint32_t ADK::ConfigureDevice(uint32_t parent, uint32_t port, uint32_t lowspeed) { - return Init(parent, port, lowspeed); // Just call Init. Yes, really! -} - -/* Connection initialization of an Android phone */ -uint32_t ADK::Init(uint32_t parent, uint32_t port, uint32_t lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint32_t rcode; - uint32_t num_of_conf; // number of configurations - UsbDeviceDefinition *p = NULL; - EpInfo *oldep_ptr = NULL; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("\r\nADK Init"); - - // check if address has already been assigned to an instance - if(bAddress) { - USBTRACE("\r\nAddress in use"); - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { - USBTRACE("\r\nAddress not found"); - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { - USBTRACE("epinfo is null\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor GET_DESCRIPTOR - rcode = pUsb->getDevDescr(0, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) { - USBTRACE("\r\nGetDevDesc1 Error "); - goto FailGetDevDescr; - } - - // Reset - UHD_BusReset(); - while( Is_uhd_starting_reset() ) {} - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - if (!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device SET_ADDRESS - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - USBTRACE("\r\nsetAddr Error "); - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - TRACE_USBHOST(printf("ADK::Init : setAddr failed with rcode %lu\r\n", rcode);) - return rcode; - }//if (rcode... - - USBTRACE2("\r\nAddr:", bAddress); - // Spec says you should wait at least 200ms. - //delay(300); - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - // Get device descriptor GET_DESCRIPTOR - rcode = pUsb->getDevDescr(bAddress, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - // Restore p->epinfo - p->epinfo = oldep_ptr; - if (rcode) - { - USBTRACE("\r\nGetDevDesc2 Error "); - goto FailGetDevDescr; - } - - TRACE_USBHOST(printf("ADK::Init : device address is now %lu\r\n", bAddress);) - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) { - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) { - goto FailSetDevTblEntry; - } - - //check if ADK device is already in accessory mode; if yes, configure and exit - if(udd->idVendor == ADK_VID && - (udd->idProduct == ADK_PID || udd->idProduct == ADB_PID)) { - USBTRACE("\r\nAcc.mode device detected"); - /* go through configurations, find first bulk-IN, bulk-OUT EP, fill epInfo and quit */ - num_of_conf = udd->bNumConfigurations; - - USBTRACE2("\r\nNC:",num_of_conf); - for (uint32_t i = 0; i < num_of_conf; i++) { - ConfigDescParser<0, 0, 0, 0> confDescrParser(this); - - delay(1); - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - -#if defined(XOOM) - //added by Jaylen Scott Vanorden - if(rcode) { - TRACE_USBHOST(printf("ADK::Init : Got 1st bad code for config: %lu\r\n", rcode);) - - // Try once more - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - } -#endif - if(rcode) { - goto FailGetConfDescr; - } - if(bNumEP > 2) { - break; - } - } // for (uint32_t i=0; isetEpInfoEntry(bAddress, 3, epInfo); - if(rcode) { - goto FailSetDevTblEntry; - } - } - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - if(rcode) { - goto FailSetConfDescr; - } - /* print endpoint structure */ - - USBTRACE("\r\nEndpoint Structure:"); - USBTRACE("\r\nEP0:"); - USBTRACE2("\r\nAddr: ", epInfo[0].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[0].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[0].epAttribs); - USBTRACE("\r\nEpout:"); - USBTRACE2("\r\nAddr: ", epInfo[epDataOutIndex].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataOutIndex].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[epDataOutIndex].epAttribs); - USBTRACE("\r\nEpin:"); - USBTRACE2("\r\nAddr: ", epInfo[epDataInIndex].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataInIndex].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[epDataInIndex].epAttribs); - - - USBTRACE("\r\nConfiguration successful"); - ready = true; - return 0; //successful configuration - }//if( buf->idVendor == ADK_VID... - - //probe device - get accessory protocol revision - { - uint32_t adkproto = 0; - delay(1); - //rcode = getProto((uint8_t*) & adkproto); // ADK_GETPROTO 0x33 - rcode = getProto((uint8_t*)buf); - -#if defined(XOOM) - //added by Jaylen Scott Vanorden - if(rcode) { - USBTRACE2("\r\nGot 1st bad code for proto: ", rcode); - // Try once more - rcode = getProto((uint8_t*) & adkproto); - } -#endif - if(rcode) { - goto FailGetProto; //init fails - } - adkproto = buf[0] | (buf[1]<<8); - USBTRACE2("\r\nADK protocol rev. ", adkproto); - } - - delay(100); - - //sending ID strings - // ADK_SENDSTR 0x34 - if( sendStr(ACCESSORY_STRING_MANUFACTURER, manufacturer) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_MANUFACTURER"); } - delay(10); - if( sendStr(ACCESSORY_STRING_MODEL, model) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_MODEL"); } - delay(10); - if( sendStr(ACCESSORY_STRING_DESCRIPTION, description) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_DESCRIPTION"); } - delay(10); - if( sendStr(ACCESSORY_STRING_VERSION, version) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_VERSION"); } - delay(10); - if( sendStr(ACCESSORY_STRING_URI, uri) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_URI"); } - delay(10); - if( sendStr(ACCESSORY_STRING_SERIAL, serial) ) { - USBTRACE("\r\nPb ACCESSORY_STRING_SERIAL"); } - - delay(100); - - USBTRACE("\r\nSwitch to accessory mode"); - //switch to accessory mode - //the Android phone will reset - rcode = switchAcc(); - if(rcode) { - goto FailSwAcc; //init fails - } - rcode = USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; - delay(100); // Give Android a chance to do its reset. This is a guess, and possibly could be lower. - goto SwAttempt; //switch to accessory mode attempted - - /* diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(rcode); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(rcode); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(rcode); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(rcode); - goto Fail; -#endif - -FailGetProto: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\ngetProto:"); - goto Fail; -#endif - -FailSwAcc: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\nswAcc:"); - goto Fail; -#endif - - //FailOnInit: - // USBTRACE("OnInit:"); - // goto Fail; - // -SwAttempt: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\nAccessory mode switch attempt"); -Fail: -#endif - USBTRACE2("\r\nADK Init Failed, error code: ", rcode); - //NotifyFail(rcode); - Release(); - return rcode; -} - -/* Extracts bulk-IN and bulk-OUT endpoint information from config descriptor */ -void ADK::EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - //ErrorMessage(PSTR("Conf.Val"), conf); - //ErrorMessage(PSTR("Iface Num"), iface); - //ErrorMessage(PSTR("Alt.Set"), alt); - - //added by Yuuichi Akagawa - if(bNumEP == 3) { - return; - } - - bConfNum = conf; - - if((pep->bmAttributes & 0x02) == 2) { - uint32_t index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - - bNumEP++; - - //PrintEndpointDescriptor(pep); - } -} - -/* Performs a cleanup after failed Init() attempt */ -uint32_t ADK::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bNumEP = 1; //must have to be reset to 1 - - bAddress = 0; - ready = false; - return 0; -} - -uint32_t ADK::RcvData(uint8_t *bytes_rcvd, uint8_t *dataptr) { - USBTRACE2("\r\nAddr: ", bAddress ); - USBTRACE2("\r\nEP: ",epInfo[epDataInIndex].epAddr); - return pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr); -} - -uint32_t ADK::SndData(uint32_t nbytes, uint8_t *dataptr) { - return pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr); -} - -void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - PrintHex (ep_ptr->bInterval, 0x80); - Notify(PSTR("\r\n"), 0x80); -} diff --git a/legacy/builder/test/libraries/USBHost/src/adk.h b/legacy/builder/test/libraries/USBHost/src/adk.h deleted file mode 100644 index ffd22cf3e1f..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/adk.h +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -/* Google ADK interface support header */ - -#ifndef ADK_H_INCLUDED -#define ADK_H_INCLUDED - -#include -#include "Usb.h" -#include "hid.h" -#include "Arduino.h" - -// #define ADK_VID 0x18D1 -// #define ADK_PID 0x2D00 -// #define ADB_PID 0x2D01 - -// JCB -#define ADK_VID 0x04E8 -#define ADK_PID 0x685C -#define ADB_PID 0x685D - -#define XOOM //enables repeating getProto() and getConf() attempts - //necessary for slow devices such as Motorola XOOM - //defined by default, can be commented out to save memory - -/* requests */ - -#define ADK_GETPROTO 51 //check USB accessory protocol version 0x33 -#define ADK_SENDSTR 52 //send identifying string 0x34 -#define ADK_ACCSTART 53 //start device in accessory mode 0x35 - -#define bmREQ_ADK_GET USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_ADK_SEND USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE - -#define ACCESSORY_STRING_MANUFACTURER 0 -#define ACCESSORY_STRING_MODEL 1 -#define ACCESSORY_STRING_DESCRIPTION 2 -#define ACCESSORY_STRING_VERSION 3 -#define ACCESSORY_STRING_URI 4 -#define ACCESSORY_STRING_SERIAL 5 - -#define ADK_MAX_ENDPOINTS 3 //endpoint 0, bulk_IN, bulk_OUT - -class ADK; - -class ADK : public USBDeviceConfig, public UsbConfigXtracter { -private: - /* ID strings */ - const char* manufacturer; - const char* model; - const char* description; - const char* version; - const char* uri; - const char* serial; - - /* ADK proprietary requests */ - uint32_t getProto(uint8_t* adkproto); - uint32_t sendStr(uint32_t index, const char* str); - uint32_t switchAcc(void); - -protected: - static const uint32_t epDataInIndex; // DataIn endpoint index - static const uint32_t epDataOutIndex; // DataOUT endpoint index - - /* Mandatory members */ - USBHost *pUsb; - uint32_t bAddress; // Device USB address - uint32_t bConfNum; // configuration number - - uint32_t bNumEP; // total number of EP in the configuration - uint32_t ready; - - /* Endpoint data structure */ - EpInfo epInfo[ADK_MAX_ENDPOINTS]; - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - -public: - ADK(USBHost *pUsb, const char* manufacturer, - const char* model, - const char* description, - const char* version, - const char* uri, - const char* serial); - - // Methods for receiving and sending data - uint32_t RcvData(uint8_t *nbytesptr, uint8_t *dataptr); - uint32_t SndData(uint32_t nbytes, uint8_t *dataptr); - - - // USBDeviceConfig implementation - virtual uint32_t ConfigureDevice(uint32_t parent, uint32_t port, uint32_t lowspeed); - virtual uint32_t Init(uint32_t parent, uint32_t port, uint32_t lowspeed); - virtual uint32_t Release(); - - virtual uint32_t Poll() { - return 0; - }; - - virtual uint32_t GetAddress() { - return bAddress; - }; - - virtual uint32_t isReady() { - return ready; - }; - - virtual uint32_t VIDPIDOK(uint32_t vid, uint32_t pid) { - return (vid == ADK_VID && (pid == ADK_PID || pid == ADB_PID)); - }; - - //UsbConfigXtracter implementation - virtual void EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); -}; //class ADK : public USBDeviceConfig ... - -/* get ADK protocol version */ - -/* returns 2 bytes in *adkproto */ -inline uint32_t ADK::getProto(uint8_t* adkproto) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_GET, ADK_GETPROTO, 0, 0, 0, 2, 2, adkproto, NULL)); -} - -/* send ADK string */ -inline uint32_t ADK::sendStr(uint32_t index, const char* str) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_SEND, ADK_SENDSTR, 0, 0, index, strlen(str) + 1, strlen(str) + 1, (uint8_t*)str, NULL)); -} - -/* switch to accessory mode */ -inline uint32_t ADK::switchAcc(void) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_SEND, ADK_ACCSTART, 0, 0, 0, 0, 0, NULL, NULL)); -} - -#endif /* ADK_H_INCLUDED */ diff --git a/legacy/builder/test/libraries/USBHost/src/confdescparser.h b/legacy/builder/test/libraries/USBHost/src/confdescparser.h deleted file mode 100644 index 6ee6a1eef2b..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/confdescparser.h +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -#if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__) -#error "Never include confdescparser.h directly; include Usb.h instead" -#else - -#define __CONFDESCPARSER_H__ - -#include - -//#define TRACE_USBHOST(x) x -#define TRACE_USBHOST(x) - -class UsbConfigXtracter { -public: - //virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0; - //virtual void InterfaceXtract(uint32_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0; - virtual void EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) = 0; -}; - -#define CP_MASK_COMPARE_CLASS 1 -#define CP_MASK_COMPARE_SUBCLASS 2 -#define CP_MASK_COMPARE_PROTOCOL 4 -#define CP_MASK_COMPARE_ALL 7 - -// Configuration Descriptor Parser Class Template - -template -class ConfigDescParser : public USBReadParser { - UsbConfigXtracter *theXtractor; - MultiValueBuffer theBuffer; - MultiByteValueParser valParser; - ByteSkipper theSkipper; - uint8_t varBuffer[16 /*sizeof(USB_CONFIGURATION_DESCRIPTOR)*/]; - - uint32_t stateParseDescr; // ParseDescriptor state - - uint32_t dscrLen; // Descriptor length - uint32_t dscrType; // Descriptor type - - bool isGoodInterface; // Apropriate interface flag - uint32_t confValue; // Configuration value - uint32_t protoValue; // Protocol value - uint32_t ifaceNumber; // Interface number - uint32_t ifaceAltSet; // Interface alternate settings - - bool UseOr; - bool ParseDescriptor(uint8_t **pp, uint32_t *pcntdn); - void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); - -public: - - void SetOR(void) { - UseOr = true; - } - ConfigDescParser(UsbConfigXtracter *xtractor); - virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset); -}; - -template -ConfigDescParser::ConfigDescParser(UsbConfigXtracter *xtractor) : - theXtractor(xtractor), - stateParseDescr(0), - dscrLen(0), - dscrType(0), -UseOr(false) { - theBuffer.pValue = varBuffer; - valParser.Initialize(&theBuffer); - theSkipper.Initialize(&theBuffer); -}; - -template -void ConfigDescParser::Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset) { - uint32_t cntdn = len; - uint8_t *p = (uint8_t*)pbuf; - - while (cntdn) - if(!ParseDescriptor(&p, &cntdn)) - return; -} - -/* Parser for the configuration descriptor. Takes values for class, subclass, protocol fields in interface descriptor and - compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ -template -bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) { - USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); - USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); - switch(stateParseDescr) { - case 0: - theBuffer.valueSize = 2; - valParser.Initialize(&theBuffer); - stateParseDescr = 1; - case 1: - if(!valParser.Parse(pp, pcntdn)) - return false; - dscrLen = *((uint8_t*)theBuffer.pValue); - dscrType = *((uint8_t*)theBuffer.pValue + 1); - stateParseDescr = 2; - case 2: - // This is a sort of hack. Assuming that two bytes are all ready in the buffer - // the pointer is positioned two bytes ahead in order for the rest of descriptor - // to be read right after the size and the type fields. - // This should be used carefully. varBuffer should be used directly to handle data - // in the buffer. - theBuffer.pValue = varBuffer + 2; - stateParseDescr = 3; - case 3: - switch(dscrType) { - case USB_DESCRIPTOR_INTERFACE: - isGoodInterface = false; - case USB_DESCRIPTOR_CONFIGURATION: - theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; - break; - case USB_DESCRIPTOR_ENDPOINT: - theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; - break; - case HID_DESCRIPTOR_HID: - theBuffer.valueSize = dscrLen - 2; - break; - } - valParser.Initialize(&theBuffer); - stateParseDescr = 4; - case 4: - switch(dscrType) { - case USB_DESCRIPTOR_CONFIGURATION: - if(!valParser.Parse(pp, pcntdn)) - return false; - confValue = ucd->bConfigurationValue; - break; - case USB_DESCRIPTOR_INTERFACE: - if(!valParser.Parse(pp, pcntdn)) - return false; - if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) - break; - if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) - break; - if(UseOr) { - if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) - break; - } else { - if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) - break; - } - isGoodInterface = true; - ifaceNumber = uid->bInterfaceNumber; - ifaceAltSet = uid->bAlternateSetting; - protoValue = uid->bInterfaceProtocol; - break; - case USB_DESCRIPTOR_ENDPOINT: - if(!valParser.Parse(pp, pcntdn)) - return false; - if(isGoodInterface) - if(theXtractor) - theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); - break; - //case HID_DESCRIPTOR_HID: - // if (!valParser.Parse(pp, pcntdn)) - // return false; - // PrintHidDescriptor((const USB_HID_DESCRIPTOR*)varBuffer); - // break; - default: - if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2)) - return false; - } - theBuffer.pValue = varBuffer; - stateParseDescr = 0; - } - return true; -} - -template -void ConfigDescParser::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - PrintHex (pDesc->bLength, 0x80); - - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - PrintHex (pDesc->bDescriptorType, 0x80); - - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - PrintHex (pDesc->bcdHID, 0x80); - - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - PrintHex (pDesc->bCountryCode, 0x80); - - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - PrintHex (pDesc->bNumDescriptors, 0x80); - - //Notify(PSTR("\r\nbDescrType:\t\t")); - //PrintHex(pDesc->bDescrType); - // - //Notify(PSTR("\r\nwDescriptorLength:\t")); - //PrintHex(pDesc->wDescriptorLength); - - for (uint32_t i = 0; i < pDesc->bNumDescriptors; i++) { - HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); - - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - PrintHex (pLT[i].bDescrType, 0x80); - - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - PrintHex (pLT[i].wDescriptorLength, 0x80); - } - Notify(PSTR("\r\n"), 0x80); -} - - -#endif // __CONFDESCPARSER_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/hexdump.h b/legacy/builder/test/libraries/USBHost/src/hexdump.h deleted file mode 100644 index 3818d850b71..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hexdump.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__HEXDUMP_H__) -#error "Never include hexdump.h directly; include Usb.h instead" -#else -#define __HEXDUMP_H__ - -extern int UsbDEBUGlvl; - -template -class HexDumper : public BASE_CLASS { - uint8_t byteCount; - OFFSET_TYPE byteTotal; - -public: - - HexDumper() : byteCount(0), byteTotal(0) { - }; - - void Initialize() { - byteCount = 0; - byteTotal = 0; - }; - - virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); -}; - -template -void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { - if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. - for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { - if(!byteCount) { - PrintHex (byteTotal, 0x80); - E_Notify(PSTR(": "), 0x80); - } - PrintHex (pbuf[j], 0x80); - E_Notify(PSTR(" "), 0x80); - - if(byteCount == 15) { - E_Notify(PSTR("\r\n"), 0x80); - byteCount = 0xFF; - } - } - } -} - -#endif // __HEXDUMP_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/hid.cpp b/legacy/builder/test/libraries/USBHost/src/hid.cpp deleted file mode 100644 index 70c785b3e61..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hid.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "hid.h" - -//get HID report descriptor - -/* WRONG! Endpoint is _ALWAYS_ ZERO for HID! We want the _INTERFACE_ value here! -uint32_t HID::GetReportDescr(uint32_t ep, USBReadParser *parser) { - const uint8_t constBufLen = 64; - uint8_t buf[constBufLen]; - - uint8_t rcode = pUsb->ctrlReq(bAddress, ep, bmREQ_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00, - HID_DESCRIPTOR_REPORT, 0x0000, 128, constBufLen, buf, (USBReadParser*)parser); - - //return ((rcode != hrSTALL) ? rcode : 0); - return rcode; -} - */ -uint32_t HID::GetReportDescr(uint32_t wIndex, USBReadParser *parser) { - const uint8_t constBufLen = 64; - uint8_t buf[constBufLen]; - - uint8_t rcode = pUsb->ctrlReq(bAddress, 0x00, bmREQ_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00, - HID_DESCRIPTOR_REPORT, wIndex, 128, constBufLen, buf, (USBReadParser*)parser); - - //return ((rcode != hrSTALL) ? rcode : 0); - return rcode; -} - -//uint32_t HID::getHidDescr( uint8_t ep, uint16_t nbytes, uint8_t* dataptr ) -//{ -// return( pUsb->ctrlReq( bAddress, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, HID_DESCRIPTOR_HID, 0x0000, nbytes, dataptr )); -//} - -uint32_t HID::SetReport(uint32_t ep, uint32_t iface, uint32_t report_type, uint32_t report_id, uint32_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL)); -} - -uint32_t HID::GetReport(uint32_t ep, uint32_t iface, uint32_t report_type, uint32_t report_id, uint32_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL)); -} - -uint32_t HID::GetIdle(uint32_t iface, uint32_t reportID, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDIN, HID_REQUEST_GET_IDLE, reportID, 0, iface, 0x0001, 0x0001, dataptr, NULL)); -} - -uint32_t HID::SetIdle(uint32_t iface, uint32_t reportID, uint32_t duration) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDOUT, HID_REQUEST_SET_IDLE, reportID, duration, iface, 0x0000, 0x0000, NULL, NULL)); -} - -uint32_t HID::SetProtocol(uint32_t iface, uint32_t protocol) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDOUT, HID_REQUEST_SET_PROTOCOL, protocol, 0x00, iface, 0x0000, 0x0000, NULL, NULL)); -} - -uint32_t HID::GetProtocol(uint32_t iface, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDIN, HID_REQUEST_GET_PROTOCOL, 0x00, 0x00, iface, 0x0001, 0x0001, dataptr, NULL)); -} - -void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); -} - -void HID::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - D_PrintHex (pDesc->bLength, 0x80); - - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - D_PrintHex (pDesc->bDescriptorType, 0x80); - - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - D_PrintHex (pDesc->bcdHID, 0x80); - - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - D_PrintHex (pDesc->bCountryCode, 0x80); - - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - D_PrintHex (pDesc->bNumDescriptors, 0x80); - - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - D_PrintHex (pDesc->bDescrType, 0x80); - - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - D_PrintHex (pDesc->wDescriptorLength, 0x80); -} diff --git a/legacy/builder/test/libraries/USBHost/src/hid.h b/legacy/builder/test/libraries/USBHost/src/hid.h deleted file mode 100644 index ca697a56829..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hid.h +++ /dev/null @@ -1,183 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -#if !defined(__HID_H__) -#define __HID_H__ - -#include "Usb.h" -#include "hidusagestr.h" - -#define MAX_REPORT_PARSERS 2 -#define HID_MAX_HID_CLASS_DESCRIPTORS 5 - -#define DATA_SIZE_MASK 0x03 -#define TYPE_MASK 0x0C -#define TAG_MASK 0xF0 - -#define DATA_SIZE_0 0x00 -#define DATA_SIZE_1 0x01 -#define DATA_SIZE_2 0x02 -#define DATA_SIZE_4 0x03 - -#define TYPE_MAIN 0x00 -#define TYPE_GLOBAL 0x04 -#define TYPE_LOCAL 0x08 - -#define TAG_MAIN_INPUT 0x80 -#define TAG_MAIN_OUTPUT 0x90 -#define TAG_MAIN_COLLECTION 0xA0 -#define TAG_MAIN_FEATURE 0xB0 -#define TAG_MAIN_ENDCOLLECTION 0xC0 - -#define TAG_GLOBAL_USAGEPAGE 0x00 -#define TAG_GLOBAL_LOGICALMIN 0x10 -#define TAG_GLOBAL_LOGICALMAX 0x20 -#define TAG_GLOBAL_PHYSMIN 0x30 -#define TAG_GLOBAL_PHYSMAX 0x40 -#define TAG_GLOBAL_UNITEXP 0x50 -#define TAG_GLOBAL_UNIT 0x60 -#define TAG_GLOBAL_REPORTSIZE 0x70 -#define TAG_GLOBAL_REPORTID 0x80 -#define TAG_GLOBAL_REPORTCOUNT 0x90 -#define TAG_GLOBAL_PUSH 0xA0 -#define TAG_GLOBAL_POP 0xB0 - -#define TAG_LOCAL_USAGE 0x00 -#define TAG_LOCAL_USAGEMIN 0x10 -#define TAG_LOCAL_USAGEMAX 0x20 - -/* HID requests */ -#define bmREQ_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_HIDIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE - -/* HID constants. Not part of chapter 9 */ -/* Class-Specific Requests */ -#define HID_REQUEST_GET_REPORT 0x01 -#define HID_REQUEST_GET_IDLE 0x02 -#define HID_REQUEST_GET_PROTOCOL 0x03 -#define HID_REQUEST_SET_REPORT 0x09 -#define HID_REQUEST_SET_IDLE 0x0A -#define HID_REQUEST_SET_PROTOCOL 0x0B - -/* Class Descriptor Types */ -#define HID_DESCRIPTOR_HID 0x21 -#define HID_DESCRIPTOR_REPORT 0x22 -#define HID_DESRIPTOR_PHY 0x23 - -/* Protocol Selection */ -#define HID_BOOT_PROTOCOL 0x00 -#define HID_RPT_PROTOCOL 0x01 - -/* HID Interface Class Code */ -#define HID_INTF 0x03 - -/* HID Interface Class SubClass Codes */ -#define HID_BOOT_INTF_SUBCLASS 0x01 - -/* HID Interface Class Protocol Codes */ -#define HID_PROTOCOL_NONE 0x00 -#define HID_PROTOCOL_KEYBOARD 0x01 -#define HID_PROTOCOL_MOUSE 0x02 - -#define HID_ITEM_TYPE_MAIN 0 -#define HID_ITEM_TYPE_GLOBAL 1 -#define HID_ITEM_TYPE_LOCAL 2 -#define HID_ITEM_TYPE_RESERVED 3 - -#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value - -#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask - -#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value -#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value -#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value -#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value -#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value - -#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0 -#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1 -#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2 -#define HID_MAIN_ITEM_COLLECTION_REPORT 3 -#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4 -#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5 -#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6 - -struct HidItemPrefix { - uint8_t bSize : 2; - uint8_t bType : 2; - uint8_t bTag : 4; -}; - -struct MainItemIOFeature { - uint8_t bmIsConstantOrData : 1; - uint8_t bmIsArrayOrVariable : 1; - uint8_t bmIsRelativeOrAbsolute : 1; - uint8_t bmIsWrapOrNoWrap : 1; - uint8_t bmIsNonLonearOrLinear : 1; - uint8_t bmIsNoPreferedOrPrefered : 1; - uint8_t bmIsNullOrNoNull : 1; - uint8_t bmIsVolatileOrNonVolatile : 1; -}; - -class HID; - -class HIDReportParser { -public: - virtual void Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf)= 0; -}; - -class HID : public USBDeviceConfig, public UsbConfigXtracter { -protected: - USBHost *pUsb; // USB class instance pointer - uint32_t bAddress; // address - -protected: - static const uint32_t epInterruptInIndex = 1; // InterruptIN endpoint index - static const uint32_t epInterruptOutIndex = 2; // InterruptOUT endpoint index - - static const uint32_t maxHidInterfaces = 3; - static const uint32_t maxEpPerInterface = 2; - static const uint32_t totalEndpoints = (maxHidInterfaces * maxEpPerInterface + 1); - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); - - virtual HIDReportParser* GetReportParser(uint32_t id); - -public: - - HID(USBHost *pusb) : pUsb(pusb) { - }; - - const USBHost* GetUsb() { - return pUsb; - }; - virtual uint32_t SetReportParser(uint32_t id, HIDReportParser *prs); - - uint32_t SetProtocol(uint32_t iface, uint32_t protocol); - uint32_t GetProtocol(uint32_t iface, uint8_t* dataptr); - uint32_t GetIdle(uint32_t iface, uint32_t reportID, uint8_t* dataptr); - uint32_t SetIdle(uint32_t iface, uint32_t reportID, uint32_t duration); - - uint32_t GetReportDescr(uint32_t ep, USBReadParser *parser = NULL); - - uint32_t GetHidDescr(uint32_t ep, uint32_t nbytes, uint8_t* dataptr); - uint32_t GetReport(uint32_t ep, uint32_t iface, uint32_t report_type, uint32_t report_id, uint32_t nbytes, uint8_t* dataptr); - uint32_t SetReport(uint32_t ep, uint32_t iface, uint32_t report_type, uint32_t report_id, uint32_t nbytes, uint8_t* dataptr); -}; - -#endif // __HID_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/hidboot.cpp b/legacy/builder/test/libraries/USBHost/src/hidboot.cpp deleted file mode 100644 index 9f6b8743ae9..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hidboot.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -#include "hidboot.h" - -void MouseReportParser::Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf) { - MOUSEINFO *pmi = (MOUSEINFO*)buf; - // Future: - // bool event; - -#if 0 - if (prevState.mouseInfo.bmLeftButton == 0 && pmi->bmLeftButton == 1) - OnLeftButtonDown(pmi); - - if (prevState.mouseInfo.bmLeftButton == 1 && pmi->bmLeftButton == 0) - OnLeftButtonUp(pmi); - - if (prevState.mouseInfo.bmRightButton == 0 && pmi->bmRightButton == 1) - OnRightButtonDown(pmi); - - if (prevState.mouseInfo.bmRightButton == 1 && pmi->bmRightButton == 0) - OnRightButtonUp(pmi); - - if (prevState.mouseInfo.bmMiddleButton == 0 && pmi->bmMiddleButton == 1) - OnMiddleButtonDown(pmi); - - if (prevState.mouseInfo.bmMiddleButton == 1 && pmi->bmMiddleButton == 0) - OnMiddleButtonUp(pmi); - - if (prevState.mouseInfo.dX != pmi->dX || prevState.mouseInfo.dY != pmi->dY) - OnMouseMove(pmi); - - if (len > sizeof (MOUSEINFO)) - for (uint32_t i = 0; ibmLeftButton ) { - if(pmi->bmLeftButton) { - OnLeftButtonDown(pmi); - } else { - OnLeftButtonUp(pmi); - } - // Future: - // event = true; - } - - if(prevState.mouseInfo.bmRightButton != pmi->bmRightButton) { - if(pmi->bmRightButton) { - OnRightButtonDown(pmi); - } else { - OnRightButtonUp(pmi); - } - // Future: - // event = true; - } - - if(prevState.mouseInfo.bmMiddleButton != pmi->bmMiddleButton) { - if(pmi->bmMiddleButton) { - OnMiddleButtonDown(pmi); - } else { - OnMiddleButtonUp(pmi); - } - // Future: - // event = true; - } - - // - // Scroll wheel(s), are not part of the spec, but we could support it. - // Logitech wireless keyboard and mouse combo reports scroll wheel in byte 4 - // We wouldn't even need to save this information. - //if(len > 3) { - //} - // - - // Mice only report motion when they actually move! - // Why not just pass the x/y values to simplify things?? - if(pmi->dX || pmi->dY) { - OnMouseMove(pmi); - // Future: - // event = true; - } - - // - // Future: - // Provide a callback that operates on the gathered events from above. - // - // if(event) OnMouse(); - // - - // Only the first byte matters (buttons). We do NOT need to save position info. - prevState.bInfo[0] = buf[0]; -#endif - -}; - -void KeyboardReportParser::Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf) { - // On error - return - if (buf[2] == 1) - return; - - //KBDINFO *pki = (KBDINFO*)buf; - - // provide event for changed control key state - if (prevState.bInfo[0x00] != buf[0x00]) { - OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]); - } - - for (uint32_t i = 2; i < 8; i++) { - bool down = false; - bool up = false; - - for (uint8_t j = 2; j < 8; j++) { - if (buf[i] == prevState.bInfo[j] && buf[i] != 1) - down = true; - if (buf[j] == prevState.bInfo[i] && prevState.bInfo[i] != 1) - up = true; - } - if (!down) { - HandleLockingKeys(hid, buf[i]); - OnKeyDown(*buf, buf[i]); - } - if (!up) - OnKeyUp(prevState.bInfo[0], prevState.bInfo[i]); - } - for(uint32_t i = 0; i < 8; i++) - prevState.bInfo[i] = buf[i]; -}; - -uint8_t KeyboardReportParser::HandleLockingKeys(HID *hid, uint8_t key) { - uint8_t old_keys = kbdLockingKeys.bLeds; - - switch (key) { - case UHS_HID_BOOT_KEY_NUM_LOCK: - kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; - break; - case UHS_HID_BOOT_KEY_CAPS_LOCK: - kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; - break; - case UHS_HID_BOOT_KEY_SCROLL_LOCK: - kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; - break; - } - - if (old_keys != kbdLockingKeys.bLeds && hid) - return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds)); - - return 0; -} - -const uint8_t KeyboardReportParser::numKeys[10] = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')'}; -const uint8_t KeyboardReportParser::symKeysUp[12] = { '_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'}; -const uint8_t KeyboardReportParser::symKeysLo[12] = { '-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'}; -const uint8_t KeyboardReportParser::padKeys[5] = { '/', '*', '-', '+', 0x13}; -#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h))) -uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) { - uint8_t shift = (mod & 0x22); - - // [a-z] - if (VALUE_WITHIN(key, 0x04, 0x1d)) { - // Upper case letters - if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && (mod & 2)) || - (kbdLockingKeys.kbdLeds.bmCapsLock == 1 && (mod & 2) == 0)) - return (key - 4 + 'A'); - - // Lower case letters - else - return (key - 4 + 'a'); - }// Numbers - else if (VALUE_WITHIN(key, 0x1e, 0x27)) { - if (shift) - return ((uint8_t)pgm_read_byte(&getNumKeys()[key - 0x1e])); - else - return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1'); - }// Keypad Numbers - else if(VALUE_WITHIN(key, 0x59, 0x61)) { - if(kbdLockingKeys.kbdLeds.bmNumLock == 1) - return (key - 0x59 + '1'); - } else if(VALUE_WITHIN(key, 0x2d, 0x38)) - return ((shift) ? (uint8_t)pgm_read_byte(&getSymKeysUp()[key - 0x2d]) : (uint8_t)pgm_read_byte(&getSymKeysLo()[key - 0x2d])); - else if(VALUE_WITHIN(key, 0x54, 0x58)) - return (uint8_t)pgm_read_byte(&getPadKeys()[key - 0x54]); - else { - switch(key) { - case UHS_HID_BOOT_KEY_SPACE: return (0x20); - case UHS_HID_BOOT_KEY_ENTER: return (0x13); - case UHS_HID_BOOT_KEY_ZERO2: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '0': 0); - case UHS_HID_BOOT_KEY_PERIOD: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '.': 0); - } - } - return ( 0); -} - diff --git a/legacy/builder/test/libraries/USBHost/src/hidboot.h b/legacy/builder/test/libraries/USBHost/src/hidboot.h deleted file mode 100644 index 621ce57ac2f..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hidboot.h +++ /dev/null @@ -1,609 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -#ifndef HIDBOOT_H_INCLUDED -#define HIDBOOT_H_INCLUDED - -#include -#include "Usb.h" -#include "hid.h" -#include "Arduino.h" - -#define UHS_HID_BOOT_KEY_ZERO 0x27 -#define UHS_HID_BOOT_KEY_ENTER 0x28 -#define UHS_HID_BOOT_KEY_SPACE 0x2c -#define UHS_HID_BOOT_KEY_CAPS_LOCK 0x39 -#define UHS_HID_BOOT_KEY_SCROLL_LOCK 0x47 -#define UHS_HID_BOOT_KEY_NUM_LOCK 0x53 -#define UHS_HID_BOOT_KEY_ZERO2 0x62 -#define UHS_HID_BOOT_KEY_PERIOD 0x63 - -// Don't worry, GCC will optimize the result to a final value. -#define bitsEndpoints(p) ((((p) & HID_PROTOCOL_KEYBOARD)? 2 : 0) | (((p) & HID_PROTOCOL_MOUSE)? 1 : 0)) -#define totalEndpoints(p) ((bitsEndpoints(p) == 3) ? 3 : 2) -#define epMUL(p) ((((p) & HID_PROTOCOL_KEYBOARD)? 1 : 0) + (((p) & HID_PROTOCOL_MOUSE)? 1 : 0)) - -// Already defined in hid.h -// #define HID_MAX_HID_CLASS_DESCRIPTORS 5 - -struct MOUSEINFO { - - struct { - uint8_t bmLeftButton : 1; - uint8_t bmRightButton : 1; - uint8_t bmMiddleButton : 1; - uint8_t bmDummy : 5; - }; - int8_t dX; - int8_t dY; -}; - -class MouseReportParser : public HIDReportParser { - - union { - MOUSEINFO mouseInfo; - uint8_t bInfo[sizeof (MOUSEINFO)]; - } prevState; - -public: - virtual void Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf); - -protected: - - virtual void OnMouseMove(MOUSEINFO *mi) { - }; - - virtual void OnLeftButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnLeftButtonDown(MOUSEINFO *mi) { - }; - - virtual void OnRightButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnRightButtonDown(MOUSEINFO *mi) { - }; - - virtual void OnMiddleButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnMiddleButtonDown(MOUSEINFO *mi) { - }; -}; - -struct MODIFIERKEYS { - uint8_t bmLeftCtrl : 1; - uint8_t bmLeftShift : 1; - uint8_t bmLeftAlt : 1; - uint8_t bmLeftGUI : 1; - uint8_t bmRightCtrl : 1; - uint8_t bmRightShift : 1; - uint8_t bmRightAlt : 1; - uint8_t bmRightGUI : 1; -}; - -struct KBDINFO { - - struct { - uint8_t bmLeftCtrl : 1; - uint8_t bmLeftShift : 1; - uint8_t bmLeftAlt : 1; - uint8_t bmLeftGUI : 1; - uint8_t bmRightCtrl : 1; - uint8_t bmRightShift : 1; - uint8_t bmRightAlt : 1; - uint8_t bmRightGUI : 1; - }; - uint8_t bReserved; - uint8_t Keys[6]; -}; - -struct KBDLEDS { - uint8_t bmNumLock : 1; - uint8_t bmCapsLock : 1; - uint8_t bmScrollLock : 1; - uint8_t bmCompose : 1; - uint8_t bmKana : 1; - uint8_t bmReserved : 3; -}; - -class KeyboardReportParser : public HIDReportParser { - static const uint8_t numKeys[10]; - static const uint8_t symKeysUp[12]; - static const uint8_t symKeysLo[12]; - static const uint8_t padKeys[5]; - -protected: - - union { - KBDINFO kbdInfo; - uint8_t bInfo[sizeof (KBDINFO)]; - } prevState; - - union { - KBDLEDS kbdLeds; - uint8_t bLeds; - } kbdLockingKeys; - - uint8_t OemToAscii(uint8_t mod, uint8_t key); - -public: - - KeyboardReportParser() { - kbdLockingKeys.bLeds = 0; - }; - - virtual void Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf); - -protected: - virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key); - - virtual void OnControlKeysChanged(uint8_t before, uint8_t after) { - }; - - virtual void OnKeyDown(uint8_t mod, uint8_t key) { - }; - - virtual void OnKeyUp(uint8_t mod, uint8_t key) { - }; - - virtual const uint8_t *getNumKeys() { - return numKeys; - }; - - virtual const uint8_t *getSymKeysUp() { - return symKeysUp; - }; - - virtual const uint8_t *getSymKeysLo() { - return symKeysLo; - }; - - virtual const uint8_t *getPadKeys() { - return padKeys; - }; -}; - -template -class HIDBoot : public HID //public USBDeviceConfig, public UsbConfigXtracter -{ - EpInfo epInfo[totalEndpoints(BOOT_PROTOCOL)]; - HIDReportParser *pRptParser[epMUL(BOOT_PROTOCOL)]; - - uint32_t bConfNum; // configuration number - uint32_t bIfaceNum; // Interface Number - uint32_t bNumIface; // number of interfaces in the configuration - uint32_t bNumEP; // total number of EP in the configuration - - uint32_t qNextPollTime; // next poll time - uint32_t bPollEnable; // poll enable flag - uint32_t bInterval; // largest interval - - void Initialize(); - - virtual HIDReportParser* GetReportParser(uint32_t id) { - return pRptParser[id]; - }; - -public: - HIDBoot(USBHost *p); - - virtual uint32_t SetReportParser(uint32_t id, HIDReportParser *prs) { - pRptParser[id] = prs; - return true; - }; - - // USBDeviceConfig implementation - virtual uint32_t Init(uint32_t parent, uint32_t port, uint32_t lowspeed); - virtual uint32_t Release(); - virtual uint32_t Poll(); - - virtual uint32_t GetAddress() { - return bAddress; - }; - - // UsbConfigXtracter implementation - virtual void EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); -}; - -template -HIDBoot::HIDBoot(USBHost *p) : - HID(p), - qNextPollTime(0), - bPollEnable(false) { - Initialize(); - - for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - pRptParser[i] = NULL; - } - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -template -void HIDBoot::Initialize() { - for(int i = 0; i < totalEndpoints(BOOT_PROTOCOL); i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - bNumEP = 1; - bNumIface = 0; - bConfNum = 0; -} - -template -uint32_t HIDBoot::Init(uint32_t parent, uint32_t port, uint32_t lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - uint32_t rcode; - UsbDeviceDefinition *p = NULL; - EpInfo *oldep_ptr = NULL; - uint32_t len = 0; - //uint16_t cd_len = 0; - - uint32_t num_of_conf; // number of configurations - //uint32_t num_of_intf; // number of interfaces - - // Get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("BM Init\r\n"); - //USBTRACE2("totalEndpoints:", (uint8_t) (totalEndpoints(BOOT_PROTOCOL))); - //USBTRACE2("epMUL:", epMUL(BOOT_PROTOCOL)); - - // Check if address has already been assigned to an instance - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - bInterval = 0; - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - // Get device descriptor GET_DESCRIPTOR - rcode = pUsb->getDevDescr(0, 0, /*8*/sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - - if(!rcode) - len = (buf[0] > constBufSize) ? constBufSize : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - - goto FailGetDevDescr; - } - - - // Reset - UHD_BusReset(); - while( Is_uhd_starting_reset() ) {} - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; - - // Assign new address to the device SET_ADDRESS - - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - //delay(2); //per USB 2.0 sect.9.2.6.3 - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - // Get device descriptor GET_DESCRIPTOR - rcode = pUsb->getDevDescr(bAddress, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - // Restore p->epinfo - p->epinfo = oldep_ptr; - if (rcode) - { - goto FailGetDevDescr; - } - - TRACE_USBHOST(printf("HIDBoot::Init : device address is now %lu\r\n", bAddress);) - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; - - USBTRACE2("NC:", num_of_conf); - - // GCC will optimize unused stuff away. - if((BOOT_PROTOCOL & (HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE)) == (HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE)) { - USBTRACE("HID_PROTOCOL_KEYBOARD AND MOUSE\r\n"); - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE, - CP_MASK_COMPARE_ALL > confDescrParser(this); - confDescrParser.SetOR(); // Use the OR variant. - for(uint32_t i = 0; i < num_of_conf; i++) { - pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) - break; - } - } else { - // GCC will optimize unused stuff away. - if(BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD) { - USBTRACE("HID_PROTOCOL_KEYBOARD\r\n"); - for(uint32_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_KEYBOARD, - CP_MASK_COMPARE_ALL> confDescrParserA(this); - - pUsb->getConfDescr(bAddress, 0, i, &confDescrParserA); - if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) - break; - } - } - - // GCC will optimize unused stuff away. - if(BOOT_PROTOCOL & HID_PROTOCOL_MOUSE) { - USBTRACE("HID_PROTOCOL_MOUSE\r\n"); - for(uint32_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_MOUSE, - CP_MASK_COMPARE_ALL> confDescrParserB(this); - - pUsb->getConfDescr(bAddress, 0, i, &confDescrParserB); - if(bNumEP == ((uint8_t)(totalEndpoints(BOOT_PROTOCOL)))) - break; - - } - } - } - USBTRACE2("bNumEP:", bNumEP); - - if(bNumEP != (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) { - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - goto Fail; - } - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - //USBTRACE2("setEpInfoEntry returned ", rcode); - USBTRACE2("Cnf:", bConfNum); - - delay(1000); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - delay(1000); - - USBTRACE2("bIfaceNum:", bIfaceNum); - USBTRACE2("bNumIface:", bNumIface); - - // Yes, mouse wants SetProtocol and SetIdle too! - for(uint32_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - USBTRACE2("\r\nInterface:", i); - rcode = SetProtocol(i, HID_BOOT_PROTOCOL); - if(rcode) goto FailSetProtocol; - USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode); - rcode = SetIdle(i, 0, 0); - USBTRACE2("SET_IDLE rcode:", rcode); - // if(rcode) goto FailSetIdle; This can fail. - // Get the RPIPE and just throw it away. - SinkParser sink; - rcode = GetReportDescr(i, (USBReadParser *)&sink); - USBTRACE2("RPIPE rcode:", rcode); - } - - // Get RPIPE and throw it away. - - if(BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD) { - // Wake keyboard interface by twinkling up to 5 LEDs that are in the spec. - // kana, compose, scroll, caps, num - rcode = 0x20; // Reuse rcode. - while(rcode) { - rcode >>= 1; - // Ignore any error returned, we don't care if LED is not supported - SetReport(0, 0, 2, 0, 1, (uint8_t*)&rcode); // Eventually becomes zero (All off) - delay(25); - } - } - USBTRACE("BM configured\r\n"); - - bPollEnable = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - - //FailSetDevTblEntry: - //#ifdef DEBUG_USB_HOST - // NotifyFailSetDevTblEntry(); - // goto Fail; - //#endif - - //FailGetConfDescr: - //#ifdef DEBUG_USB_HOST - // NotifyFailGetConfDescr(); - // goto Fail; - //#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailSetProtocol: -#ifdef DEBUG_USB_HOST - USBTRACE("SetProto:"); - goto Fail; -#endif - - //FailSetIdle: - //#ifdef DEBUG_USB_HOST - // USBTRACE("SetIdle:"); - //#endif - -Fail: -#ifdef DEBUG_USB_HOST - NotifyFail(rcode); -#endif - Release(); - - return rcode; -} - -template -void HIDBoot::EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - // If the first configuration satisfies, the others are not considered. - //if(bNumEP > 1 && conf != bConfNum) - if(bNumEP == totalEndpoints(BOOT_PROTOCOL)) - return; - - bConfNum = conf; - bIfaceNum = iface; - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { - if(pep->bInterval > bInterval) bInterval = pep->bInterval; - - // Fill in the endpoint info structure - epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[bNumEP].epAttribs = 0; - epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; - bNumEP++; - - } -} - -template -uint32_t HIDBoot::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bConfNum = 0; - bIfaceNum = 0; - bNumEP = 1; - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - - return 0; -} - -template -uint32_t HIDBoot::Poll() { - uint32_t rcode = 0; - - if(bPollEnable && ((long)(millis() - qNextPollTime) >= 0L)) { - - // To-do: optimize manually, using the for loop only if needed. - for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - const uint16_t const_buff_len = 16; - uint8_t buf[const_buff_len]; - - USBTRACE3("(hidboot.h) i=", i, 0x81); - USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 0x81); - USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81); - uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize; - UHD_Pipe_Alloc(bAddress, epInfo[epInterruptInIndex + i].epAddr, USB_HOST_PTYPE_BULK, USB_EP_DIR_IN, epInfo[epInterruptInIndex + i].maxPktSize, 0, USB_HOST_NB_BK_1); - rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, (uint8_t*)&read, buf); - // SOME buggy dongles report extra keys (like sleep) using a 2 byte packet on the wrong endpoint. - // Since keyboard and mice must report at least 3 bytes, we ignore the extra data. - if(!rcode && read > 2) { - if(pRptParser[i]) - pRptParser[i]->Parse((HID*)this, 0, (uint8_t)read, buf); -#ifdef DEBUG_USB_HOST - // We really don't care about errors and anomalies unless we are debugging. - } else { - if(rcode != USB_ERRORFLOW) { - USBTRACE3("(hidboot.h) Poll:", rcode, 0x81); - } - if(!rcode && read) { - USBTRACE3("(hidboot.h) Strange read count: ", read, 0x80); - USBTRACE3("(hidboot.h) Interface:", i, 0x80); - } - } - - if(!rcode && read && (UsbDEBUGlvl > 0x7f)) { - for(uint8_t i = 0; i < read; i++) { - PrintHex (buf[i], 0x80); - USBTRACE1(" ", 0x80); - } - if(read) - USBTRACE1("\r\n", 0x80); -#endif - } - - } - qNextPollTime = millis() + bInterval; - } - return rcode; -} - -#endif /* HIDBOOT_H_INCLUDED */ diff --git a/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.cpp b/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.cpp deleted file mode 100644 index 17e1e35a9df..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.cpp +++ /dev/null @@ -1,1599 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "hidescriptorparser.h" - -const char * const ReportDescParserBase::usagePageTitles0[] PROGMEM = { - pstrUsagePageGenericDesktopControls, - pstrUsagePageSimulationControls, - pstrUsagePageVRControls, - pstrUsagePageSportControls, - pstrUsagePageGameControls, - pstrUsagePageGenericDeviceControls, - pstrUsagePageKeyboardKeypad, - pstrUsagePageLEDs, - pstrUsagePageButton, - pstrUsagePageOrdinal, - pstrUsagePageTelephone, - pstrUsagePageConsumer, - pstrUsagePageDigitizer, - pstrUsagePagePID, - pstrUsagePageUnicode -}; - -const char * const ReportDescParserBase::usagePageTitles1[] PROGMEM = { - pstrUsagePageBarCodeScanner, - pstrUsagePageScale, - pstrUsagePageMSRDevices, - pstrUsagePagePointOfSale, - pstrUsagePageCameraControl, - pstrUsagePageArcade -}; -const char * const ReportDescParserBase::genDesktopTitles0[] PROGMEM = { - pstrUsagePointer, - pstrUsageMouse, - pstrUsageJoystick, - pstrUsageGamePad, - pstrUsageKeyboard, - pstrUsageKeypad, - pstrUsageMultiAxisController, - pstrUsageTabletPCSystemControls - -}; -const char * const ReportDescParserBase::genDesktopTitles1[] PROGMEM = { - pstrUsageX, - pstrUsageY, - pstrUsageZ, - pstrUsageRx, - pstrUsageRy, - pstrUsageRz, - pstrUsageSlider, - pstrUsageDial, - pstrUsageWheel, - pstrUsageHatSwitch, - pstrUsageCountedBuffer, - pstrUsageByteCount, - pstrUsageMotionWakeup, - pstrUsageStart, - pstrUsageSelect, - pstrUsagePageReserved, - pstrUsageVx, - pstrUsageVy, - pstrUsageVz, - pstrUsageVbrx, - pstrUsageVbry, - pstrUsageVbrz, - pstrUsageVno, - pstrUsageFeatureNotification, - pstrUsageResolutionMultiplier -}; -const char * const ReportDescParserBase::genDesktopTitles2[] PROGMEM = { - pstrUsageSystemControl, - pstrUsageSystemPowerDown, - pstrUsageSystemSleep, - pstrUsageSystemWakeup, - pstrUsageSystemContextMenu, - pstrUsageSystemMainMenu, - pstrUsageSystemAppMenu, - pstrUsageSystemMenuHelp, - pstrUsageSystemMenuExit, - pstrUsageSystemMenuSelect, - pstrUsageSystemMenuRight, - pstrUsageSystemMenuLeft, - pstrUsageSystemMenuUp, - pstrUsageSystemMenuDown, - pstrUsageSystemColdRestart, - pstrUsageSystemWarmRestart, - pstrUsageDPadUp, - pstrUsageDPadDown, - pstrUsageDPadRight, - pstrUsageDPadLeft -}; -const char * const ReportDescParserBase::genDesktopTitles3[] PROGMEM = { - pstrUsageSystemDock, - pstrUsageSystemUndock, - pstrUsageSystemSetup, - pstrUsageSystemBreak, - pstrUsageSystemDebuggerBreak, - pstrUsageApplicationBreak, - pstrUsageApplicationDebuggerBreak, - pstrUsageSystemSpeakerMute, - pstrUsageSystemHibernate -}; -const char * const ReportDescParserBase::genDesktopTitles4[] PROGMEM = { - pstrUsageSystemDisplayInvert, - pstrUsageSystemDisplayInternal, - pstrUsageSystemDisplayExternal, - pstrUsageSystemDisplayBoth, - pstrUsageSystemDisplayDual, - pstrUsageSystemDisplayToggleIntExt, - pstrUsageSystemDisplaySwapPriSec, - pstrUsageSystemDisplayLCDAutoscale -}; -const char * const ReportDescParserBase::simuTitles0[] PROGMEM = { - pstrUsageFlightSimulationDevice, - pstrUsageAutomobileSimulationDevice, - pstrUsageTankSimulationDevice, - pstrUsageSpaceshipSimulationDevice, - pstrUsageSubmarineSimulationDevice, - pstrUsageSailingSimulationDevice, - pstrUsageMotocicleSimulationDevice, - pstrUsageSportsSimulationDevice, - pstrUsageAirplaneSimulationDevice, - pstrUsageHelicopterSimulationDevice, - pstrUsageMagicCarpetSimulationDevice, - pstrUsageBicycleSimulationDevice -}; -const char * const ReportDescParserBase::simuTitles1[] PROGMEM = { - pstrUsageFlightControlStick, - pstrUsageFlightStick, - pstrUsageCyclicControl, - pstrUsageCyclicTrim, - pstrUsageFlightYoke, - pstrUsageTrackControl -}; -const char * const ReportDescParserBase::simuTitles2[] PROGMEM = { - pstrUsageAileron, - pstrUsageAileronTrim, - pstrUsageAntiTorqueControl, - pstrUsageAutopilotEnable, - pstrUsageChaffRelease, - pstrUsageCollectiveControl, - pstrUsageDiveBrake, - pstrUsageElectronicCountermeasures, - pstrUsageElevator, - pstrUsageElevatorTrim, - pstrUsageRudder, - pstrUsageThrottle, - pstrUsageFlightCommunications, - pstrUsageFlareRelease, - pstrUsageLandingGear, - pstrUsageToeBrake, - pstrUsageTrigger, - pstrUsageWeaponsArm, - pstrUsageWeaponsSelect, - pstrUsageWingFlaps, - pstrUsageAccelerator, - pstrUsageBrake, - pstrUsageClutch, - pstrUsageShifter, - pstrUsageSteering, - pstrUsageTurretDirection, - pstrUsageBarrelElevation, - pstrUsageDivePlane, - pstrUsageBallast, - pstrUsageBicycleCrank, - pstrUsageHandleBars, - pstrUsageFrontBrake, - pstrUsageRearBrake -}; -const char * const ReportDescParserBase::vrTitles0[] PROGMEM = { - pstrUsageBelt, - pstrUsageBodySuit, - pstrUsageFlexor, - pstrUsageGlove, - pstrUsageHeadTracker, - pstrUsageHeadMountedDisplay, - pstrUsageHandTracker, - pstrUsageOculometer, - pstrUsageVest, - pstrUsageAnimatronicDevice -}; -const char * const ReportDescParserBase::vrTitles1[] PROGMEM = { - pstrUsageStereoEnable, - pstrUsageDisplayEnable -}; -const char * const ReportDescParserBase::sportsCtrlTitles0[] PROGMEM = { - pstrUsageBaseballBat, - pstrUsageGolfClub, - pstrUsageRowingMachine, - pstrUsageTreadmill -}; -const char * const ReportDescParserBase::sportsCtrlTitles1[] PROGMEM = { - pstrUsageOar, - pstrUsageSlope, - pstrUsageRate, - pstrUsageStickSpeed, - pstrUsageStickFaceAngle, - pstrUsageStickHeelToe, - pstrUsageStickFollowThough, - pstrUsageStickTempo, - pstrUsageStickType, - pstrUsageStickHeight -}; -const char * const ReportDescParserBase::sportsCtrlTitles2[] PROGMEM = { - pstrUsagePutter, - pstrUsage1Iron, - pstrUsage2Iron, - pstrUsage3Iron, - pstrUsage4Iron, - pstrUsage5Iron, - pstrUsage6Iron, - pstrUsage7Iron, - pstrUsage8Iron, - pstrUsage9Iron, - pstrUsage10Iron, - pstrUsage11Iron, - pstrUsageSandWedge, - pstrUsageLoftWedge, - pstrUsagePowerWedge, - pstrUsage1Wood, - pstrUsage3Wood, - pstrUsage5Wood, - pstrUsage7Wood, - pstrUsage9Wood -}; -const char * const ReportDescParserBase::gameTitles0[] PROGMEM = { - pstrUsage3DGameController, - pstrUsagePinballDevice, - pstrUsageGunDevice -}; -const char * const ReportDescParserBase::gameTitles1[] PROGMEM = { - pstrUsagePointOfView, - pstrUsageTurnRightLeft, - pstrUsagePitchForwardBackward, - pstrUsageRollRightLeft, - pstrUsageMoveRightLeft, - pstrUsageMoveForwardBackward, - pstrUsageMoveUpDown, - pstrUsageLeanRightLeft, - pstrUsageLeanForwardBackward, - pstrUsageHeightOfPOV, - pstrUsageFlipper, - pstrUsageSecondaryFlipper, - pstrUsageBump, - pstrUsageNewGame, - pstrUsageShootBall, - pstrUsagePlayer, - pstrUsageGunBolt, - pstrUsageGunClip, - pstrUsageGunSelector, - pstrUsageGunSingleShot, - pstrUsageGunBurst, - pstrUsageGunAutomatic, - pstrUsageGunSafety, - pstrUsageGamepadFireJump, - pstrUsageGamepadTrigger -}; -const char * const ReportDescParserBase::genDevCtrlTitles[] PROGMEM = { - pstrUsageBatteryStrength, - pstrUsageWirelessChannel, - pstrUsageWirelessID, - pstrUsageDiscoverWirelessControl, - pstrUsageSecurityCodeCharEntered, - pstrUsageSecurityCodeCharErased, - pstrUsageSecurityCodeCleared -}; -const char * const ReportDescParserBase::ledTitles[] PROGMEM = { - pstrUsageNumLock, - pstrUsageCapsLock, - pstrUsageScrollLock, - pstrUsageCompose, - pstrUsageKana, - pstrUsagePower, - pstrUsageShift, - pstrUsageDoNotDisturb, - pstrUsageMute, - pstrUsageToneEnable, - pstrUsageHighCutFilter, - pstrUsageLowCutFilter, - pstrUsageEqualizerEnable, - pstrUsageSoundFieldOn, - pstrUsageSurroundOn, - pstrUsageRepeat, - pstrUsageStereo, - pstrUsageSamplingRateDetect, - pstrUsageSpinning, - pstrUsageCAV, - pstrUsageCLV, - pstrUsageRecordingFormatDetect, - pstrUsageOffHook, - pstrUsageRing, - pstrUsageMessageWaiting, - pstrUsageDataMode, - pstrUsageBatteryOperation, - pstrUsageBatteryOK, - pstrUsageBatteryLow, - pstrUsageSpeaker, - pstrUsageHeadSet, - pstrUsageHold, - pstrUsageMicrophone, - pstrUsageCoverage, - pstrUsageNightMode, - pstrUsageSendCalls, - pstrUsageCallPickup, - pstrUsageConference, - pstrUsageStandBy, - pstrUsageCameraOn, - pstrUsageCameraOff, - pstrUsageOnLine, - pstrUsageOffLine, - pstrUsageBusy, - pstrUsageReady, - pstrUsagePaperOut, - pstrUsagePaperJam, - pstrUsageRemote, - pstrUsageForward, - pstrUsageReverse, - pstrUsageStop, - pstrUsageRewind, - pstrUsageFastForward, - pstrUsagePlay, - pstrUsagePause, - pstrUsageRecord, - pstrUsageError, - pstrUsageSelectedIndicator, - pstrUsageInUseIndicator, - pstrUsageMultiModeIndicator, - pstrUsageIndicatorOn, - pstrUsageIndicatorFlash, - pstrUsageIndicatorSlowBlink, - pstrUsageIndicatorFastBlink, - pstrUsageIndicatorOff, - pstrUsageFlashOnTime, - pstrUsageSlowBlinkOnTime, - pstrUsageSlowBlinkOffTime, - pstrUsageFastBlinkOnTime, - pstrUsageFastBlinkOffTime, - pstrUsageIndicatorColor, - pstrUsageIndicatorRed, - pstrUsageIndicatorGreen, - pstrUsageIndicatorAmber, - pstrUsageGenericIndicator, - pstrUsageSystemSuspend, - pstrUsageExternalPowerConnected -}; -const char * const ReportDescParserBase::telTitles0 [] PROGMEM = { - pstrUsagePhone, - pstrUsageAnsweringMachine, - pstrUsageMessageControls, - pstrUsageHandset, - pstrUsageHeadset, - pstrUsageTelephonyKeyPad, - pstrUsageProgrammableButton -}; -const char * const ReportDescParserBase::telTitles1 [] PROGMEM = { - pstrUsageHookSwitch, - pstrUsageFlash, - pstrUsageFeature, - pstrUsageHold, - pstrUsageRedial, - pstrUsageTransfer, - pstrUsageDrop, - pstrUsagePark, - pstrUsageForwardCalls, - pstrUsageAlternateFunction, - pstrUsageLine, - pstrUsageSpeakerPhone, - pstrUsageConference, - pstrUsageRingEnable, - pstrUsageRingSelect, - pstrUsagePhoneMute, - pstrUsageCallerID, - pstrUsageSend -}; -const char * const ReportDescParserBase::telTitles2 [] PROGMEM = { - pstrUsageSpeedDial, - pstrUsageStoreNumber, - pstrUsageRecallNumber, - pstrUsagePhoneDirectory -}; -const char * const ReportDescParserBase::telTitles3 [] PROGMEM = { - pstrUsageVoiceMail, - pstrUsageScreenCalls, - pstrUsageDoNotDisturb, - pstrUsageMessage, - pstrUsageAnswerOnOff -}; -const char * const ReportDescParserBase::telTitles4 [] PROGMEM = { - pstrUsageInsideDialTone, - pstrUsageOutsideDialTone, - pstrUsageInsideRingTone, - pstrUsageOutsideRingTone, - pstrUsagePriorityRingTone, - pstrUsageInsideRingback, - pstrUsagePriorityRingback, - pstrUsageLineBusyTone, - pstrUsageReorderTone, - pstrUsageCallWaitingTone, - pstrUsageConfirmationTone1, - pstrUsageConfirmationTone2, - pstrUsageTonesOff, - pstrUsageOutsideRingback, - pstrUsageRinger -}; -const char * const ReportDescParserBase::telTitles5 [] PROGMEM = { - pstrUsagePhoneKey0, - pstrUsagePhoneKey1, - pstrUsagePhoneKey2, - pstrUsagePhoneKey3, - pstrUsagePhoneKey4, - pstrUsagePhoneKey5, - pstrUsagePhoneKey6, - pstrUsagePhoneKey7, - pstrUsagePhoneKey8, - pstrUsagePhoneKey9, - pstrUsagePhoneKeyStar, - pstrUsagePhoneKeyPound, - pstrUsagePhoneKeyA, - pstrUsagePhoneKeyB, - pstrUsagePhoneKeyC, - pstrUsagePhoneKeyD -}; -const char * const ReportDescParserBase::consTitles0[] PROGMEM = { - pstrUsageConsumerControl, - pstrUsageNumericKeyPad, - pstrUsageProgrammableButton, - pstrUsageMicrophone, - pstrUsageHeadphone, - pstrUsageGraphicEqualizer -}; -const char * const ReportDescParserBase::consTitles1[] PROGMEM = { - pstrUsagePlus10, - pstrUsagePlus100, - pstrUsageAMPM -}; -const char * const ReportDescParserBase::consTitles2[] PROGMEM = { - pstrUsagePower, - pstrUsageReset, - pstrUsageSleep, - pstrUsageSleepAfter, - pstrUsageSleepMode, - pstrUsageIllumination, - pstrUsageFunctionButtons - -}; -const char * const ReportDescParserBase::consTitles3[] PROGMEM = { - pstrUsageMenu, - pstrUsageMenuPick, - pstrUsageMenuUp, - pstrUsageMenuDown, - pstrUsageMenuLeft, - pstrUsageMenuRight, - pstrUsageMenuEscape, - pstrUsageMenuValueIncrease, - pstrUsageMenuValueDecrease -}; -const char * const ReportDescParserBase::consTitles4[] PROGMEM = { - pstrUsageDataOnScreen, - pstrUsageClosedCaption, - pstrUsageClosedCaptionSelect, - pstrUsageVCRTV, - pstrUsageBroadcastMode, - pstrUsageSnapshot, - pstrUsageStill -}; -const char * const ReportDescParserBase::consTitles5[] PROGMEM = { - pstrUsageSelection, - pstrUsageAssignSelection, - pstrUsageModeStep, - pstrUsageRecallLast, - pstrUsageEnterChannel, - pstrUsageOrderMovie, - pstrUsageChannel, - pstrUsageMediaSelection, - pstrUsageMediaSelectComputer, - pstrUsageMediaSelectTV, - pstrUsageMediaSelectWWW, - pstrUsageMediaSelectDVD, - pstrUsageMediaSelectTelephone, - pstrUsageMediaSelectProgramGuide, - pstrUsageMediaSelectVideoPhone, - pstrUsageMediaSelectGames, - pstrUsageMediaSelectMessages, - pstrUsageMediaSelectCD, - pstrUsageMediaSelectVCR, - pstrUsageMediaSelectTuner, - pstrUsageQuit, - pstrUsageHelp, - pstrUsageMediaSelectTape, - pstrUsageMediaSelectCable, - pstrUsageMediaSelectSatellite, - pstrUsageMediaSelectSecurity, - pstrUsageMediaSelectHome, - pstrUsageMediaSelectCall, - pstrUsageChannelIncrement, - pstrUsageChannelDecrement, - pstrUsageMediaSelectSAP, - pstrUsagePageReserved, - pstrUsageVCRPlus, - pstrUsageOnce, - pstrUsageDaily, - pstrUsageWeekly, - pstrUsageMonthly -}; -const char * const ReportDescParserBase::consTitles6[] PROGMEM = { - pstrUsagePlay, - pstrUsagePause, - pstrUsageRecord, - pstrUsageFastForward, - pstrUsageRewind, - pstrUsageScanNextTrack, - pstrUsageScanPreviousTrack, - pstrUsageStop, - pstrUsageEject, - pstrUsageRandomPlay, - pstrUsageSelectDisk, - pstrUsageEnterDisk, - pstrUsageRepeat, - pstrUsageTracking, - pstrUsageTrackNormal, - pstrUsageSlowTracking, - pstrUsageFrameForward, - pstrUsageFrameBackwards, - pstrUsageMark, - pstrUsageClearMark, - pstrUsageRepeatFromMark, - pstrUsageReturnToMark, - pstrUsageSearchMarkForward, - pstrUsageSearchMarkBackwards, - pstrUsageCounterReset, - pstrUsageShowCounter, - pstrUsageTrackingIncrement, - pstrUsageTrackingDecrement, - pstrUsageStopEject, - pstrUsagePlayPause, - pstrUsagePlaySkip -}; -const char * const ReportDescParserBase::consTitles7[] PROGMEM = { - pstrUsageVolume, - pstrUsageBalance, - pstrUsageMute, - pstrUsageBass, - pstrUsageTreble, - pstrUsageBassBoost, - pstrUsageSurroundMode, - pstrUsageLoudness, - pstrUsageMPX, - pstrUsageVolumeIncrement, - pstrUsageVolumeDecrement -}; -const char * const ReportDescParserBase::consTitles8[] PROGMEM = { - pstrUsageSpeedSelect, - pstrUsagePlaybackSpeed, - pstrUsageStandardPlay, - pstrUsageLongPlay, - pstrUsageExtendedPlay, - pstrUsageSlow -}; -const char * const ReportDescParserBase::consTitles9[] PROGMEM = { - pstrUsageFanEnable, - pstrUsageFanSpeed, - pstrUsageLightEnable, - pstrUsageLightIlluminationLevel, - pstrUsageClimateControlEnable, - pstrUsageRoomTemperature, - pstrUsageSecurityEnable, - pstrUsageFireAlarm, - pstrUsagePoliceAlarm, - pstrUsageProximity, - pstrUsageMotion, - pstrUsageDuresAlarm, - pstrUsageHoldupAlarm, - pstrUsageMedicalAlarm -}; -const char * const ReportDescParserBase::consTitlesA[] PROGMEM = { - pstrUsageBalanceRight, - pstrUsageBalanceLeft, - pstrUsageBassIncrement, - pstrUsageBassDecrement, - pstrUsageTrebleIncrement, - pstrUsageTrebleDecrement -}; -const char * const ReportDescParserBase::consTitlesB[] PROGMEM = { - pstrUsageSpeakerSystem, - pstrUsageChannelLeft, - pstrUsageChannelRight, - pstrUsageChannelCenter, - pstrUsageChannelFront, - pstrUsageChannelCenterFront, - pstrUsageChannelSide, - pstrUsageChannelSurround, - pstrUsageChannelLowFreqEnhancement, - pstrUsageChannelTop, - pstrUsageChannelUnknown -}; -const char * const ReportDescParserBase::consTitlesC[] PROGMEM = { - pstrUsageSubChannel, - pstrUsageSubChannelIncrement, - pstrUsageSubChannelDecrement, - pstrUsageAlternateAudioIncrement, - pstrUsageAlternateAudioDecrement -}; -const char * const ReportDescParserBase::consTitlesD[] PROGMEM = { - pstrUsageApplicationLaunchButtons, - pstrUsageALLaunchButtonConfigTool, - pstrUsageALProgrammableButton, - pstrUsageALConsumerControlConfig, - pstrUsageALWordProcessor, - pstrUsageALTextEditor, - pstrUsageALSpreadsheet, - pstrUsageALGraphicsEditor, - pstrUsageALPresentationApp, - pstrUsageALDatabaseApp, - pstrUsageALEmailReader, - pstrUsageALNewsreader, - pstrUsageALVoicemail, - pstrUsageALContactsAddressBook, - pstrUsageALCalendarSchedule, - pstrUsageALTaskProjectManager, - pstrUsageALLogJournalTimecard, - pstrUsageALCheckbookFinance, - pstrUsageALCalculator, - pstrUsageALAVCapturePlayback, - pstrUsageALLocalMachineBrowser, - pstrUsageALLANWANBrow, - pstrUsageALInternetBrowser, - pstrUsageALRemoteNetISPConnect, - pstrUsageALNetworkConference, - pstrUsageALNetworkChat, - pstrUsageALTelephonyDialer, - pstrUsageALLogon, - pstrUsageALLogoff, - pstrUsageALLogonLogoff, - pstrUsageALTermLockScrSav, - pstrUsageALControlPannel, - pstrUsageALCommandLineProcessorRun, - pstrUsageALProcessTaskManager, - pstrUsageALSelectTaskApplication, - pstrUsageALNextTaskApplication, - pstrUsageALPreviousTaskApplication, - pstrUsageALPreemptiveHaltTaskApp, - pstrUsageALIntegratedHelpCenter, - pstrUsageALDocuments, - pstrUsageALThesaurus, - pstrUsageALDictionary, - pstrUsageALDesktop, - pstrUsageALSpellCheck, - pstrUsageALGrammarCheck, - pstrUsageALWirelessStatus, - pstrUsageALKeyboardLayout, - pstrUsageALVirusProtection, - pstrUsageALEncryption, - pstrUsageALScreenSaver, - pstrUsageALAlarms, - pstrUsageALClock, - pstrUsageALFileBrowser, - pstrUsageALPowerStatus, - pstrUsageALImageBrowser, - pstrUsageALAudioBrowser, - pstrUsageALMovieBrowser, - pstrUsageALDigitalRightsManager, - pstrUsageALDigitalWallet, - pstrUsagePageReserved, - pstrUsageALInstantMessaging, - pstrUsageALOEMFeaturesBrowser, - pstrUsageALOEMHelp, - pstrUsageALOnlineCommunity, - pstrUsageALEntertainmentContentBrow, - pstrUsageALOnlineShoppingBrowser, - pstrUsageALSmartCardInfoHelp, - pstrUsageALMarketMonitorFinBrowser, - pstrUsageALCustomCorpNewsBrowser, - pstrUsageALOnlineActivityBrowser, - pstrUsageALResearchSearchBrowser, - pstrUsageALAudioPlayer -}; -const char * const ReportDescParserBase::consTitlesE[] PROGMEM = { - pstrUsageGenericGUIAppControls, - pstrUsageACNew, - pstrUsageACOpen, - pstrUsageACClose, - pstrUsageACExit, - pstrUsageACMaximize, - pstrUsageACMinimize, - pstrUsageACSave, - pstrUsageACPrint, - pstrUsageACProperties, - pstrUsageACUndo, - pstrUsageACCopy, - pstrUsageACCut, - pstrUsageACPaste, - pstrUsageACSelectAll, - pstrUsageACFind, - pstrUsageACFindAndReplace, - pstrUsageACSearch, - pstrUsageACGoto, - pstrUsageACHome, - pstrUsageACBack, - pstrUsageACForward, - pstrUsageACStop, - pstrUsageACRefresh, - pstrUsageACPreviousLink, - pstrUsageACNextLink, - pstrUsageACBookmarks, - pstrUsageACHistory, - pstrUsageACSubscriptions, - pstrUsageACZoomIn, - pstrUsageACZoomOut, - pstrUsageACZoom, - pstrUsageACFullScreenView, - pstrUsageACNormalView, - pstrUsageACViewToggle, - pstrUsageACScrollUp, - pstrUsageACScrollDown, - pstrUsageACScroll, - pstrUsageACPanLeft, - pstrUsageACPanRight, - pstrUsageACPan, - pstrUsageACNewWindow, - pstrUsageACTileHoriz, - pstrUsageACTileVert, - pstrUsageACFormat, - pstrUsageACEdit, - pstrUsageACBold, - pstrUsageACItalics, - pstrUsageACUnderline, - pstrUsageACStrikethrough, - pstrUsageACSubscript, - pstrUsageACSuperscript, - pstrUsageACAllCaps, - pstrUsageACRotate, - pstrUsageACResize, - pstrUsageACFlipHorizontal, - pstrUsageACFlipVertical, - pstrUsageACMirrorHorizontal, - pstrUsageACMirrorVertical, - pstrUsageACFontSelect, - pstrUsageACFontColor, - pstrUsageACFontSize, - pstrUsageACJustifyLeft, - pstrUsageACJustifyCenterH, - pstrUsageACJustifyRight, - pstrUsageACJustifyBlockH, - pstrUsageACJustifyTop, - pstrUsageACJustifyCenterV, - pstrUsageACJustifyBottom, - pstrUsageACJustifyBlockV, - pstrUsageACIndentDecrease, - pstrUsageACIndentIncrease, - pstrUsageACNumberedList, - pstrUsageACRestartNumbering, - pstrUsageACBulletedList, - pstrUsageACPromote, - pstrUsageACDemote, - pstrUsageACYes, - pstrUsageACNo, - pstrUsageACCancel, - pstrUsageACCatalog, - pstrUsageACBuyChkout, - pstrUsageACAddToCart, - pstrUsageACExpand, - pstrUsageACExpandAll, - pstrUsageACCollapse, - pstrUsageACCollapseAll, - pstrUsageACPrintPreview, - pstrUsageACPasteSpecial, - pstrUsageACInsertMode, - pstrUsageACDelete, - pstrUsageACLock, - pstrUsageACUnlock, - pstrUsageACProtect, - pstrUsageACUnprotect, - pstrUsageACAttachComment, - pstrUsageACDeleteComment, - pstrUsageACViewComment, - pstrUsageACSelectWord, - pstrUsageACSelectSentence, - pstrUsageACSelectParagraph, - pstrUsageACSelectColumn, - pstrUsageACSelectRow, - pstrUsageACSelectTable, - pstrUsageACSelectObject, - pstrUsageACRedoRepeat, - pstrUsageACSort, - pstrUsageACSortAscending, - pstrUsageACSortDescending, - pstrUsageACFilter, - pstrUsageACSetClock, - pstrUsageACViewClock, - pstrUsageACSelectTimeZone, - pstrUsageACEditTimeZone, - pstrUsageACSetAlarm, - pstrUsageACClearAlarm, - pstrUsageACSnoozeAlarm, - pstrUsageACResetAlarm, - pstrUsageACSyncronize, - pstrUsageACSendReceive, - pstrUsageACSendTo, - pstrUsageACReply, - pstrUsageACReplyAll, - pstrUsageACForwardMessage, - pstrUsageACSend, - pstrUsageACAttachFile, - pstrUsageACUpload, - pstrUsageACDownload, - pstrUsageACSetBorders, - pstrUsageACInsertRow, - pstrUsageACInsertColumn, - pstrUsageACInsertFile, - pstrUsageACInsertPicture, - pstrUsageACInsertObject, - pstrUsageACInsertSymbol, - pstrUsageACSaveAndClose, - pstrUsageACRename, - pstrUsageACMerge, - pstrUsageACSplit, - pstrUsageACDistributeHorizontaly, - pstrUsageACDistributeVerticaly -}; -const char * const ReportDescParserBase::digitTitles0[] PROGMEM = { - pstrUsageDigitizer, - pstrUsagePen, - pstrUsageLightPen, - pstrUsageTouchScreen, - pstrUsageTouchPad, - pstrUsageWhiteBoard, - pstrUsageCoordinateMeasuringMachine, - pstrUsage3DDigitizer, - pstrUsageStereoPlotter, - pstrUsageArticulatedArm, - pstrUsageArmature, - pstrUsageMultiplePointDigitizer, - pstrUsageFreeSpaceWand -}; -const char * const ReportDescParserBase::digitTitles1[] PROGMEM = { - pstrUsageStylus, - pstrUsagePuck, - pstrUsageFinger - -}; -const char * const ReportDescParserBase::digitTitles2[] PROGMEM = { - pstrUsageTipPressure, - pstrUsageBarrelPressure, - pstrUsageInRange, - pstrUsageTouch, - pstrUsageUntouch, - pstrUsageTap, - pstrUsageQuality, - pstrUsageDataValid, - pstrUsageTransducerIndex, - pstrUsageTabletFunctionKeys, - pstrUsageProgramChangeKeys, - pstrUsageBatteryStrength, - pstrUsageInvert, - pstrUsageXTilt, - pstrUsageYTilt, - pstrUsageAzimuth, - pstrUsageAltitude, - pstrUsageTwist, - pstrUsageTipSwitch, - pstrUsageSecondaryTipSwitch, - pstrUsageBarrelSwitch, - pstrUsageEraser, - pstrUsageTabletPick -}; -const char * const ReportDescParserBase::aplphanumTitles0[] PROGMEM = { - pstrUsageAlphanumericDisplay, - pstrUsageBitmappedDisplay -}; -const char * const ReportDescParserBase::aplphanumTitles1[] PROGMEM = { - pstrUsageDisplayAttributesReport, - pstrUsageASCIICharacterSet, - pstrUsageDataReadBack, - pstrUsageFontReadBack, - pstrUsageDisplayControlReport, - pstrUsageClearDisplay, - pstrUsageDisplayEnable, - pstrUsageScreenSaverDelay, - pstrUsageScreenSaverEnable, - pstrUsageVerticalScroll, - pstrUsageHorizontalScroll, - pstrUsageCharacterReport, - pstrUsageDisplayData, - pstrUsageDisplayStatus, - pstrUsageStatusNotReady, - pstrUsageStatusReady, - pstrUsageErrorNotALoadableCharacter, - pstrUsageErrorFotDataCanNotBeRead, - pstrUsageCursorPositionReport, - pstrUsageRow, - pstrUsageColumn, - pstrUsageRows, - pstrUsageColumns, - pstrUsageCursorPixelPosition, - pstrUsageCursorMode, - pstrUsageCursorEnable, - pstrUsageCursorBlink, - pstrUsageFontReport, - pstrUsageFontData, - pstrUsageCharacterWidth, - pstrUsageCharacterHeight, - pstrUsageCharacterSpacingHorizontal, - pstrUsageCharacterSpacingVertical, - pstrUsageUnicodeCharset, - pstrUsageFont7Segment, - pstrUsage7SegmentDirectMap, - pstrUsageFont14Segment, - pstrUsage14SegmentDirectMap, - pstrUsageDisplayBrightness, - pstrUsageDisplayContrast, - pstrUsageCharacterAttribute, - pstrUsageAttributeReadback, - pstrUsageAttributeData, - pstrUsageCharAttributeEnhance, - pstrUsageCharAttributeUnderline, - pstrUsageCharAttributeBlink -}; -const char * const ReportDescParserBase::aplphanumTitles2[] PROGMEM = { - pstrUsageBitmapSizeX, - pstrUsageBitmapSizeY, - pstrUsagePageReserved, - pstrUsageBitDepthFormat, - pstrUsageDisplayOrientation, - pstrUsagePaletteReport, - pstrUsagePaletteDataSize, - pstrUsagePaletteDataOffset, - pstrUsagePaletteData, - pstrUsageBlitReport, - pstrUsageBlitRectangleX1, - pstrUsageBlitRectangleY1, - pstrUsageBlitRectangleX2, - pstrUsageBlitRectangleY2, - pstrUsageBlitData, - pstrUsageSoftButton, - pstrUsageSoftButtonID, - pstrUsageSoftButtonSide, - pstrUsageSoftButtonOffset1, - pstrUsageSoftButtonOffset2, - pstrUsageSoftButtonReport -}; -const char * const ReportDescParserBase::medInstrTitles0[] PROGMEM = { - pstrUsageVCRAcquisition, - pstrUsageFreezeThaw, - pstrUsageClipStore, - pstrUsageUpdate, - pstrUsageNext, - pstrUsageSave, - pstrUsagePrint, - pstrUsageMicrophoneEnable -}; -const char * const ReportDescParserBase::medInstrTitles1[] PROGMEM = { - pstrUsageCine, - pstrUsageTransmitPower, - pstrUsageVolume, - pstrUsageFocus, - pstrUsageDepth -}; -const char * const ReportDescParserBase::medInstrTitles2[] PROGMEM = { - pstrUsageSoftStepPrimary, - pstrUsageSoftStepSecondary -}; -const char * const ReportDescParserBase::medInstrTitles3[] PROGMEM = { - pstrUsageZoomSelect, - pstrUsageZoomAdjust, - pstrUsageSpectralDopplerModeSelect, - pstrUsageSpectralDopplerModeAdjust, - pstrUsageColorDopplerModeSelect, - pstrUsageColorDopplerModeAdjust, - pstrUsageMotionModeSelect, - pstrUsageMotionModeAdjust, - pstrUsage2DModeSelect, - pstrUsage2DModeAdjust -}; -const char * const ReportDescParserBase::medInstrTitles4[] PROGMEM = { - pstrUsageSoftControlSelect, - pstrUsageSoftControlAdjust -}; - -void ReportDescParserBase::Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset) { - uint32_t cntdn = (uint32_t)len; - uint8_t *p = (uint8_t*)pbuf; - - - totalSize = 0; - - while(cntdn) { - //USB_HOST_SERIAL.println(""); - //PrintHex(offset + len - cntdn); - //USB_HOST_SERIAL.print(":"); - - ParseItem(&p, &cntdn); - - //if (ParseItem(&p, &cntdn)) - // return; - } - //USBTRACE2("Total:", totalSize); -} - -void ReportDescParserBase::PrintValue(uint8_t *p, uint8_t len) { - E_Notify(PSTR("("), 0x80); - for(; len; p++, len--) - PrintHex (*p, 0x80); - E_Notify(PSTR(")"), 0x80); -} - -void ReportDescParserBase::PrintByteValue(uint8_t data) { - E_Notify(PSTR("("), 0x80); - PrintHex (data, 0x80); - E_Notify(PSTR(")"), 0x80); -} - -void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { - switch(prefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): - E_Notify(PSTR("\r\nPush"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_POP): - E_Notify(PSTR("\r\nPop"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - E_Notify(PSTR("\r\nUsage Page"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): - E_Notify(PSTR("\r\nLogical Min"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): - E_Notify(PSTR("\r\nLogical Max"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): - E_Notify(PSTR("\r\nPhysical Min"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): - E_Notify(PSTR("\r\nPhysical Max"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): - E_Notify(PSTR("\r\nUnit Exp"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): - E_Notify(PSTR("\r\nUnit"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - E_Notify(PSTR("\r\nReport Size"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - E_Notify(PSTR("\r\nReport Count"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - E_Notify(PSTR("\r\nReport Id"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - E_Notify(PSTR("\r\nUsage"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - E_Notify(PSTR("\r\nUsage Min"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - E_Notify(PSTR("\r\nUsage Max"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_COLLECTION): - E_Notify(PSTR("\r\nCollection"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): - E_Notify(PSTR("\r\nEnd Collection"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - E_Notify(PSTR("\r\nInput"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - E_Notify(PSTR("\r\nOutput"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_FEATURE): - E_Notify(PSTR("\r\nFeature"), 0x80); - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) -} - -uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - //reinterpret_cast<>(varBuffer); - switch(itemParseState) { - case 0: - if(**pp == HID_LONG_ITEM_PREFIX) - USBTRACE("\r\nLONG\r\n"); - else { - uint8_t size = ((**pp) & DATA_SIZE_MASK); - - itemPrefix = (**pp); - itemSize = 1 + ((size == DATA_SIZE_4) ? 4 : size); - - PrintItemTitle(itemPrefix); - } - (*pp)++; - (*pcntdn)--; - itemSize--; - itemParseState = 1; - - if(!itemSize) - break; - - if(!pcntdn) - return enErrorIncomplete; - case 1: - //USBTRACE2("\r\niSz:",itemSize); - - theBuffer.valueSize = itemSize; - valParser.Initialize(&theBuffer); - itemParseState = 2; - case 2: - if(!valParser.Parse(pp, pcntdn)) - return enErrorIncomplete; - itemParseState = 3; - case 3: - { - uint8_t data = *((uint8_t*)varBuffer); - - switch(itemPrefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - if(pfUsage) { - if(theBuffer.valueSize > 1) { - uint16_t* ui16 = reinterpret_cast(varBuffer); - pfUsage(*ui16); - } else - pfUsage(data); - } - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - rptSize = data; - PrintByteValue(data); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - rptCount = data; - PrintByteValue(data); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): - case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): - PrintValue(varBuffer, theBuffer.valueSize); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): - case (TYPE_GLOBAL | TAG_GLOBAL_POP): - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - SetUsagePage(data); - PrintUsagePage(data); - PrintByteValue(data); - break; - case (TYPE_MAIN | TAG_MAIN_COLLECTION): - case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): - switch(data) { - case 0x00: - E_Notify(PSTR(" Physical"), 0x80); - break; - case 0x01: - E_Notify(PSTR(" Application"), 0x80); - break; - case 0x02: - E_Notify(PSTR(" Logical"), 0x80); - break; - case 0x03: - E_Notify(PSTR(" Report"), 0x80); - break; - case 0x04: - E_Notify(PSTR(" Named Array"), 0x80); - break; - case 0x05: - E_Notify(PSTR(" Usage Switch"), 0x80); - break; - case 0x06: - E_Notify(PSTR(" Usage Modifier"), 0x80); - break; - default: - E_Notify(PSTR(" Vendor Defined("), 0x80); - PrintHex (data, 0x80); - E_Notify(PSTR(")"), 0x80); - } - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - case (TYPE_MAIN | TAG_MAIN_FEATURE): - totalSize += (uint16_t)rptSize * (uint16_t)rptCount; - rptSize = 0; - rptCount = 0; - E_Notify(PSTR("("), 0x80); - PrintBin (data, 0x80); - E_Notify(PSTR(")"), 0x80); - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) - } - } // switch (itemParseState) - itemParseState = 0; - return enErrorSuccess; -} - -ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = { - &ReportDescParserBase::PrintGenericDesktopPageUsage, - &ReportDescParserBase::PrintSimulationControlsPageUsage, - &ReportDescParserBase::PrintVRControlsPageUsage, - &ReportDescParserBase::PrintSportsControlsPageUsage, - &ReportDescParserBase::PrintGameControlsPageUsage, - &ReportDescParserBase::PrintGenericDeviceControlsPageUsage, - NULL, // Keyboard/Keypad - &ReportDescParserBase::PrintLEDPageUsage, - &ReportDescParserBase::PrintButtonPageUsage, - &ReportDescParserBase::PrintOrdinalPageUsage, - &ReportDescParserBase::PrintTelephonyPageUsage, - &ReportDescParserBase::PrintConsumerPageUsage, - &ReportDescParserBase::PrintDigitizerPageUsage, - NULL, // Reserved - NULL, // PID - NULL // Unicode -}; - -void ReportDescParserBase::SetUsagePage(uint16_t page) { - pfUsage = NULL; - - if(VALUE_BETWEEN(page, 0x00, 0x11)) - pfUsage = (usagePageFunctions[page - 1]); - - // Dead code... - // - // pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]); - //else if (page > 0x7f && page < 0x84) - // E_Notify(pstrUsagePageMonitor); - //else if (page > 0x83 && page < 0x8c) - // E_Notify(pstrUsagePagePower); - //else if (page > 0x8b && page < 0x92) - // E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c])); - //else if (page > 0xfeff && page <= 0xffff) - // E_Notify(pstrUsagePageVendorDefined); - // - else - switch(page) { - case 0x14: - pfUsage = &ReportDescParserBase::PrintAlphanumDisplayPageUsage; - break; - case 0x40: - pfUsage = &ReportDescParserBase::PrintMedicalInstrumentPageUsage; - break; - } -} - -void ReportDescParserBase::PrintUsagePage(uint16_t page) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(page, 0x00, 0x11, w, E_Notify, usagePageTitles0, 0x80) - else output_if_between(page, 0x8b, 0x92, w, E_Notify, usagePageTitles1, 0x80) - else if(VALUE_BETWEEN(page, 0x7f, 0x84)) - E_Notify(pstrUsagePageMonitor, 0x80); - else if(VALUE_BETWEEN(page, 0x83, 0x8c)) - E_Notify(pstrUsagePagePower, 0x80); - else if(page > 0xfeff /* && page <= 0xffff */) - E_Notify(pstrUsagePageVendorDefined, 0x80); - else - switch(page) { - case 0x14: - E_Notify(pstrUsagePageAlphaNumericDisplay, 0x80); - break; - case 0x40: - E_Notify(pstrUsagePageMedicalInstruments, 0x80); - break; - default: - E_Notify(pstrUsagePageUndefined, 0x80); - } -} - -void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) { - E_Notify(pstrSpace, 0x80); - E_Notify(PSTR("Btn"), 0x80); - PrintHex (usage, 0x80); - E_Notify(PSTR("\r\n"), 0x80); - //USB_HOST_SERIAL.print(usage, HEX); -} - -void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) { - E_Notify(pstrSpace, 0x80); - E_Notify(PSTR("Inst"), 0x80); - // Sorry, HEX for now... - PrintHex (usage, 0x80); - E_Notify(PSTR("\r\n"), 0x80); - //USB_HOST_SERIAL.print(usage, DEC); -} - -void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0a, w, E_Notify, genDesktopTitles0, 0x80) - else output_if_between(usage, 0x2f, 0x49, w, E_Notify, genDesktopTitles1, 0x80) - else output_if_between(usage, 0x7f, 0x94, w, E_Notify, genDesktopTitles2, 0x80) - else output_if_between(usage, 0x9f, 0xa9, w, E_Notify, genDesktopTitles3, 0x80) - else output_if_between(usage, 0xaf, 0xb8, w, E_Notify, genDesktopTitles4, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintSimulationControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0d, w, E_Notify, simuTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x26, w, E_Notify, simuTitles1, 0x80) - else output_if_between(usage, 0xaf, 0xd1, w, E_Notify, simuTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintVRControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0b, w, E_Notify, vrTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x22, w, E_Notify, vrTitles1, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintSportsControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x05, w, E_Notify, sportsCtrlTitles0, 0x80) - else output_if_between(usage, 0x2f, 0x3a, w, E_Notify, sportsCtrlTitles1, 0x80) - else output_if_between(usage, 0x4f, 0x64, w, E_Notify, sportsCtrlTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintGameControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x04, w, E_Notify, gameTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x3a, w, E_Notify, gameTitles1, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintGenericDeviceControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x1f, 0x27, w, E_Notify, genDevCtrlTitles, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintLEDPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x4e, w, E_Notify, ledTitles, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintTelephonyPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x08, w, E_Notify, telTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x32, w, E_Notify, telTitles1, 0x80) - else output_if_between(usage, 0x4f, 0x54, w, E_Notify, telTitles2, 0x80) - else output_if_between(usage, 0x6f, 0x75, w, E_Notify, telTitles3, 0x80) - else output_if_between(usage, 0x8f, 0x9f, w, E_Notify, telTitles4, 0x80) - else output_if_between(usage, 0xaf, 0xc0, w, E_Notify, telTitles5, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintConsumerPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x07, w, E_Notify, consTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x23, w, E_Notify, consTitles1, 0x80) - else output_if_between(usage, 0x2f, 0x37, w, E_Notify, consTitles2, 0x80) - else output_if_between(usage, 0x3f, 0x49, w, E_Notify, consTitles3, 0x80) - else output_if_between(usage, 0x5f, 0x67, w, E_Notify, consTitles4, 0x80) - else output_if_between(usage, 0x7f, 0xa5, w, E_Notify, consTitles5, 0x80) - else output_if_between(usage, 0xaf, 0xcf, w, E_Notify, consTitles6, 0x80) - else output_if_between(usage, 0xdf, 0xeb, w, E_Notify, consTitles7, 0x80) - else output_if_between(usage, 0xef, 0xf6, w, E_Notify, consTitles8, 0x80) - else output_if_between(usage, 0xff, 0x10e, w, E_Notify, consTitles9, 0x80) - else output_if_between(usage, 0x14f, 0x156, w, E_Notify, consTitlesA, 0x80) - else output_if_between(usage, 0x15f, 0x16b, w, E_Notify, consTitlesB, 0x80) - else output_if_between(usage, 0x16f, 0x175, w, E_Notify, consTitlesC, 0x80) - else output_if_between(usage, 0x17f, 0x1c8, w, E_Notify, consTitlesD, 0x80) - else output_if_between(usage, 0x1ff, 0x29d, w, E_Notify, consTitlesE, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintDigitizerPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0e, w, E_Notify, digitTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x23, w, E_Notify, digitTitles1, 0x80) - else output_if_between(usage, 0x2f, 0x47, w, E_Notify, digitTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintAlphanumDisplayPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x03, w, E_Notify, aplphanumTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x4e, w, E_Notify, aplphanumTitles1, 0x80) - else output_if_between(usage, 0x7f, 0x96, w, E_Notify, digitTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - if(usage == 1) E_Notify(pstrUsageMedicalUltrasound, 0x80); - else if(usage == 0x70) - E_Notify(pstrUsageDepthGainCompensation, 0x80); - else output_if_between(usage, 0x1f, 0x28, w, E_Notify, medInstrTitles0, 0x80) - else output_if_between(usage, 0x3f, 0x45, w, E_Notify, medInstrTitles1, 0x80) - else output_if_between(usage, 0x5f, 0x62, w, E_Notify, medInstrTitles2, 0x80) - else output_if_between(usage, 0x7f, 0x8a, w, E_Notify, medInstrTitles3, 0x80) - else output_if_between(usage, 0x9f, 0xa2, w, E_Notify, medInstrTitles4, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - - switch(itemParseState) { - case 0: - if(**pp == HID_LONG_ITEM_PREFIX) - USBTRACE("\r\nLONG\r\n"); - else { - uint8_t size = ((**pp) & DATA_SIZE_MASK); - itemPrefix = (**pp); - itemSize = 1 + ((size == DATA_SIZE_4) ? 4 : size); - } - (*pp)++; - (*pcntdn)--; - itemSize--; - itemParseState = 1; - - if(!itemSize) - break; - - if(!pcntdn) - return enErrorIncomplete; - case 1: - theBuffer.valueSize = itemSize; - valParser.Initialize(&theBuffer); - itemParseState = 2; - case 2: - if(!valParser.Parse(pp, pcntdn)) - return enErrorIncomplete; - itemParseState = 3; - case 3: - { - uint8_t data = *((uint8_t*)varBuffer); - - switch(itemPrefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - if(pfUsage) { - if(theBuffer.valueSize > 1) { - uint16_t* ui16 = reinterpret_cast(varBuffer); - pfUsage(*ui16); - } else - pfUsage(data); - } - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - rptSize = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - rptCount = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - rptId = data; - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - useMin = data; - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - useMax = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - SetUsagePage(data); - break; - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - case (TYPE_MAIN | TAG_MAIN_FEATURE): - rptSize = 0; - rptCount = 0; - useMin = 0; - useMax = 0; - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - OnInputItem(data); - - totalSize += (uint16_t)rptSize * (uint16_t)rptCount; - - rptSize = 0; - rptCount = 0; - useMin = 0; - useMax = 0; - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) - } - } // switch (itemParseState) - itemParseState = 0; - return enErrorSuccess; -} - -void ReportDescParser2::OnInputItem(uint8_t itm) { - uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8); - uint32_t tmp = (byte_offset << 3); - uint8_t bit_offset = totalSize - tmp; // number of bits in the current byte already handled - uint8_t *p = pBuf + byte_offset; // current byte pointer - - if(bit_offset) - *p >>= bit_offset; - - uint8_t usage = useMin; - - bool print_usemin_usemax = ((useMin < useMax) && ((itm & 3) == 2) && pfUsage) ? true : false; - - uint8_t bits_of_byte = 8; - - // for each field in field array defined by rptCount - for(uint8_t field = 0; field < rptCount; field++, usage++) { - - union { - uint8_t bResult[4]; - uint16_t wResult[2]; - uint32_t dwResult; - } result; - - result.dwResult = 0; - uint8_t mask = 0; - - if(print_usemin_usemax) - pfUsage(usage); - - // bits_left - number of bits in the field(array of fields, depending on Report Count) left to process - // bits_of_byte - number of bits in current byte left to process - // bits_to_copy - number of bits to copy to result buffer - - // for each bit in a field - for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; - bits_left -= bits_to_copy) { - bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left; - - result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it - - uint8_t val = *p; - - val >>= (8 - bits_of_byte); // Shift by the number of bits already processed - - mask = 0; - - for(uint8_t j = bits_to_copy; j; j--) { - mask <<= 1; - mask |= 1; - } - - result.bResult[0] = (result.bResult[0] | (val & mask)); - - bits_of_byte -= bits_to_copy; - - if(bits_of_byte < 1) { - bits_of_byte = 8; - p++; - } - } - PrintByteValue(result.dwResult); - } - E_Notify(PSTR("\r\n"), 0x80); -} - -void UniversalReportParser::Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf) { - ReportDescParser2 prs(len, buf); - - uint8_t ret = hid->GetReportDescr(0, &prs); - - if(ret) - ErrorMessage (PSTR("GetReportDescr-2"), ret); -} diff --git a/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.h b/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.h deleted file mode 100644 index 65803df5d40..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hidescriptorparser.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__HIDDESCRIPTORPARSER_H__) -#define __HIDDESCRIPTORPARSER_H__ - -#include "hid.h" - -class ReportDescParserBase : public USBReadParser { -public: - typedef void (*UsagePageFunc)(uint16_t usage); - - static void PrintGenericDesktopPageUsage(uint16_t usage); - static void PrintSimulationControlsPageUsage(uint16_t usage); - static void PrintVRControlsPageUsage(uint16_t usage); - static void PrintSportsControlsPageUsage(uint16_t usage); - static void PrintGameControlsPageUsage(uint16_t usage); - static void PrintGenericDeviceControlsPageUsage(uint16_t usage); - static void PrintLEDPageUsage(uint16_t usage); - static void PrintButtonPageUsage(uint16_t usage); - static void PrintOrdinalPageUsage(uint16_t usage); - static void PrintTelephonyPageUsage(uint16_t usage); - static void PrintConsumerPageUsage(uint16_t usage); - static void PrintDigitizerPageUsage(uint16_t usage); - static void PrintAlphanumDisplayPageUsage(uint16_t usage); - static void PrintMedicalInstrumentPageUsage(uint16_t usage); - - static void PrintValue(uint8_t *p, uint8_t len); - static void PrintByteValue(uint8_t data); - - static void PrintItemTitle(uint8_t prefix); - - static const char * const usagePageTitles0[]; - static const char * const usagePageTitles1[]; - static const char * const genDesktopTitles0[]; - static const char * const genDesktopTitles1[]; - static const char * const genDesktopTitles2[]; - static const char * const genDesktopTitles3[]; - static const char * const genDesktopTitles4[]; - static const char * const simuTitles0[]; - static const char * const simuTitles1[]; - static const char * const simuTitles2[]; - static const char * const vrTitles0[]; - static const char * const vrTitles1[]; - static const char * const sportsCtrlTitles0[]; - static const char * const sportsCtrlTitles1[]; - static const char * const sportsCtrlTitles2[]; - static const char * const gameTitles0[]; - static const char * const gameTitles1[]; - static const char * const genDevCtrlTitles[]; - static const char * const ledTitles[]; - static const char * const telTitles0[]; - static const char * const telTitles1[]; - static const char * const telTitles2[]; - static const char * const telTitles3[]; - static const char * const telTitles4[]; - static const char * const telTitles5[]; - static const char * const consTitles0[]; - static const char * const consTitles1[]; - static const char * const consTitles2[]; - static const char * const consTitles3[]; - static const char * const consTitles4[]; - static const char * const consTitles5[]; - static const char * const consTitles6[]; - static const char * const consTitles7[]; - static const char * const consTitles8[]; - static const char * const consTitles9[]; - static const char * const consTitlesA[]; - static const char * const consTitlesB[]; - static const char * const consTitlesC[]; - static const char * const consTitlesD[]; - static const char * const consTitlesE[]; - static const char * const digitTitles0[]; - static const char * const digitTitles1[]; - static const char * const digitTitles2[]; - static const char * const aplphanumTitles0[]; - static const char * const aplphanumTitles1[]; - static const char * const aplphanumTitles2[]; - static const char * const medInstrTitles0[]; - static const char * const medInstrTitles1[]; - static const char * const medInstrTitles2[]; - static const char * const medInstrTitles3[]; - static const char * const medInstrTitles4[]; - -protected: - static UsagePageFunc usagePageFunctions[]; - - MultiValueBuffer theBuffer; - MultiByteValueParser valParser; - ByteSkipper theSkipper; - uint8_t varBuffer[sizeof (USB_CONFIGURATION_DESCRIPTOR)]; - - uint8_t itemParseState; // Item parser state variable - uint8_t itemSize; // Item size - uint8_t itemPrefix; // Item prefix (first byte) - uint8_t rptSize; // Report Size - uint8_t rptCount; // Report Count - - uint16_t totalSize; // Report size in bits - - virtual uint8_t ParseItem(uint8_t **pp, uint32_t *pcntdn); - - UsagePageFunc pfUsage; - - static void PrintUsagePage(uint16_t page); - void SetUsagePage(uint16_t page); - -public: - - ReportDescParserBase() : - itemParseState(0), - itemSize(0), - itemPrefix(0), - rptSize(0), - rptCount(0), - pfUsage(NULL) { - theBuffer.pValue = varBuffer; - valParser.Initialize(&theBuffer); - theSkipper.Initialize(&theBuffer); - }; - - virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset); - - enum { - enErrorSuccess = 0 - , enErrorIncomplete // value or record is partialy read in buffer - , enErrorBufferTooSmall - }; -}; - -class ReportDescParser : public ReportDescParserBase { -}; - -class ReportDescParser2 : public ReportDescParserBase { - uint8_t rptId; // Report ID - uint8_t useMin; // Usage Minimum - uint8_t useMax; // Usage Maximum - uint8_t fieldCount; // Number of field being currently processed - - void OnInputItem(uint8_t itm); // Method which is called every time Input item is found - - uint8_t *pBuf; // Report buffer pointer - uint8_t bLen; // Report length - -protected: - virtual uint8_t ParseItem(uint8_t **pp, uint32_t *pcntdn); - -public: - - ReportDescParser2(uint16_t len, uint8_t *pbuf) : - ReportDescParserBase(), rptId(0), useMin(0), useMax(0), fieldCount(0), pBuf(pbuf), bLen(len) { - }; -}; - -class UniversalReportParser : public HIDReportParser { -public: - virtual void Parse(HID *hid, uint32_t is_rpt_id, uint32_t len, uint8_t *buf); -}; - -#endif // __HIDDESCRIPTORPARSER_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/hiduniversal.cpp b/legacy/builder/test/libraries/USBHost/src/hiduniversal.cpp deleted file mode 100644 index ac5309b8d41..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hiduniversal.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "Arduino.h" -#include "hiduniversal.h" - -HIDUniversal::HIDUniversal(USBHost *p) : -HID(p), -qNextPollTime(0), -pollInterval(0), -bPollEnable(false), -bHasReportId(false) { - Initialize(); - - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint16_t HIDUniversal::GetHidClassDescrLen(uint8_t type, uint8_t num) { - for(uint8_t i = 0, n = 0; i < HID_MAX_HID_CLASS_DESCRIPTORS; i++) { - if(descrInfo[i].bDescrType == type) { - if(n == num) - return descrInfo[i].wDescriptorLength; - n++; - } - } - return 0; -} - -void HIDUniversal::Initialize() { - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - rptParsers[i].rptId = 0; - rptParsers[i].rptParser = NULL; - } - for(uint8_t i = 0; i < HID_MAX_HID_CLASS_DESCRIPTORS; i++) { - descrInfo[i].bDescrType = 0; - descrInfo[i].wDescriptorLength = 0; - } - for(uint8_t i = 0; i < maxHidInterfaces; i++) { - hidInterfaces[i].bmInterface = 0; - hidInterfaces[i].bmProtocol = 0; - - for(uint8_t j = 0; j < maxEpPerInterface; j++) - hidInterfaces[i].epIndex[j] = 0; - } - for(uint8_t i = 0; i < totalEndpoints; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - bNumEP = 1; - bNumIface = 0; - bConfNum = 0; - pollInterval = 0; - - ZeroMemory(constBuffLen, prevBuf); -} - -uint32_t HIDUniversal::SetReportParser(uint32_t id, HIDReportParser *prs) { - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - if(rptParsers[i].rptId == 0 && rptParsers[i].rptParser == NULL) { - rptParsers[i].rptId = id; - rptParsers[i].rptParser = prs; - return true; - } - } - return false; -} - -HIDReportParser* HIDUniversal::GetReportParser(uint32_t id) { - if(!bHasReportId) - return ((rptParsers[0].rptParser) ? rptParsers[0].rptParser : NULL); - - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - if(rptParsers[i].rptId == id) - return rptParsers[i].rptParser; - } - return NULL; -} - -uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDeviceDefinition *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t len = 0; - - uint8_t num_of_conf; // number of configurations - //uint8_t num_of_intf; // number of interfaces - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("HU Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf); - - if(!rcode) - len = (buf[0] > constBufSize) ? constBufSize : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - - goto FailGetDevDescr; - } - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - //delay(2); //per USB 2.0 sect.9.2.6.3 - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; // Can be used by classes that inherits this class to check the VID and PID of the connected device - PID = udd->idProduct; - - num_of_conf = udd->bNumConfigurations; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - //HexDumper HexDump; - ConfigDescParser confDescrParser(this); - - //rcode = pUsb->getConfDescr(bAddress, 0, i, &HexDump); - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 2) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Cnf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - for(uint8_t i = 0; i < bNumIface; i++) { - if(hidInterfaces[i].epIndex[epInterruptInIndex] == 0) - continue; - - rcode = SetIdle(hidInterfaces[i].bmInterface, 0, 0); - - if(rcode)/* && rcode != hrSTALL) */ - goto FailSetIdle; - } - - USBTRACE("HU configured\r\n"); - - OnInitSuccessful(); - - bPollEnable = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - - -FailSetIdle: -#ifdef DEBUG_USB_HOST - USBTRACE("SetIdle:"); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto) { - for(uint8_t i = 0; i < bNumIface && i < maxHidInterfaces; i++) - if(hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt - && hidInterfaces[i].bmProtocol == proto) - return hidInterfaces + i; - return NULL; -} - -void HIDUniversal::EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - // If the first configuration satisfies, the others are not concidered. - if(bNumEP > 1 && conf != bConfNum) - return; - - //ErrorMessage(PSTR("\r\nConf.Val"), conf); - //ErrorMessage(PSTR("Iface Num"), iface); - //ErrorMessage(PSTR("Alt.Set"), alt); - - bConfNum = conf; - - uint8_t index = 0; - HIDInterface *piface = FindInterface(iface, alt, proto); - - // Fill in interface structure in case of new interface - if(!piface) { - piface = hidInterfaces + bNumIface; - piface->bmInterface = iface; - piface->bmAltSet = alt; - piface->bmProtocol = proto; - bNumIface++; - } - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - index = epInterruptOutIndex; - - if(index) { - // Fill in the endpoint info structure - epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[bNumEP].epAttribs = 0; - epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; - - // Fill in the endpoint index list - piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F); - - if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints - pollInterval = pep->bInterval; - - bNumEP++; - } - //PrintEndpointDescriptor(pep); -} - -uint32_t HIDUniversal::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bNumEP = 1; - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - return 0; -} - -bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2) { - for(uint8_t i = 0; i < len; i++) - if(buf1[i] != buf2[i]) - return false; - return true; -} - -void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf) { - for(uint8_t i = 0; i < len; i++) - buf[i] = 0; -} - -void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest) { - for(uint8_t i = 0; i < len; i++) - dest[i] = src[i]; -} - -uint32_t HIDUniversal::Poll() { - uint32_t rcode = 0; - - if(!bPollEnable) - return 0; - - if((long)(millis() - qNextPollTime) >= 0L) { - qNextPollTime = millis() + pollInterval; - - uint8_t buf[constBuffLen]; - - for(uint8_t i = 0; i < bNumIface; i++) { - uint8_t index = hidInterfaces[i].epIndex[epInterruptInIndex]; - uint16_t read = (uint8_t)epInfo[index].maxPktSize; - - ZeroMemory(constBuffLen, buf); - - uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, (uint8_t*)&read, buf); - - if(rcode) { - if(rcode != USB_ERRORFLOW/*hrNAK*/) - USBTRACE3("(hiduniversal.h) Poll:", rcode, 0x81); - return rcode; - } - - if(read > constBuffLen) - read = constBuffLen; - - bool identical = BuffersIdentical(read, buf, prevBuf); - - SaveBuffer(read, buf, prevBuf); - - if(identical) - return 0; -#if 0 - Notify(PSTR("\r\nBuf: "), 0x80); - - for(uint8_t i = 0; i < read; i++) { - D_PrintHex (buf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - - Notify(PSTR("\r\n"), 0x80); -#endif - ParseHIDData(this, bHasReportId, (uint8_t)read, buf); - - HIDReportParser *prs = GetReportParser(((bHasReportId) ? *buf : 0)); - - if(prs) - prs->Parse(this, bHasReportId, (uint8_t)read, buf); - } - } - return rcode; -} diff --git a/legacy/builder/test/libraries/USBHost/src/hiduniversal.h b/legacy/builder/test/libraries/USBHost/src/hiduniversal.h deleted file mode 100644 index 9c033f0ab91..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hiduniversal.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(__HIDUNIVERSAL_H__) -#define __HIDUNIVERSAL_H__ - -#include "hid.h" -//#include "hidescriptorparser.h" - -class HIDUniversal : public HID { - - struct ReportParser { - uint8_t rptId; - HIDReportParser *rptParser; - } rptParsers[MAX_REPORT_PARSERS]; - - // HID class specific descriptor type and length info obtained from HID descriptor - HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]; - - // Returns HID class specific descriptor length by its type and order number - uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num); - - struct HIDInterface { - struct { - uint8_t bmInterface : 3; - uint8_t bmAltSet : 3; - uint8_t bmProtocol : 2; - }; - uint8_t epIndex[maxEpPerInterface]; - }; - - uint8_t bConfNum; // configuration number - uint8_t bNumIface; // number of interfaces in the configuration - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - uint8_t pollInterval; - bool bPollEnable; // poll enable flag - - static const uint16_t constBuffLen = 64; // event buffer length - uint8_t prevBuf[constBuffLen]; // previous event buffer - - void Initialize(); - HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); - - void ZeroMemory(uint8_t len, uint8_t *buf); - bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2); - void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest); - -protected: - EpInfo epInfo[totalEndpoints]; - HIDInterface hidInterfaces[maxHidInterfaces]; - - bool bHasReportId; - - uint16_t PID, VID; // PID and VID of connected device - - // HID implementation - virtual HIDReportParser* GetReportParser(uint32_t id); - - virtual uint32_t OnInitSuccessful() { - return 0; - }; - - virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - return; - }; - -public: - HIDUniversal(USBHost *p); - - // HID implementation - virtual uint32_t SetReportParser(uint32_t id, HIDReportParser *prs); - - // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint32_t Release(); - virtual uint32_t Poll(); - - virtual uint32_t GetAddress() { - return bAddress; - }; - - virtual uint32_t isReady() { - return bPollEnable; - }; - - // UsbConfigXtracter implementation - virtual void EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); -}; - -#endif // __HIDUNIVERSAL_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/hidusagestr.h b/legacy/builder/test/libraries/USBHost/src/hidusagestr.h deleted file mode 100644 index 71e53787399..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/hidusagestr.h +++ /dev/null @@ -1,977 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -#if !defined( __HIDUSAGESTR_H__) -#define __HIDUSAGESTR_H__ - -#include "Usb.h" - -const char pstrSpace [] PROGMEM = " "; -const char pstrCRLF [] PROGMEM = "\r\n"; -const char pstrSingleTab [] PROGMEM = "\t"; -const char pstrDoubleTab [] PROGMEM = "\t\t"; -const char pstrTripleTab [] PROGMEM = "\t\t\t"; - -// Usage Page String Titles -const char pstrUsagePageUndefined [] PROGMEM = "Undef"; -const char pstrUsagePageGenericDesktopControls [] PROGMEM = "Gen Desktop Ctrls"; -const char pstrUsagePageSimulationControls [] PROGMEM = "Simu Ctrls"; -const char pstrUsagePageVRControls [] PROGMEM = "VR Ctrls"; -const char pstrUsagePageSportControls [] PROGMEM = "Sport Ctrls"; -const char pstrUsagePageGameControls [] PROGMEM = "Game Ctrls"; -const char pstrUsagePageGenericDeviceControls [] PROGMEM = "Gen Dev Ctrls"; -const char pstrUsagePageKeyboardKeypad [] PROGMEM = "Kbrd/Keypad"; -const char pstrUsagePageLEDs [] PROGMEM = "LEDs"; -const char pstrUsagePageButton [] PROGMEM = "Button"; -const char pstrUsagePageOrdinal [] PROGMEM = "Ordinal"; -const char pstrUsagePageTelephone [] PROGMEM = "Tel"; -const char pstrUsagePageConsumer [] PROGMEM = "Consumer"; -const char pstrUsagePageDigitizer [] PROGMEM = "Digitizer"; -const char pstrUsagePagePID [] PROGMEM = "PID"; -const char pstrUsagePageUnicode [] PROGMEM = "Unicode"; -const char pstrUsagePageAlphaNumericDisplay [] PROGMEM = "Alpha Num Disp"; -const char pstrUsagePageMedicalInstruments [] PROGMEM = "Medical Instr"; -const char pstrUsagePageMonitor [] PROGMEM = "Monitor"; -const char pstrUsagePagePower [] PROGMEM = "Power"; -const char pstrUsagePageBarCodeScanner [] PROGMEM = "Bar Code Scan"; -const char pstrUsagePageScale [] PROGMEM = "Scale"; -const char pstrUsagePageMSRDevices [] PROGMEM = "Magn Stripe Read Dev"; -const char pstrUsagePagePointOfSale [] PROGMEM = "POS"; -const char pstrUsagePageCameraControl [] PROGMEM = "Cam Ctrl"; -const char pstrUsagePageArcade [] PROGMEM = "Arcade"; -const char pstrUsagePageReserved [] PROGMEM = "Reserved"; -const char pstrUsagePageVendorDefined [] PROGMEM = "Vendor Def"; - -// Generic Desktop Controls Page -const char pstrUsagePointer [] PROGMEM = "Pointer"; -const char pstrUsageMouse [] PROGMEM = "Mouse"; -const char pstrUsageJoystick [] PROGMEM = "Joystick"; -const char pstrUsageGamePad [] PROGMEM = "Game Pad"; -const char pstrUsageKeyboard [] PROGMEM = "Kbrd"; -const char pstrUsageKeypad [] PROGMEM = "Keypad"; -const char pstrUsageMultiAxisController [] PROGMEM = "Multi-axis Ctrl"; -const char pstrUsageTabletPCSystemControls [] PROGMEM = "Tablet PC Sys Ctrls"; -const char pstrUsageX [] PROGMEM = "X"; -const char pstrUsageY [] PROGMEM = "Y"; -const char pstrUsageZ [] PROGMEM = "Z"; -const char pstrUsageRx [] PROGMEM = "Rx"; -const char pstrUsageRy [] PROGMEM = "Ry"; -const char pstrUsageRz [] PROGMEM = "Rz"; -const char pstrUsageSlider [] PROGMEM = "Slider"; -const char pstrUsageDial [] PROGMEM = "Dial"; -const char pstrUsageWheel [] PROGMEM = "Wheel"; -const char pstrUsageHatSwitch [] PROGMEM = "Hat Switch"; -const char pstrUsageCountedBuffer [] PROGMEM = "Counted Buf"; -const char pstrUsageByteCount [] PROGMEM = "Byte Count"; -const char pstrUsageMotionWakeup [] PROGMEM = "Motion Wakeup"; -const char pstrUsageStart [] PROGMEM = "Start"; -const char pstrUsageSelect [] PROGMEM = "Sel"; -const char pstrUsageVx [] PROGMEM = "Vx"; -const char pstrUsageVy [] PROGMEM = "Vy"; -const char pstrUsageVz [] PROGMEM = "Vz"; -const char pstrUsageVbrx [] PROGMEM = "Vbrx"; -const char pstrUsageVbry [] PROGMEM = "Vbry"; -const char pstrUsageVbrz [] PROGMEM = "Vbrz"; -const char pstrUsageVno [] PROGMEM = "Vno"; -const char pstrUsageFeatureNotification [] PROGMEM = "Feature Notif"; -const char pstrUsageResolutionMultiplier [] PROGMEM = "Res Mult"; -const char pstrUsageSystemControl [] PROGMEM = "Sys Ctrl"; -const char pstrUsageSystemPowerDown [] PROGMEM = "Sys Pwr Down"; -const char pstrUsageSystemSleep [] PROGMEM = "Sys Sleep"; -const char pstrUsageSystemWakeup [] PROGMEM = "Sys Wakeup"; -const char pstrUsageSystemContextMenu [] PROGMEM = "Sys Context Menu"; -const char pstrUsageSystemMainMenu [] PROGMEM = "Sys Main Menu"; -const char pstrUsageSystemAppMenu [] PROGMEM = "Sys App Menu"; -const char pstrUsageSystemMenuHelp [] PROGMEM = "Sys Menu Help"; -const char pstrUsageSystemMenuExit [] PROGMEM = "Sys Menu Exit"; -const char pstrUsageSystemMenuSelect [] PROGMEM = "Sys Menu Select"; -const char pstrUsageSystemMenuRight [] PROGMEM = "Sys Menu Right"; -const char pstrUsageSystemMenuLeft [] PROGMEM = "Sys Menu Left"; -const char pstrUsageSystemMenuUp [] PROGMEM = "Sys Menu Up"; -const char pstrUsageSystemMenuDown [] PROGMEM = "Sys Menu Down"; -const char pstrUsageSystemColdRestart [] PROGMEM = "Sys Cold Restart"; -const char pstrUsageSystemWarmRestart [] PROGMEM = "Sys Warm Restart"; -const char pstrUsageDPadUp [] PROGMEM = "D-pad Up"; -const char pstrUsageDPadDown [] PROGMEM = "D-pad Down"; -const char pstrUsageDPadRight [] PROGMEM = "D-pad Right"; -const char pstrUsageDPadLeft [] PROGMEM = "D-pad Left"; -const char pstrUsageSystemDock [] PROGMEM = "Sys Dock"; -const char pstrUsageSystemUndock [] PROGMEM = "Sys Undock"; -const char pstrUsageSystemSetup [] PROGMEM = "Sys Setup"; -const char pstrUsageSystemBreak [] PROGMEM = "Sys Break"; -const char pstrUsageSystemDebuggerBreak [] PROGMEM = "Sys Dbg Brk"; -const char pstrUsageApplicationBreak [] PROGMEM = "App Break"; -const char pstrUsageApplicationDebuggerBreak [] PROGMEM = "App Dbg Brk"; -const char pstrUsageSystemSpeakerMute [] PROGMEM = "Sys Spk Mute"; -const char pstrUsageSystemHibernate [] PROGMEM = "Sys Hiber"; -const char pstrUsageSystemDisplayInvert [] PROGMEM = "Sys Disp Inv"; -const char pstrUsageSystemDisplayInternal [] PROGMEM = "Sys Disp Int"; -const char pstrUsageSystemDisplayExternal [] PROGMEM = "Sys Disp Ext"; -const char pstrUsageSystemDisplayBoth [] PROGMEM = "Sys Disp Both"; -const char pstrUsageSystemDisplayDual [] PROGMEM = "Sys Disp Dual"; -const char pstrUsageSystemDisplayToggleIntExt [] PROGMEM = "Sys Disp Tgl Int/Ext"; -const char pstrUsageSystemDisplaySwapPriSec [] PROGMEM = "Sys Disp Swap Pri/Sec"; -const char pstrUsageSystemDisplayLCDAutoscale [] PROGMEM = "Sys Disp LCD Autoscale"; - -// Simulation Controls Page -const char pstrUsageFlightSimulationDevice [] PROGMEM = "Flight Simu Dev"; -const char pstrUsageAutomobileSimulationDevice [] PROGMEM = "Auto Simu Dev"; -const char pstrUsageTankSimulationDevice [] PROGMEM = "Tank Simu Dev"; -const char pstrUsageSpaceshipSimulationDevice [] PROGMEM = "Space Simu Dev"; -const char pstrUsageSubmarineSimulationDevice [] PROGMEM = "Subm Simu Dev"; -const char pstrUsageSailingSimulationDevice [] PROGMEM = "Sail Simu Dev"; -const char pstrUsageMotocicleSimulationDevice [] PROGMEM = "Moto Simu Dev"; -const char pstrUsageSportsSimulationDevice [] PROGMEM = "Sport Simu Dev"; -const char pstrUsageAirplaneSimulationDevice [] PROGMEM = "Airp Simu Dev"; -const char pstrUsageHelicopterSimulationDevice [] PROGMEM = "Heli Simu Dev"; -const char pstrUsageMagicCarpetSimulationDevice [] PROGMEM = "Magic Carpet Simu Dev"; -const char pstrUsageBicycleSimulationDevice [] PROGMEM = "Bike Simu Dev"; -const char pstrUsageFlightControlStick [] PROGMEM = "Flight Ctrl Stick"; -const char pstrUsageFlightStick [] PROGMEM = "Flight Stick"; -const char pstrUsageCyclicControl [] PROGMEM = "Cyclic Ctrl"; -const char pstrUsageCyclicTrim [] PROGMEM = "Cyclic Trim"; -const char pstrUsageFlightYoke [] PROGMEM = "Flight Yoke"; -const char pstrUsageTrackControl [] PROGMEM = "Track Ctrl"; -const char pstrUsageAileron [] PROGMEM = "Aileron"; -const char pstrUsageAileronTrim [] PROGMEM = "Aileron Trim"; -const char pstrUsageAntiTorqueControl [] PROGMEM = "Anti-Torque Ctrl"; -const char pstrUsageAutopilotEnable [] PROGMEM = "Autopilot Enable"; -const char pstrUsageChaffRelease [] PROGMEM = "Chaff Release"; -const char pstrUsageCollectiveControl [] PROGMEM = "Collective Ctrl"; -const char pstrUsageDiveBrake [] PROGMEM = "Dive Brake"; -const char pstrUsageElectronicCountermeasures [] PROGMEM = "El Countermeasures"; -const char pstrUsageElevator [] PROGMEM = "Elevator"; -const char pstrUsageElevatorTrim [] PROGMEM = "Elevator Trim"; -const char pstrUsageRudder [] PROGMEM = "Rudder"; -const char pstrUsageThrottle [] PROGMEM = "Throttle"; -const char pstrUsageFlightCommunications [] PROGMEM = "Flight Comm"; -const char pstrUsageFlareRelease [] PROGMEM = "Flare Release"; -const char pstrUsageLandingGear [] PROGMEM = "Landing Gear"; -const char pstrUsageToeBrake [] PROGMEM = "Toe Brake"; -const char pstrUsageTrigger [] PROGMEM = "Trigger"; -const char pstrUsageWeaponsArm [] PROGMEM = "Weapons Arm"; -const char pstrUsageWeaponsSelect [] PROGMEM = "Weapons Sel"; -const char pstrUsageWingFlaps [] PROGMEM = "Wing Flaps"; -const char pstrUsageAccelerator [] PROGMEM = "Accel"; -const char pstrUsageBrake [] PROGMEM = "Brake"; -const char pstrUsageClutch [] PROGMEM = "Clutch"; -const char pstrUsageShifter [] PROGMEM = "Shifter"; -const char pstrUsageSteering [] PROGMEM = "Steering"; -const char pstrUsageTurretDirection [] PROGMEM = "Turret Dir"; -const char pstrUsageBarrelElevation [] PROGMEM = "Barrel Ele"; -const char pstrUsageDivePlane [] PROGMEM = "Dive Plane"; -const char pstrUsageBallast [] PROGMEM = "Ballast"; -const char pstrUsageBicycleCrank [] PROGMEM = "Bicycle Crank"; -const char pstrUsageHandleBars [] PROGMEM = "Handle Bars"; -const char pstrUsageFrontBrake [] PROGMEM = "Front Brake"; -const char pstrUsageRearBrake [] PROGMEM = "Rear Brake"; - -// VR Controls Page -const char pstrUsageBelt [] PROGMEM = "Belt"; -const char pstrUsageBodySuit [] PROGMEM = "Body Suit"; -const char pstrUsageFlexor [] PROGMEM = "Flexor"; -const char pstrUsageGlove [] PROGMEM = "Glove"; -const char pstrUsageHeadTracker [] PROGMEM = "Head Track"; -const char pstrUsageHeadMountedDisplay [] PROGMEM = "Head Disp"; -const char pstrUsageHandTracker [] PROGMEM = "Hand Track"; -const char pstrUsageOculometer [] PROGMEM = "Oculometer"; -const char pstrUsageVest [] PROGMEM = "Vest"; -const char pstrUsageAnimatronicDevice [] PROGMEM = "Animat Dev"; -const char pstrUsageStereoEnable [] PROGMEM = "Stereo Enbl"; -const char pstrUsageDisplayEnable [] PROGMEM = "Display Enbl"; - -// Sport Controls Page -const char pstrUsageBaseballBat [] PROGMEM = "Baseball Bat"; -const char pstrUsageGolfClub [] PROGMEM = "Golf Club"; -const char pstrUsageRowingMachine [] PROGMEM = "Rowing Mach"; -const char pstrUsageTreadmill [] PROGMEM = "Treadmill"; -const char pstrUsageOar [] PROGMEM = "Oar"; -const char pstrUsageSlope [] PROGMEM = "Slope"; -const char pstrUsageRate [] PROGMEM = "Rate"; -const char pstrUsageStickSpeed [] PROGMEM = "Stick Speed"; -const char pstrUsageStickFaceAngle [] PROGMEM = "Stick Face Ang"; -const char pstrUsageStickHeelToe [] PROGMEM = "Stick Heel/Toe"; -const char pstrUsageStickFollowThough [] PROGMEM = "Stick Flw Thru"; -const char pstrUsageStickTempo [] PROGMEM = "Stick Tempo"; -const char pstrUsageStickType [] PROGMEM = "Stick Type"; -const char pstrUsageStickHeight [] PROGMEM = "Stick Hght"; -const char pstrUsagePutter [] PROGMEM = "Putter"; -const char pstrUsage1Iron [] PROGMEM = "1 Iron"; -const char pstrUsage2Iron [] PROGMEM = "2 Iron"; -const char pstrUsage3Iron [] PROGMEM = "3 Iron"; -const char pstrUsage4Iron [] PROGMEM = "4 Iron"; -const char pstrUsage5Iron [] PROGMEM = "5 Iron"; -const char pstrUsage6Iron [] PROGMEM = "6 Iron"; -const char pstrUsage7Iron [] PROGMEM = "7 Iron"; -const char pstrUsage8Iron [] PROGMEM = "8 Iron"; -const char pstrUsage9Iron [] PROGMEM = "9 Iron"; -const char pstrUsage10Iron [] PROGMEM = "10 Iron"; -const char pstrUsage11Iron [] PROGMEM = "11 Iron"; -const char pstrUsageSandWedge [] PROGMEM = "Sand Wedge"; -const char pstrUsageLoftWedge [] PROGMEM = "Loft Wedge"; -const char pstrUsagePowerWedge [] PROGMEM = "Pwr Wedge"; -const char pstrUsage1Wood [] PROGMEM = "1 Wood"; -const char pstrUsage3Wood [] PROGMEM = "3 Wood"; -const char pstrUsage5Wood [] PROGMEM = "5 Wood"; -const char pstrUsage7Wood [] PROGMEM = "7 Wood"; -const char pstrUsage9Wood [] PROGMEM = "9 Wood"; - -// Game Controls Page -const char pstrUsage3DGameController [] PROGMEM = "3D Game Ctrl"; -const char pstrUsagePinballDevice [] PROGMEM = "Pinball Dev"; -const char pstrUsageGunDevice [] PROGMEM = "Gun Dev"; -const char pstrUsagePointOfView [] PROGMEM = "POV"; -const char pstrUsageTurnRightLeft [] PROGMEM = "Turn Right Left"; -const char pstrUsagePitchForwardBackward [] PROGMEM = "Pitch Fwd/Back"; -const char pstrUsageRollRightLeft [] PROGMEM = "Roll Right/Left"; -const char pstrUsageMoveRightLeft [] PROGMEM = "Move Right/Left"; -const char pstrUsageMoveForwardBackward [] PROGMEM = "Move Fwd/Back"; -const char pstrUsageMoveUpDown [] PROGMEM = "Move Up/Down"; -const char pstrUsageLeanRightLeft [] PROGMEM = "Lean Right/Left"; -const char pstrUsageLeanForwardBackward [] PROGMEM = "Lean Fwd/Back"; -const char pstrUsageHeightOfPOV [] PROGMEM = "Height of POV"; -const char pstrUsageFlipper [] PROGMEM = "Flipper"; -const char pstrUsageSecondaryFlipper [] PROGMEM = "Second Flipper"; -const char pstrUsageBump [] PROGMEM = "Bump"; -const char pstrUsageNewGame [] PROGMEM = "New Game"; -const char pstrUsageShootBall [] PROGMEM = "Shoot Ball"; -const char pstrUsagePlayer [] PROGMEM = "Player"; -const char pstrUsageGunBolt [] PROGMEM = "Gun Bolt"; -const char pstrUsageGunClip [] PROGMEM = "Gun Clip"; -const char pstrUsageGunSelector [] PROGMEM = "Gun Sel"; -const char pstrUsageGunSingleShot [] PROGMEM = "Gun Sngl Shot"; -const char pstrUsageGunBurst [] PROGMEM = "Gun Burst"; -const char pstrUsageGunAutomatic [] PROGMEM = "Gun Auto"; -const char pstrUsageGunSafety [] PROGMEM = "Gun Safety"; -const char pstrUsageGamepadFireJump [] PROGMEM = "Gamepad Fire/Jump"; -const char pstrUsageGamepadTrigger [] PROGMEM = "Gamepad Trig"; - -// Generic Device Controls Page -const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength"; -const char pstrUsageWirelessChannel [] PROGMEM = "Wireless Ch"; -const char pstrUsageWirelessID [] PROGMEM = "Wireless ID"; -const char pstrUsageDiscoverWirelessControl [] PROGMEM = "Discover Wireless Ctrl"; -const char pstrUsageSecurityCodeCharEntered [] PROGMEM = "Sec Code Char Entrd"; -const char pstrUsageSecurityCodeCharErased [] PROGMEM = "Sec Code Char Erased"; -const char pstrUsageSecurityCodeCleared [] PROGMEM = "Sec Code Cleared"; - -// LED Page -const char pstrUsageNumLock [] PROGMEM = "Num Lock"; -const char pstrUsageCapsLock [] PROGMEM = "Caps Lock"; -const char pstrUsageScrollLock [] PROGMEM = "Scroll Lock"; -const char pstrUsageCompose [] PROGMEM = "Compose"; -const char pstrUsageKana [] PROGMEM = "Kana"; -const char pstrUsagePower [] PROGMEM = "Pwr"; -const char pstrUsageShift [] PROGMEM = "Shift"; -const char pstrUsageDoNotDisturb [] PROGMEM = "DND"; -const char pstrUsageMute [] PROGMEM = "Mute"; -const char pstrUsageToneEnable [] PROGMEM = "Tone Enbl"; -const char pstrUsageHighCutFilter [] PROGMEM = "High Cut Fltr"; -const char pstrUsageLowCutFilter [] PROGMEM = "Low Cut Fltr"; -const char pstrUsageEqualizerEnable [] PROGMEM = "Eq Enbl"; -const char pstrUsageSoundFieldOn [] PROGMEM = "Sound Field On"; -const char pstrUsageSurroundOn [] PROGMEM = "Surround On"; -const char pstrUsageRepeat [] PROGMEM = "Repeat"; -const char pstrUsageStereo [] PROGMEM = "Stereo"; -const char pstrUsageSamplingRateDetect [] PROGMEM = "Smpl Rate Detect"; -const char pstrUsageSpinning [] PROGMEM = "Spinning"; -const char pstrUsageCAV [] PROGMEM = "CAV"; -const char pstrUsageCLV [] PROGMEM = "CLV"; -const char pstrUsageRecordingFormatDetect [] PROGMEM = "Rec Format Detect"; -const char pstrUsageOffHook [] PROGMEM = "Off Hook"; -const char pstrUsageRing [] PROGMEM = "Ring"; -const char pstrUsageMessageWaiting [] PROGMEM = "Msg Wait"; -const char pstrUsageDataMode [] PROGMEM = "Data Mode"; -const char pstrUsageBatteryOperation [] PROGMEM = "Bat Op"; -const char pstrUsageBatteryOK [] PROGMEM = "Bat OK"; -const char pstrUsageBatteryLow [] PROGMEM = "Bat Low"; -const char pstrUsageSpeaker [] PROGMEM = "Speaker"; -const char pstrUsageHeadSet [] PROGMEM = "Head Set"; -const char pstrUsageHold [] PROGMEM = "Hold"; -const char pstrUsageMicrophone [] PROGMEM = "Mic"; -const char pstrUsageCoverage [] PROGMEM = "Coverage"; -const char pstrUsageNightMode [] PROGMEM = "Night Mode"; -const char pstrUsageSendCalls [] PROGMEM = "Send Calls"; -const char pstrUsageCallPickup [] PROGMEM = "Call Pickup"; -const char pstrUsageConference [] PROGMEM = "Conf"; -const char pstrUsageStandBy [] PROGMEM = "Stand-by"; -const char pstrUsageCameraOn [] PROGMEM = "Cam On"; -const char pstrUsageCameraOff [] PROGMEM = "Cam Off"; -const char pstrUsageOnLine [] PROGMEM = "On-Line"; -const char pstrUsageOffLine [] PROGMEM = "Off-Line"; -const char pstrUsageBusy [] PROGMEM = "Busy"; -const char pstrUsageReady [] PROGMEM = "Ready"; -const char pstrUsagePaperOut [] PROGMEM = "Paper Out"; -const char pstrUsagePaperJam [] PROGMEM = "Paper Jam"; -const char pstrUsageRemote [] PROGMEM = "Remote"; -const char pstrUsageForward [] PROGMEM = "Fwd"; -const char pstrUsageReverse [] PROGMEM = "Rev"; -const char pstrUsageStop [] PROGMEM = "Stop"; -const char pstrUsageRewind [] PROGMEM = "Rewind"; -const char pstrUsageFastForward [] PROGMEM = "Fast Fwd"; -const char pstrUsagePlay [] PROGMEM = "Play"; -const char pstrUsagePause [] PROGMEM = "Pause"; -const char pstrUsageRecord [] PROGMEM = "Rec"; -const char pstrUsageError [] PROGMEM = "Error"; -const char pstrUsageSelectedIndicator [] PROGMEM = "Usage Sel Ind"; -const char pstrUsageInUseIndicator [] PROGMEM = "Usage In Use Ind"; -const char pstrUsageMultiModeIndicator [] PROGMEM = "Usage Multi Mode Ind"; -const char pstrUsageIndicatorOn [] PROGMEM = "Ind On"; -const char pstrUsageIndicatorFlash [] PROGMEM = "Ind Flash"; -const char pstrUsageIndicatorSlowBlink [] PROGMEM = "Ind Slow Blk"; -const char pstrUsageIndicatorFastBlink [] PROGMEM = "Ind Fast Blk"; -const char pstrUsageIndicatorOff [] PROGMEM = "Ind Off"; -const char pstrUsageFlashOnTime [] PROGMEM = "Flash On Time"; -const char pstrUsageSlowBlinkOnTime [] PROGMEM = "Slow Blk On Time"; -const char pstrUsageSlowBlinkOffTime [] PROGMEM = "Slow Blk Off Time"; -const char pstrUsageFastBlinkOnTime [] PROGMEM = "Fast Blk On Time"; -const char pstrUsageFastBlinkOffTime [] PROGMEM = "Fast Blk Off Time"; -const char pstrUsageIndicatorColor [] PROGMEM = "Usage Ind Color"; -const char pstrUsageIndicatorRed [] PROGMEM = "Ind Red"; -const char pstrUsageIndicatorGreen [] PROGMEM = "Ind Green"; -const char pstrUsageIndicatorAmber [] PROGMEM = "Ind Amber"; -const char pstrUsageGenericIndicator [] PROGMEM = "Gen Ind"; -const char pstrUsageSystemSuspend [] PROGMEM = "Sys Suspend"; -const char pstrUsageExternalPowerConnected [] PROGMEM = "Ext Pwr Conn"; - -// Telephony Usage Page -const char pstrUsagePhone [] PROGMEM = "Phone"; -const char pstrUsageAnsweringMachine [] PROGMEM = "Answ Mach"; -const char pstrUsageMessageControls [] PROGMEM = "Msg Ctrls"; -const char pstrUsageHandset [] PROGMEM = "Handset"; -const char pstrUsageHeadset [] PROGMEM = "Headset"; -const char pstrUsageTelephonyKeyPad [] PROGMEM = "Tel Key Pad"; -const char pstrUsageProgrammableButton [] PROGMEM = "Prog Button"; -const char pstrUsageHookSwitch [] PROGMEM = "Hook Sw"; -const char pstrUsageFlash [] PROGMEM = "Flash"; -const char pstrUsageFeature [] PROGMEM = "Feature"; -//const char pstrUsageHold [] PROGMEM = "Hold"; -const char pstrUsageRedial [] PROGMEM = "Redial"; -const char pstrUsageTransfer [] PROGMEM = "Transfer"; -const char pstrUsageDrop [] PROGMEM = "Drop"; -const char pstrUsagePark [] PROGMEM = "Park"; -const char pstrUsageForwardCalls [] PROGMEM = "Fwd Calls"; -const char pstrUsageAlternateFunction [] PROGMEM = "Alt Func"; -const char pstrUsageLine [] PROGMEM = "Line"; -const char pstrUsageSpeakerPhone [] PROGMEM = "Spk Phone"; -//const char pstrUsageConference [] PROGMEM = "Conference"; -const char pstrUsageRingEnable [] PROGMEM = "Ring Enbl"; -const char pstrUsageRingSelect [] PROGMEM = "Ring Sel"; -const char pstrUsagePhoneMute [] PROGMEM = "Phone Mute"; -const char pstrUsageCallerID [] PROGMEM = "Caller ID"; -const char pstrUsageSend [] PROGMEM = "Send"; -const char pstrUsageSpeedDial [] PROGMEM = "Speed Dial"; -const char pstrUsageStoreNumber [] PROGMEM = "Store Num"; -const char pstrUsageRecallNumber [] PROGMEM = "Recall Num"; -const char pstrUsagePhoneDirectory [] PROGMEM = "Phone Dir"; -const char pstrUsageVoiceMail [] PROGMEM = "Voice Mail"; -const char pstrUsageScreenCalls [] PROGMEM = "Screen Calls"; -//const char pstrUsageDoNotDisturb [] PROGMEM = "Do Not Disturb"; -const char pstrUsageMessage [] PROGMEM = "Msg"; -const char pstrUsageAnswerOnOff [] PROGMEM = "Answer On/Off"; -const char pstrUsageInsideDialTone [] PROGMEM = "Inside Dial Tone"; -const char pstrUsageOutsideDialTone [] PROGMEM = "Outside Dial Tone"; -const char pstrUsageInsideRingTone [] PROGMEM = "Inside Ring Tone"; -const char pstrUsageOutsideRingTone [] PROGMEM = "Outside Ring Tone"; -const char pstrUsagePriorityRingTone [] PROGMEM = "Prior Ring Tone"; -const char pstrUsageInsideRingback [] PROGMEM = "Inside Ringback"; -const char pstrUsagePriorityRingback [] PROGMEM = "Priority Ringback"; -const char pstrUsageLineBusyTone [] PROGMEM = "Ln Busy Tone"; -const char pstrUsageReorderTone [] PROGMEM = "Reorder Tone"; -const char pstrUsageCallWaitingTone [] PROGMEM = "Call Wait Tone"; -const char pstrUsageConfirmationTone1 [] PROGMEM = "Cnfrm Tone1"; -const char pstrUsageConfirmationTone2 [] PROGMEM = "Cnfrm Tone2"; -const char pstrUsageTonesOff [] PROGMEM = "Tones Off"; -const char pstrUsageOutsideRingback [] PROGMEM = "Outside Ringback"; -const char pstrUsageRinger [] PROGMEM = "Ringer"; -const char pstrUsagePhoneKey0 [] PROGMEM = "0"; -const char pstrUsagePhoneKey1 [] PROGMEM = "1"; -const char pstrUsagePhoneKey2 [] PROGMEM = "2"; -const char pstrUsagePhoneKey3 [] PROGMEM = "3"; -const char pstrUsagePhoneKey4 [] PROGMEM = "4"; -const char pstrUsagePhoneKey5 [] PROGMEM = "5"; -const char pstrUsagePhoneKey6 [] PROGMEM = "6"; -const char pstrUsagePhoneKey7 [] PROGMEM = "7"; -const char pstrUsagePhoneKey8 [] PROGMEM = "8"; -const char pstrUsagePhoneKey9 [] PROGMEM = "9"; -const char pstrUsagePhoneKeyStar [] PROGMEM = "*"; -const char pstrUsagePhoneKeyPound [] PROGMEM = "#"; -const char pstrUsagePhoneKeyA [] PROGMEM = "A"; -const char pstrUsagePhoneKeyB [] PROGMEM = "B"; -const char pstrUsagePhoneKeyC [] PROGMEM = "C"; -const char pstrUsagePhoneKeyD [] PROGMEM = "D"; - -// Consumer Usage Page -const char pstrUsageConsumerControl [] PROGMEM = "Consumer Ctrl"; -const char pstrUsageNumericKeyPad [] PROGMEM = "Num Key Pad"; -//const char pstrUsageProgrammableButton [] PROGMEM = "Prog Btn"; -//const char pstrUsageMicrophone [] PROGMEM = "Mic"; -const char pstrUsageHeadphone [] PROGMEM = "Headphone"; -const char pstrUsageGraphicEqualizer [] PROGMEM = "Graph Eq"; -const char pstrUsagePlus10 [] PROGMEM = "+10"; -const char pstrUsagePlus100 [] PROGMEM = "+100"; -const char pstrUsageAMPM [] PROGMEM = "AM/PM"; -//const char pstrUsagePower [] PROGMEM = "Pwr"; -const char pstrUsageReset [] PROGMEM = "Reset"; -const char pstrUsageSleep [] PROGMEM = "Sleep"; -const char pstrUsageSleepAfter [] PROGMEM = "Sleep After"; -const char pstrUsageSleepMode [] PROGMEM = "Sleep Mode"; -const char pstrUsageIllumination [] PROGMEM = "Illumin"; -const char pstrUsageFunctionButtons [] PROGMEM = "Func Btns"; -const char pstrUsageMenu [] PROGMEM = "Menu"; -const char pstrUsageMenuPick [] PROGMEM = "Menu Pick"; -const char pstrUsageMenuUp [] PROGMEM = "Menu Up"; -const char pstrUsageMenuDown [] PROGMEM = "Menu Down"; -const char pstrUsageMenuLeft [] PROGMEM = "Menu Left"; -const char pstrUsageMenuRight [] PROGMEM = "Menu Right"; -const char pstrUsageMenuEscape [] PROGMEM = "Menu Esc"; -const char pstrUsageMenuValueIncrease [] PROGMEM = "Menu Val Inc"; -const char pstrUsageMenuValueDecrease [] PROGMEM = "Menu Val Dec"; -const char pstrUsageDataOnScreen [] PROGMEM = "Data On Scr"; -const char pstrUsageClosedCaption [] PROGMEM = "Closed Cptn"; -const char pstrUsageClosedCaptionSelect [] PROGMEM = "Closed Cptn Sel"; -const char pstrUsageVCRTV [] PROGMEM = "VCR/TV"; -const char pstrUsageBroadcastMode [] PROGMEM = "Brdcast Mode"; -const char pstrUsageSnapshot [] PROGMEM = "Snapshot"; -const char pstrUsageStill [] PROGMEM = "Still"; -const char pstrUsageSelection [] PROGMEM = "Sel"; -const char pstrUsageAssignSelection [] PROGMEM = "Assign Sel"; -const char pstrUsageModeStep [] PROGMEM = "Mode Step"; -const char pstrUsageRecallLast [] PROGMEM = "Recall Last"; -const char pstrUsageEnterChannel [] PROGMEM = "Entr Channel"; -const char pstrUsageOrderMovie [] PROGMEM = "Ord Movie"; -const char pstrUsageChannel [] PROGMEM = "Channel"; -const char pstrUsageMediaSelection [] PROGMEM = "Med Sel"; -const char pstrUsageMediaSelectComputer [] PROGMEM = "Med Sel Comp"; -const char pstrUsageMediaSelectTV [] PROGMEM = "Med Sel TV"; -const char pstrUsageMediaSelectWWW [] PROGMEM = "Med Sel WWW"; -const char pstrUsageMediaSelectDVD [] PROGMEM = "Med Sel DVD"; -const char pstrUsageMediaSelectTelephone [] PROGMEM = "Med Sel Tel"; -const char pstrUsageMediaSelectProgramGuide [] PROGMEM = "Med Sel PG"; -const char pstrUsageMediaSelectVideoPhone [] PROGMEM = "Med Sel Vid"; -const char pstrUsageMediaSelectGames [] PROGMEM = "Med Sel Games"; -const char pstrUsageMediaSelectMessages [] PROGMEM = "Med Sel Msg"; -const char pstrUsageMediaSelectCD [] PROGMEM = "Med Sel CD"; -const char pstrUsageMediaSelectVCR [] PROGMEM = "Med Sel VCR"; -const char pstrUsageMediaSelectTuner [] PROGMEM = "Med Sel Tuner"; -const char pstrUsageQuit [] PROGMEM = "Quit"; -const char pstrUsageHelp [] PROGMEM = "Help"; -const char pstrUsageMediaSelectTape [] PROGMEM = "Med Sel Tape"; -const char pstrUsageMediaSelectCable [] PROGMEM = "Med Sel Cbl"; -const char pstrUsageMediaSelectSatellite [] PROGMEM = "Med Sel Sat"; -const char pstrUsageMediaSelectSecurity [] PROGMEM = "Med Sel Secur"; -const char pstrUsageMediaSelectHome [] PROGMEM = "Med Sel Home"; -const char pstrUsageMediaSelectCall [] PROGMEM = "Med Sel Call"; -const char pstrUsageChannelIncrement [] PROGMEM = "Ch Inc"; -const char pstrUsageChannelDecrement [] PROGMEM = "Ch Dec"; -const char pstrUsageMediaSelectSAP [] PROGMEM = "Med Sel SAP"; -const char pstrUsageVCRPlus [] PROGMEM = "VCR+"; -const char pstrUsageOnce [] PROGMEM = "Once"; -const char pstrUsageDaily [] PROGMEM = "Daily"; -const char pstrUsageWeekly [] PROGMEM = "Weekly"; -const char pstrUsageMonthly [] PROGMEM = "Monthly"; -//const char pstrUsagePlay [] PROGMEM = "Play"; -//const char pstrUsagePause [] PROGMEM = "Pause"; -//const char pstrUsageRecord [] PROGMEM = "Rec"; -//const char pstrUsageFastForward [] PROGMEM = "FF"; -//const char pstrUsageRewind [] PROGMEM = "Rewind"; -const char pstrUsageScanNextTrack [] PROGMEM = "Next Track"; -const char pstrUsageScanPreviousTrack [] PROGMEM = "Prev Track"; -//const char pstrUsageStop [] PROGMEM = "Stop"; -const char pstrUsageEject [] PROGMEM = "Eject"; -const char pstrUsageRandomPlay [] PROGMEM = "Random"; -const char pstrUsageSelectDisk [] PROGMEM = "Sel Disk"; -const char pstrUsageEnterDisk [] PROGMEM = "Ent Disk"; -//const char pstrUsageRepeat [] PROGMEM = "Repeat"; -const char pstrUsageTracking [] PROGMEM = "Tracking"; -const char pstrUsageTrackNormal [] PROGMEM = "Trk Norm"; -const char pstrUsageSlowTracking [] PROGMEM = "Slow Trk"; -const char pstrUsageFrameForward [] PROGMEM = "Frm Fwd"; -const char pstrUsageFrameBackwards [] PROGMEM = "Frm Back"; -const char pstrUsageMark [] PROGMEM = "Mark"; -const char pstrUsageClearMark [] PROGMEM = "Clr Mark"; -const char pstrUsageRepeatFromMark [] PROGMEM = "Rpt Mark"; -const char pstrUsageReturnToMark [] PROGMEM = "Ret to Mark"; -const char pstrUsageSearchMarkForward [] PROGMEM = "Search Mark Fwd"; -const char pstrUsageSearchMarkBackwards [] PROGMEM = "Search Mark Back"; -const char pstrUsageCounterReset [] PROGMEM = "Counter Reset"; -const char pstrUsageShowCounter [] PROGMEM = "Show Counter"; -const char pstrUsageTrackingIncrement [] PROGMEM = "Track Inc"; -const char pstrUsageTrackingDecrement [] PROGMEM = "Track Dec"; -const char pstrUsageStopEject [] PROGMEM = "Stop/Eject"; -const char pstrUsagePlayPause [] PROGMEM = "Play/Pause"; -const char pstrUsagePlaySkip [] PROGMEM = "Play/Skip"; -const char pstrUsageVolume [] PROGMEM = "Vol"; -const char pstrUsageBalance [] PROGMEM = "Balance"; -//const char pstrUsageMute [] PROGMEM = "Mute"; -const char pstrUsageBass [] PROGMEM = "Bass"; -const char pstrUsageTreble [] PROGMEM = "Treble"; -const char pstrUsageBassBoost [] PROGMEM = "Bass Boost"; -const char pstrUsageSurroundMode [] PROGMEM = "Surround"; -const char pstrUsageLoudness [] PROGMEM = "Loud"; -const char pstrUsageMPX [] PROGMEM = "MPX"; -const char pstrUsageVolumeIncrement [] PROGMEM = "Vol Inc"; -const char pstrUsageVolumeDecrement [] PROGMEM = "Vol Dec"; -const char pstrUsageSpeedSelect [] PROGMEM = "Speed"; -const char pstrUsagePlaybackSpeed [] PROGMEM = "Play Speed"; -const char pstrUsageStandardPlay [] PROGMEM = "Std Play"; -const char pstrUsageLongPlay [] PROGMEM = "Long Play"; -const char pstrUsageExtendedPlay [] PROGMEM = "Ext Play"; -const char pstrUsageSlow [] PROGMEM = "Slow"; -const char pstrUsageFanEnable [] PROGMEM = "Fan Enbl"; -const char pstrUsageFanSpeed [] PROGMEM = "Fan Speed"; -const char pstrUsageLightEnable [] PROGMEM = "Light Enbl"; -const char pstrUsageLightIlluminationLevel [] PROGMEM = "Light Illum Lev"; -const char pstrUsageClimateControlEnable [] PROGMEM = "Climate Enbl"; -const char pstrUsageRoomTemperature [] PROGMEM = "Room Temp"; -const char pstrUsageSecurityEnable [] PROGMEM = "Secur Enbl"; -const char pstrUsageFireAlarm [] PROGMEM = "Fire Alm"; -const char pstrUsagePoliceAlarm [] PROGMEM = "Police Alm"; -const char pstrUsageProximity [] PROGMEM = "Prox"; -const char pstrUsageMotion [] PROGMEM = "Motion"; -const char pstrUsageDuresAlarm [] PROGMEM = "Dures Alm"; -const char pstrUsageHoldupAlarm [] PROGMEM = "Holdup Alm"; -const char pstrUsageMedicalAlarm [] PROGMEM = "Med Alm"; -const char pstrUsageBalanceRight [] PROGMEM = "Balance Right"; -const char pstrUsageBalanceLeft [] PROGMEM = "Balance Left"; -const char pstrUsageBassIncrement [] PROGMEM = "Bass Inc"; -const char pstrUsageBassDecrement [] PROGMEM = "Bass Dec"; -const char pstrUsageTrebleIncrement [] PROGMEM = "Treble Inc"; -const char pstrUsageTrebleDecrement [] PROGMEM = "Treble Dec"; -const char pstrUsageSpeakerSystem [] PROGMEM = "Spk Sys"; -const char pstrUsageChannelLeft [] PROGMEM = "Ch Left"; -const char pstrUsageChannelRight [] PROGMEM = "Ch Right"; -const char pstrUsageChannelCenter [] PROGMEM = "Ch Center"; -const char pstrUsageChannelFront [] PROGMEM = "Ch Front"; -const char pstrUsageChannelCenterFront [] PROGMEM = "Ch Cntr Front"; -const char pstrUsageChannelSide [] PROGMEM = "Ch Side"; -const char pstrUsageChannelSurround [] PROGMEM = "Ch Surround"; -const char pstrUsageChannelLowFreqEnhancement [] PROGMEM = "Ch Low Freq Enh"; -const char pstrUsageChannelTop [] PROGMEM = "Ch Top"; -const char pstrUsageChannelUnknown [] PROGMEM = "Ch Unk"; -const char pstrUsageSubChannel [] PROGMEM = "Sub-ch"; -const char pstrUsageSubChannelIncrement [] PROGMEM = "Sub-ch Inc"; -const char pstrUsageSubChannelDecrement [] PROGMEM = "Sub-ch Dec"; -const char pstrUsageAlternateAudioIncrement [] PROGMEM = "Alt Aud Inc"; -const char pstrUsageAlternateAudioDecrement [] PROGMEM = "Alt Aud Dec"; -const char pstrUsageApplicationLaunchButtons [] PROGMEM = "App Launch Btns"; -const char pstrUsageALLaunchButtonConfigTool [] PROGMEM = "AL Launch Conf Tl"; -const char pstrUsageALProgrammableButton [] PROGMEM = "AL Pgm Btn"; -const char pstrUsageALConsumerControlConfig [] PROGMEM = "AL Cons Ctrl Cfg"; -const char pstrUsageALWordProcessor [] PROGMEM = "AL Word Proc"; -const char pstrUsageALTextEditor [] PROGMEM = "AL Txt Edtr"; -const char pstrUsageALSpreadsheet [] PROGMEM = "AL Sprdsheet"; -const char pstrUsageALGraphicsEditor [] PROGMEM = "AL Graph Edtr"; -const char pstrUsageALPresentationApp [] PROGMEM = "AL Present App"; -const char pstrUsageALDatabaseApp [] PROGMEM = "AL DB App"; -const char pstrUsageALEmailReader [] PROGMEM = "AL E-mail Rdr"; -const char pstrUsageALNewsreader [] PROGMEM = "AL Newsrdr"; -const char pstrUsageALVoicemail [] PROGMEM = "AL Voicemail"; -const char pstrUsageALContactsAddressBook [] PROGMEM = "AL Addr Book"; -const char pstrUsageALCalendarSchedule [] PROGMEM = "AL Clndr/Schdlr"; -const char pstrUsageALTaskProjectManager [] PROGMEM = "AL Task/Prj Mgr"; -const char pstrUsageALLogJournalTimecard [] PROGMEM = "AL Log/Jrnl/Tmcrd"; -const char pstrUsageALCheckbookFinance [] PROGMEM = "AL Chckbook/Fin"; -const char pstrUsageALCalculator [] PROGMEM = "AL Calc"; -const char pstrUsageALAVCapturePlayback [] PROGMEM = "AL A/V Capt/Play"; -const char pstrUsageALLocalMachineBrowser [] PROGMEM = "AL Loc Mach Brow"; -const char pstrUsageALLANWANBrow [] PROGMEM = "AL LAN/WAN Brow"; -const char pstrUsageALInternetBrowser [] PROGMEM = "AL I-net Brow"; -const char pstrUsageALRemoteNetISPConnect [] PROGMEM = "AL Rem Net Con"; -const char pstrUsageALNetworkConference [] PROGMEM = "AL Net Conf"; -const char pstrUsageALNetworkChat [] PROGMEM = "AL Net Chat"; -const char pstrUsageALTelephonyDialer [] PROGMEM = "AL Tel/Dial"; -const char pstrUsageALLogon [] PROGMEM = "AL Logon"; -const char pstrUsageALLogoff [] PROGMEM = "AL Logoff"; -const char pstrUsageALLogonLogoff [] PROGMEM = "AL Logon/Logoff"; -const char pstrUsageALTermLockScrSav [] PROGMEM = "AL Term Lock/Scr Sav"; -const char pstrUsageALControlPannel [] PROGMEM = "AL Ctrl Pan"; -const char pstrUsageALCommandLineProcessorRun [] PROGMEM = "AL Cmd/Run"; -const char pstrUsageALProcessTaskManager [] PROGMEM = "AL Task Mgr"; -const char pstrUsageALSelectTaskApplication [] PROGMEM = "AL Sel App"; -const char pstrUsageALNextTaskApplication [] PROGMEM = "AL Next App"; -const char pstrUsageALPreviousTaskApplication [] PROGMEM = "AL Prev App"; -const char pstrUsageALPreemptiveHaltTaskApp [] PROGMEM = "AL Prmpt Halt App"; -const char pstrUsageALIntegratedHelpCenter [] PROGMEM = "AL Hlp Cntr"; -const char pstrUsageALDocuments [] PROGMEM = "AL Docs"; -const char pstrUsageALThesaurus [] PROGMEM = "AL Thsrs"; -const char pstrUsageALDictionary [] PROGMEM = "AL Dict"; -const char pstrUsageALDesktop [] PROGMEM = "AL Desktop"; -const char pstrUsageALSpellCheck [] PROGMEM = "AL Spell Chk"; -const char pstrUsageALGrammarCheck [] PROGMEM = "AL Gram Chk"; -const char pstrUsageALWirelessStatus [] PROGMEM = "AL Wireless Sts"; -const char pstrUsageALKeyboardLayout [] PROGMEM = "AL Kbd Layout"; -const char pstrUsageALVirusProtection [] PROGMEM = "AL Vir Protect"; -const char pstrUsageALEncryption [] PROGMEM = "AL Encrypt"; -const char pstrUsageALScreenSaver [] PROGMEM = "AL Scr Sav"; -const char pstrUsageALAlarms [] PROGMEM = "AL Alarms"; -const char pstrUsageALClock [] PROGMEM = "AL Clock"; -const char pstrUsageALFileBrowser [] PROGMEM = "AL File Brow"; -const char pstrUsageALPowerStatus [] PROGMEM = "AL Pwr Sts"; -const char pstrUsageALImageBrowser [] PROGMEM = "AL Img Brow"; -const char pstrUsageALAudioBrowser [] PROGMEM = "AL Aud Brow"; -const char pstrUsageALMovieBrowser [] PROGMEM = "AL Mov Brow"; -const char pstrUsageALDigitalRightsManager [] PROGMEM = "AL Dig Rights Mgr"; -const char pstrUsageALDigitalWallet [] PROGMEM = "AL Dig Wallet"; -const char pstrUsageALInstantMessaging [] PROGMEM = "AL Inst Msg"; -const char pstrUsageALOEMFeaturesBrowser [] PROGMEM = "AL OEM Tips Brow"; -const char pstrUsageALOEMHelp [] PROGMEM = "AL OEM Hlp"; -const char pstrUsageALOnlineCommunity [] PROGMEM = "AL Online Com"; -const char pstrUsageALEntertainmentContentBrow [] PROGMEM = "AL Ent Cont Brow"; -const char pstrUsageALOnlineShoppingBrowser [] PROGMEM = "AL Online Shop Brow"; -const char pstrUsageALSmartCardInfoHelp [] PROGMEM = "AL SmartCard Inf"; -const char pstrUsageALMarketMonitorFinBrowser [] PROGMEM = "AL Market Brow"; -const char pstrUsageALCustomCorpNewsBrowser [] PROGMEM = "AL Cust Corp News Brow"; -const char pstrUsageALOnlineActivityBrowser [] PROGMEM = "AL Online Act Brow"; -const char pstrUsageALResearchSearchBrowser [] PROGMEM = "AL Search Brow"; -const char pstrUsageALAudioPlayer [] PROGMEM = "AL Aud Player"; -const char pstrUsageGenericGUIAppControls [] PROGMEM = "Gen GUI App Ctrl"; -const char pstrUsageACNew [] PROGMEM = "AC New"; -const char pstrUsageACOpen [] PROGMEM = "AC Open"; -const char pstrUsageACClose [] PROGMEM = "AC Close"; -const char pstrUsageACExit [] PROGMEM = "AC Exit"; -const char pstrUsageACMaximize [] PROGMEM = "AC Max"; -const char pstrUsageACMinimize [] PROGMEM = "AC Min"; -const char pstrUsageACSave [] PROGMEM = "AC Save"; -const char pstrUsageACPrint [] PROGMEM = "AC Print"; -const char pstrUsageACProperties [] PROGMEM = "AC Prop"; -const char pstrUsageACUndo [] PROGMEM = "AC Undo"; -const char pstrUsageACCopy [] PROGMEM = "AC Copy"; -const char pstrUsageACCut [] PROGMEM = "AC Cut"; -const char pstrUsageACPaste [] PROGMEM = "AC Paste"; -const char pstrUsageACSelectAll [] PROGMEM = "AC Sel All"; -const char pstrUsageACFind [] PROGMEM = "AC Find"; -const char pstrUsageACFindAndReplace [] PROGMEM = "AC Find/Replace"; -const char pstrUsageACSearch [] PROGMEM = "AC Search"; -const char pstrUsageACGoto [] PROGMEM = "AC Goto"; -const char pstrUsageACHome [] PROGMEM = "AC Home"; -const char pstrUsageACBack [] PROGMEM = "AC Back"; -const char pstrUsageACForward [] PROGMEM = "AC Fwd"; -const char pstrUsageACStop [] PROGMEM = "AC Stop"; -const char pstrUsageACRefresh [] PROGMEM = "AC Refresh"; -const char pstrUsageACPreviousLink [] PROGMEM = "AC Prev Link"; -const char pstrUsageACNextLink [] PROGMEM = "AC Next Link"; -const char pstrUsageACBookmarks [] PROGMEM = "AC Bkmarks"; -const char pstrUsageACHistory [] PROGMEM = "AC Hist"; -const char pstrUsageACSubscriptions [] PROGMEM = "AC Subscr"; -const char pstrUsageACZoomIn [] PROGMEM = "AC Zoom In"; -const char pstrUsageACZoomOut [] PROGMEM = "AC Zoom Out"; -const char pstrUsageACZoom [] PROGMEM = "AC Zoom"; -const char pstrUsageACFullScreenView [] PROGMEM = "AC Full Scr"; -const char pstrUsageACNormalView [] PROGMEM = "AC Norm View"; -const char pstrUsageACViewToggle [] PROGMEM = "AC View Tgl"; -const char pstrUsageACScrollUp [] PROGMEM = "AC Scroll Up"; -const char pstrUsageACScrollDown [] PROGMEM = "AC Scroll Down"; -const char pstrUsageACScroll [] PROGMEM = "AC Scroll"; -const char pstrUsageACPanLeft [] PROGMEM = "AC Pan Left"; -const char pstrUsageACPanRight [] PROGMEM = "AC Pan Right"; -const char pstrUsageACPan [] PROGMEM = "AC Pan"; -const char pstrUsageACNewWindow [] PROGMEM = "AC New Wnd"; -const char pstrUsageACTileHoriz [] PROGMEM = "AC Tile Horiz"; -const char pstrUsageACTileVert [] PROGMEM = "AC Tile Vert"; -const char pstrUsageACFormat [] PROGMEM = "AC Frmt"; -const char pstrUsageACEdit [] PROGMEM = "AC Edit"; -const char pstrUsageACBold [] PROGMEM = "AC Bold"; -const char pstrUsageACItalics [] PROGMEM = "AC Ital"; -const char pstrUsageACUnderline [] PROGMEM = "AC Under"; -const char pstrUsageACStrikethrough [] PROGMEM = "AC Strike"; -const char pstrUsageACSubscript [] PROGMEM = "AC Sub"; -const char pstrUsageACSuperscript [] PROGMEM = "AC Super"; -const char pstrUsageACAllCaps [] PROGMEM = "AC All Caps"; -const char pstrUsageACRotate [] PROGMEM = "AC Rotate"; -const char pstrUsageACResize [] PROGMEM = "AC Resize"; -const char pstrUsageACFlipHorizontal [] PROGMEM = "AC Flp H"; -const char pstrUsageACFlipVertical [] PROGMEM = "AC Flp V"; -const char pstrUsageACMirrorHorizontal [] PROGMEM = "AC Mir H"; -const char pstrUsageACMirrorVertical [] PROGMEM = "AC Mir V"; -const char pstrUsageACFontSelect [] PROGMEM = "AC Fnt Sel"; -const char pstrUsageACFontColor [] PROGMEM = "AC Fnt Clr"; -const char pstrUsageACFontSize [] PROGMEM = "AC Fnt Size"; -const char pstrUsageACJustifyLeft [] PROGMEM = "AC Just Left"; -const char pstrUsageACJustifyCenterH [] PROGMEM = "AC Just Cent H"; -const char pstrUsageACJustifyRight [] PROGMEM = "AC Just Right"; -const char pstrUsageACJustifyBlockH [] PROGMEM = "AC Just Block H"; -const char pstrUsageACJustifyTop [] PROGMEM = "AC Just Top"; -const char pstrUsageACJustifyCenterV [] PROGMEM = "AC Just Cent V"; -const char pstrUsageACJustifyBottom [] PROGMEM = "AC Just Bot"; -const char pstrUsageACJustifyBlockV [] PROGMEM = "AC Just Block V"; -const char pstrUsageACIndentDecrease [] PROGMEM = "AC Indent Dec"; -const char pstrUsageACIndentIncrease [] PROGMEM = "AC Indent Inc"; -const char pstrUsageACNumberedList [] PROGMEM = "AC Num List"; -const char pstrUsageACRestartNumbering [] PROGMEM = "AC Res Num"; -const char pstrUsageACBulletedList [] PROGMEM = "AC Blt List"; -const char pstrUsageACPromote [] PROGMEM = "AC Promote"; -const char pstrUsageACDemote [] PROGMEM = "AC Demote"; -const char pstrUsageACYes [] PROGMEM = "AC Yes"; -const char pstrUsageACNo [] PROGMEM = "AC No"; -const char pstrUsageACCancel [] PROGMEM = "AC Cancel"; -const char pstrUsageACCatalog [] PROGMEM = "AC Ctlg"; -const char pstrUsageACBuyChkout [] PROGMEM = "AC Buy"; -const char pstrUsageACAddToCart [] PROGMEM = "AC Add2Cart"; -const char pstrUsageACExpand [] PROGMEM = "AC Xpnd"; -const char pstrUsageACExpandAll [] PROGMEM = "AC Xpand All"; -const char pstrUsageACCollapse [] PROGMEM = "AC Collapse"; -const char pstrUsageACCollapseAll [] PROGMEM = "AC Collapse All"; -const char pstrUsageACPrintPreview [] PROGMEM = "AC Prn Prevw"; -const char pstrUsageACPasteSpecial [] PROGMEM = "AC Paste Spec"; -const char pstrUsageACInsertMode [] PROGMEM = "AC Ins Mode"; -const char pstrUsageACDelete [] PROGMEM = "AC Del"; -const char pstrUsageACLock [] PROGMEM = "AC Lock"; -const char pstrUsageACUnlock [] PROGMEM = "AC Unlock"; -const char pstrUsageACProtect [] PROGMEM = "AC Prot"; -const char pstrUsageACUnprotect [] PROGMEM = "AC Unprot"; -const char pstrUsageACAttachComment [] PROGMEM = "AC Attach Cmnt"; -const char pstrUsageACDeleteComment [] PROGMEM = "AC Del Cmnt"; -const char pstrUsageACViewComment [] PROGMEM = "AC View Cmnt"; -const char pstrUsageACSelectWord [] PROGMEM = "AC Sel Word"; -const char pstrUsageACSelectSentence [] PROGMEM = "AC Sel Sntc"; -const char pstrUsageACSelectParagraph [] PROGMEM = "AC Sel Para"; -const char pstrUsageACSelectColumn [] PROGMEM = "AC Sel Col"; -const char pstrUsageACSelectRow [] PROGMEM = "AC Sel Row"; -const char pstrUsageACSelectTable [] PROGMEM = "AC Sel Tbl"; -const char pstrUsageACSelectObject [] PROGMEM = "AC Sel Obj"; -const char pstrUsageACRedoRepeat [] PROGMEM = "AC Redo"; -const char pstrUsageACSort [] PROGMEM = "AC Sort"; -const char pstrUsageACSortAscending [] PROGMEM = "AC Sort Asc"; -const char pstrUsageACSortDescending [] PROGMEM = "AC Sort Desc"; -const char pstrUsageACFilter [] PROGMEM = "AC Filt"; -const char pstrUsageACSetClock [] PROGMEM = "AC Set Clk"; -const char pstrUsageACViewClock [] PROGMEM = "AC View Clk"; -const char pstrUsageACSelectTimeZone [] PROGMEM = "AC Sel Time Z"; -const char pstrUsageACEditTimeZone [] PROGMEM = "AC Edt Time Z"; -const char pstrUsageACSetAlarm [] PROGMEM = "AC Set Alm"; -const char pstrUsageACClearAlarm [] PROGMEM = "AC Clr Alm"; -const char pstrUsageACSnoozeAlarm [] PROGMEM = "AC Snz Alm"; -const char pstrUsageACResetAlarm [] PROGMEM = "AC Rst Alm"; -const char pstrUsageACSyncronize [] PROGMEM = "AC Sync"; -const char pstrUsageACSendReceive [] PROGMEM = "AC Snd/Rcv"; -const char pstrUsageACSendTo [] PROGMEM = "AC Snd To"; -const char pstrUsageACReply [] PROGMEM = "AC Reply"; -const char pstrUsageACReplyAll [] PROGMEM = "AC Reply All"; -const char pstrUsageACForwardMessage [] PROGMEM = "AC Fwd Msg"; -const char pstrUsageACSend [] PROGMEM = "AC Snd"; -const char pstrUsageACAttachFile [] PROGMEM = "AC Att File"; -const char pstrUsageACUpload [] PROGMEM = "AC Upld"; -const char pstrUsageACDownload [] PROGMEM = "AC Dnld"; -const char pstrUsageACSetBorders [] PROGMEM = "AC Set Brd"; -const char pstrUsageACInsertRow [] PROGMEM = "AC Ins Row"; -const char pstrUsageACInsertColumn [] PROGMEM = "AC Ins Col"; -const char pstrUsageACInsertFile [] PROGMEM = "AC Ins File"; -const char pstrUsageACInsertPicture [] PROGMEM = "AC Ins Pic"; -const char pstrUsageACInsertObject [] PROGMEM = "AC Ins Obj"; -const char pstrUsageACInsertSymbol [] PROGMEM = "AC Ins Sym"; -const char pstrUsageACSaveAndClose [] PROGMEM = "AC Sav&Cls"; -const char pstrUsageACRename [] PROGMEM = "AC Rename"; -const char pstrUsageACMerge [] PROGMEM = "AC Merge"; -const char pstrUsageACSplit [] PROGMEM = "AC Split"; -const char pstrUsageACDistributeHorizontaly [] PROGMEM = "AC Dist Hor"; -const char pstrUsageACDistributeVerticaly [] PROGMEM = "AC Dist Ver"; - -// Digitaizers -const char pstrUsageDigitizer [] PROGMEM = "Digitizer"; -const char pstrUsagePen [] PROGMEM = "Pen"; -const char pstrUsageLightPen [] PROGMEM = "Light Pen"; -const char pstrUsageTouchScreen [] PROGMEM = "Touch Scr"; -const char pstrUsageTouchPad [] PROGMEM = "Touch Pad"; -const char pstrUsageWhiteBoard [] PROGMEM = "White Brd"; -const char pstrUsageCoordinateMeasuringMachine [] PROGMEM = "Coord Meas Mach"; -const char pstrUsage3DDigitizer [] PROGMEM = "3D Dgtz"; -const char pstrUsageStereoPlotter [] PROGMEM = "Stereo Plot"; -const char pstrUsageArticulatedArm [] PROGMEM = "Art Arm"; -const char pstrUsageArmature [] PROGMEM = "Armature"; -const char pstrUsageMultiplePointDigitizer [] PROGMEM = "Multi Point Dgtz"; -const char pstrUsageFreeSpaceWand [] PROGMEM = "Free Space Wand"; -const char pstrUsageStylus [] PROGMEM = "Stylus"; -const char pstrUsagePuck [] PROGMEM = "Puck"; -const char pstrUsageFinger [] PROGMEM = "Finger"; -const char pstrUsageTipPressure [] PROGMEM = "Tip Press"; -const char pstrUsageBarrelPressure [] PROGMEM = "Brl Press"; -const char pstrUsageInRange [] PROGMEM = "In Range"; -const char pstrUsageTouch [] PROGMEM = "Touch"; -const char pstrUsageUntouch [] PROGMEM = "Untouch"; -const char pstrUsageTap [] PROGMEM = "Tap"; -const char pstrUsageQuality [] PROGMEM = "Qlty"; -const char pstrUsageDataValid [] PROGMEM = "Data Valid"; -const char pstrUsageTransducerIndex [] PROGMEM = "Transducer Ind"; -const char pstrUsageTabletFunctionKeys [] PROGMEM = "Tabl Func Keys"; -const char pstrUsageProgramChangeKeys [] PROGMEM = "Pgm Chng Keys"; -//const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength"; -const char pstrUsageInvert [] PROGMEM = "Invert"; -const char pstrUsageXTilt [] PROGMEM = "X Tilt"; -const char pstrUsageYTilt [] PROGMEM = "Y Tilt"; -const char pstrUsageAzimuth [] PROGMEM = "Azimuth"; -const char pstrUsageAltitude [] PROGMEM = "Altitude"; -const char pstrUsageTwist [] PROGMEM = "Twist"; -const char pstrUsageTipSwitch [] PROGMEM = "Tip Sw"; -const char pstrUsageSecondaryTipSwitch [] PROGMEM = "Scnd Tip Sw"; -const char pstrUsageBarrelSwitch [] PROGMEM = "Brl Sw"; -const char pstrUsageEraser [] PROGMEM = "Eraser"; -const char pstrUsageTabletPick [] PROGMEM = "Tbl Pick"; - -// Alphanumeric Display Page -const char pstrUsageAlphanumericDisplay [] PROGMEM = "Alphanum Disp"; -const char pstrUsageBitmappedDisplay [] PROGMEM = "Bmp Disp"; -const char pstrUsageDisplayAttributesReport [] PROGMEM = "Disp Attr Rpt"; -const char pstrUsageASCIICharacterSet [] PROGMEM = "ASCII chset"; -const char pstrUsageDataReadBack [] PROGMEM = "Data Rd Back"; -const char pstrUsageFontReadBack [] PROGMEM = "Fnt Rd Back"; -const char pstrUsageDisplayControlReport [] PROGMEM = "Disp Ctrl Rpt"; -const char pstrUsageClearDisplay [] PROGMEM = "Clr Disp"; -//const char pstrUsageDisplayEnable [] PROGMEM = "Disp Enbl"; -const char pstrUsageScreenSaverDelay [] PROGMEM = "Scr Sav Delay"; -const char pstrUsageScreenSaverEnable [] PROGMEM = "Scr Sav Enbl"; -const char pstrUsageVerticalScroll [] PROGMEM = "V Scroll"; -const char pstrUsageHorizontalScroll [] PROGMEM = "H Scroll"; -const char pstrUsageCharacterReport [] PROGMEM = "Char Rpt"; -const char pstrUsageDisplayData [] PROGMEM = "Disp Data"; -const char pstrUsageDisplayStatus [] PROGMEM = "Disp Stat"; -const char pstrUsageStatusNotReady [] PROGMEM = "Stat !Ready"; -const char pstrUsageStatusReady [] PROGMEM = "Stat Ready"; -const char pstrUsageErrorNotALoadableCharacter [] PROGMEM = "Err Not Ld Char"; -const char pstrUsageErrorFotDataCanNotBeRead [] PROGMEM = "Fnt Data Rd Err"; -const char pstrUsageCursorPositionReport [] PROGMEM = "Cur Pos Rpt"; -const char pstrUsageRow [] PROGMEM = "Row"; -const char pstrUsageColumn [] PROGMEM = "Col"; -const char pstrUsageRows [] PROGMEM = "Rows"; -const char pstrUsageColumns [] PROGMEM = "Cols"; -const char pstrUsageCursorPixelPosition [] PROGMEM = "Cur Pix Pos"; -const char pstrUsageCursorMode [] PROGMEM = "Cur Mode"; -const char pstrUsageCursorEnable [] PROGMEM = "Cur Enbl"; -const char pstrUsageCursorBlink [] PROGMEM = "Cur Blnk"; -const char pstrUsageFontReport [] PROGMEM = "Fnt Rpt"; -const char pstrUsageFontData [] PROGMEM = "Fnt Data"; -const char pstrUsageCharacterWidth [] PROGMEM = "Char Wdth"; -const char pstrUsageCharacterHeight [] PROGMEM = "Char Hght"; -const char pstrUsageCharacterSpacingHorizontal [] PROGMEM = "Char Space H"; -const char pstrUsageCharacterSpacingVertical [] PROGMEM = "Char Space V"; -const char pstrUsageUnicodeCharset [] PROGMEM = "Unicode Char"; -const char pstrUsageFont7Segment [] PROGMEM = "Fnt 7-seg"; -const char pstrUsage7SegmentDirectMap [] PROGMEM = "7-seg map"; -const char pstrUsageFont14Segment [] PROGMEM = "Fnt 14-seg"; -const char pstrUsage14SegmentDirectMap [] PROGMEM = "14-seg map"; -const char pstrUsageDisplayBrightness [] PROGMEM = "Disp Bright"; -const char pstrUsageDisplayContrast [] PROGMEM = "Disp Cntrst"; -const char pstrUsageCharacterAttribute [] PROGMEM = "Char Attr"; -const char pstrUsageAttributeReadback [] PROGMEM = "Attr Readbk"; -const char pstrUsageAttributeData [] PROGMEM = "Attr Data"; -const char pstrUsageCharAttributeEnhance [] PROGMEM = "Char Attr Enh"; -const char pstrUsageCharAttributeUnderline [] PROGMEM = "Char Attr Undl"; -const char pstrUsageCharAttributeBlink [] PROGMEM = "Char Attr Blnk"; -const char pstrUsageBitmapSizeX [] PROGMEM = "Bmp Size X"; -const char pstrUsageBitmapSizeY [] PROGMEM = "Bmp Size Y"; -const char pstrUsageBitDepthFormat [] PROGMEM = "Bit Dpth Fmt"; -const char pstrUsageDisplayOrientation [] PROGMEM = "Disp Ornt"; -const char pstrUsagePaletteReport [] PROGMEM = "Pal Rpt"; -const char pstrUsagePaletteDataSize [] PROGMEM = "Pal Data Size"; -const char pstrUsagePaletteDataOffset [] PROGMEM = "Pal Data Off"; -const char pstrUsagePaletteData [] PROGMEM = "Pal Data"; -const char pstrUsageBlitReport [] PROGMEM = "Blit Rpt"; -const char pstrUsageBlitRectangleX1 [] PROGMEM = "Blit Rect X1"; -const char pstrUsageBlitRectangleY1 [] PROGMEM = "Blit Rect Y1"; -const char pstrUsageBlitRectangleX2 [] PROGMEM = "Blit Rect X2"; -const char pstrUsageBlitRectangleY2 [] PROGMEM = "Blit Rect Y2"; -const char pstrUsageBlitData [] PROGMEM = "Blit Data"; -const char pstrUsageSoftButton [] PROGMEM = "Soft Btn"; -const char pstrUsageSoftButtonID [] PROGMEM = "Soft Btn ID"; -const char pstrUsageSoftButtonSide [] PROGMEM = "Soft Btn Side"; -const char pstrUsageSoftButtonOffset1 [] PROGMEM = "Soft Btn Off1"; -const char pstrUsageSoftButtonOffset2 [] PROGMEM = "Soft Btn Off2"; -const char pstrUsageSoftButtonReport [] PROGMEM = "Soft Btn Rpt"; - -// Medical Instrument Page -const char pstrUsageMedicalUltrasound [] PROGMEM = "Med Ultrasnd"; -const char pstrUsageVCRAcquisition [] PROGMEM = "VCR/Acq"; -const char pstrUsageFreezeThaw [] PROGMEM = "Freeze"; -const char pstrUsageClipStore [] PROGMEM = "Clip Store"; -const char pstrUsageUpdate [] PROGMEM = "Update"; -const char pstrUsageNext [] PROGMEM = "Next"; -const char pstrUsageSave [] PROGMEM = "Save"; -const char pstrUsagePrint [] PROGMEM = "Print"; -const char pstrUsageMicrophoneEnable [] PROGMEM = "Mic Enbl"; -const char pstrUsageCine [] PROGMEM = "Cine"; -const char pstrUsageTransmitPower [] PROGMEM = "Trans Pwr"; -//const char pstrUsageVolume [] PROGMEM = "Vol"; -const char pstrUsageFocus [] PROGMEM = "Focus"; -const char pstrUsageDepth [] PROGMEM = "Depth"; -const char pstrUsageSoftStepPrimary [] PROGMEM = "Soft Stp-Pri"; -const char pstrUsageSoftStepSecondary [] PROGMEM = "Soft Stp-Sec"; -const char pstrUsageDepthGainCompensation [] PROGMEM = "Dpth Gain Comp"; -const char pstrUsageZoomSelect [] PROGMEM = "Zoom Sel"; -const char pstrUsageZoomAdjust [] PROGMEM = "Zoom Adj"; -const char pstrUsageSpectralDopplerModeSelect [] PROGMEM = "Spec Dop Mode Sel"; -const char pstrUsageSpectralDopplerModeAdjust [] PROGMEM = "Spec Dop Mode Adj"; -const char pstrUsageColorDopplerModeSelect [] PROGMEM = "Color Dop Mode Sel"; -const char pstrUsageColorDopplerModeAdjust [] PROGMEM = "Color Dop Mode Adj"; -const char pstrUsageMotionModeSelect [] PROGMEM = "Motion Mode Sel"; -const char pstrUsageMotionModeAdjust [] PROGMEM = "Motion Mode Adj"; -const char pstrUsage2DModeSelect [] PROGMEM = "2D Mode Sel"; -const char pstrUsage2DModeAdjust [] PROGMEM = "2D Mode Adj"; -const char pstrUsageSoftControlSelect [] PROGMEM = "Soft Ctrl Sel"; -const char pstrUsageSoftControlAdjust [] PROGMEM = "Soft Ctrl Adj"; - -//extern const char *usagePageTitles0[15]; -//const char *usagePageTitles1[]; -//const char *genDesktopTitles0[]; -//const char *genDesktopTitles1[]; -//const char *genDesktopTitles2[]; -//const char *genDesktopTitles3[]; -//const char *genDesktopTitles4[]; -//const char *simuTitles0[]; -//const char *simuTitles1[]; -//const char *simuTitles2[]; -//const char *vrTitles0[]; -//const char *vrTitles1[]; -//const char *sportsCtrlTitles0[]; -//const char *sportsCtrlTitles1[]; -//const char *sportsCtrlTitles2[]; -//const char *gameTitles0[]; -//const char *gameTitles1[]; -//const char *genDevCtrlTitles[]; -//const char *ledTitles[]; -//const char *telTitles0[]; -//const char *telTitles1[]; -//const char *telTitles2[]; -//const char *telTitles3[]; -//const char *telTitles4[]; -//const char *telTitles5[]; -//const char *consTitles0[]; -//const char *consTitles1[]; -//const char *consTitles2[]; -//const char *consTitles3[]; -//const char *consTitles4[]; -//const char *consTitles5[]; -//const char *consTitles6[]; -//const char *consTitles7[]; -//const char *consTitles8[]; -//const char *consTitles9[]; -//const char *consTitlesA[]; -//const char *consTitlesB[]; -//const char *consTitlesC[]; -//const char *consTitlesD[]; -//const char *consTitlesE[]; -//const char *digitTitles0[]; -//const char *digitTitles1[]; -//const char *digitTitles2[]; -//const char *aplphanumTitles0[]; -//const char *aplphanumTitles1[]; -//const char *aplphanumTitles2[]; -//const char *medInstrTitles0[]; -//const char *medInstrTitles1[]; -//const char *medInstrTitles2[]; -//const char *medInstrTitles3[]; -//const char *medInstrTitles4[]; - -#endif //__HIDUSAGESTR_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/macros.h b/legacy/builder/test/libraries/USBHost/src/macros.h deleted file mode 100644 index 5df3faff8ab..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/macros.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(MACROS_H) -#error "Never include macros.h directly; include Usb.h instead" -#else -#define MACROS_H - -//////////////////////////////////////////////////////////////////////////////// -// HANDY MACROS -//////////////////////////////////////////////////////////////////////////////// - -#define VALUE_BETWEEN(v,l,h) (((v)>(l)) && ((v)<(h))) -#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h))) -#define output_pgm_message(wa,fp,mp,el) wa = &mp, fp((char *)/*pgm_read_pointer*/(wa), el) -#define output_if_between(v,l,h,wa,fp,mp,el) if(VALUE_BETWEEN(v,l,h)) output_pgm_message(wa,fp,mp[v-(l+1)],el); - -#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) -#ifndef __BYTE_GRABBING_DEFINED__ -#define __BYTE_GRABBING_DEFINED__ 1 -#ifdef BROKEN_OPTIMIZER_LITTLE_ENDIAN -// Note: Use this if your compiler generates horrible assembler! -#define BGRAB0(__usi__) (((uint8_t *)&(__usi__))[0]) -#define BGRAB1(__usi__) (((uint8_t *)&(__usi__))[1]) -#define BGRAB2(__usi__) (((uint8_t *)&(__usi__))[2]) -#define BGRAB3(__usi__) (((uint8_t *)&(__usi__))[3]) -#define BGRAB4(__usi__) (((uint8_t *)&(__usi__))[4]) -#define BGRAB5(__usi__) (((uint8_t *)&(__usi__))[5]) -#define BGRAB6(__usi__) (((uint8_t *)&(__usi__))[6]) -#define BGRAB7(__usi__) (((uint8_t *)&(__usi__))[7]) -#else -// Note: The cast alone to uint8_t is actually enough. -// GCC throws out the "& 0xff", and the size is no different. -// Some compilers need it. -#define BGRAB0(__usi__) ((uint8_t)((__usi__) & 0xff )) -#define BGRAB1(__usi__) ((uint8_t)(((__usi__) >> 8) & 0xff)) -#define BGRAB2(__usi__) ((uint8_t)(((__usi__) >> 16) & 0xff)) -#define BGRAB3(__usi__) ((uint8_t)(((__usi__) >> 24) & 0xff)) -#define BGRAB4(__usi__) ((uint8_t)(((__usi__) >> 32) & 0xff)) -#define BGRAB5(__usi__) ((uint8_t)(((__usi__) >> 40) & 0xff)) -#define BGRAB6(__usi__) ((uint8_t)(((__usi__) >> 48) & 0xff)) -#define BGRAB7(__usi__) ((uint8_t)(((__usi__) >> 56) & 0xff)) -#endif -#define BOVER1(__usi__) ((uint16_t)(__usi__) << 8) -#define BOVER2(__usi__) ((uint32_t)(__usi__) << 16) -#define BOVER3(__usi__) ((uint32_t)(__usi__) << 24) -#define BOVER4(__usi__) ((uint64_t)(__usi__) << 32) -#define BOVER5(__usi__) ((uint64_t)(__usi__) << 40) -#define BOVER6(__usi__) ((uint64_t)(__usi__) << 48) -#define BOVER7(__usi__) ((uint64_t)(__usi__) << 56) - -// These are the smallest and fastest ways I have found so far in pure C/C++. -#define BMAKE16(__usc1__,__usc0__) ((uint16_t)((uint16_t)(__usc0__) | (uint16_t)BOVER1(__usc1__))) -#define BMAKE32(__usc3__,__usc2__,__usc1__,__usc0__) ((uint32_t)((uint32_t)(__usc0__) | (uint32_t)BOVER1(__usc1__) | (uint32_t)BOVER2(__usc2__) | (uint32_t)BOVER3(__usc3__))) -#define BMAKE64(__usc7__,__usc6__,__usc5__,__usc4__,__usc3__,__usc2__,__usc1__,__usc0__) ((uint64_t)((uint64_t)__usc0__ | (uint64_t)BOVER1(__usc1__) | (uint64_t)BOVER2(__usc2__) | (uint64_t)BOVER3(__usc3__) | (uint64_t)BOVER4(__usc4__) | (uint64_t)BOVER5(__usc5__) | (uint64_t)BOVER6(__usc6__) | (uint64_t)BOVER1(__usc7__))) -#endif - -/* - * Debug macros: Strings are stored in progmem (flash) instead of RAM. - */ -#define USBTRACE(s) (Notify(PSTR(s), 0x80)) -#define USBTRACE1(s,l) (Notify(PSTR(s), l)) -#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80)) -#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l)) - - -#endif /* MACROS_H */ - diff --git a/legacy/builder/test/libraries/USBHost/src/message.cpp b/legacy/builder/test/libraries/USBHost/src/message.cpp deleted file mode 100644 index bdcdd18331c..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/message.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "Usb.h" -// 0x80 is the default (i.e. trace) to turn off set this global to something lower. -// this allows for 126 other debugging levels. -// TO-DO: Allow assignment to a different serial port by software -int UsbDEBUGlvl = 0x80; - -void E_Notifyc(char c, int lvl) { - if(UsbDEBUGlvl < lvl) return; -#if defined(ARDUINO) && ARDUINO >=100 - USB_HOST_SERIAL.print(c); -#else - USB_HOST_SERIAL.print(c, BYTE); -#endif - //USB_HOST_SERIAL.flush(); -} - -void E_Notify(char const * msg, int lvl) { - if(UsbDEBUGlvl < lvl) return; - if(!msg) return; - char c; - - while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl); -} - -void E_NotifyStr(char const * msg, int lvl) { - if(UsbDEBUGlvl < lvl) return; - if(!msg) return; - char c; - - while((c = *msg++)) E_Notifyc(c, lvl); -} - -void E_Notify(uint8_t b, int lvl) { - if(UsbDEBUGlvl < lvl) return; -#if defined(ARDUINO) && ARDUINO >=100 - USB_HOST_SERIAL.print(b); -#else - USB_HOST_SERIAL.print(b, DEC); -#endif - //USB_HOST_SERIAL.flush(); -} - -void E_Notify(double d, int lvl) { - if(UsbDEBUGlvl < lvl) return; - USB_HOST_SERIAL.print(d); - //USB_HOST_SERIAL.flush(); -} - -#ifdef DEBUG_USB_HOST - -void NotifyFailGetDevDescr(void) { - Notify(PSTR("\r\ngetDevDescr "), 0x80); -} - -void NotifyFailSetDevTblEntry(void) { - Notify(PSTR("\r\nsetDevTblEn "), 0x80); -} - -void NotifyFailGetConfDescr(void) { - Notify(PSTR("\r\ngetConf "), 0x80); -} - -void NotifyFailSetConfDescr(void) { - Notify(PSTR("\r\nsetConf "), 0x80); -} - -void NotifyFailGetDevDescr(uint8_t reason) { - NotifyFailGetDevDescr(); - NotifyFail(reason); -} - -void NotifyFailSetDevTblEntry(uint8_t reason) { - NotifyFailSetDevTblEntry(); - NotifyFail(reason); - -} - -void NotifyFailGetConfDescr(uint8_t reason) { - NotifyFailGetConfDescr(); - NotifyFail(reason); -} - -void NotifyFailSetConfDescr(uint8_t reason) { - NotifyFailSetConfDescr(); - NotifyFail(reason); -} - -void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) { - Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); - D_PrintHex (VID, 0x80); - Notify(PSTR(" PID: "), 0x80); - D_PrintHex (PID, 0x80); -} - -void NotifyFail(uint8_t rcode) { - D_PrintHex (rcode, 0x80); - Notify(PSTR("\r\n"), 0x80); -} -#endif diff --git a/legacy/builder/test/libraries/USBHost/src/message.h b/legacy/builder/test/libraries/USBHost/src/message.h deleted file mode 100644 index c26628e7f28..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/message.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__MESSAGE_H__) -#error "Never include message.h directly; include Usb.h instead" -#else -#define __MESSAGE_H__ - -extern int UsbDEBUGlvl; - -void E_Notify(char const * msg, int lvl); -void E_Notify(uint8_t b, int lvl); -void E_NotifyStr(char const * msg, int lvl); -void E_Notifyc(char c, int lvl); - -#ifdef DEBUG_USB_HOST -#define Notify E_Notify -#define NotifyStr E_NotifyStr -#define Notifyc E_Notifyc -void NotifyFailGetDevDescr(uint8_t reason); -void NotifyFailSetDevTblEntry(uint8_t reason); -void NotifyFailGetConfDescr(uint8_t reason); -void NotifyFailSetConfDescr(uint8_t reason); -void NotifyFailGetDevDescr(void); -void NotifyFailSetDevTblEntry(void); -void NotifyFailGetConfDescr(void); -void NotifyFailSetConfDescr(void); -void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); -void NotifyFail(uint8_t rcode); -#else -#define Notify(...) ((void)0) -#define NotifyStr(...) ((void)0) -#define Notifyc(...) ((void)0) -#define NotifyFailGetDevDescr(...) ((void)0) -#define NotifyFailSetDevTblEntry(...) ((void)0) -#define NotifyFailGetConfDescr(...) ((void)0) -#define NotifyFailGetDevDescr(...) ((void)0) -#define NotifyFailSetDevTblEntry(...) ((void)0) -#define NotifyFailGetConfDescr(...) ((void)0) -#define NotifyFailSetConfDescr(...) ((void)0) -#define NotifyFailUnknownDevice(...) ((void)0) -#define NotifyFail(...) ((void)0) -#endif - -template -void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG_USB_HOST - Notify(msg, level); - Notify(PSTR(": "), level); - D_PrintHex (rcode, level); - Notify(PSTR("\r\n"), level); -#endif -} - -template -void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG_USB_HOST - Notify(msg, 0x80); - Notify(PSTR(": "), 0x80); - D_PrintHex (rcode, 0x80); - Notify(PSTR("\r\n"), 0x80); -#endif -} - -#endif // __MESSAGE_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/parsetools.cpp b/legacy/builder/test/libraries/USBHost/src/parsetools.cpp deleted file mode 100644 index 00ca9e6427f..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/parsetools.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ -#include "Usb.h" - -bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { - if(!pBuf) { - Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); - return false; - } - for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) - pBuf[valueSize - countDown] = (**pp); - - if(countDown) - return false; - - countDown = valueSize; - return true; -} - -bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { - switch(nStage) { - case 0: - pBuf->valueSize = lenSize; - theParser.Initialize(pBuf); - nStage = 1; - - case 1: - if(!theParser.Parse(pp, pcntdn)) - return false; - - arLen = 0; - arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); - arLenCntdn = arLen; - nStage = 2; - - case 2: - pBuf->valueSize = valSize; - theParser.Initialize(pBuf); - nStage = 3; - - case 3: - for(; arLenCntdn; arLenCntdn--) { - if(!theParser.Parse(pp, pcntdn)) - return false; - - if(pf) - pf(pBuf, (arLen - arLenCntdn), me); - } - - nStage = 0; - } - return true; -} diff --git a/legacy/builder/test/libraries/USBHost/src/parsetools.h b/legacy/builder/test/libraries/USBHost/src/parsetools.h deleted file mode 100644 index d463358913f..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/parsetools.h +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -#if !defined(_usb_h_) || defined(__PARSETOOLS_H__) -#error "Never include parsetools.h directly; include Usb.h instead" -#else -#define __PARSETOOLS_H__ - -#include -//#include "Arduino.h" - -struct MultiValueBuffer { - uint8_t valueSize; - void *pValue; -}; - -class MultiByteValueParser { - uint8_t *pBuf; - uint32_t countDown; - uint32_t valueSize; - -public: - - MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { - }; - - const uint8_t* GetBuffer() { - return pBuf; - }; - - void Initialize(MultiValueBuffer * const pbuf) { - pBuf = (uint8_t*)pbuf->pValue; - countDown = valueSize = pbuf->valueSize; - }; - - bool Parse(uint8_t **pp, uint32_t *pcntdn); -}; - -class ByteSkipper { - uint8_t *pBuf; - uint32_t nStage; - uint32_t countDown; - -public: - - ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) { - }; - - void Initialize(MultiValueBuffer *pbuf) { - pBuf = (uint8_t*)pbuf->pValue; - countDown = 0; - }; - - bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) { - switch(nStage) { - case 0: - countDown = bytes_to_skip; - nStage++; - case 1: - for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); - - if(!countDown) - nStage = 0; - }; - return (!countDown); - }; -}; - -// Pointer to a callback function triggered for each element of PTP array when used with PTPArrayParser -typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t count, const void *me); - -class PTPListParser { -public: - - enum ParseMode { - modeArray, modeRange/*, modeEnum*/ - }; - -private: - uint32_t nStage; - uint32_t enStage; - - uint32_t arLen; - uint32_t arLenCntdn; - - uint32_t lenSize; // size of the array length field in bytes - uint32_t valSize; // size of the array element in bytes - - MultiValueBuffer *pBuf; - - // The only parser for both size and array element parsing - MultiByteValueParser theParser; - - uint32_t /*ParseMode*/ prsMode; - -public: - - PTPListParser() : - nStage(0), - enStage(0), - arLen(0), - arLenCntdn(0), - lenSize(0), - valSize(0), - pBuf(NULL), - prsMode(modeArray) { - }; - - void Initialize(const uint32_t len_size, const uint32_t val_size, MultiValueBuffer * const p, const uint32_t mode = modeArray) { - pBuf = p; - lenSize = len_size; - valSize = val_size; - prsMode = mode; - - if(prsMode == modeRange) { - arLenCntdn = arLen = 3; - nStage = 2; - } else { - arLenCntdn = arLen = 0; - nStage = 0; - } - enStage = 0; - theParser.Initialize(p); - }; - - bool Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = NULL); -}; - -#endif // __PARSETOOLS_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/printhex.h b/legacy/builder/test/libraries/USBHost/src/printhex.h deleted file mode 100644 index 369d7e1f7eb..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/printhex.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(__PRINTHEX_H__) -#error "Never include printhex.h directly; include Usb.h instead" -#else -#define __PRINTHEX_H__ - -void E_Notifyc(char c, int lvl); - -template -void PrintHex(T val, int lvl) { - int num_nibbles = sizeof (T) * 2; - - do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); - if(v > 57) v += 7; - E_Notifyc(v, lvl); - } while(--num_nibbles); -} - -template -void PrintBin(T val, int lvl) { - for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) - if(val & mask) - E_Notifyc('1', lvl); - else - E_Notifyc('0', lvl); -} - -template -void SerialPrintHex(T val) { - int num_nibbles = sizeof (T) * 2; - - do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); - if(v > 57) v += 7; - USB_HOST_SERIAL.print(v); - } while(--num_nibbles); -} - -template -void PrintHex2(Print *prn, T val) { - T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); - - while(mask > 1) { - if(val < mask) - prn->print("0"); - - mask >>= 4; - } - prn->print((T)val, HEX); -} - -template void D_PrintHex(T val, int lvl) { -#ifdef DEBUG_USB_HOST - PrintHex (val, lvl); -#endif -} - -template -void D_PrintBin(T val, int lvl) { -#ifdef DEBUG_USB_HOST - PrintBin (val, lvl); -#endif -} - - - -#endif // __PRINTHEX_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/sink_parser.h b/legacy/builder/test/libraries/USBHost/src/sink_parser.h deleted file mode 100644 index a23637d2b74..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/sink_parser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__SINK_PARSER_H__) -#error "Never include hexdump.h directly; include Usb.h instead" -#else -#define __SINK_PARSER_H__ - -extern int UsbDEBUGlvl; - -// This parser does absolutely nothing with the data, just swallows it. - -template -class SinkParser : public BASE_CLASS { -public: - - SinkParser() { - }; - - void Initialize() { - }; - - void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { - }; -}; - - -#endif // __HEXDUMP_H__ diff --git a/legacy/builder/test/libraries/USBHost/src/usb_ch9.h b/legacy/builder/test/libraries/USBHost/src/usb_ch9.h deleted file mode 100644 index 09dd94b9b46..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/usb_ch9.h +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com -*/ - -#if !defined(_usb_h_) || defined(_ch9_h_) -#error "Never include usb_ch9.h directly; include Usb.h instead" -#else - -/* USB chapter 9 structures */ -#define _ch9_h_ - -#include - -/* Misc.USB constants */ -#define DEV_DESCR_LEN 18 //device descriptor length -#define CONF_DESCR_LEN 9 //configuration descriptor length -#define INTR_DESCR_LEN 9 //interface descriptor length -#define EP_DESCR_LEN 7 //endpoint descriptor length - -/* Standard Device Requests */ - -#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS -#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE -#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE -#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS -#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR -#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR -#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION -#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION -#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE -#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE -#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME - -#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt -#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up -#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode - -/* Setup Data Constants */ - -#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer -#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer -#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard -#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class -#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor -#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device -#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface -#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint -#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other - -/* USB descriptors */ - -#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. -#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. -#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. -#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. -#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. -#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. -#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. -#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. -#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. - -#define HID_DESCRIPTOR_HID 0x21 - - - -/* OTG SET FEATURE Constants */ -#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP -#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP -#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP - -/* USB Endpoint Transfer Types */ -#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. -#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. -#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. -#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. -#define bmUSB_TRANSFER_TYPE 0x03 // bit mask to separate transfer type from ISO attributes - - -/* Standard Feature Selectors for CLEAR_FEATURE Requests */ -#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient -#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient -#define USB_FEATURE_TEST_MODE 2 // Device recipient - -_Pragma("pack(1)") - -/* descriptor data structures */ - -/* Device descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). - uint16_t bcdUSB; // USB Spec Release Number (BCD). - uint8_t bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bDeviceSubClass; // Subclass code (assigned by the USB-IF). - uint8_t bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bMaxPacketSize0; // Maximum packet size for endpoint 0. - uint16_t idVendor; // Vendor ID (assigned by the USB-IF). - uint16_t idProduct; // Product ID (assigned by the manufacturer). - uint16_t bcdDevice; // Device release number (BCD). - uint8_t iManufacturer; // Index of String Descriptor describing the manufacturer. - uint8_t iProduct; // Index of String Descriptor describing the product. - uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. - uint8_t bNumConfigurations; // Number of possible configurations. -} USB_DEVICE_DESCRIPTOR; - -/* Configuration descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). - uint16_t wTotalLength; // Total length of all descriptors for this configuration. - uint8_t bNumInterfaces; // Number of interfaces in this configuration. - uint8_t bConfigurationValue; // Value of this configuration (1 based). - uint8_t iConfiguration; // Index of String Descriptor describing the configuration. - uint8_t bmAttributes; // Configuration characteristics. - uint8_t bMaxPower; // Maximum power consumed by this configuration. -} USB_CONFIGURATION_DESCRIPTOR; - -/* Interface descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). - uint8_t bInterfaceNumber; // Number of this interface (0 based). - uint8_t bAlternateSetting; // Value of this alternate interface setting. - uint8_t bNumEndpoints; // Number of endpoints in this interface. - uint8_t bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). - uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t iInterface; // Index of String Descriptor describing the interface. -} USB_INTERFACE_DESCRIPTOR; - -/* Endpoint descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). - uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). - uint8_t bmAttributes; // Endpoint transfer type. - uint16_t wMaxPacketSize; // Maximum packet size. - uint8_t bInterval; // Polling interval in frames. -} USB_ENDPOINT_DESCRIPTOR; - - -/* HID descriptor */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - uint16_t bcdHID; // HID class specification release - uint8_t bCountryCode; - uint8_t bNumDescriptors; // Number of additional class specific descriptors - uint8_t bDescrType; // Type of class descriptor - uint16_t wDescriptorLength; // Total size of the Report descriptor -} USB_HID_DESCRIPTOR; - -typedef struct { - uint8_t bDescrType; // Type of class descriptor - uint16_t wDescriptorLength; // Total size of the Report descriptor -} HID_CLASS_DESCRIPTOR_LEN_AND_TYPE; - -_Pragma("pack()") - -#endif // _ch9_h_ - diff --git a/legacy/builder/test/libraries/USBHost/src/usbhub.cpp b/legacy/builder/test/libraries/USBHost/src/usbhub.cpp deleted file mode 100644 index 55d5bc1f1c4..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/usbhub.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "usbhub.h" -#include "delay.h" - -bool USBHub::bResetInitiated = false; - -USBHub::USBHub(USBHost *p) : -pUsb(p), -bAddress(0), -bNbrPorts(0), -//bInitState(0), -qNextPollTime(0), -bPollEnable(false) { - epInfo[0].epAddr = 0; - epInfo[0].maxPktSize = 8; - epInfo[0].epAttribs = 0; - epInfo[0].bmNakPower = USB_NAK_MAX_POWER; - - epInfo[1].epAddr = 1; - epInfo[1].maxPktSize = 8; //kludge - epInfo[1].epAttribs = 0; - epInfo[1].bmNakPower = USB_NAK_NOWAIT; - - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint32_t USBHub::Init(uint32_t parent, uint32_t port, uint32_t lowspeed) { - uint8_t buf[32]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - HubDescriptor* hd = reinterpret_cast(buf); - USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast(buf); - uint32_t rcode; - UsbDeviceDefinition *p = NULL; - EpInfo *oldep_ptr = NULL; - uint32_t len = 0; - uint32_t cd_len = 0; - - //USBTRACE("\r\nHub Init Start "); - //D_PrintHex (bInitState, 0x80); - - AddressPool &addrPool = pUsb->GetAddressPool(); - - //switch (bInitState) { - // case 0: - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf); - - p->lowspeed = false; - - if(!rcode) - len = (buf[0] > 32) ? 32 : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - return rcode; - } - - // Extract device class from device descriptor - // If device class is not a hub return - if(udd->bDeviceClass != 0x09) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, (udd->bDeviceClass == 0x09) ? true : false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - addrPool.FreeAddress(bAddress); - bAddress = 0; - return rcode; - } - - //USBTRACE2("\r\nHub address: ", bAddress ); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 2, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - // bInitState = 1; - - // case 1: - // Get hub descriptor - rcode = GetHubDescriptor(0, 8, buf); - - if(rcode) - goto FailGetHubDescr; - - // Save number of ports for future use - bNbrPorts = hd->bNbrPorts; - - // bInitState = 2; - - // case 2: - // Read configuration Descriptor in Order To Obtain Proper Configuration Value - rcode = pUsb->getConfDescr(bAddress, 0, 8, 0, buf); - - if(!rcode) { - cd_len = ucd->wTotalLength; - rcode = pUsb->getConfDescr(bAddress, 0, cd_len, 0, buf); - } - if(rcode) - goto FailGetConfDescr; - - // The following code is of no practical use in real life applications. - // It only intended for the usb protocol sniffer to properly parse hub-class requests. - { - uint8_t buf2[24]; - - rcode = pUsb->getConfDescr(bAddress, 0, buf[0], 0, buf2); - - if(rcode) - goto FailGetConfDescr; - } - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, buf[5]); - - if(rcode) - goto FailSetConfDescr; - - // bInitState = 3; - - // case 3: - // Power on all ports - for(uint32_t j = 1; j <= bNbrPorts; j++) - SetPortFeature(HUB_FEATURE_PORT_POWER, j, 0); //HubPortPowerOn(j); - - pUsb->SetHubPreMask(); - bPollEnable = true; - // bInitState = 0; - //} - //bInitState = 0; - //USBTRACE("...OK\r\n"); - return 0; - - // Oleg, No debugging?? -- xxxajk -FailGetDevDescr: - goto Fail; - -FailSetDevTblEntry: - goto Fail; - -FailGetHubDescr: - goto Fail; - -FailGetConfDescr: - goto Fail; - -FailSetConfDescr: - goto Fail; - -Fail: - USBTRACE("...FAIL\r\n"); - return rcode; -} - -uint32_t USBHub::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - if(bAddress == 0x41) - pUsb->SetHubPreMask(); - - bAddress = 0; - bNbrPorts = 0; - qNextPollTime = 0; - bPollEnable = false; - return 0; -} - -uint32_t USBHub::Poll() { - uint32_t rcode = 0; - - if(!bPollEnable) - return 0; - - if(((long)(millis() - qNextPollTime) >= 0L)) { - rcode = CheckHubStatus(); - qNextPollTime = millis() + 100; - } - return rcode; -} - -uint32_t USBHub::CheckHubStatus() { - uint32_t rcode; - uint8_t buf[8]; - uint32_t read = 1; - - rcode = pUsb->inTransfer(bAddress, 1, (uint8_t*)&read, buf); - - if(rcode) - return rcode; - - //if (buf[0] & 0x01) // Hub Status Change - //{ - // pUsb->PrintHubStatus(addr); - // rcode = GetHubStatus(1, 0, 1, 4, buf); - // if (rcode) - // { - // USB_HOST_SERIAL.print("GetHubStatus Error"); - // USB_HOST_SERIAL.println(rcode, HEX); - // return rcode; - // } - //} - for(uint32_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) { - if(buf[0] & mask) { - HubEvent evt; - evt.bmEvent = 0; - - rcode = GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) - continue; - - rcode = PortStatusChange(port, evt); - - if(rcode == HUB_ERROR_PORT_HAS_BEEN_RESET) - return 0; - - if(rcode) - return rcode; - } - } // for - - for(uint32_t port = 1; port <= bNbrPorts; port++) { - HubEvent evt; - evt.bmEvent = 0; - - rcode = GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) - continue; - - if((evt.bmStatus & bmHUB_PORT_STATE_CHECK_DISABLED) != bmHUB_PORT_STATE_DISABLED) - continue; - - // Emulate connection event for the port - evt.bmChange |= bmHUB_PORT_STATUS_C_PORT_CONNECTION; - - rcode = PortStatusChange(port, evt); - - if(rcode == HUB_ERROR_PORT_HAS_BEEN_RESET) - return 0; - - if(rcode) - return rcode; - } // for - return 0; -} - -void USBHub::ResetHubPort(uint32_t port) { - HubEvent evt; - evt.bmEvent = 0; - uint8_t rcode; - - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - SetPortFeature(HUB_FEATURE_PORT_RESET, port, 0); - - - for(int i = 0; i < 3; i++) { - rcode = GetPortStatus(port, 4, evt.evtBuff); - if(rcode) break; // Some kind of error, bail. - if(evt.bmEvent == bmHUB_PORT_EVENT_RESET_COMPLETE || evt.bmEvent == bmHUB_PORT_EVENT_LS_RESET_COMPLETE) { - break; - } - delay(100); // simulate polling. - } - ClearPortFeature(HUB_FEATURE_C_PORT_RESET, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - delay(20); -} - -uint32_t USBHub::PortStatusChange(uint32_t port, HubEvent &evt) { - switch(evt.bmEvent) { - // Device connected event - case bmHUB_PORT_EVENT_CONNECT: - case bmHUB_PORT_EVENT_LS_CONNECT: - if(bResetInitiated) - return 0; - - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - SetPortFeature(HUB_FEATURE_PORT_RESET, port, 0); - bResetInitiated = true; - return HUB_ERROR_PORT_HAS_BEEN_RESET; - - // Device disconnected event - case bmHUB_PORT_EVENT_DISCONNECT: - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - bResetInitiated = false; - - UsbDeviceAddress a; - a.devAddress = 0; - a.bmHub = 0; - a.bmParent = bAddress; - a.bmAddress = port; - pUsb->ReleaseDevice(a.devAddress); - return 0; - - // Reset complete event - case bmHUB_PORT_EVENT_RESET_COMPLETE: - case bmHUB_PORT_EVENT_LS_RESET_COMPLETE: - ClearPortFeature(HUB_FEATURE_C_PORT_RESET, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - - delay(20); - - a.devAddress = bAddress; - - pUsb->Configuring(a.bmAddress, port, (evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED)); - bResetInitiated = false; - break; - - } // switch (evt.bmEvent) - return 0; -} - -void PrintHubPortStatus(USBHub *hubptr, uint32_t addr, uint32_t port, uint32_t print_changes) { - uint8_t rcode = 0; - HubEvent evt; - - rcode = hubptr->GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) { - USB_HOST_SERIAL.println("ERROR!"); - return; - } - USB_HOST_SERIAL.print("\r\nPort "); - USB_HOST_SERIAL.println(port, DEC); - - USB_HOST_SERIAL.println("Status"); - USB_HOST_SERIAL.print("CONNECTION:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC); - USB_HOST_SERIAL.print("ENABLE:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC); - USB_HOST_SERIAL.print("SUSPEND:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC); - USB_HOST_SERIAL.print("OVER_CURRENT:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC); - USB_HOST_SERIAL.print("RESET:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC); - USB_HOST_SERIAL.print("POWER:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC); - USB_HOST_SERIAL.print("LOW_SPEED:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC); - USB_HOST_SERIAL.print("HIGH_SPEED:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC); - USB_HOST_SERIAL.print("TEST:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC); - USB_HOST_SERIAL.print("INDICATOR:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC); - - if(!print_changes) - return; - - USB_HOST_SERIAL.println("\r\nChange"); - USB_HOST_SERIAL.print("CONNECTION:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC); - USB_HOST_SERIAL.print("ENABLE:\t\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC); - USB_HOST_SERIAL.print("SUSPEND:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC); - USB_HOST_SERIAL.print("OVER_CURRENT:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC); - USB_HOST_SERIAL.print("RESET:\t\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC); -} diff --git a/legacy/builder/test/libraries/USBHost/src/usbhub.h b/legacy/builder/test/libraries/USBHost/src/usbhub.h deleted file mode 100644 index 6a80a123137..00000000000 --- a/legacy/builder/test/libraries/USBHost/src/usbhub.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__USBHUB_H__) -#define __USBHUB_H__ - -#include "Usb.h" - -#define USB_DESCRIPTOR_HUB 0x09 // Hub descriptor type - -// Hub Requests -#define bmREQ_CLEAR_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_CLEAR_PORT_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_CLEAR_TT_BUFFER USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_GET_HUB_DESCRIPTOR USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_GET_HUB_STATUS USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_GET_PORT_STATUS USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_RESET_TT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_SET_HUB_DESCRIPTOR USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_SET_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_SET_PORT_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_GET_TT_STATE USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_STOP_TT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER - -// Hub Class Requests -#define HUB_REQUEST_CLEAR_TT_BUFFER 8 -#define HUB_REQUEST_RESET_TT 9 -#define HUB_REQUEST_GET_TT_STATE 10 -#define HUB_REQUEST_STOP_TT 11 - -// Hub Features -#define HUB_FEATURE_C_HUB_LOCAL_POWER 0 -#define HUB_FEATURE_C_HUB_OVER_CURRENT 1 -#define HUB_FEATURE_PORT_CONNECTION 0 -#define HUB_FEATURE_PORT_ENABLE 1 -#define HUB_FEATURE_PORT_SUSPEND 2 -#define HUB_FEATURE_PORT_OVER_CURRENT 3 -#define HUB_FEATURE_PORT_RESET 4 -#define HUB_FEATURE_PORT_POWER 8 -#define HUB_FEATURE_PORT_LOW_SPEED 9 -#define HUB_FEATURE_C_PORT_CONNECTION 16 -#define HUB_FEATURE_C_PORT_ENABLE 17 -#define HUB_FEATURE_C_PORT_SUSPEND 18 -#define HUB_FEATURE_C_PORT_OVER_CURRENT 19 -#define HUB_FEATURE_C_PORT_RESET 20 -#define HUB_FEATURE_PORT_TEST 21 -#define HUB_FEATURE_PORT_INDICATOR 22 - -// Hub Port Test Modes -#define HUB_PORT_TEST_MODE_J 1 -#define HUB_PORT_TEST_MODE_K 2 -#define HUB_PORT_TEST_MODE_SE0_NAK 3 -#define HUB_PORT_TEST_MODE_PACKET 4 -#define HUB_PORT_TEST_MODE_FORCE_ENABLE 5 - -// Hub Port Indicator Color -#define HUB_PORT_INDICATOR_AUTO 0 -#define HUB_PORT_INDICATOR_AMBER 1 -#define HUB_PORT_INDICATOR_GREEN 2 -#define HUB_PORT_INDICATOR_OFF 3 - -// Hub Port Status Bitmasks -#define bmHUB_PORT_STATUS_PORT_CONNECTION 0x0001 -#define bmHUB_PORT_STATUS_PORT_ENABLE 0x0002 -#define bmHUB_PORT_STATUS_PORT_SUSPEND 0x0004 -#define bmHUB_PORT_STATUS_PORT_OVER_CURRENT 0x0008 -#define bmHUB_PORT_STATUS_PORT_RESET 0x0010 -#define bmHUB_PORT_STATUS_PORT_POWER 0x0100 -#define bmHUB_PORT_STATUS_PORT_LOW_SPEED 0x0200 -#define bmHUB_PORT_STATUS_PORT_HIGH_SPEED 0x0400 -#define bmHUB_PORT_STATUS_PORT_TEST 0x0800 -#define bmHUB_PORT_STATUS_PORT_INDICATOR 0x1000 - -// Hub Port Status Change Bitmasks (used one byte instead of two) -#define bmHUB_PORT_STATUS_C_PORT_CONNECTION 0x0001 -#define bmHUB_PORT_STATUS_C_PORT_ENABLE 0x0002 -#define bmHUB_PORT_STATUS_C_PORT_SUSPEND 0x0004 -#define bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT 0x0008 -#define bmHUB_PORT_STATUS_C_PORT_RESET 0x0010 - -// Hub Status Bitmasks (used one byte instead of two) -#define bmHUB_STATUS_LOCAL_POWER_SOURCE 0x01 -#define bmHUB_STATUS_OVER_CURRENT 0x12 - -// Hub Status Change Bitmasks (used one byte instead of two) -#define bmHUB_STATUS_C_LOCAL_POWER_SOURCE 0x01 -#define bmHUB_STATUS_C_OVER_CURRENT 0x12 - - -// Hub Port Configuring Substates -#define USB_STATE_HUB_PORT_CONFIGURING 0xb0 -#define USB_STATE_HUB_PORT_POWERED_OFF 0xb1 -#define USB_STATE_HUB_PORT_WAIT_FOR_POWER_GOOD 0xb2 -#define USB_STATE_HUB_PORT_DISCONNECTED 0xb3 -#define USB_STATE_HUB_PORT_DISABLED 0xb4 -#define USB_STATE_HUB_PORT_RESETTING 0xb5 -#define USB_STATE_HUB_PORT_ENABLED 0xb6 - -// Additional Error Codes -#define HUB_ERROR_PORT_HAS_BEEN_RESET 0xb1 - -// The bit mask to check for all necessary state bits -#define bmHUB_PORT_STATUS_ALL_MAIN ((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE | bmHUB_PORT_STATUS_C_PORT_SUSPEND | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND) - -// Bit mask to check for DISABLED state in HubEvent::bmStatus field -#define bmHUB_PORT_STATE_CHECK_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND) - -// Hub Port States -#define bmHUB_PORT_STATE_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION) - -// Hub Port Events -#define bmHUB_PORT_EVENT_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION) -#define bmHUB_PORT_EVENT_DISCONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER) -#define bmHUB_PORT_EVENT_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION) - -#define bmHUB_PORT_EVENT_LS_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) -#define bmHUB_PORT_EVENT_LS_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) -#define bmHUB_PORT_EVENT_LS_PORT_ENABLED (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) - -struct HubDescriptor { - uint32_t bDescLength; // descriptor length - uint32_t bDescriptorType; // descriptor type - uint32_t bNbrPorts; // number of ports a hub equiped with - - struct { - uint32_t LogPwrSwitchMode : 2; - uint32_t CompoundDevice : 1; - uint32_t OverCurrentProtectMode : 2; - uint32_t TTThinkTime : 2; - uint32_t PortIndicatorsSupported : 1; - uint32_t Reserved : 24; - } __attribute__((packed)); - - uint32_t bPwrOn2PwrGood; - uint32_t bHubContrCurrent; -} __attribute__((packed)); - -struct HubEvent { - - union { - - struct { - uint32_t bmStatus; // port status bits - uint32_t bmChange; // port status change bits - } __attribute__((packed)); - uint32_t bmEvent; - uint8_t evtBuff[4]; - }; -} __attribute__((packed)); - -class USBHub : USBDeviceConfig { - static bool bResetInitiated; // True when reset is triggered - - USBHost *pUsb; // USB class instance pointer - - EpInfo epInfo[2]; // interrupt endpoint info structure - - uint32_t bAddress; // address - uint32_t bNbrPorts; // number of ports - // uint8_t bInitState; // initialization state variable - uint32_t qNextPollTime; // next poll time - uint32_t bPollEnable; // poll enable flag - - uint32_t CheckHubStatus(); - uint32_t PortStatusChange(uint32_t port, HubEvent &evt); - -public: - USBHub(USBHost *p); - - uint32_t ClearHubFeature(uint32_t fid); - uint32_t ClearPortFeature(uint32_t fid, uint32_t port, uint32_t sel = 0); - uint32_t GetHubDescriptor(uint32_t index, uint32_t nbytes, uint8_t *dataptr); - uint32_t GetHubStatus(uint32_t nbytes, uint8_t* dataptr); - uint32_t GetPortStatus(uint32_t port, uint32_t nbytes, uint8_t* dataptr); - uint32_t SetHubDescriptor(uint32_t port, uint32_t nbytes, uint8_t* dataptr); - uint32_t SetHubFeature(uint32_t fid); - uint32_t SetPortFeature(uint32_t fid, uint32_t port, uint32_t sel = 0); - - void PrintHubStatus(); - - virtual uint32_t Init(uint32_t parent, uint32_t port, uint32_t lowspeed); - virtual uint32_t Release(); - virtual uint32_t Poll(); - virtual void ResetHubPort(uint32_t port); - - virtual uint32_t GetAddress() { - return bAddress; - }; - - virtual uint32_t DEVCLASSOK(uint32_t klass) { - return (klass == 0x09); - } - -}; - -// Clear Hub Feature - -inline uint32_t USBHub::ClearHubFeature(uint32_t fid) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CLEAR_HUB_FEATURE, USB_REQUEST_CLEAR_FEATURE, fid, 0, 0, 0, 0, NULL, NULL)); -} -// Clear Port Feature - -inline uint32_t USBHub::ClearPortFeature(uint32_t fid, uint32_t port, uint32_t sel) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CLEAR_PORT_FEATURE, USB_REQUEST_CLEAR_FEATURE, fid, 0, ((0x0000 | port) | (sel << 8)), 0, 0, NULL, NULL)); -} -// Get Hub Descriptor - -inline uint32_t USBHub::GetHubDescriptor(uint32_t index, uint32_t nbytes, uint8_t *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_HUB_DESCRIPTOR, USB_REQUEST_GET_DESCRIPTOR, index, 0x29, 0, nbytes, nbytes, dataptr, NULL)); -} -// Get Hub Status - -inline uint32_t USBHub::GetHubStatus(uint32_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_HUB_STATUS, USB_REQUEST_GET_STATUS, 0, 0, 0x0000, nbytes, nbytes, dataptr, NULL)); -} -// Get Port Status - -inline uint32_t USBHub::GetPortStatus(uint32_t port, uint32_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_PORT_STATUS, USB_REQUEST_GET_STATUS, 0, 0, port, nbytes, nbytes, dataptr, NULL)); -} -// Set Hub Descriptor - -inline uint32_t USBHub::SetHubDescriptor(uint32_t port, uint32_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_HUB_DESCRIPTOR, USB_REQUEST_SET_DESCRIPTOR, 0, 0, port, nbytes, nbytes, dataptr, NULL)); -} -// Set Hub Feature - -inline uint32_t USBHub::SetHubFeature(uint32_t fid) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_HUB_FEATURE, USB_REQUEST_SET_FEATURE, fid, 0, 0, 0, 0, NULL, NULL)); -} -// Set Port Feature - -inline uint32_t USBHub::SetPortFeature(uint32_t fid, uint32_t port, uint32_t sel) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_PORT_FEATURE, USB_REQUEST_SET_FEATURE, fid, 0, (((0x0000 | sel) << 8) | port), 0, 0, NULL, NULL)); -} - -void PrintHubPortStatus(USBHost *usbptr, uint32_t addr, uint32_t port, uint32_t print_changes = false); - -#endif // __USBHUB_H__ diff --git a/legacy/builder/test/libraries/testlib1/testlib1.h b/legacy/builder/test/libraries/testlib1/testlib1.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/testlib2/testlib2.h b/legacy/builder/test/libraries/testlib2/testlib2.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/testlib3/testlib3.h b/legacy/builder/test/libraries/testlib3/testlib3.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/testlib4/testlib4.h b/legacy/builder/test/libraries/testlib4/testlib4.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/wronglib/library.properties b/legacy/builder/test/libraries/wronglib/library.properties deleted file mode 100644 index b235c667680..00000000000 --- a/legacy/builder/test/libraries/wronglib/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=wronglib -version=1.0 -author=Arduino -maintainer=Arduino -sentence=sentence -paragraph=paragraph -url=url -architectures=* -category=Other diff --git a/legacy/builder/test/libraries/wronglib/src/.gitkeep b/legacy/builder/test/libraries/wronglib/src/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/libraries/wronglib/utility/.gitkeep b/legacy/builder/test/libraries/wronglib/utility/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/merge_sketch_with_bootloader_test.go b/legacy/builder/test/merge_sketch_with_bootloader_test.go deleted file mode 100644 index f7c9a24024f..00000000000 --- a/legacy/builder/test/merge_sketch_with_bootloader_test.go +++ /dev/null @@ -1,208 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "fmt" - "path/filepath" - "strings" - "testing" - - "github.com/arduino/arduino-cli/legacy/builder/types" - paths "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -func TestMergeSketchWithBootloader(t *testing.T) { - ctx := prepareBuilderTestContext(t, nil, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno") - defer cleanUpBuilderTestContext(t, ctx) - - buildPath := ctx.Builder.GetBuildPath() - err := buildPath.Join("sketch").MkdirAll() - require.NoError(t, err) - - fakeSketchHex := `:100000000C9434000C9446000C9446000C9446006A -:100010000C9446000C9446000C9446000C94460048 -:100020000C9446000C9446000C9446000C94460038 -:100030000C9446000C9446000C9446000C94460028 -:100040000C9448000C9446000C9446000C94460016 -:100050000C9446000C9446000C9446000C94460008 -:100060000C9446000C94460011241FBECFEFD8E03C -:10007000DEBFCDBF21E0A0E0B1E001C01D92A930FC -:10008000B207E1F70E9492000C94DC000C9400008F -:100090001F920F920FB60F9211242F933F938F93BD -:1000A0009F93AF93BF938091050190910601A0911A -:1000B0000701B09108013091040123E0230F2D378F -:1000C00020F40196A11DB11D05C026E8230F02965C -:1000D000A11DB11D20930401809305019093060199 -:1000E000A0930701B0930801809100019091010154 -:1000F000A0910201B09103010196A11DB11D809351 -:10010000000190930101A0930201B0930301BF91FC -:10011000AF919F918F913F912F910F900FBE0F90B4 -:100120001F901895789484B5826084BD84B58160F1 -:1001300084BD85B5826085BD85B5816085BD8091B2 -:100140006E00816080936E0010928100809181002A -:100150008260809381008091810081608093810022 -:10016000809180008160809380008091B1008460E4 -:100170008093B1008091B00081608093B000809145 -:100180007A00846080937A0080917A008260809304 -:100190007A0080917A00816080937A0080917A0061 -:1001A000806880937A001092C100C0E0D0E0209770 -:0C01B000F1F30E940000FBCFF894FFCF99 -:00000001FF -` - err = buildPath.Join("sketch", "sketch1.ino.hex").WriteFile([]byte(fakeSketchHex)) - require.NoError(t, err) - - err = ctx.Builder.MergeSketchWithBootloader() - require.NoError(t, err) - - bytes, err := buildPath.Join("sketch", "sketch1.ino.with_bootloader.hex").ReadFile() - require.NoError(t, err) - mergedSketchHex := string(bytes) - - require.Contains(t, mergedSketchHex, ":100000000C9434000C9446000C9446000C9446006A\n") - require.True(t, strings.HasSuffix(mergedSketchHex, ":00000001FF\n")) -} - -func TestMergeSketchWithBootloaderSketchInBuildPath(t *testing.T) { - ctx := prepareBuilderTestContext(t, nil, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno") - defer cleanUpBuilderTestContext(t, ctx) - - buildPath := ctx.Builder.GetBuildPath() - err := buildPath.Join("sketch").MkdirAll() - require.NoError(t, err) - - fakeSketchHex := `:100000000C9434000C9446000C9446000C9446006A -:100010000C9446000C9446000C9446000C94460048 -:100020000C9446000C9446000C9446000C94460038 -:100030000C9446000C9446000C9446000C94460028 -:100040000C9448000C9446000C9446000C94460016 -:100050000C9446000C9446000C9446000C94460008 -:100060000C9446000C94460011241FBECFEFD8E03C -:10007000DEBFCDBF21E0A0E0B1E001C01D92A930FC -:10008000B207E1F70E9492000C94DC000C9400008F -:100090001F920F920FB60F9211242F933F938F93BD -:1000A0009F93AF93BF938091050190910601A0911A -:1000B0000701B09108013091040123E0230F2D378F -:1000C00020F40196A11DB11D05C026E8230F02965C -:1000D000A11DB11D20930401809305019093060199 -:1000E000A0930701B0930801809100019091010154 -:1000F000A0910201B09103010196A11DB11D809351 -:10010000000190930101A0930201B0930301BF91FC -:10011000AF919F918F913F912F910F900FBE0F90B4 -:100120001F901895789484B5826084BD84B58160F1 -:1001300084BD85B5826085BD85B5816085BD8091B2 -:100140006E00816080936E0010928100809181002A -:100150008260809381008091810081608093810022 -:10016000809180008160809380008091B1008460E4 -:100170008093B1008091B00081608093B000809145 -:100180007A00846080937A0080917A008260809304 -:100190007A0080917A00816080937A0080917A0061 -:1001A000806880937A001092C100C0E0D0E0209770 -:0C01B000F1F30E940000FBCFF894FFCF99 -:00000001FF -` - err = buildPath.Join("sketch1.ino.hex").WriteFile([]byte(fakeSketchHex)) - require.NoError(t, err) - - err = ctx.Builder.MergeSketchWithBootloader() - require.NoError(t, err) - - bytes, err := buildPath.Join("sketch1.ino.with_bootloader.hex").ReadFile() - require.NoError(t, err) - mergedSketchHex := string(bytes) - - fmt.Println(string(mergedSketchHex)) - require.Contains(t, mergedSketchHex, ":100000000C9434000C9446000C9446000C9446006A\n") - require.True(t, strings.HasSuffix(mergedSketchHex, ":00000001FF\n")) -} - -func TestMergeSketchWithBootloaderWhenNoBootloaderAvailable(t *testing.T) { - ctx := prepareBuilderTestContext(t, nil, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno") - defer cleanUpBuilderTestContext(t, ctx) - - buildPath := ctx.Builder.GetBuildPath() - buildProperties := ctx.Builder.GetBuildProperties() - buildProperties.Remove("bootloader.noblink") - buildProperties.Remove("bootloader.file") - - err := ctx.Builder.MergeSketchWithBootloader() - require.NoError(t, err) - - exist, err := buildPath.Join("sketch.ino.with_bootloader.hex").ExistCheck() - require.NoError(t, err) - require.False(t, exist) -} - -// TODO convert in a compile test and we check against the real .hex -func TestMergeSketchWithBootloaderPathIsParameterized(t *testing.T) { - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools"), - BuiltInLibrariesDirs: paths.New("downloaded_libraries"), - OtherLibrariesDirs: paths.NewPathList("libraries"), - } - ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:mymega:cpu=atmega2560") - defer cleanUpBuilderTestContext(t, ctx) - - buildPath := ctx.Builder.GetBuildPath() - err := buildPath.Join("sketch").MkdirAll() - require.NoError(t, err) - - fakeSketchHex := `:100000000C9434000C9446000C9446000C9446006A -:100010000C9446000C9446000C9446000C94460048 -:100020000C9446000C9446000C9446000C94460038 -:100030000C9446000C9446000C9446000C94460028 -:100040000C9448000C9446000C9446000C94460016 -:100050000C9446000C9446000C9446000C94460008 -:100060000C9446000C94460011241FBECFEFD8E03C -:10007000DEBFCDBF21E0A0E0B1E001C01D92A930FC -:10008000B207E1F70E9492000C94DC000C9400008F -:100090001F920F920FB60F9211242F933F938F93BD -:1000A0009F93AF93BF938091050190910601A0911A -:1000B0000701B09108013091040123E0230F2D378F -:1000C00020F40196A11DB11D05C026E8230F02965C -:1000D000A11DB11D20930401809305019093060199 -:1000E000A0930701B0930801809100019091010154 -:1000F000A0910201B09103010196A11DB11D809351 -:10010000000190930101A0930201B0930301BF91FC -:10011000AF919F918F913F912F910F900FBE0F90B4 -:100120001F901895789484B5826084BD84B58160F1 -:1001300084BD85B5826085BD85B5816085BD8091B2 -:100140006E00816080936E0010928100809181002A -:100150008260809381008091810081608093810022 -:10016000809180008160809380008091B1008460E4 -:100170008093B1008091B00081608093B000809145 -:100180007A00846080937A0080917A008260809304 -:100190007A0080917A00816080937A0080917A0061 -:1001A000806880937A001092C100C0E0D0E0209770 -:0C01B000F1F30E940000FBCFF894FFCF99 -:00000001FF -` - err = buildPath.Join("sketch", "sketch1.ino.hex").WriteFile([]byte(fakeSketchHex)) - require.NoError(t, err) - - err = ctx.Builder.MergeSketchWithBootloader() - require.NoError(t, err) - - bytes, err := buildPath.Join("sketch", "sketch1.ino.with_bootloader.hex").ReadFile() - require.NoError(t, err) - mergedSketchHex := string(bytes) - - require.Contains(t, mergedSketchHex, ":100000000C9434000C9446000C9446000C9446006A\n") - require.True(t, strings.HasSuffix(mergedSketchHex, ":00000001FF\n")) -} diff --git a/legacy/builder/test/setup_build_properties_test.go b/legacy/builder/test/setup_build_properties_test.go deleted file mode 100644 index 68aaa6b0574..00000000000 --- a/legacy/builder/test/setup_build_properties_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "path/filepath" - "testing" - - "github.com/arduino/arduino-cli/legacy/builder/types" - paths "github.com/arduino/go-paths-helper" - "github.com/arduino/go-properties-orderedmap" - "github.com/stretchr/testify/require" -) - -// TODO maybe create a test that actually check all the keys -func TestSetupBuildProperties(t *testing.T) { - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"), - } - ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno") - defer cleanUpBuilderTestContext(t, ctx) - - buildProperties := ctx.Builder.GetBuildProperties() - - require.Equal(t, "ARDUINO", buildProperties.Get("software")) - - require.Equal(t, "uno", buildProperties.Get("_id")) - require.Equal(t, "Arduino/Genuino Uno", buildProperties.Get("name")) - require.Equal(t, "0x2341", buildProperties.Get("vid.0")) - require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern")) - require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path")) - - requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "downloaded_hardware/arduino/avr") - requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "downloaded_hardware/arduino") - require.Equal(t, "10607", buildProperties.Get("runtime.ide.version")) - require.NotEmpty(t, buildProperties.Get("runtime.os")) - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1") - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5") - - bossacPath := buildProperties.Get("runtime.tools.bossac.path") - bossac161Path := buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path") - bossac15Path := buildProperties.Get("runtime.tools.bossac-1.5-arduino.path") - requireEquivalentPaths(t, bossac161Path, "downloaded_tools/bossac/1.6.1-arduino") - requireEquivalentPaths(t, bossac15Path, "downloaded_tools/bossac/1.5-arduino") - requireEquivalentPaths(t, bossacPath, bossac161Path, bossac15Path) - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr") - - requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1") - - require.True(t, buildProperties.ContainsKey("extra.time.utc")) - require.True(t, buildProperties.ContainsKey("extra.time.local")) - require.True(t, buildProperties.ContainsKey("extra.time.zone")) - require.True(t, buildProperties.ContainsKey("extra.time.dst")) -} - -// TODO make this integration tests -func TestSetupBuildPropertiesWithSomeCustomOverrides(t *testing.T) { - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"), - } - ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno") - defer cleanUpBuilderTestContext(t, ctx) - customBuildProp := []string{"name=fake name", "tools.avrdude.config.path=non existent path with space and a ="} - customProps, err := properties.LoadFromSlice(customBuildProp) - require.NoError(t, err) - - buildProperties := ctx.Builder.GetBuildProperties().Merge(customProps) - require.Equal(t, "ARDUINO", buildProperties.Get("software")) - require.Equal(t, "uno", buildProperties.Get("_id")) - require.Equal(t, "fake name", buildProperties.Get("name")) - require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern")) - require.Equal(t, "non existent path with space and a =", buildProperties.Get("tools.avrdude.config.path")) -} - -// TODO go to compile_4 that uses the custom_yum to compile and we also verify this properties -func TestSetupBuildPropertiesUserHardware(t *testing.T) { - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"), - } - ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun") - defer cleanUpBuilderTestContext(t, ctx) - - buildProperties := ctx.Builder.GetBuildProperties() - - require.Equal(t, "ARDUINO", buildProperties.Get("software")) - - require.Equal(t, "custom_yun", buildProperties.Get("_id")) - require.Equal(t, "caterina/Caterina-custom_yun.hex", buildProperties.Get("bootloader.file")) - requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), filepath.Join("user_hardware", "my_avr_platform", "avr")) - requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), filepath.Join("user_hardware", "my_avr_platform")) -} - -func TestSetupBuildPropertiesWithMissingPropsFromParentPlatformTxtFiles(t *testing.T) { - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"), - } - ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun") - defer cleanUpBuilderTestContext(t, ctx) - - buildProperties := ctx.Builder.GetBuildProperties() - - require.Equal(t, "ARDUINO", buildProperties.Get("software")) - - require.Equal(t, "custom_yun", buildProperties.Get("_id")) - require.Equal(t, "Arduino Yún", buildProperties.Get("name")) - require.Equal(t, "0x2341", buildProperties.Get("vid.0")) - require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern")) - require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path")) - - requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "user_hardware/my_avr_platform/avr") - requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "user_hardware/my_avr_platform") - require.Equal(t, "10607", buildProperties.Get("runtime.ide.version")) - require.NotEmpty(t, buildProperties.Get("runtime.os")) - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path"), "downloaded_tools/bossac/1.6.1-arduino") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.5-arduino.path"), "downloaded_tools/bossac/1.5-arduino") - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac.path"), "downloaded_tools/bossac/1.6.1-arduino", "downloaded_tools/bossac/1.5-arduino") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr") - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr") - - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr") - requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc-4.8.1-arduino5.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr") - - requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1") - - require.True(t, buildProperties.ContainsKey("extra.time.utc")) - require.True(t, buildProperties.ContainsKey("extra.time.local")) - require.True(t, buildProperties.ContainsKey("extra.time.zone")) - require.True(t, buildProperties.ContainsKey("extra.time.dst")) -} diff --git a/legacy/builder/test/sketch1/header.h b/legacy/builder/test/sketch1/header.h deleted file mode 100644 index 2e24536f9fb..00000000000 --- a/legacy/builder/test/sketch1/header.h +++ /dev/null @@ -1 +0,0 @@ -#define TRUE FALSE \ No newline at end of file diff --git a/legacy/builder/test/store_build_options_map_test.go b/legacy/builder/test/store_build_options_map_test.go deleted file mode 100644 index ad087a0c48b..00000000000 --- a/legacy/builder/test/store_build_options_map_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "testing" - - "github.com/arduino/arduino-cli/arduino/builder" - "github.com/arduino/arduino-cli/arduino/sketch" - paths "github.com/arduino/go-paths-helper" - "github.com/arduino/go-properties-orderedmap" - "github.com/stretchr/testify/require" -) - -func TestCheckIfBuildOptionsChanged(t *testing.T) { - hardwareDirs := paths.NewPathList("hardware") - builtInToolsDirs := paths.NewPathList("tools") - builtInLibrariesDirs := paths.New("built-in libraries") - otherLibrariesDirs := paths.NewPathList("libraries") - fqbn := parseFQBN(t, "my:nice:fqbn") - - buildPath := SetupBuildPath(t) - defer buildPath.RemoveAll() - - buildProperties := properties.NewFromHashmap(map[string]string{"compiler.optimization_flags": "-Os"}) - buildOptionsManager := builder.NewBuildOptionsManager( - hardwareDirs, builtInToolsDirs, otherLibrariesDirs, - builtInLibrariesDirs, buildPath, &sketch.Sketch{FullPath: paths.New("sketchLocation")}, []string{"custom=prop"}, - fqbn, false, - buildProperties.Get("compiler.optimization_flags"), - buildProperties.GetPath("runtime.platform.path"), - buildProperties.GetPath("build.core.path"), - nil, - ) - - err := buildOptionsManager.WipeBuildPath() - require.NoError(t, err) - - exist, err := buildPath.Join("build.options.json").ExistCheck() - require.NoError(t, err) - require.True(t, exist) - - bytes, err := buildPath.Join("build.options.json").ReadFile() - require.NoError(t, err) - - require.Equal(t, `{ - "additionalFiles": "", - "builtInLibrariesFolders": "built-in libraries", - "builtInToolsFolders": "tools", - "compiler.optimization_flags": "-Os", - "customBuildProperties": "custom=prop", - "fqbn": "my:nice:fqbn", - "hardwareFolders": "hardware", - "otherLibrariesFolders": "libraries", - "sketchLocation": "sketchLocation" -}`, string(bytes)) -} - -//func TestWipeoutBuildPathIfBuildOptionsChanged(t *testing.T) { -// buildPath := SetupBuildPath(t) -// defer buildPath.RemoveAll() -// -// buildOptionsJsonPrevious := "{ \"old\":\"old\" }" -// buildOptionsJson := "{ \"new\":\"new\" }" -// -// buildPath.Join("should_be_deleted.txt").Truncate() -// -// _, err := builder.WipeoutBuildPathIfBuildOptionsChanged( -// false, -// buildPath, -// buildOptionsJson, -// buildOptionsJsonPrevious, -// nil, -// ) -// require.NoError(t, err) -// -// exist, err := buildPath.ExistCheck() -// require.NoError(t, err) -// require.True(t, exist) -// -// files, err := buildPath.ReadDir() -// require.NoError(t, err) -// require.Equal(t, 0, len(files)) -// -// exist, err = buildPath.Join("should_be_deleted.txt").ExistCheck() -// require.NoError(t, err) -// require.False(t, exist) -//} -// -//func TestWipeoutBuildPathIfBuildOptionsChangedNoPreviousBuildOptions(t *testing.T) { -// buildPath := SetupBuildPath(t) -// defer buildPath.RemoveAll() -// -// buildOptionsJson := "{ \"new\":\"new\" }" -// -// require.NoError(t, buildPath.Join("should_not_be_deleted.txt").Truncate()) -// -// _, err := builder.WipeoutBuildPathIfBuildOptionsChanged( -// false, -// buildPath, -// buildOptionsJson, -// "", -// nil, -// ) -// require.NoError(t, err) -// -// exist, err := buildPath.ExistCheck() -// require.NoError(t, err) -// require.True(t, exist) -// -// files, err := buildPath.ReadDir() -// require.NoError(t, err) -// require.Equal(t, 1, len(files)) -// -// exist, err = buildPath.Join("should_not_be_deleted.txt").ExistCheck() -// require.NoError(t, err) -// require.True(t, exist) -//} diff --git a/legacy/builder/test/tools_builtin/avr/builtin_tools_versions.txt b/legacy/builder/test/tools_builtin/avr/builtin_tools_versions.txt deleted file mode 100644 index a071f413464..00000000000 --- a/legacy/builder/test/tools_builtin/avr/builtin_tools_versions.txt +++ /dev/null @@ -1,2 +0,0 @@ -arduino.avrdude=6.0.1-arduino5 -arduino.avr-gcc=4.8.1-arduino5 diff --git a/legacy/builder/test/tools_loader_test.go b/legacy/builder/test/tools_loader_test.go deleted file mode 100644 index 3460ac82c76..00000000000 --- a/legacy/builder/test/tools_loader_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "testing" - - paths "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -func requireEquivalentPaths(t *testing.T, actual string, expected ...string) { - if len(expected) == 1 { - actualAbs, err := paths.New(actual).Abs() - require.NoError(t, err) - expectedAbs, err := paths.New(expected[0]).Abs() - require.NoError(t, err) - require.Equal(t, expectedAbs.String(), actualAbs.String()) - } else { - actualAbs, err := paths.New(actual).Abs() - require.NoError(t, err) - expectedAbs := paths.NewPathList(expected...) - require.NoError(t, expectedAbs.ToAbs()) - require.Contains(t, expectedAbs.AsStrings(), actualAbs.String()) - } -} diff --git a/legacy/builder/test/try_build_of_problematic_sketch_test.go b/legacy/builder/test/try_build_of_problematic_sketch_test.go deleted file mode 100644 index 6504bcd9b84..00000000000 --- a/legacy/builder/test/try_build_of_problematic_sketch_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// Copyright 2015 Matthijs Kooijman -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "path/filepath" - "testing" - - "github.com/arduino/arduino-cli/arduino/builder/preprocessor" - "github.com/arduino/arduino-cli/legacy/builder" - "github.com/arduino/arduino-cli/legacy/builder/types" - paths "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -// TODO add them in the compile_4 -func TestTryBuild033(t *testing.T) { - tryBuild(t, paths.New("sketch_that_includes_arduino_h", "sketch_that_includes_arduino_h.ino")) -} - -func TestTryBuild034(t *testing.T) { - tryBuild(t, paths.New("sketch_with_static_asserts", "sketch_with_static_asserts.ino")) -} - -func TestTryBuild035(t *testing.T) { - tryBuild(t, paths.New("sketch_with_enum_class", "sketch_with_enum_class.ino")) -} - -func TestTryBuild036(t *testing.T) { - ctx := makeDefaultContext() - tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch_fastleds", "sketch_fastleds.ino")) -} - -func TestTryBuild037(t *testing.T) { - tryBuild(t, paths.New("sketch_with_externC", "sketch_with_externC.ino")) -} - -func TestTryBuild038(t *testing.T) { - tryBuild(t, paths.New("sketch_with_multiline_prototypes", "sketch_with_multiline_prototypes.ino")) -} - -func TestTryBuild039(t *testing.T) { - ctx := makeDefaultContext() - tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch12", "sketch12.ino")) -} - -func TestTryBuild040(t *testing.T) { - tryBuild(t, paths.New("sketch_with_externC_multiline", "sketch_with_externC_multiline.ino")) -} - -func TestTryBuild041(t *testing.T) { - tryBuild(t, paths.New("sketch_with_multiline_template", "sketch_with_multiline_template.ino")) -} - -func TestTryBuild042(t *testing.T) { - tryBuild(t, paths.New("sketch_with_fake_function_pointer", "sketch_with_fake_function_pointer.ino")) -} - -func makeDefaultContext() *types.Context { - preprocessor.DebugPreprocessor = true - return &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "downloaded_board_manager_stuff"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools"), - BuiltInLibrariesDirs: paths.New("downloaded_libraries"), - OtherLibrariesDirs: paths.NewPathList("libraries"), - } -} - -func tryBuild(t *testing.T, sketchLocation *paths.Path) { - tryBuildWithContext(t, makeDefaultContext(), "arduino:avr:leonardo", sketchLocation) -} - -func tryBuildWithContext(t *testing.T, ctx *types.Context, fqbn string, sketchLocation *paths.Path) { - ctx = prepareBuilderTestContext(t, ctx, sketchLocation, fqbn) - defer cleanUpBuilderTestContext(t, ctx) - - err := builder.RunBuilder(ctx) - require.NoError(t, err, "Build error for "+sketchLocation.String()) -} diff --git a/legacy/builder/test/user_hardware/arduino/avr/.gitkeep b/legacy/builder/test/user_hardware/arduino/avr/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/boards.txt b/legacy/builder/test/user_hardware/my_avr_platform/avr/boards.txt deleted file mode 100644 index bf794a46f71..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/boards.txt +++ /dev/null @@ -1,89 +0,0 @@ -menu.cpu=Processor - -custom_yun.name=Arduino Yún -custom_yun.upload.via_ssh=true - -custom_yun.build.core=arduino:arduino -custom_yun.bootloader.tool=arduino:avrdude -custom_yun.upload.tool=arduino:avrdude - -custom_yun.vid.0=0x2341 -custom_yun.pid.0=0x0041 -custom_yun.vid.1=0x2341 -custom_yun.pid.1=0x8041 -custom_yun.upload.protocol=avr109 -custom_yun.upload.maximum_size=28672 -custom_yun.upload.maximum_data_size=2560 -custom_yun.upload.speed=57600 -custom_yun.upload.disable_flushing=true -custom_yun.upload.use_1200bps_touch=true -custom_yun.upload.wait_for_upload_port=true - -custom_yun.bootloader.low_fuses=0xff -custom_yun.bootloader.high_fuses=0xd8 -custom_yun.bootloader.extended_fuses=0xfb -custom_yun.bootloader.file=caterina/Caterina-custom_yun.hex -custom_yun.bootloader.unlock_bits=0x3F -custom_yun.bootloader.lock_bits=0x2F - -custom_yun.build.mcu=atmega32u4 -custom_yun.build.f_cpu=16000000L -custom_yun.build.vid=0x2341 -custom_yun.build.pid=0x8041 -custom_yun.build.usb_product="Arduino My" -custom_yun.build.board=AVR_YUN -custom_yun.build.variant=arduino:yun -custom_yun.build.extra_flags={build.usb_flags} - -mymega.name=Arduino Mega or Mega 2560 - -mymega.vid.0=0x2341 -mymega.pid.0=0x0010 -mymega.vid.1=0x2341 -mymega.pid.1=0x0042 -mymega.vid.2=0x2A03 -mymega.pid.2=0x0010 -mymega.vid.3=0x2A03 -mymega.pid.3=0x0042 - -mymega.upload.tool=avrdude -mymega.upload.maximum_data_size=8192 - -mymega.bootloader.tool=avrdude -mymega.bootloader.low_fuses=0xFF -mymega.bootloader.unlock_bits=0x3F -mymega.bootloader.lock_bits=0x0F - -mymega.build.f_cpu=16000000L -mymega.build.core=arduino -mymega.build.variant=mega - -mymega.menu.cpu.atmega2560=ATmega2560 (Mega 2560) - -mymega.menu.cpu.atmega2560.upload.protocol=wiring -mymega.menu.cpu.atmega2560.upload.maximum_size=253952 -mymega.menu.cpu.atmega2560.upload.speed=115200 - -mymega.menu.cpu.atmega2560.bootloader._folder=stk500v2 -mymega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 -mymega.menu.cpu.atmega2560.bootloader.extended_fuses=0xFD -mymega.menu.cpu.atmega2560.bootloader.file={bootloader._folder}/stk500boot_v2_mega2560.hex - -mymega.menu.cpu.atmega2560.build.mcu=atmega2560 -# Do not define build.board to test autogeneration -#mymega.menu.cpu.atmega2560.build.board=AVR_MYMEGA2560 - -mymega.menu.cpu.atmega1280=ATmega1280 - -mymega.menu.cpu.atmega1280.upload.protocol=arduino -mymega.menu.cpu.atmega1280.upload.maximum_size=126976 -mymega.menu.cpu.atmega1280.upload.speed=57600 - -mymega.menu.cpu.atmega1280.bootloader._folder=atmega -mymega.menu.cpu.atmega1280.bootloader.high_fuses=0xDA -mymega.menu.cpu.atmega1280.bootloader.extended_fuses=0xF5 -mymega.menu.cpu.atmega1280.bootloader.file={bootloader._folder}/ATmegaBOOT_168_atmega1280.hex - -mymega.menu.cpu.atmega1280.build.mcu=atmega1280 -# define custom build.board for testing -mymega.menu.cpu.atmega1280.build.board=MYMEGA1280 diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/bootloaders/stk500v2/stk500boot_v2_mega2560.hex b/legacy/builder/test/user_hardware/my_avr_platform/avr/bootloaders/stk500v2/stk500boot_v2_mega2560.hex deleted file mode 100644 index c52e690a102..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/bootloaders/stk500v2/stk500boot_v2_mega2560.hex +++ /dev/null @@ -1,469 +0,0 @@ -:020000023000CC -:10E000000D9489F10D94B2F10D94B2F10D94B2F129 -:10E010000D94B2F10D94B2F10D94B2F10D94B2F1F0 -:10E020000D94B2F10D94B2F10D94B2F10D94B2F1E0 -:10E030000D94B2F10D94B2F10D94B2F10D94B2F1D0 -:10E040000D94B2F10D94B2F10D94B2F10D94B2F1C0 -:10E050000D94B2F10D94B2F10D94B2F10D94B2F1B0 -:10E060000D94B2F10D94B2F10D94B2F10D94B2F1A0 -:10E070000D94B2F10D94B2F10D94B2F10D94B2F190 -:10E080000D94B2F10D94B2F10D94B2F10D94B2F180 -:10E090000D94B2F10D94B2F10D94B2F10D94B2F170 -:10E0A0000D94B2F10D94B2F10D94B2F10D94B2F160 -:10E0B0000D94B2F10D94B2F10D94B2F10D94B2F150 -:10E0C0000D94B2F10D94B2F10D94B2F10D94B2F140 -:10E0D0000D94B2F10D94B2F10D94B2F10D94B2F130 -:10E0E0000D94B2F141546D656761323536300041AF -:10E0F000726475696E6F206578706C6F72657220DE -:10E1000073746B3530305632206279204D4C530099 -:10E11000426F6F746C6F616465723E004875683F52 -:10E1200000436F6D70696C6564206F6E203D200048 -:10E130004350552054797065202020203D20005FF9 -:10E140005F4156525F415243485F5F3D2000415658 -:10E1500052204C696243205665723D20004743437C -:10E160002056657273696F6E203D20004350552024 -:10E1700049442020202020203D20004C6F7720663D -:10E18000757365202020203D20004869676820665F -:10E190007573652020203D200045787420667573D6 -:10E1A00065202020203D20004C6F636B2066757336 -:10E1B000652020203D20004D617220203720323024 -:10E1C000313300312E362E3800342E332E350056A2 -:10E1D00023202020414444522020206F7020636F70 -:10E1E00064652020202020696E73747275637469E1 -:10E1F0006F6E2061646472202020496E74657272B3 -:10E20000757074006E6F20766563746F7200726A49 -:10E210006D702020006A6D70200057686174207056 -:10E220006F72743A00506F7274206E6F7420737541 -:10E2300070706F72746564004D7573742062652030 -:10E2400061206C6574746572002000577269747483 -:10E25000696E672045450052656164696E672045B7 -:10E26000450045452065727220636E743D00504F35 -:10E27000525400303D5A65726F2061646472003FF1 -:10E280003D43505520737461747300403D454550C3 -:10E29000524F4D207465737400423D426C696E6B41 -:10E2A000204C454400453D44756D70204545505215 -:10E2B0004F4D00463D44756D7020464C415348001B -:10E2C000483D48656C70004C3D4C69737420492F83 -:10E2D0004F20506F72747300513D51756974005234 -:10E2E0003D44756D702052414D00563D73686F7707 -:10E2F00020696E7465727275707420566563746FF0 -:10E30000727300593D506F727420626C696E6B00BD -:10E310002A0011241FBECFEFD1E2DEBFCDBF01E046 -:10E320000CBF12E0A0E0B2E0EEE1FDEF03E00BBFB6 -:10E3300002C007900D92A030B107D9F712E0A0E01B -:10E34000B2E001C01D92AE30B107E1F70F9460F367 -:10E350000D948DFE01E20EBF0FEF0DBF11241FBE05 -:10E360000D9460F30D9400F020E030E040ED57E0B4 -:10E3700005C0FA013197F1F72F5F3F4F2817390792 -:10E38000C0F308959C01260F311DC901A0E0B0E043 -:10E390002F5F3F4FABBFFC018791882361F08093D3 -:10E3A000C6008091C00086FFFCCF8091C0008064D1 -:10E3B0008093C000EACF08958DE08093C6008091DD -:10E3C000C00086FFFCCF8091C00080648093C000B5 -:10E3D0008AE08093C6008091C00086FFFCCF8091C8 -:10E3E000C00080648093C00008950F94C2F10F9420 -:10E3F000DCF10895FC019081992359F09093C600B7 -:10E400008091C00086FFFCCF8091C0008064809323 -:10E41000C0003196992379F70895282F982F929567 -:10E420009F70892F805D8A3308F0895F8093C600D2 -:10E430008091C00086FFFCCF8091C00080648093F3 -:10E44000C000822F8F70982F905D9A3308F0995FEB -:10E450009093C6008091C00086FFFCCF8091C000E1 -:10E4600080648093C00008959C01FB01853691056E -:10E470001CF46330710594F0C90164E670E00F94F8 -:10E480002EFE605D7F4F6093C6008091C00086FFC6 -:10E49000FCCF8091C00080648093C0002B30310598 -:10E4A00014F43297B4F0C90164E670E00F942EFEC4 -:10E4B0006AE070E00F942EFE605D7F4F6093C600AF -:10E4C0008091C00086FFFCCF8091C0008064809363 -:10E4D000C000C9016AE070E00F942EFEC0968093E0 -:10E4E000C6008091C00086FFFCCF8091C000806490 -:10E4F0008093C00008951F93182F8EE692EE60E07F -:10E500000F94C2F11093C6008091C00086FFFCCF2B -:10E510008091C00080648093C0000F94DCF11F9153 -:10E5200008952F923F924F925F926F927F928F92B7 -:10E530009F92AF92BF92CF92DF92EF92FF920F9392 -:10E540001F93DF93CF93CDB7DEB762970FB6F894E2 -:10E55000DEBF0FBECDBF382E622ECA01DB015C01CB -:10E560006D01772420E2222E2E010894411C511CBB -:10E570008BC081E0A81680E0B80681E0C80680E084 -:10E58000D80628F0C601AA27BB270F940DF2BB2797 -:10E59000AD2D9C2D8B2D0F940DF28A2D0F940DF225 -:10E5A0002092C6008091C00086FFFCCF8091C00001 -:10E5B00080648093C0009DE29093C6008091C0006B -:10E5C00086FFFCCF8091C00080648093C0002092C1 -:10E5D000C6008091C00086FFFCCF8091C00080649F -:10E5E0008093C00019828601750188249924A1E0D6 -:10E5F0003A1651F03A1620F0B2E03B1661F409C029 -:10E600000BBFF701779007C0C7010F9477FE782EF4 -:10E6100002C0F7017080872D0F940DF22092C60082 -:10E620008091C00086FFFCCF8091C0008064809301 -:10E63000C000872D8052F401EF70F0708F3520F408 -:10E64000E40DF51D708204C0E40DF51D8EE280839B -:10E650000894E11CF11C011D111D0894811C911CE2 -:10E6600090E18916910409F0C2CF80E190E0A0E02A -:10E67000B0E0A80EB91ECA1EDB1E198AC2010F9493 -:10E68000FAF10F94DCF16A94662009F072CF629679 -:10E690000FB6F894DEBF0FBECDBFCF91DF911F91B3 -:10E6A0000F91FF90EF90DF90CF90BF90AF909F9031 -:10E6B0008F907F906F905F904F903F902F90089534 -:10E6C0002F923F924F925F926F927F928F929F9282 -:10E6D000AF92BF92CF92DF92EF92FF920F931F9370 -:10E6E000DF93CF93CDB7DEB7CD53D1400FB6F894BB -:10E6F000DEBF0FBECDBF01E20EBF0FEF0DBF94B75F -:10E70000F894A89514BE80916000886180936000A1 -:10E7100010926000789493FF05C0E0910002F091A0 -:10E7200001021995279A2F9A8091C00082608093E8 -:10E73000C00080E18093C40088E18093C1000000A4 -:10E74000EE24FF24870144E0A42EB12CCC24DD2448 -:10E7500024C0C5010197F1F70894E11CF11C011DCB -:10E76000111D21E2E2162EE4F20620E0020720E06D -:10E77000120718F031E0C32ED12CC801B70127ECE5 -:10E780003BE140E050E00F9441FE611571058105C9 -:10E79000910519F485B1805885B98091C00087FD35 -:10E7A00003C0C114D104A9F2A6014F5F5F4FC25E3E -:10E7B000DE4F59834883CE51D140C25EDE4F8881FF -:10E7C0009981CE51D140019711F00D9410FEC05D9A -:10E7D000DE4F19821882C053D14060E0C15DDE4F28 -:10E7E0001882CF52D14088249924C35DDE4F19820C -:10E7F0001882CD52D140C05EDE4F188219821A8233 -:10E800001B82C052D140CE5CDE4F188219821A8220 -:10E810001B82C253D140EE24FF2487010BBFF701B6 -:10E8200007911691C45CDE4F19830883CC53D14005 -:10E830000D940BFEC25EDE4F28813981CE51D1404E -:10E840002130310509F52091C600C25EDE4F1982E4 -:10E850001882CE51D14022C02F5F3F4F4F4F5F4FA4 -:10E86000213082E138078AE7480780E0580780F0C6 -:10E87000C45CDE4FE881F981CC53D140EF5FFF4F9C -:10E8800019F0EE27FF27099420E030E040E050E047 -:10E890008091C00087FFE0CF2091C600C35DDE4FAE -:10E8A00048815981CD52D1404F5F5F4FC35DDE4FEC -:10E8B00059834883CD52D140213209F063C64A3092 -:10E8C000510508F05FC60894811C911C53E0851621 -:10E8D000910409F059C600E010E018C081E280936D -:10E8E000C6008091C00086FFFCCF8091C00080648C -:10E8F0008093C0002F5F3F4F2931310579F70F9486 -:10E90000DCF10F5F1F4F0530110519F020E030E0FA -:10E91000E5CF10920A0210920B0210920C02109294 -:10E920000D02109206021092070210920802109235 -:10E930000902109202021092030210920402109235 -:10E9400005028FEE90EE60E00F94F5F180E191EE1C -:10E9500060E00F94C2F18091C00087FFFCCF9091DE -:10E96000C600903608F09F759032B8F09093C600BC -:10E970008091C00086FFFCCF8091C00080648093AE -:10E98000C000A0E2A093C6008091C00086FFFCCF2B -:10E990008091C00080648093C000983409F4D7C18E -:10E9A0009934B8F4923409F459C1933458F490333B -:10E9B00019F1903308F4E3C59F33A1F1903409F0C5 -:10E9C000DEC5BDC0953409F470C1963409F0D7C5D1 -:10E9D00098C1923509F42BC2933538F49C3409F46C -:10E9E000F5C1913509F0CBC518C2963509F445C279 -:10E9F000993509F0C4C567C483E792EE62E00F94CD -:10EA0000F5F110920602109207021092080210927D -:10EA1000090210920A0210920B0210920C0210923C -:10EA20000D0213C18FE792EE62E00F94F5F18FEEC5 -:10EA300090EE60E00F94F5F181E291EE60E00F94CA -:10EA4000C2F187EB91EE60E00F94F5F180E391EE77 -:10EA500060E00F94C2F184EE90EE60E00F94F5F167 -:10EA60008FE391EE60E00F94C2F186E090E061E008 -:10EA700070E00F9434F20F94DCF18DE591EE60E0DC -:10EA80000F94C2F189EC91EE60E00F94F5F18EE401 -:10EA900091EE60E00F94C2F183EC91EE60E00F9490 -:10EAA000F5F18CE691EE60E00F94C2F18EE10F94E7 -:10EAB0000DF288E90F940DF281E00F940DF20F949E -:10EAC000DCF18BE791EE60E00F94C2F119E0E0E039 -:10EAD000F0E010935700E4918E2F0F940DF20F94F5 -:10EAE000DCF18AE891EE60E00F94C2F1E3E0F0E03F -:10EAF00010935700E4918E2F0F940DF20F94DCF1D8 -:10EB000089E991EE60E00F94C2F1E2E0F0E0109349 -:10EB10005700E4918E2F0F940DF20F94DCF188EAE8 -:10EB200091EE60E00F94C2F1E1E0F0E01093570045 -:10EB30001491812F0F940DF20F94DCF107CF8BE825 -:10EB400092EE62E00F94F5F18BE492EE60E00F94A8 -:10EB5000F5F10F94DCF100E010E019C0C8016F2D51 -:10EB60000F947FFEFF2031F489E492EE60E00F9471 -:10EB7000C2F10BC0F092C6008091C00086FFFCCFAE -:10EB80008091C00080648093C0000F5F1F4FC80158 -:10EB900081519F41A0E0B0E0ABBFFC01F790BAE229 -:10EBA000FB1621F0E2E000301E07C1F60F94DCF105 -:10EBB0000F94DCF187E592EE60E00F94F5F10F948D -:10EBC000DCF1CC24DD2400E010E01EC0C8010F946D -:10EBD00077FEF82E882331F489E492EE60E00F94FA -:10EBE000C2F10BC08093C6008091C00086FFFCCFAD -:10EBF0008091C00080648093C000FE1419F00894D6 -:10EC0000C11CD11C0F5F1F4FC80181519F41A0E063 -:10EC1000B0E0ABBFFC01E790FAE2EF1621F022E092 -:10EC20000030120799F60F94DCF10F94DCF182E6C4 -:10EC300092EE60E00F94C2F1C60161E070E00F94C3 -:10EC400034F20F94DCF10F94DCF110920202109276 -:10EC50000302109204021092050278CE89E992EE26 -:10EC600062E00F94F5F1279A2F9A16C02F9880E052 -:10EC700090E0E0EDF7E03197F1F7019684369105E9 -:10EC8000C1F72F9A80E090E0E0EDF7E03197F1F7DF -:10EC9000019684369105C1F78091C00087FFE6CFC9 -:10ECA0008091C00087FFFCCF64C485EA92EE62E0E9 -:10ECB0000F94F5F140910202509103026091040219 -:10ECC0007091050281E020E10F9491F2809102029F -:10ECD00090910302A0910402B091050280509F4FD1 -:10ECE000AF4FBF4F8093020290930302A0930402A0 -:10ECF000B093050280509041A040B04008F426CE69 -:10ED0000A4CF83EB92EE62E00F94F5F140910602FE -:10ED100050910702609108027091090280E020E1A1 -:10ED20000F9491F28091060290910702A09108023F -:10ED3000B091090280509F4FAF4FBF4F80930602A2 -:10ED400090930702A0930802B0930902FFCD80ECD4 -:10ED500092EE62E00F94F5F183E792EE60E00F949B -:10ED6000F5F18FE792EE60E00F94F5F18BE892EE0B -:10ED700060E00F94F5F189E992EE60E00F94F5F10F -:10ED800085EA92EE60E00F94F5F183EB92EE60E09D -:10ED90000F94F5F180EC92EE60E00F94F5F187ECC2 -:10EDA00092EE60E00F94F5F188ED92EE60E00F9442 -:10EDB000F5F18FED92EE60E00F94F5F18AEE92EEB0 -:10EDC00060E00F94F5F183E093EEBDCD87EC92EE19 -:10EDD00062E00F94F5F181E40F947BF282E40F94EA -:10EDE0007BF283E40F947BF284E40F947BF285E45E -:10EDF0000F947BF286E40F947BF287E40F947BF20E -:10EE000088E40F947BF28AE40F947BF28BE40F94F6 -:10EE10007BF28CE40F947BF299CD88ED92EE62E068 -:10EE20000F94F5F1772473948824992409C48FED05 -:10EE300092EE62E00F94F5F140910A0250910B02BC -:10EE400060910C0270910D0282E020E10F9491F22A -:10EE500080910A0290910B02A0910C02B0910D02D8 -:10EE600080509F4FAF4FBF4F80930A0290930B0289 -:10EE7000A0930C02B0930D0269CD8AEE92EE62E08F -:10EE80000F94F5F184EE90EE60E00F94F5F18FECC5 -:10EE900091EE60E00F94F5F1662477244301CC5D98 -:10EEA000DE4F19821882C452D140D401C301B695F5 -:10EEB000A79597958795CA5DDE4F88839983AA8326 -:10EEC000BB83C652D140CC5DDE4FA881B981C4520C -:10EED000D1401196CC5DDE4FB983A883C452D14096 -:10EEE000CD0162E070E00F9434F2B0E2B093C6005E -:10EEF0008091C00086FFFCCF8091C0008064809329 -:10EF0000C000EDE2E093C6008091C00086FFFCCF18 -:10EF10008091C00080648093C000F0E2F093C6004E -:10EF20008091C00086FFFCCF8091C00080648093F8 -:10EF3000C000CA5DDE4FE880F9800A811B81C6529D -:10EF4000D140BB27A12F902F8F2D0F940DF2CA5DBA -:10EF5000DE4F8881C652D1400F940DF2B0E2FB2EF5 -:10EF6000F092C6008091C00086FFFCCF8091C00067 -:10EF700080648093C0000DE30093C6008091C000C0 -:10EF800086FFFCCF8091C00080648093C00010E2B7 -:10EF90001093C6008091C00086FFFCCF8091C00016 -:10EFA00080648093C0008BBEF3012791C65DDE4F65 -:10EFB0002883CA52D140A22EBB24CC24DD2408943D -:10EFC000611C711C811C911C8BBEF3018791282E42 -:10EFD0003324442455240894611C711C811C911C09 -:10EFE0008BBEF3013791C55DDE4F3883CB52D140E4 -:10EFF0000894611C711C811C911C8BBEF30147910C -:10F00000C45DDE4F4883CC52D140ADEFEA2EAFEF66 -:10F01000FA2EAFEF0A2FAFEF1A2F6E0C7F1C801E57 -:10F02000911E142D032DF22CEE24EA0CFB1C0C1D5A -:10F030001D1D0F940DF220E22093C6008091C000A8 -:10F0400086FFFCCF8091C00080648093C000C65DC5 -:10F05000DE4F8881CA52D1400F940DF230E23093D6 -:10F06000C6008091C00086FFFCCF8091C000806404 -:10F070008093C000C45DDE4F8881CC52D1400F9494 -:10F080000DF240E24093C6008091C00086FFFCCFA5 -:10F090008091C00080648093C000C55DDE4F888190 -:10F0A000CB52D1400F940DF250E25093C6008091A4 -:10F0B000C00086FFFCCF8091C00080648093C000B8 -:10F0C0008FEFE8168FEFF80680E0080780E018075A -:10F0D00031F484E092EE60E00F94C2F1DFC0D80119 -:10F0E000C7018070907CA070B0708050904CA040A0 -:10F0F000B040D1F52FEF3FE340E050E0E222F322B1 -:10F1000004231523CA5DDE4FA880B980CA80DB8046 -:10F11000C652D140AE0CBF1CC01ED11EAA0CBB1CD7 -:10F12000CC1CDD1C8EE092EE60E00F94C2F1BB2798 -:10F13000A12F902F8F2D0F940DF28E2D0F940DF285 -:10F1400030E23093C6008091C00086FFFCCF8091F2 -:10F15000C00080648093C0004EE34093C60080915D -:10F16000C00086FFFCCF87C08EE09EEFA0E0B0E03D -:10F17000E822F9220A231B239CE0E91694E9F90608 -:10F1800090E0090790E0190709F088C0C45DDE4FE0 -:10F19000A881CC52D140EA2EFF2400E010E0102FCD -:10F1A0000F2DFE2CEE24C55DDE4FB881CB52D14031 -:10F1B000EB0EF11C011D111DD601C501817090706F -:10F1C000A070B070DC0199278827E80EF91E0A1F8D -:10F1D0001B1F20EF30E040E050E0A222B322C42207 -:10F1E000D52241E1AA0CBB1CCC1CDD1C4A95D1F7F1 -:10F1F000EA0CFB1C0C1D1D1D81E090E0A0E0B0E0BE -:10F20000282239224A225B2235E1220C331C441C7D -:10F21000551C3A95D1F7E20CF31C041D151D57013E -:10F220006801AA0CBB1CCC1CDD1C85E192EE60E0E1 -:10F230000F94C2F1C801AA27BB270F940DF2BB2778 -:10F24000A12F902F8F2D0F940DF28E2D0F940DF274 -:10F2500090E29093C6008091C00086FFFCCF809121 -:10F26000C00080648093C000AEE3A093C60080918C -:10F27000C00086FFFCCF8091C00080648093C000F6 -:10F28000C601AA27BB270F940DF2BB27AD2D9C2DDD -:10F290008B2D0F940DF28A2D0F940DF20F94DCF14B -:10F2A000CC5DDE4FE881F981C452D140F99709F471 -:10F2B0004DCBF4E0EF2EF12C012D112D6E0C7F1CA7 -:10F2C000801E911EF2CD83E093EE62E00F94F5F183 -:10F2D0008AE192EE60E00F94C2F18091C00087FF56 -:10F2E000FCCF1091C6001F751093C6008091C0001E -:10F2F00086FFFCCF8091C00080648093C0000F9493 -:10F30000DCF1812F81548A3108F036C1163409F4BA -:10F3100095C0173490F4133409F44EC0143430F40B -:10F320001134F1F0123409F01DC130C0143409F465 -:10F3300059C0153409F016C16BC01A3409F4C4C0A1 -:10F340001B3438F4173409F48FC0183409F00AC19B -:10F35000A1C01B3409F4D2C01C3409F003C1E8C0B9 -:10F360008FEF81B90DC082B1809582B980E090E0C5 -:10F37000E0EDF7E03197F1F70196883C9105C1F790 -:10F380008091C00087FFEFCF12B8EFC08FEF84B934 -:10F390000DC085B1809585B980E090E0E0EDF7E0A3 -:10F3A0003197F1F70196883C9105C1F78091C00033 -:10F3B00087FFEFCF15B8D9C08FEF87B90DC088B1DF -:10F3C000809588B980E090E0E0EDF7E03197F1F7C3 -:10F3D0000196883C9105C1F78091C00087FFEFCF6F -:10F3E00018B8C3C08FEF8AB90DC08BB180958BB9A7 -:10F3F00080E090E0E0EDF7E03197F1F70196883C8E -:10F400009105C1F78091C00087FFEFCF1BB8ADC059 -:10F410008FEF8DB90DC08EB180958EB980E090E0F0 -:10F42000E0EDF7E03197F1F70196883C9105C1F7DF -:10F430008091C00087FFEFCF1EB897C08FEF80BBD1 -:10F440000DC081B3809581BB80E090E0E0EDF7E0F6 -:10F450003197F1F70196883C9105C1F78091C00082 -:10F4600087FFEFCF11BA81C08FEF83BB0DC084B38C -:10F47000809584BB80E090E0E0EDF7E03197F1F714 -:10F480000196883C9105C1F78091C00087FFEFCFBE -:10F4900014BA6BC08FEF809301010FC080910201FD -:10F4A00080958093020180E090E0E0EDF7E03197F5 -:10F4B000F1F70196883C9105C1F78091C00087FF64 -:10F4C000EDCF1092020151C08FEF809304010FC065 -:10F4D0008091050180958093050180E090E0E0ED4A -:10F4E000F7E03197F1F70196883C9105C1F78091DB -:10F4F000C00087FFEDCF1092050137C08FEF8093DA -:10F5000007010FC08091080180958093080180E079 -:10F5100090E0E0EDF7E03197F1F70196883C910536 -:10F52000C1F78091C00087FFEDCF109208011DC088 -:10F530008FEF80930A010FC080910B01809580931B -:10F540000B0180E090E0E0EDF7E03197F1F70196F4 -:10F55000883C9105C1F78091C00087FFEDCF1092E4 -:10F560000B0103C085E292EEEEC98091C00087FFD7 -:10F57000FCCF8091C600EAC988E392EEE4C98CE131 -:10F5800091EEE1C988249924933011F1943028F444 -:10F59000913089F09230B8F408C0953061F195301F -:10F5A000F0F0963009F048C043C02B3109F042C951 -:10F5B00091E06BE13FC96227C15DDE4F2883CF52E6 -:10F5C000D14092E037C9B22FA0E0622793E032C960 -:10F5D000822F90E0A82BB92B622794E02BC92E3004 -:10F5E00009F039C3622795E0C05DDE4F19821882A9 -:10F5F000C053D1401FC9E1E0F0E0EC0FFD1FC05D3A -:10F60000DE4F08811981C053D140E00FF11F2083E4 -:10F610000F5F1F4FC05DDE4F19830883C053D14079 -:10F6200062270A171B0709F005C9D80196E002C92D -:10F63000261709F010C303C0973009F0FBC87724E0 -:10F640009981933109F412C19431C8F4963009F4C8 -:10F65000D8C0973050F4923009F406C1933009F4C1 -:10F660006DC0913009F059C253C0913109F477C08F -:10F67000923108F0BBC0903109F04FC2F5C098310B -:10F6800009F487C0993150F4953109F4EFC09531F0 -:10F6900008F4C6C1963109F040C2C2C19A3109F4DA -:10F6A0006CC09A3108F491C09B3109F45BC09D3164 -:10F6B00009F033C29D81903359F48F81882311F46E -:10F6C0009EE11CC0813011F091E018C098E916C08D -:10F6D000892F807591F0903539F4E0E0F0E089E011 -:10F6E0008093570094910AC0983539F4E3E0F0E034 -:10F6F00089E080935700949101C090E01A821B82A8 -:10F700008D818C831D829E831F8227E030E009C299 -:10F710001A8288E08B8381E48C8386E58D8382E581 -:10F720008E8389E48F8383E5888780E589878FE5E9 -:10F730008A8782E38B872BE030E0F3C18A818139AD -:10F7400041F0823941F0803911F48FE005C080E04A -:10F7500003C082E001C08AE01A828B8344C0772410 -:10F76000739482C08D81882311F48EE12CC0813086 -:10F7700011F081E028C088E926C01A82E1E0F0E0BB -:10F7800089E08093570084918B831C8224E030E0D1 -:10F79000C8C18B81803589F48C81883039F4E2E0EE -:10F7A000F0E089E08093570084910DC0E0E0F0E044 -:10F7B00089E080935700849106C0E3E0F0E089E09F -:10F7C0008093570084911A82DFCF8D81836C99E0FA -:10F7D000E1E0F0E0082E90935700E89507B600FCB2 -:10F7E000FDCF1A821B8223E030E09BC180EC8A832C -:10F7F000CE5CDE4F188219821A821B82C253D1401E -:10F800008EC18A8190E0A0E0B0E0582F44273327D2 -:10F8100022278B8190E0A0E0B0E0DC0199278827C7 -:10F82000282B392B4A2B5B2B8D8190E0A0E0B0E098 -:10F83000282B392B4A2B5B2B8C8190E0A0E0B0E089 -:10F84000BA2FA92F982F8827282B392B4A2B5B2BCF -:10F85000220F331F441F551FC05EDE4F288339839C -:10F860004A835B83C052D1401A8259C13A81C95C34 -:10F87000DE4F3883C753D140CA5CDE4F1882C6536F -:10F88000D1408B81C82EDD24CA5CDE4F488159816E -:10F89000C653D140C42AD52A933109F082C0CE5C28 -:10F8A000DE4F88819981AA81BB81C253D1408050AB -:10F8B000904CA340B04030F583E0CE5CDE4FE88052 -:10F8C000F9800A811B81C253D140F70100935B008C -:10F8D00080935700E89507B600FCFDCFCE5CDE4F65 -:10F8E000088119812A813B81C253D14000501F4FAA -:10F8F0002F4F3F4FCE5CDE4F088319832A833B8313 -:10F90000C253D140C05EDE4F488159816A817B81FC -:10F91000C052D140DE011B9631E08C9111962C91A2 -:10F9200011971296C75CDE4F2883C953D140C85C3B -:10F93000DE4F1882C853D14090E0C85CDE4FE881AA -:10F94000F981C853D1408E2B9F2B0C01FA01609393 -:10F950005B0030935700E89511244E5F5F4F6F4F67 -:10F960007F4F0EEFE02E0FEFF02ECE0CDF1CC114F8 -:10F97000D10499F685E0C05EDE4F088119812A81A5 -:10F980003B81C052D140F80120935B008093570027 -:10F99000E89507B600FCFDCF81E180935700E8951C -:10F9A00035C0C05EDE4F88819981AA81BB81C0527B -:10F9B000D140B695A795979587957C018601ABE0D8 -:10F9C000AA2EB12CAC0EBD1E0BC0D5016D915D01F0 -:10F9D000C7010F947FFE0894E11CF11C01501040F8 -:10F9E0000115110591F7A60160E070E0440F551F65 -:10F9F000661F771FC05EDE4FE880F9800A811B8199 -:10FA0000C052D1404E0D5F1D601F711F1A82C05E33 -:10FA1000DE4F488359836A837B83C052D1407FC0C5 -:10FA2000FA80C55CDE4FF882CB53D140C65CDE4F16 -:10FA30001882CA53D1408B81C82EDD24C65CDE4FAC -:10FA400008811981CA53D140C02AD12A1A828981DA -:10FA5000BE016D5F7F4F843121F59601C05EDE4FA0 -:10FA6000E880F9800A811B81C052D1400BBFF701A9 -:10FA700087919691DB018C9311969C936E5F7F4FDB -:10FA8000D801C7010296A11DB11DC05EDE4F88835B -:10FA90009983AA83BB83C052D14022503040F1F6F3 -:10FAA00036C0C05EDE4F288139814A815B81C052F9 -:10FAB000D1400894C108D108760100E010E0089414 -:10FAC000C11CD11C0894E11CF11C011D111DE20E8A -:10FAD000F31E041F151F21BDBB27A52F942F832FB5 -:10FAE00082BD2F5F3F4F4F4F5F4FF89A80B5DB01CC -:10FAF0008D93BD012E153F054007510761F7C05E8C -:10FB0000DE4F288339834A835B83C052D1409601FC -:10FB10002D5F3F4FFB01108204C080EC8A8322E0FE -:10FB200030E08BE18093C6008091C00086FFFCCF5F -:10FB30008091C00080648093C000C15DDE4FF88179 -:10FB4000CF52D140F093C6008091C00086FFFCCF19 -:10FB50008091C00080648093C000432F3093C60022 -:10FB60008091C00086FFFCCF8091C00080648093AC -:10FB7000C000922F2093C6008091C00086FFFCCF6A -:10FB80008091C00080648093C0008EE08093C600A6 -:10FB90008091C00086FFFCCF8091C000806480937C -:10FBA000C00065E1C15DDE4FE880CF52D1406E25D7 -:10FBB00069276427FE01319610C090819093C6009A -:10FBC0008091C00086FFFCCF31968091C000806498 -:10FBD0008093C0006927215030402115310569F715 -:10FBE0006093C6008091C00086FFFCCF8091C0006A -:10FBF00080648093C00085B1805885B9772081F4F6 -:10FC0000C15DDE4F0881CF52D1400F5FC15DDE4F35 -:10FC10000883CF52D14090E0A0E0B0E00D941AF4F8 -:10FC200027982F9880E090E020ED37E0F901319798 -:10FC3000F1F7019684369105C9F700008091C00064 -:10FC40008D7F8093C00081E180935700E895EE2777 -:10FC5000FF270994FFCF90E00D941AF497FB092E2B -:10FC600007260AD077FD04D02ED006D000201AF443 -:10FC7000709561957F4F0895F6F7909581959F4F08 -:10FC80000895A1E21A2EAA1BBB1BFD010DC0AA1FDD -:10FC9000BB1FEE1FFF1FA217B307E407F50720F0F5 -:10FCA000A21BB30BE40BF50B661F771F881F991F70 -:10FCB0001A9469F760957095809590959B01AC01B9 -:10FCC000BD01CF010895AA1BBB1B51E107C0AA1FAC -:10FCD000BB1FA617B70710F0A61BB70B881F991FED -:10FCE0005A95A9F780959095BC01CD010895F99991 -:10FCF000FECF92BD81BDF89A992780B50895262F31 -:10FD0000F999FECF1FBA92BD81BD20BD0FB6F89400 -:0EFD1000FA9AF99A0FBE01960895F894FFCF63 -:040000033000E000E9 -:00000001FF diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/SPI.cpp b/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/SPI.cpp deleted file mode 100644 index af14e07b12f..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/SPI.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2010 by Cristian Maglie - * Copyright (c) 2014 by Paul Stoffregen (Transaction API) - * Copyright (c) 2014 by Matthijs Kooijman (SPISettings AVR) - * Copyright (c) 2014 by Andrew J. Kroll (atomicity fixes) - * SPI Master library for arduino. - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of either the GNU General Public License version 2 - * or the GNU Lesser General Public License version 2.1, both as - * published by the Free Software Foundation. - */ - -#include "SPI.h" - -SPIClass SPI; - -uint8_t SPIClass::initialized = 0; -uint8_t SPIClass::interruptMode = 0; -uint8_t SPIClass::interruptMask = 0; -uint8_t SPIClass::interruptSave = 0; -#ifdef SPI_TRANSACTION_MISMATCH_LED -uint8_t SPIClass::inTransactionFlag = 0; -#endif - -void SPIClass::begin() -{ - uint8_t sreg = SREG; - noInterrupts(); // Protect from a scheduler and prevent transactionBegin - if (!initialized) { - // Set SS to high so a connected chip will be "deselected" by default - uint8_t port = digitalPinToPort(SS); - uint8_t bit = digitalPinToBitMask(SS); - volatile uint8_t *reg = portModeRegister(port); - - // if the SS pin is not already configured as an output - // then set it high (to enable the internal pull-up resistor) - if(!(*reg & bit)){ - digitalWrite(SS, HIGH); - } - - // When the SS pin is set as OUTPUT, it can be used as - // a general purpose output port (it doesn't influence - // SPI operations). - pinMode(SS, OUTPUT); - - // Warning: if the SS pin ever becomes a LOW INPUT then SPI - // automatically switches to Slave, so the data direction of - // the SS pin MUST be kept as OUTPUT. - SPCR |= _BV(MSTR); - SPCR |= _BV(SPE); - - // Set direction register for SCK and MOSI pin. - // MISO pin automatically overrides to INPUT. - // By doing this AFTER enabling SPI, we avoid accidentally - // clocking in a single bit since the lines go directly - // from "input" to SPI control. - // http://code.google.com/p/arduino/issues/detail?id=888 - pinMode(SCK, OUTPUT); - pinMode(MOSI, OUTPUT); - } - initialized++; // reference count - SREG = sreg; -} - -void SPIClass::end() { - uint8_t sreg = SREG; - noInterrupts(); // Protect from a scheduler and prevent transactionBegin - // Decrease the reference counter - if (initialized) - initialized--; - // If there are no more references disable SPI - if (!initialized) { - SPCR &= ~_BV(SPE); - interruptMode = 0; - #ifdef SPI_TRANSACTION_MISMATCH_LED - inTransactionFlag = 0; - #endif - } - SREG = sreg; -} - -// mapping of interrupt numbers to bits within SPI_AVR_EIMSK -#if defined(__AVR_ATmega32U4__) - #define SPI_INT0_MASK (1< - * Copyright (c) 2014 by Paul Stoffregen (Transaction API) - * Copyright (c) 2014 by Matthijs Kooijman (SPISettings AVR) - * Copyright (c) 2014 by Andrew J. Kroll (atomicity fixes) - * SPI Master library for arduino. - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of either the GNU General Public License version 2 - * or the GNU Lesser General Public License version 2.1, both as - * published by the Free Software Foundation. - */ - -#ifndef _SPI_H_INCLUDED -#define _SPI_H_INCLUDED - -#include - -// SPI_HAS_TRANSACTION means SPI has beginTransaction(), endTransaction(), -// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode) -#define SPI_HAS_TRANSACTION 1 - -// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method -#define SPI_HAS_NOTUSINGINTERRUPT 1 - -// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version. -// This way when there is a bug fix you can check this define to alert users -// of your code if it uses better version of this library. -// This also implies everything that SPI_HAS_TRANSACTION as documented above is -// available too. -#define SPI_ATOMIC_VERSION 1 - -// Uncomment this line to add detection of mismatched begin/end transactions. -// A mismatch occurs if other libraries fail to use SPI.endTransaction() for -// each SPI.beginTransaction(). Connect an LED to this pin. The LED will turn -// on if any mismatch is ever detected. -//#define SPI_TRANSACTION_MISMATCH_LED 5 - -#ifndef LSBFIRST -#define LSBFIRST 0 -#endif -#ifndef MSBFIRST -#define MSBFIRST 1 -#endif - -#define SPI_CLOCK_DIV4 0x00 -#define SPI_CLOCK_DIV16 0x01 -#define SPI_CLOCK_DIV64 0x02 -#define SPI_CLOCK_DIV128 0x03 -#define SPI_CLOCK_DIV2 0x04 -#define SPI_CLOCK_DIV8 0x05 -#define SPI_CLOCK_DIV32 0x06 - -#define SPI_MODE0 0x00 -#define SPI_MODE1 0x04 -#define SPI_MODE2 0x08 -#define SPI_MODE3 0x0C - -#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR -#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR -#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR - -// define SPI_AVR_EIMSK for AVR boards with external interrupt pins -#if defined(EIMSK) - #define SPI_AVR_EIMSK EIMSK -#elif defined(GICR) - #define SPI_AVR_EIMSK GICR -#elif defined(GIMSK) - #define SPI_AVR_EIMSK GIMSK -#endif - -class SPISettings { -public: - SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) { - if (__builtin_constant_p(clock)) { - init_AlwaysInline(clock, bitOrder, dataMode); - } else { - init_MightInline(clock, bitOrder, dataMode); - } - } - SPISettings() { - init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); - } -private: - void init_MightInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) { - init_AlwaysInline(clock, bitOrder, dataMode); - } - void init_AlwaysInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) - __attribute__((__always_inline__)) { - // Clock settings are defined as follows. Note that this shows SPI2X - // inverted, so the bits form increasing numbers. Also note that - // fosc/64 appears twice - // SPR1 SPR0 ~SPI2X Freq - // 0 0 0 fosc/2 - // 0 0 1 fosc/4 - // 0 1 0 fosc/8 - // 0 1 1 fosc/16 - // 1 0 0 fosc/32 - // 1 0 1 fosc/64 - // 1 1 0 fosc/64 - // 1 1 1 fosc/128 - - // We find the fastest clock that is less than or equal to the - // given clock rate. The clock divider that results in clock_setting - // is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the - // slowest (128 == 2 ^^ 7, so clock_div = 6). - uint8_t clockDiv; - - // When the clock is known at compiletime, use this if-then-else - // cascade, which the compiler knows how to completely optimize - // away. When clock is not known, use a loop instead, which generates - // shorter code. - if (__builtin_constant_p(clock)) { - if (clock >= F_CPU / 2) { - clockDiv = 0; - } else if (clock >= F_CPU / 4) { - clockDiv = 1; - } else if (clock >= F_CPU / 8) { - clockDiv = 2; - } else if (clock >= F_CPU / 16) { - clockDiv = 3; - } else if (clock >= F_CPU / 32) { - clockDiv = 4; - } else if (clock >= F_CPU / 64) { - clockDiv = 5; - } else { - clockDiv = 6; - } - } else { - uint32_t clockSetting = F_CPU / 2; - clockDiv = 0; - while (clockDiv < 6 && clock < clockSetting) { - clockSetting /= 2; - clockDiv++; - } - } - - // Compensate for the duplicate fosc/64 - if (clockDiv == 6) - clockDiv = 7; - - // Invert the SPI2X bit - clockDiv ^= 0x1; - - // Pack into the SPISettings class - spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) | - (dataMode & SPI_MODE_MASK) | ((clockDiv >> 1) & SPI_CLOCK_MASK); - spsr = clockDiv & SPI_2XCLOCK_MASK; - } - uint8_t spcr; - uint8_t spsr; - friend class SPIClass; -}; - - -class SPIClass { -public: - // Initialize the SPI library - static void begin(); - - // If SPI is used from within an interrupt, this function registers - // that interrupt with the SPI library, so beginTransaction() can - // prevent conflicts. The input interruptNumber is the number used - // with attachInterrupt. If SPI is used from a different interrupt - // (eg, a timer), interruptNumber should be 255. - static void usingInterrupt(uint8_t interruptNumber); - // And this does the opposite. - static void notUsingInterrupt(uint8_t interruptNumber); - // Note: the usingInterrupt and notUsingInterrupt functions should - // not to be called from ISR context or inside a transaction. - // For details see: - // https://github.com/arduino/Arduino/pull/2381 - // https://github.com/arduino/Arduino/pull/2449 - - // Before using SPI.transfer() or asserting chip select pins, - // this function is used to gain exclusive access to the SPI bus - // and configure the correct settings. - inline static void beginTransaction(SPISettings settings) { - if (interruptMode > 0) { - uint8_t sreg = SREG; - noInterrupts(); - - #ifdef SPI_AVR_EIMSK - if (interruptMode == 1) { - interruptSave = SPI_AVR_EIMSK; - SPI_AVR_EIMSK &= ~interruptMask; - SREG = sreg; - } else - #endif - { - interruptSave = sreg; - } - } - - #ifdef SPI_TRANSACTION_MISMATCH_LED - if (inTransactionFlag) { - pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); - digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); - } - inTransactionFlag = 1; - #endif - - SPCR = settings.spcr; - SPSR = settings.spsr; - } - - // Write to the SPI bus (MOSI pin) and also receive (MISO pin) - inline static uint8_t transfer(uint8_t data) { - SPDR = data; - /* - * The following NOP introduces a small delay that can prevent the wait - * loop form iterating when running at the maximum speed. This gives - * about 10% more speed, even if it seems counter-intuitive. At lower - * speeds it is unnoticed. - */ - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; // wait - return SPDR; - } - inline static uint16_t transfer16(uint16_t data) { - union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out; - in.val = data; - if (!(SPCR & _BV(DORD))) { - SPDR = in.msb; - asm volatile("nop"); // See transfer(uint8_t) function - while (!(SPSR & _BV(SPIF))) ; - out.msb = SPDR; - SPDR = in.lsb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.lsb = SPDR; - } else { - SPDR = in.lsb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.lsb = SPDR; - SPDR = in.msb; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))) ; - out.msb = SPDR; - } - return out.val; - } - inline static void transfer(void *buf, size_t count) { - if (count == 0) return; - uint8_t *p = (uint8_t *)buf; - SPDR = *p; - while (--count > 0) { - uint8_t out = *(p + 1); - while (!(SPSR & _BV(SPIF))) ; - uint8_t in = SPDR; - SPDR = out; - *p++ = in; - } - while (!(SPSR & _BV(SPIF))) ; - *p = SPDR; - } - // After performing a group of transfers and releasing the chip select - // signal, this function allows others to access the SPI bus - inline static void endTransaction(void) { - #ifdef SPI_TRANSACTION_MISMATCH_LED - if (!inTransactionFlag) { - pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); - digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); - } - inTransactionFlag = 0; - #endif - - if (interruptMode > 0) { - #ifdef SPI_AVR_EIMSK - uint8_t sreg = SREG; - #endif - noInterrupts(); - #ifdef SPI_AVR_EIMSK - if (interruptMode == 1) { - SPI_AVR_EIMSK = interruptSave; - SREG = sreg; - } else - #endif - { - SREG = interruptSave; - } - } - } - - // Disable the SPI bus - static void end(); - - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setBitOrder(uint8_t bitOrder) { - if (bitOrder == LSBFIRST) SPCR |= _BV(DORD); - else SPCR &= ~(_BV(DORD)); - } - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setDataMode(uint8_t dataMode) { - SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode; - } - // This function is deprecated. New applications should use - // beginTransaction() to configure SPI settings. - inline static void setClockDivider(uint8_t clockDiv) { - SPCR = (SPCR & ~SPI_CLOCK_MASK) | (clockDiv & SPI_CLOCK_MASK); - SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK); - } - // These undocumented functions should not be used. SPI.transfer() - // polls the hardware flag which is automatically cleared as the - // AVR responds to SPI's interrupt - inline static void attachInterrupt() { SPCR |= _BV(SPIE); } - inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); } - -private: - static uint8_t initialized; - static uint8_t interruptMode; // 0=none, 1=mask, 2=global - static uint8_t interruptMask; // which interrupts to mask - static uint8_t interruptSave; // temp storage, to restore state - #ifdef SPI_TRANSACTION_MISMATCH_LED - static uint8_t inTransactionFlag; - #endif -}; - -extern SPIClass SPI; - -#endif diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino deleted file mode 100644 index 8104fcbc252..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino +++ /dev/null @@ -1,143 +0,0 @@ -/* - SCP1000 Barometric Pressure Sensor Display - - Shows the output of a Barometric Pressure Sensor on a - Uses the SPI library. For details on the sensor, see: - http://www.sparkfun.com/commerce/product_info.php?products_id=8161 - http://www.vti.fi/en/support/obsolete_products/pressure_sensors/ - - This sketch adapted from Nathan Seidle's SCP1000 example for PIC: - http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip - - Circuit: - SCP1000 sensor attached to pins 6, 7, 10 - 13: - DRDY: pin 6 - CSB: pin 7 - MOSI: pin 11 - MISO: pin 12 - SCK: pin 13 - - created 31 July 2010 - modified 14 August 2010 - by Tom Igoe - */ - -// the sensor communicates using SPI, so include the library: -#include - -//Sensor's memory register addresses: -const int PRESSURE = 0x1F; //3 most significant bits of pressure -const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure -const int TEMPERATURE = 0x21; //16 bit temperature reading -const byte READ = 0b11111100; // SCP1000's read command -const byte WRITE = 0b00000010; // SCP1000's write command - -// pins used for the connection with the sensor -// the other you need are controlled by the SPI library): -const int dataReadyPin = 6; -const int chipSelectPin = 7; - -void setup() { - Serial.begin(9600); - - // start the SPI library: - SPI.begin(); - - // initalize the data ready and chip select pins: - pinMode(dataReadyPin, INPUT); - pinMode(chipSelectPin, OUTPUT); - - //Configure SCP1000 for low noise configuration: - writeRegister(0x02, 0x2D); - writeRegister(0x01, 0x03); - writeRegister(0x03, 0x02); - // give the sensor time to set up: - delay(100); -} - -void loop() { - //Select High Resolution Mode - writeRegister(0x03, 0x0A); - - // don't do anything until the data ready pin is high: - if (digitalRead(dataReadyPin) == HIGH) { - //Read the temperature data - int tempData = readRegister(0x21, 2); - - // convert the temperature to celsius and display it: - float realTemp = (float)tempData / 20.0; - Serial.print("Temp[C]="); - Serial.print(realTemp); - - - //Read the pressure data highest 3 bits: - byte pressure_data_high = readRegister(0x1F, 1); - pressure_data_high &= 0b00000111; //you only needs bits 2 to 0 - - //Read the pressure data lower 16 bits: - unsigned int pressure_data_low = readRegister(0x20, 2); - //combine the two parts into one 19-bit number: - long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4; - - // display the temperature: - Serial.println("\tPressure [Pa]=" + String(pressure)); - } -} - -//Read from or write to register from the SCP1000: -unsigned int readRegister(byte thisRegister, int bytesToRead ) { - byte inByte = 0; // incoming byte from the SPI - unsigned int result = 0; // result to return - Serial.print(thisRegister, BIN); - Serial.print("\t"); - // SCP1000 expects the register name in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the address and the command into one byte - byte dataToSend = thisRegister & READ; - Serial.println(thisRegister, BIN); - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - // send the device the register you want to read: - SPI.transfer(dataToSend); - // send a value of 0 to read the first byte returned: - result = SPI.transfer(0x00); - // decrement the number of bytes left to read: - bytesToRead--; - // if you still have another byte to read: - if (bytesToRead > 0) { - // shift the first byte left, then get the second byte: - result = result << 8; - inByte = SPI.transfer(0x00); - // combine the byte you just got with the previous one: - result = result | inByte; - // decrement the number of bytes left to read: - bytesToRead--; - } - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); - // return the result: - return(result); -} - - -//Sends a write command to SCP1000 - -void writeRegister(byte thisRegister, byte thisValue) { - - // SCP1000 expects the register address in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the register address and the command into one byte: - byte dataToSend = thisRegister | WRITE; - - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - - SPI.transfer(dataToSend); //Send register location - SPI.transfer(thisValue); //Send value to record into register - - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); -} - diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino deleted file mode 100644 index b135a74f4ed..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino +++ /dev/null @@ -1,71 +0,0 @@ -/* - Digital Pot Control - - This example controls an Analog Devices AD5206 digital potentiometer. - The AD5206 has 6 potentiometer channels. Each channel's pins are labeled - A - connect this to voltage - W - this is the pot's wiper, which changes when you set it - B - connect this to ground. - - The AD5206 is SPI-compatible,and to command it, you send two bytes, - one with the channel number (0 - 5) and one with the resistance value for the - channel (0 - 255). - - The circuit: - * All A pins of AD5206 connected to +5V - * All B pins of AD5206 connected to ground - * An LED and a 220-ohm resisor in series connected from each W pin to ground - * CS - to digital pin 10 (SS pin) - * SDI - to digital pin 11 (MOSI pin) - * CLK - to digital pin 13 (SCK pin) - - created 10 Aug 2010 - by Tom Igoe - - Thanks to Heather Dewey-Hagborg for the original tutorial, 2005 - -*/ - - -// inslude the SPI library: -#include - - -// set pin 10 as the slave select for the digital pot: -const int slaveSelectPin = 10; - -void setup() { - // set the slaveSelectPin as an output: - pinMode (slaveSelectPin, OUTPUT); - // initialize SPI: - SPI.begin(); -} - -void loop() { - // go through the six channels of the digital pot: - for (int channel = 0; channel < 6; channel++) { - // change the resistance on this channel from min to max: - for (int level = 0; level < 255; level++) { - digitalPotWrite(channel, level); - delay(10); - } - // wait a second at the top: - delay(100); - // change the resistance on this channel from max to min: - for (int level = 0; level < 255; level++) { - digitalPotWrite(channel, 255 - level); - delay(10); - } - } - -} - -void digitalPotWrite(int address, int value) { - // take the SS pin low to select the chip: - digitalWrite(slaveSelectPin, LOW); - // send in the address and value via SPI: - SPI.transfer(address); - SPI.transfer(value); - // take the SS pin high to de-select the chip: - digitalWrite(slaveSelectPin, HIGH); -} diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/keywords.txt b/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/keywords.txt deleted file mode 100644 index fa7616581aa..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/keywords.txt +++ /dev/null @@ -1,36 +0,0 @@ -####################################### -# Syntax Coloring Map SPI -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SPI KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -begin KEYWORD2 -end KEYWORD2 -transfer KEYWORD2 -setBitOrder KEYWORD2 -setDataMode KEYWORD2 -setClockDivider KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### -SPI_CLOCK_DIV4 LITERAL1 -SPI_CLOCK_DIV16 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_CLOCK_DIV128 LITERAL1 -SPI_CLOCK_DIV2 LITERAL1 -SPI_CLOCK_DIV8 LITERAL1 -SPI_CLOCK_DIV32 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_MODE0 LITERAL1 -SPI_MODE1 LITERAL1 -SPI_MODE2 LITERAL1 -SPI_MODE3 LITERAL1 \ No newline at end of file diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/library.properties b/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/library.properties deleted file mode 100644 index 07af8696109..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/libraries/SPI/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=SPI -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE. -paragraph= -url=http://arduino.cc/en/Reference/SPI -architectures=avr -types=Arduino - diff --git a/legacy/builder/test/user_hardware/my_avr_platform/avr/platform.txt b/legacy/builder/test/user_hardware/my_avr_platform/avr/platform.txt deleted file mode 100644 index cc0be0a0c5f..00000000000 --- a/legacy/builder/test/user_hardware/my_avr_platform/avr/platform.txt +++ /dev/null @@ -1,9 +0,0 @@ - -# Arduino AVR Core and platform. -# ------------------------------ - -# For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification - -name=My AVR Boards -version=9.9.9 \ No newline at end of file diff --git a/legacy/builder/test/user_hardware/my_symlinked_avr_platform b/legacy/builder/test/user_hardware/my_symlinked_avr_platform deleted file mode 120000 index 8f67ba7ea89..00000000000 --- a/legacy/builder/test/user_hardware/my_symlinked_avr_platform +++ /dev/null @@ -1 +0,0 @@ -my_avr_platform \ No newline at end of file diff --git a/legacy/builder/types/context.go b/legacy/builder/types/context.go index e720af613d1..64b85c93fe2 100644 --- a/legacy/builder/types/context.go +++ b/legacy/builder/types/context.go @@ -19,8 +19,6 @@ import ( "github.com/arduino/arduino-cli/arduino/builder" "github.com/arduino/arduino-cli/arduino/builder/detector" "github.com/arduino/arduino-cli/arduino/builder/logger" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - paths "github.com/arduino/go-paths-helper" ) // Context structure @@ -28,11 +26,4 @@ type Context struct { Builder *builder.Builder SketchLibrariesDetector *detector.SketchLibrariesDetector BuilderLogger *logger.BuilderLogger - - // Used only by legacy tests - HardwareDirs paths.PathList - BuiltInToolsDirs paths.PathList - BuiltInLibrariesDirs *paths.Path - OtherLibrariesDirs paths.PathList - PackageManager *packagemanager.Explorer }