├── .clang-format ├── .gitignore ├── LICENSE ├── LICENSE.3-clause-bsd-clear ├── README.md ├── arduino-build.sh ├── arduino-win-build.bat ├── firmware-syntiant-tinyml.ino ├── lib ├── Adafruit_ASFcore │ ├── Adafruit_ASFcore.h │ ├── README.md │ ├── clock.h │ ├── clock_feature.h │ ├── compiler.h │ ├── gclk.c │ ├── gclk.h │ ├── i2s.c │ ├── i2s.h │ ├── interrupt.h │ ├── interrupt │ │ ├── interrupt_sam_nvic.c │ │ └── interrupt_sam_nvic.h │ ├── interrupt_sam_nvic.c │ ├── interrupt_sam_nvic.h │ ├── library.properties │ ├── parts.h │ ├── pinmux.c │ ├── pinmux.h │ ├── power.h │ ├── preprocessor │ │ ├── mrecursion.h │ │ ├── mrepeat.h │ │ ├── preprocessor.h │ │ ├── stringz.h │ │ └── tpaste.h │ ├── reset.h │ ├── status_codes.h │ ├── system.c │ ├── system.h │ ├── system_interrupt.h │ ├── system_interrupt_features.h │ ├── tc.c │ ├── tc.h │ ├── tc_interrupt.c │ ├── tc_interrupt.h │ ├── wdt.c │ └── wdt.h ├── Arduino USBCore driver │ ├── README.md │ └── USBCore.cpp ├── AudioUSB │ ├── documentation │ │ ├── Doxyfile │ │ └── src │ │ │ └── Logo.png │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── AudioUSB.cpp │ │ └── AudioUSB.h ├── NDP │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── NDP.cpp │ │ └── NDP.h ├── NDP_utils │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── NDP_GPIO.h │ │ ├── NDP_PMU.cpp │ │ ├── NDP_PMU.h │ │ ├── NDP_SPI.cpp │ │ ├── NDP_SPI.h │ │ ├── NDP_Serial.h │ │ ├── NDP_loadModel.cpp │ │ ├── NDP_loadModel.h │ │ └── NDP_utils.h ├── PMIC_SGM41512 │ ├── library.properties │ └── src │ │ ├── SGM41512.cpp │ │ └── SGM41512.h ├── SerialFlash │ ├── .piopm │ ├── README.md │ ├── SerialFlash.h │ ├── SerialFlashChip.cpp │ ├── SerialFlashDirectory.cpp │ ├── doc │ │ └── w25q128fv.jpg │ ├── docs │ │ └── issue_template.md │ ├── examples │ │ ├── CopyFromSD │ │ │ └── CopyFromSD.ino │ │ ├── CopyFromSerial │ │ │ └── CopyFromSerial.ino │ │ ├── EraseEverything │ │ │ └── EraseEverything.ino │ │ ├── ListFiles │ │ │ └── ListFiles.ino │ │ ├── MP3Player │ │ │ └── MP3Player.ino │ │ ├── RawHardwareTest │ │ │ └── RawHardwareTest.ino │ │ └── ReadBenchmark │ │ │ └── ReadBenchmark.ino │ ├── extras │ │ └── rawfile-uploader.py │ ├── keywords.txt │ ├── library.json │ ├── library.properties │ ├── tests.txt │ └── util │ │ └── SerialFlash_directwrite.h └── syntiant_ilib │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── VERSION │ ├── syntiant_ilib │ ├── syntiant_ndp10x_micro.h │ ├── syntiant_ndp_error.h │ ├── syntiant_ndp_ilib_version.h │ └── syntiant_portability.h │ ├── syntiant_ndp10x_micro.c │ └── syntiant_ndp10x_micro_arduino.h ├── src ├── QCBOR │ ├── inc │ │ ├── UsefulBuf.h │ │ └── qcbor.h │ └── src │ │ ├── UsefulBuf.c │ │ ├── ieee754.c │ │ ├── ieee754.h │ │ ├── qcbor_decode.c │ │ └── qcbor_encode.c ├── edge-impulse-sdk │ ├── classifier │ │ ├── ei_model_types.h │ │ └── inferencing_engines │ │ │ └── engines.h │ ├── porting │ │ ├── arduino │ │ │ └── ei_classifier_porting.cpp │ │ └── ei_classifier_porting.h │ └── tensorflow │ │ └── lite │ │ └── micro │ │ └── debug_log.h ├── ei_sample_storage.cpp ├── ei_sample_storage.h ├── ei_setup.cpp ├── firmware-sdk │ ├── .gitignore │ ├── README.md │ ├── at-server │ │ ├── ei_at_command_set.h │ │ ├── ei_at_history.h │ │ ├── ei_at_parser.cpp │ │ ├── ei_at_parser.h │ │ ├── ei_at_server.cpp │ │ ├── ei_at_server.h │ │ ├── ei_at_server_singleton.cpp │ │ └── ei_line_buffer.h │ ├── at_base64_lib.cpp │ ├── at_base64_lib.h │ ├── ei_camera_interface.h │ ├── ei_config_types.h │ ├── ei_device_info_lib.h │ ├── ei_device_interface.h │ ├── ei_device_lib.cpp │ ├── ei_device_lib.h │ ├── ei_device_memory.h │ ├── ei_fusion.cpp │ ├── ei_fusion.h │ ├── ei_image_nn.h │ ├── jpeg │ │ ├── JPEGENC.cpp │ │ ├── JPEGENC.h │ │ ├── encode_as_jpg.h │ │ └── jpeg.h │ ├── sensor_aq.cpp │ └── sensor_aq.h ├── ingestion-sdk-c │ ├── ei_config.h │ └── ei_config_types.h ├── ingestion-sdk-platform │ └── syntiant │ │ ├── ei_device_info.h │ │ ├── ei_device_syntiant_samd.cpp │ │ ├── ei_device_syntiant_samd.h │ │ ├── ei_syntiant_fs_commands.cpp │ │ └── ei_syntiant_fs_commands.h ├── model-parameters │ ├── model_metadata.h │ └── model_variables.h ├── repl │ ├── at_base64.h │ ├── at_cmd_interface.h │ ├── at_cmds.h │ ├── repl.cpp │ └── repl.h ├── sensor_aq_mbedtls │ ├── sensor_aq_mbedtls_hs256.cpp │ └── sensor_aq_mbedtls_hs256.h ├── sensors │ ├── ei_fusion_sensors_config.h │ ├── ei_inertialsensor.cpp │ ├── ei_inertialsensor.h │ ├── ei_sampler.cpp │ └── ei_sampler.h ├── syntiant.cpp └── syntiant.h ├── syntiant_arduino_version.h └── update_libraries_windows.bat /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: WebKit 4 | AccessModifierOffset: -4 5 | AlignAfterOpenBracket: AlwaysBreak 6 | AlignConsecutiveMacros: true 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | AlignEscapedNewlines: Right 10 | AlignOperands: false 11 | AlignTrailingComments: false 12 | AllowAllArgumentsOnNextLine: false 13 | AllowAllConstructorInitializersOnNextLine: false 14 | AllowAllParametersOfDeclarationOnNextLine: false 15 | AllowShortBlocksOnASingleLine: Empty 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: None 18 | AllowShortLambdasOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: Never 20 | AllowShortLoopsOnASingleLine: false 21 | AlwaysBreakAfterDefinitionReturnType: None 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: false 24 | AlwaysBreakTemplateDeclarations: MultiLine 25 | BinPackArguments: false 26 | BinPackParameters: false 27 | BraceWrapping: 28 | AfterCaseLabel: false 29 | AfterClass: false 30 | AfterControlStatement: false 31 | AfterEnum: true 32 | AfterFunction: true 33 | AfterNamespace: false 34 | AfterObjCDeclaration: false 35 | AfterStruct: false 36 | AfterUnion: false 37 | AfterExternBlock: false 38 | BeforeCatch: false 39 | BeforeElse: true 40 | IndentBraces: false 41 | SplitEmptyFunction: true 42 | SplitEmptyRecord: true 43 | SplitEmptyNamespace: true 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Custom 46 | BreakBeforeInheritanceComma: false 47 | BreakInheritanceList: BeforeColon 48 | BreakBeforeTernaryOperators: true 49 | BreakConstructorInitializersBeforeComma: false 50 | BreakConstructorInitializers: BeforeComma 51 | BreakAfterJavaFieldAnnotations: false 52 | BreakStringLiterals: true 53 | ColumnLimit: 100 54 | CommentPragmas: '^ IWYU pragma:' 55 | CompactNamespaces: false 56 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 57 | ConstructorInitializerIndentWidth: 4 58 | ContinuationIndentWidth: 4 59 | Cpp11BracedListStyle: false 60 | DeriveLineEnding: true 61 | DerivePointerAlignment: false 62 | DisableFormat: false 63 | ExperimentalAutoDetectBinPacking: false 64 | FixNamespaceComments: false 65 | ForEachMacros: 66 | - foreach 67 | - Q_FOREACH 68 | - BOOST_FOREACH 69 | IncludeBlocks: Preserve 70 | IncludeCategories: 71 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 72 | Priority: 2 73 | SortPriority: 0 74 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 75 | Priority: 3 76 | SortPriority: 0 77 | - Regex: '.*' 78 | Priority: 1 79 | SortPriority: 0 80 | IncludeIsMainRegex: '(Test)?$' 81 | IncludeIsMainSourceRegex: '' 82 | IndentCaseLabels: false 83 | IndentCaseBlocks: false 84 | IndentGotoLabels: true 85 | IndentPPDirectives: None 86 | IndentWidth: 4 87 | IndentWrappedFunctionNames: false 88 | JavaScriptQuotes: Leave 89 | JavaScriptWrapImports: true 90 | KeepEmptyLinesAtTheStartOfBlocks: true 91 | MacroBlockBegin: '' 92 | MacroBlockEnd: '' 93 | MaxEmptyLinesToKeep: 1 94 | NamespaceIndentation: None 95 | ObjCBinPackProtocolList: Auto 96 | ObjCBlockIndentWidth: 4 97 | ObjCSpaceAfterProperty: true 98 | ObjCSpaceBeforeProtocolList: true 99 | PenaltyBreakAssignment: 20 100 | PenaltyBreakBeforeFirstCallParameter: 10 101 | PenaltyBreakComment: 100000 102 | PenaltyBreakFirstLessLess: 120 103 | PenaltyBreakString: 1000 104 | PenaltyBreakTemplateDeclaration: 10 105 | PenaltyExcessCharacter: 100 106 | PenaltyReturnTypeOnItsOwnLine: 60 107 | PointerAlignment: Right 108 | ReflowComments: false 109 | SortIncludes: true 110 | SortUsingDeclarations: true 111 | SpaceAfterCStyleCast: false 112 | SpaceAfterLogicalNot: false 113 | SpaceAfterTemplateKeyword: true 114 | SpaceBeforeAssignmentOperators: true 115 | SpaceBeforeCpp11BracedList: true 116 | SpaceBeforeCtorInitializerColon: true 117 | SpaceBeforeInheritanceColon: true 118 | SpaceBeforeParens: ControlStatements 119 | SpaceBeforeRangeBasedForLoopColon: true 120 | SpaceInEmptyBlock: true 121 | SpaceInEmptyParentheses: false 122 | SpacesBeforeTrailingComments: 1 123 | SpacesInAngles: false 124 | SpacesInConditionalStatement: false 125 | SpacesInContainerLiterals: true 126 | SpacesInCStyleCastParentheses: false 127 | SpacesInParentheses: false 128 | SpacesInSquareBrackets: false 129 | SpaceBeforeSquareBrackets: false 130 | Standard: c++11 131 | StatementMacros: 132 | - Q_UNUSED 133 | - QT_REQUIRE_VERSION 134 | TabWidth: 8 135 | UseCRLF: false 136 | UseTab: Never 137 | ... 138 | 139 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #build output files 2 | *.bin 3 | *.elf 4 | *.map 5 | *.hex 6 | 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Unless specifically indicated otherwise in a file or license file in the directory, files are licensed under the 3-Clause BSD Clear license, as can be found in: LICENSE.3-clause-bsd-clear -------------------------------------------------------------------------------- /LICENSE.3-clause-bsd-clear: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | 3 | Copyright (c) 2025 EdgeImpulse Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted (subject to the limitations in the disclaimer 8 | below) provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Config build and flash 2 | 3 | This project uses the `arduino-cli` compiler to build & flash new firmware. Windows users also need Arduino IDE (tested with v1.8.15). 4 | 5 | 6 | ### Usage - macOS and Linux 7 | 8 | The script will verify if all needed libraries and the samd core is installed and install them if needed. If you prefer to do this 9 | step manually, follow the step in the next chapter. 10 | 11 | For building the project: 12 | 13 | * For audio support, use: 14 | ``` 15 | ./arduino-build.sh --build 16 | ``` 17 | 18 | * For IMU sensor support, use: 19 | ``` 20 | ./arduino-build.sh --build --with-imu 21 | ``` 22 | 23 | 24 | For flashing use: 25 | 26 | ``` 27 | ./arduino-build.sh --flash 28 | ``` 29 | 30 | 31 | You can also do both by using: 32 | ``` 33 | ./arduino-build.sh --all [--with-imu] 34 | ``` 35 | 36 | 37 | ### Usage - Windows 38 | 39 | * Run `update_libraries_windows.bat` script to install Arduino libraries. 40 | 41 | For building the project: 42 | 43 | * For audio support, use: 44 | ``` 45 | ./arduino-win-build.bat --build 46 | ``` 47 | 48 | * For IMU sensor support, use: 49 | ``` 50 | ./arduino-win-build.bat --build --with-imu 51 | ``` 52 | 53 | 54 | For flashing use, put the board in boot mode (double click on the reset button when connecting the board to USB, while the orange LED is blinking. In boot mode you should see the red LED fading on and off): 55 | 56 | ``` 57 | ./arduino-win-build.bat --flash 58 | ``` 59 | 60 | 61 | You can also do both by using: 62 | ``` 63 | ./arduino-win-build.bat --all [--with-imu] 64 | ``` 65 | 66 | ## Setup Manually 67 | 68 | * Install Board package SAMD v1.8.9 69 | 70 | * Install following libraries using Arduino Library manager (use exact versions): 71 | * avdweb_SAMDtimer@1.0.0 72 | * Adafruit ZeroTimer Library@1.0.1 73 | * Adafruit BusIO@1.8.2 74 | * Adafruit GFX Library@1.10.10 75 | * Adafruit SSD1306@2.4.6 76 | * nicohood/HID-Project@2.6.1 77 | * SdFat@2.0.6 78 | 79 | * Install the following libraries as a Zip library: 80 | * lib/Adafruit_ASFcore 81 | * lib/PMIC_SGM41512 82 | * lib/AudioUSB 83 | * lib/NDP 84 | * lib/NDP_utils 85 | * lib/SerialFlash 86 | * lib/syntiant_ilib 87 | 88 | * Patch the _Arduino USBCore driver_: copy `lib/Arduino USBCore driver/USBCore.cpp` in SAMD package folder (ie: /Users/[USER]/Library/Arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/USB/) 89 | -------------------------------------------------------------------------------- /arduino-win-build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set PROJECT=firmware-syntiant-tinyml 4 | set BOARD=arduino:samd:mkrzero 5 | set ARDUINO_CLI=arduino-cli 6 | set BUILD_OPTION=--build 7 | set FLASH_OPTION=--flash 8 | set ALL_OPTION=--all 9 | 10 | set SENSOR_WITH_IMU=--with-imu 11 | :: use --with-imu flag as 2nd argument to build firmware for IMU 12 | set COMMAND=%1 13 | set SENSOR=%2 14 | 15 | set /A EXPECTED_CLI_MAJOR=0 16 | set /A EXPECTED_CLI_MINOR=18 17 | 18 | where /q %ARDUINO_CLI% 19 | IF ERRORLEVEL 1 ( 20 | ECHO Cannot find 'arduino-cli' in your PATH. Install the Arduino CLI before you continue. 21 | ECHO Installation instructions: https://arduino.github.io/arduino-cli/latest/ 22 | EXIT /B 23 | ) 24 | 25 | :: check if compile with imu 26 | IF "%SENSOR%" == "--with-imu" ( 27 | set CPP_FLAGS=-DWITH_IMU 28 | ) ELSE ( 29 | set CPP_FLAGS= 30 | ) 31 | 32 | :: define and include 33 | set DEFINE=-DEI_SENSOR_AQ_STREAM=FILE -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x804f -DUSBCON -DUSB_MANUFACTURER=\"Syntiant\" -DUSB_PRODUCT=\"TinyML\" 34 | set INCLUDE=-I.\\src\\ -I\\ingestion-sdk-platform\\repl\\ -I.\\src\\ingestion-sdk-platform\\syntiant\\ -I.\\src\\sensors\\ -I.\\src\\ingestion-sdk-c\\ -I.\\src\\QCBOR\\inc\\ -I.\\src\\sensor_aq_mbedtls\\ 35 | 36 | :: just build 37 | IF %COMMAND% == %BUILD_OPTION% goto :BUILD 38 | 39 | :: look for connected board 40 | goto :FIND_COM_PORT 41 | :COMM_FOUND 42 | 43 | IF %COMMAND% == %FLASH_OPTION% goto :FLASH 44 | 45 | IF %COMMAND% == %ALL_OPTION% goto :ALL else goto :COMMON_EXIT 46 | 47 | echo No valid command 48 | 49 | goto :COMMON_EXIT 50 | 51 | :BUILD 52 | echo Building %PROJECT% 53 | echo %ARDUINO_CLI% compile --fqbn %BOARD% --build-property "build.extra_flags=%DEFINE% %INCLUDE%" --build-property "compiler.cpp.extra_flags=%CPP_FLAGS%" %PROJECT% --output-dir . 54 | %ARDUINO_CLI% compile --fqbn %BOARD% --build-property "build.extra_flags=%DEFINE% %INCLUDE%" --build-property "compiler.cpp.extra_flags=%CPP_FLAGS%" %PROJECT% --output-dir . 55 | goto :COMMON_EXIT 56 | 57 | :FLASH 58 | echo Flashing %PROJECT% 59 | echo %ARDUINO_CLI% upload -p %found_com% --fqbn %BOARD% 60 | %ARDUINO_CLI% upload -p %found_com% --fqbn %BOARD% 61 | goto :COMMON_EXIT 62 | 63 | :ALL 64 | echo Building %PROJECT% 65 | echo %ARDUINO_CLI% compile --fqbn %BOARD% --build-property "build.extra_flags=%DEFINE% %INCLUDE%" %PROJECT% --output-dir . 66 | %ARDUINO_CLI% compile --fqbn %BOARD% --build-property "build.extra_flags=%DEFINE% %INCLUDE%" %PROJECT% --output-dir . 67 | echo Flashing %PROJECT% 68 | echo %ARDUINO_CLI% upload -p %found_com% --fqbn %BOARD% --input-dir . 69 | %ARDUINO_CLI% upload -p %found_com% --fqbn %BOARD% --input-dir . 70 | goto :COMMON_EXIT 71 | 72 | :: check for COM port and if they are listed as Arduino 73 | :FIND_COM_PORT 74 | @setlocal enableextensions enabledelayedexpansion 75 | 76 | :: wmic /format:list strips trailing spaces (at least for path win32_pnpentity) 77 | for /f "tokens=1* delims==" %%I in ('wmic path win32_pnpentity get caption /format:list ^| find "Arduino"') do ( 78 | call :setCOM "%%~J" 79 | ) 80 | 81 | :: Check if any returned value 82 | if "%found_com%"=="" ( 83 | echo No valid COM found 84 | goto :COMMON_EXIT 85 | ) 86 | goto :COMM_FOUND 87 | 88 | :setCOM 89 | 90 | setlocal 91 | 92 | set "str=%~1" 93 | set "test=%~1" 94 | 95 | set "num=%str:*(COM=%" 96 | set "num=%num:)=%" 97 | set str=%str:(COM=&rem.% 98 | 99 | endlocal & set found_com=COM%num% 100 | goto :EOF 101 | 102 | :COMMON_EXIT 103 | -------------------------------------------------------------------------------- /firmware-syntiant-tinyml.ino: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "src/syntiant.h" 36 | #include 37 | #include 38 | #include 39 | 40 | /** 41 | * @brief Called when a inference matches 1 of the features 42 | * 43 | * @param[in] event The event 44 | * @param[in] confidence The confidence 45 | * @param[in] anomaly_score The anomaly score 46 | */ 47 | void on_classification_changed(const char *event, float confidence, float anomaly_score) { 48 | 49 | // here you can write application code, e.g. to toggle LEDs based on keywords 50 | if (strcmp(event, "stop") == 0) { 51 | // Toggle LED 52 | digitalWrite(LED_RED, HIGH); 53 | } 54 | 55 | if (strcmp(event, "go") == 0) { 56 | // Toggle LED 57 | digitalWrite(LED_GREEN, HIGH); 58 | } 59 | } 60 | 61 | 62 | 63 | void setup(void) 64 | { 65 | syntiant_setup(); 66 | } 67 | 68 | void loop(void) 69 | { 70 | syntiant_loop(); 71 | } -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/Adafruit_ASFcore.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/firmware-syntiant-tinyml/30afeb48b86159022dfc9cc14bff674304e8369e/lib/Adafruit_ASFcore/Adafruit_ASFcore.h -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/README.md: -------------------------------------------------------------------------------- 1 | # ASF (Atmel Software Framework) for Arduino Zero / Adafruit Feather M0 (SAMD21) 2 | 3 | Copy of ASF (Atmel Software Framework) excerpts for the SAMD21 processor used in the Arduino Zero / Adafruit Feather M0 boards. 4 | You typically won't use this library directly, instead other libraries will depend on this library and use the code 5 | within it to simplify their implementation. 6 | 7 | All code is taken directly from Atmel's ASF: http://www.atmel.com/tools/avrsoftwareframework.aspx?tab=overview 8 | 9 | The code is copyright Atmel and released by them under the following license: 10 | 11 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following 15 | disclaimer. 16 | 17 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 18 | disclaimer in the documentation and/or other materials provided with the distribution. 19 | 20 | 3. The name of Atmel may not be used to endorse or promote products derived from this software without specific 21 | prior written permission. 22 | 23 | 4. This software may only be redistributed and used in connection with an Atmel microcontroller product. 24 | 25 | THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 26 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 27 | PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN 28 | NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 29 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 30 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 33 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM Clock Driver 5 | * 6 | * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /* 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | #ifndef SYSTEM_CLOCK_H_INCLUDED 47 | #define SYSTEM_CLOCK_H_INCLUDED 48 | 49 | #include "compiler.h" 50 | #include "gclk.h" 51 | #include "clock_feature.h" 52 | 53 | #endif /* SYSTEM_CLOCK_H_INCLUDED */ 54 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/interrupt.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2011-2012, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | #ifndef UTILS_INTERRUPT_H 30 | #define UTILS_INTERRUPT_H 31 | 32 | //#include 33 | 34 | #include "interrupt/interrupt_sam_nvic.h" 35 | 36 | /** 37 | * \defgroup interrupt_group Global interrupt management 38 | * 39 | * This is a driver for global enabling and disabling of interrupts. 40 | * 41 | * @{ 42 | */ 43 | 44 | #if defined(__DOXYGEN__) 45 | /** 46 | * \def CONFIG_INTERRUPT_FORCE_INTC 47 | * \brief Force usage of the ASF INTC driver 48 | * 49 | * Predefine this symbol when preprocessing to force the use of the ASF INTC driver. 50 | * This is useful to ensure compatibility across compilers and shall be used only when required 51 | * by the application needs. 52 | */ 53 | # define CONFIG_INTERRUPT_FORCE_INTC 54 | #endif 55 | 56 | //! \name Global interrupt flags 57 | //@{ 58 | /** 59 | * \typedef irqflags_t 60 | * \brief Type used for holding state of interrupt flag 61 | */ 62 | 63 | /** 64 | * \def cpu_irq_enable 65 | * \brief Enable interrupts globally 66 | */ 67 | 68 | /** 69 | * \def cpu_irq_disable 70 | * \brief Disable interrupts globally 71 | */ 72 | 73 | /** 74 | * \fn irqflags_t cpu_irq_save(void) 75 | * \brief Get and clear the global interrupt flags 76 | * 77 | * Use in conjunction with \ref cpu_irq_restore. 78 | * 79 | * \return Current state of interrupt flags. 80 | * 81 | * \note This function leaves interrupts disabled. 82 | */ 83 | 84 | /** 85 | * \fn void cpu_irq_restore(irqflags_t flags) 86 | * \brief Restore global interrupt flags 87 | * 88 | * Use in conjunction with \ref cpu_irq_save. 89 | * 90 | * \param flags State to set interrupt flag to. 91 | */ 92 | 93 | /** 94 | * \fn bool cpu_irq_is_enabled_flags(irqflags_t flags) 95 | * \brief Check if interrupts are globally enabled in supplied flags 96 | * 97 | * \param flags Currents state of interrupt flags. 98 | * 99 | * \return True if interrupts are enabled. 100 | */ 101 | 102 | /** 103 | * \def cpu_irq_is_enabled 104 | * \brief Check if interrupts are globally enabled 105 | * 106 | * \return True if interrupts are enabled. 107 | */ 108 | //@} 109 | 110 | //! @} 111 | 112 | /** 113 | * \ingroup interrupt_group 114 | * \defgroup interrupt_deprecated_group Deprecated interrupt definitions 115 | */ 116 | 117 | #endif /* UTILS_INTERRUPT_H */ 118 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/interrupt/interrupt_sam_nvic.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2011-2012, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | 30 | #include "interrupt_sam_nvic.h" 31 | 32 | #if !defined(__DOXYGEN__) 33 | /* Deprecated - global flag to determine the global interrupt state. Required by 34 | * QTouch library, however new applications should use cpu_irq_is_enabled() 35 | * which probes the true global interrupt state from the CPU special registers. 36 | */ 37 | volatile bool g_interrupt_enabled = true; 38 | #endif 39 | 40 | void cpu_irq_enter_critical(void) 41 | { 42 | if (cpu_irq_critical_section_counter == 0) { 43 | if (cpu_irq_is_enabled()) { 44 | cpu_irq_disable(); 45 | cpu_irq_prev_interrupt_state = true; 46 | } else { 47 | /* Make sure the to save the prev state as false */ 48 | cpu_irq_prev_interrupt_state = false; 49 | } 50 | 51 | } 52 | 53 | cpu_irq_critical_section_counter++; 54 | } 55 | 56 | void cpu_irq_leave_critical(void) 57 | { 58 | /* Check if the user is trying to leave a critical section when not in a critical section */ 59 | Assert(cpu_irq_critical_section_counter > 0); 60 | 61 | cpu_irq_critical_section_counter--; 62 | 63 | /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag 64 | was enabled when entering critical state */ 65 | if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) { 66 | cpu_irq_enable(); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/interrupt_sam_nvic.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Global interrupt management for SAM D20, SAM3 and SAM4 (NVIC based) 5 | * 6 | * Copyright (c) 2012-2015 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /* 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #include "interrupt_sam_nvic.h" 48 | 49 | #if !defined(__DOXYGEN__) 50 | /* Deprecated - global flag to determine the global interrupt state. Required by 51 | * QTouch library, however new applications should use cpu_irq_is_enabled() 52 | * which probes the true global interrupt state from the CPU special registers. 53 | */ 54 | volatile bool g_interrupt_enabled = true; 55 | #endif 56 | 57 | void cpu_irq_enter_critical(void) 58 | { 59 | if (cpu_irq_critical_section_counter == 0) { 60 | if (cpu_irq_is_enabled()) { 61 | cpu_irq_disable(); 62 | cpu_irq_prev_interrupt_state = true; 63 | } else { 64 | /* Make sure the to save the prev state as false */ 65 | cpu_irq_prev_interrupt_state = false; 66 | } 67 | 68 | } 69 | 70 | cpu_irq_critical_section_counter++; 71 | } 72 | 73 | void cpu_irq_leave_critical(void) 74 | { 75 | /* Check if the user is trying to leave a critical section when not in a critical section */ 76 | Assert(cpu_irq_critical_section_counter > 0); 77 | 78 | cpu_irq_critical_section_counter--; 79 | 80 | /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag 81 | was enabled when entering critical state */ 82 | if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) { 83 | cpu_irq_enable(); 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit Arduino Zero ASF Core Library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=ASF (Atmel Software Framework) files used by Adafruit's Arduino Zero/SAMD21 libraries. 6 | paragraph=ASF (Atmel Software Framework) files used by Adafruit's Arduino Zero/SAMD21 libraries. This is a dependency of other libraries like Adafruit_ZeroTimer. 7 | category=Other 8 | url=https://github.com/adafruit/Adafruit_ASFcore 9 | architectures=* 10 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/preprocessor/preprocessor.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2011-2012, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | 30 | #ifndef _PREPROCESSOR_H_ 31 | #define _PREPROCESSOR_H_ 32 | 33 | #include "tpaste.h" 34 | #include "stringz.h" 35 | #include "mrepeat.h" 36 | #include "mrecursion.h" 37 | 38 | #endif // _PREPROCESSOR_H_ 39 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/preprocessor/stringz.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2011-2012, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | 30 | #ifndef _STRINGZ_H_ 31 | #define _STRINGZ_H_ 32 | 33 | /** 34 | * \defgroup group_sam0_utils_stringz Preprocessor - Stringize 35 | * 36 | * \ingroup group_sam0_utils 37 | * 38 | * @{ 39 | */ 40 | 41 | /** \brief Stringize. 42 | * 43 | * Stringize a preprocessing token, this token being allowed to be \#defined. 44 | * 45 | * May be used only within macros with the token passed as an argument if the 46 | * token is \#defined. 47 | * 48 | * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) 49 | * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to 50 | * writing "A0". 51 | */ 52 | #define STRINGZ(x) #x 53 | 54 | /** \brief Absolute stringize. 55 | * 56 | * Stringize a preprocessing token, this token being allowed to be \#defined. 57 | * 58 | * No restriction of use if the token is \#defined. 59 | * 60 | * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is 61 | * equivalent to writing "A0". 62 | */ 63 | #define ASTRINGZ(x) STRINGZ(x) 64 | 65 | /** @} */ 66 | 67 | #endif // _STRINGZ_H_ 68 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/preprocessor/tpaste.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2011-2012, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | #ifndef _TPASTE_H_ 30 | #define _TPASTE_H_ 31 | 32 | /** 33 | * \defgroup group_sam0_utils_tpaste Preprocessor - Token Paste 34 | * 35 | * \ingroup group_sam0_utils 36 | * 37 | * @{ 38 | */ 39 | 40 | /** \name Token Paste 41 | * 42 | * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. 43 | * 44 | * May be used only within macros with the tokens passed as arguments if the tokens are \#defined. 45 | * 46 | * For example, writing TPASTE2(U, WIDTH) within a macro \#defined by 47 | * UTYPE(WIDTH) and invoked as UTYPE(UL_WIDTH) with UL_WIDTH \#defined as 32 is 48 | * equivalent to writing U32. 49 | * 50 | * @{ */ 51 | #define TPASTE2( a, b) a##b 52 | #define TPASTE3( a, b, c) a##b##c 53 | #define TPASTE4( a, b, c, d) a##b##c##d 54 | #define TPASTE5( a, b, c, d, e) a##b##c##d##e 55 | #define TPASTE6( a, b, c, d, e, f) a##b##c##d##e##f 56 | #define TPASTE7( a, b, c, d, e, f, g) a##b##c##d##e##f##g 57 | #define TPASTE8( a, b, c, d, e, f, g, h) a##b##c##d##e##f##g##h 58 | #define TPASTE9( a, b, c, d, e, f, g, h, i) a##b##c##d##e##f##g##h##i 59 | #define TPASTE10(a, b, c, d, e, f, g, h, i, j) a##b##c##d##e##f##g##h##i##j 60 | /** @} */ 61 | 62 | /** \name Absolute Token Paste 63 | * 64 | * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. 65 | * 66 | * No restriction of use if the tokens are \#defined. 67 | * 68 | * For example, writing ATPASTE2(U, UL_WIDTH) anywhere with UL_WIDTH \#defined 69 | * as 32 is equivalent to writing U32. 70 | * 71 | * @{ */ 72 | #define ATPASTE2( a, b) TPASTE2( a, b) 73 | #define ATPASTE3( a, b, c) TPASTE3( a, b, c) 74 | #define ATPASTE4( a, b, c, d) TPASTE4( a, b, c, d) 75 | #define ATPASTE5( a, b, c, d, e) TPASTE5( a, b, c, d, e) 76 | #define ATPASTE6( a, b, c, d, e, f) TPASTE6( a, b, c, d, e, f) 77 | #define ATPASTE7( a, b, c, d, e, f, g) TPASTE7( a, b, c, d, e, f, g) 78 | #define ATPASTE8( a, b, c, d, e, f, g, h) TPASTE8( a, b, c, d, e, f, g, h) 79 | #define ATPASTE9( a, b, c, d, e, f, g, h, i) TPASTE9( a, b, c, d, e, f, g, h, i) 80 | #define ATPASTE10(a, b, c, d, e, f, g, h, i, j) TPASTE10(a, b, c, d, e, f, g, h, i, j) 81 | /** @} */ 82 | 83 | /** @} */ 84 | 85 | #endif // _TPASTE_H_ 86 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/reset.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM Reset related functionality 5 | * 6 | * Copyright (C) 2014-2015 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /* 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | #ifndef RESET_H_INCLUDED 47 | #define RESET_H_INCLUDED 48 | 49 | #include 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * \addtogroup asfdoc_sam0_system_group 57 | * @{ 58 | */ 59 | 60 | /** 61 | * \brief Reset causes of the system. 62 | * 63 | * List of possible reset causes of the system. 64 | */ 65 | enum system_reset_cause { 66 | /** The system was last reset by a software reset. */ 67 | SYSTEM_RESET_CAUSE_SOFTWARE = PM_RCAUSE_SYST, 68 | /** The system was last reset by the watchdog timer. */ 69 | SYSTEM_RESET_CAUSE_WDT = PM_RCAUSE_WDT, 70 | /** The system was last reset because the external reset line was pulled low. */ 71 | SYSTEM_RESET_CAUSE_EXTERNAL_RESET = PM_RCAUSE_EXT, 72 | /** The system was last reset by the BOD33. */ 73 | SYSTEM_RESET_CAUSE_BOD33 = PM_RCAUSE_BOD33, 74 | /** The system was last reset by the BOD12. */ 75 | SYSTEM_RESET_CAUSE_BOD12 = PM_RCAUSE_BOD12, 76 | /** The system was last reset by the POR (Power on reset). */ 77 | SYSTEM_RESET_CAUSE_POR = PM_RCAUSE_POR, 78 | }; 79 | 80 | 81 | /** 82 | * \name Reset Control 83 | * @{ 84 | */ 85 | 86 | /** 87 | * \brief Reset the MCU. 88 | * 89 | * Resets the MCU and all associated peripherals and registers, except RTC, all 32KHz sources, 90 | * WDT (if ALWAYSON is set) and GCLK (if WRTLOCK is set). 91 | * 92 | */ 93 | static inline void system_reset(void) 94 | { 95 | NVIC_SystemReset(); 96 | } 97 | 98 | /** 99 | * \brief Return the reset cause. 100 | * 101 | * Retrieves the cause of the last system reset. 102 | * 103 | * \return An enum value indicating the cause of the last system reset. 104 | */ 105 | static inline enum system_reset_cause system_get_reset_cause(void) 106 | { 107 | return (enum system_reset_cause)PM->RCAUSE.reg; 108 | } 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | /** @} */ 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* RESET_H_INCLUDED */ 120 | -------------------------------------------------------------------------------- /lib/Adafruit_ASFcore/system.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM System related functionality 5 | * 6 | * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /* 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #include 48 | 49 | /** 50 | * \internal 51 | * Dummy initialization function, used as a weak alias target for the various 52 | * init functions called by \ref system_init(). 53 | */ 54 | void _system_dummy_init(void); 55 | void _system_dummy_init(void) 56 | { 57 | return; 58 | } 59 | 60 | #if !defined(__DOXYGEN__) 61 | # if defined(__GNUC__) 62 | void system_clock_init(void) WEAK __attribute__((alias("_system_dummy_init"))); 63 | void system_board_init(void) WEAK __attribute__((alias("_system_dummy_init"))); 64 | void _system_events_init(void) WEAK __attribute__((alias("_system_dummy_init"))); 65 | void _system_extint_init(void) WEAK __attribute__((alias("_system_dummy_init"))); 66 | void _system_divas_init(void) WEAK __attribute__((alias("_system_dummy_init"))); 67 | # elif defined(__ICCARM__) 68 | void system_clock_init(void); 69 | void system_board_init(void); 70 | void _system_events_init(void); 71 | void _system_extint_init(void); 72 | void _system_divas_init(void); 73 | # pragma weak system_clock_init=_system_dummy_init 74 | # pragma weak system_board_init=_system_dummy_init 75 | # pragma weak _system_events_init=_system_dummy_init 76 | # pragma weak _system_extint_init=_system_dummy_init 77 | # pragma weak _system_divas_init=_system_dummy_init 78 | # endif 79 | #endif 80 | 81 | /** 82 | * \brief Initialize system 83 | * 84 | * This function will call the various initialization functions within the 85 | * system namespace. If a given optional system module is not available, the 86 | * associated call will effectively be a NOP (No Operation). 87 | * 88 | * Currently the following initialization functions are supported: 89 | * - System clock initialization (via the SYSTEM CLOCK sub-module) 90 | * - Board hardware initialization (via the Board module) 91 | * - Event system driver initialization (via the EVSYS module) 92 | * - External Interrupt driver initialization (via the EXTINT module) 93 | */ 94 | void system_init(void) 95 | { 96 | /* Configure GCLK and clock sources according to conf_clocks.h */ 97 | system_clock_init(); 98 | 99 | /* Initialize board hardware */ 100 | system_board_init(); 101 | 102 | /* Initialize EVSYS hardware */ 103 | _system_events_init(); 104 | 105 | /* Initialize External hardware */ 106 | _system_extint_init(); 107 | 108 | /* Initialize DIVAS hardware */ 109 | _system_divas_init(); 110 | } 111 | 112 | -------------------------------------------------------------------------------- /lib/Arduino USBCore driver/README.md: -------------------------------------------------------------------------------- 1 | 2 | # USBCore driver for audio over USB 3 | 4 | In order to get the audio over USB working replace driver `USBCore.cpp` located in: 5 | 6 | 7 | ``` 8 | home/arjan/.platformio/packages/framework-arduino-samd@1.8.9/cores/arduino/USB/USBCore.cpp 9 | ``` 10 | 11 | with this one. 12 | -------------------------------------------------------------------------------- /lib/AudioUSB/documentation/src/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/firmware-syntiant-tinyml/30afeb48b86159022dfc9cc14bff674304e8369e/lib/AudioUSB/documentation/src/Logo.png -------------------------------------------------------------------------------- /lib/AudioUSB/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Keyboard 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | AudioUSB KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | available KEYWORD2 17 | accept KEYWORD2 18 | read KEYWORD2 19 | flush KEYWORD2 20 | sendAudio KEYWORD2 21 | write KEYWORD2 22 | sendAudio KEYWORD2 23 | 24 | ####################################### 25 | # Constants (LITERAL1) 26 | ####################################### 27 | 28 | -------------------------------------------------------------------------------- /lib/AudioUSB/library.properties: -------------------------------------------------------------------------------- 1 | name=AudioUSB 2 | version=0.0.1 3 | author=Martin Weetman, Gary Grewal, Arduino 4 | maintainer= 5 | sentence=Allows an Arduino board with USB capabilites to act as a microphone over USB. 6 | paragraph= 7 | category=Device Control 8 | url=http://www.syntiant.com 9 | architectures=avr,sam,samd 10 | -------------------------------------------------------------------------------- /lib/AudioUSB/src/AudioUSB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2015, Gary Grewal 3 | ** Permission to use, copy, modify, and/or distribute this software for 4 | ** any purpose with or without fee is hereby granted, provided that the 5 | ** above copyright notice and this permission notice appear in all copies. 6 | ** 7 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 8 | ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 9 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 10 | ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES 11 | ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 12 | ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 13 | ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 14 | ** SOFTWARE. 15 | */ 16 | 17 | #include "AudioUSB.h" 18 | 19 | #define Audio_AC_INTERFACE pluggedInterface // Audio AC Interface 20 | #define Audio_INTERFACE ((uint8_t)(pluggedInterface+1)) 21 | #define Audio_STREAMING_INTERFACE ((uint8_t)(pluggedInterface+2)) 22 | 23 | #define Audio_FIRST_ENDPOINT pluggedEndpoint 24 | #define Audio_ENDPOINT_OUT pluggedEndpoint 25 | #define Audio_ENDPOINT_IN ((uint8_t)(pluggedEndpoint+1)) 26 | 27 | #define Audio_RX Audio_ENDPOINT_OUT 28 | #define Audio_TX Audio_ENDPOINT_IN 29 | 30 | Audio_ AudioUSB; 31 | 32 | int Audio_::getInterface(uint8_t* interfaceNum) 33 | { 34 | interfaceNum[0] += 2; // uses 2 interfaces 35 | //interfaceNum[0] += 3; // uses 3 interfaces 36 | 37 | AudioDescriptor _AudioInterface __attribute__((aligned(4))) = 38 | { 39 | D_IAD(Audio_AC_INTERFACE, 2, Audio_AUDIO, Audio_AUDIO_CONTROL, 0), 40 | //D_IAD(Audio_AC_INTERFACE, 3, Audio_AUDIO, Audio_AUDIO_CONTROL, 0), 41 | D_INTERFACE(Audio_AC_INTERFACE,0,Audio_AUDIO,Audio_AUDIO_CONTROL,0), 42 | D_AC_INTERFACE(0x1, Audio_INTERFACE), 43 | D_Audio_INJACK(Audio_JACK_INPUT_TERMINAL_DESCRIPTOR, 0x1), 44 | D_Audio_OUTJACK(Audio_JACK_OUTPUT_TERMINAL_DESCRIPTOR, 0x2, 1, 1, 1), 45 | D_INTERFACE_ZERO(Audio_INTERFACE), 46 | D_INTERFACE_ONE(Audio_INTERFACE), 47 | D_AS_INTERFACE, 48 | D_AS_FORMAT, 49 | D_Audio_JACK_EP(USB_ENDPOINT_IN(Audio_ENDPOINT_OUT),USB_ENDPOINT_TYPE_ISOCHRONOUS,Audio_BUFFER_SIZE), 50 | D_AUDIO_DATA_EP 51 | }; 52 | return USB_SendControl2(0, &_AudioInterface, sizeof(_AudioInterface)); 53 | } 54 | 55 | bool Audio_::setup(USBSetup& setup __attribute__((unused))) 56 | { 57 | //Support requests here if needed. Typically these are optional 58 | return false; 59 | } 60 | 61 | int Audio_::getDescriptor(USBSetup& setup __attribute__((unused))) 62 | { 63 | return 0; 64 | } 65 | 66 | uint8_t Audio_::getShortName(char* name) 67 | { 68 | memcpy(name, "Audio", 5); 69 | return 5; 70 | } 71 | 72 | size_t Audio_::write(const int16_t *buffer, size_t size) 73 | { 74 | USBDevice.send(pluggedEndpoint, buffer, size); 75 | return 1; 76 | 77 | /* only try to send bytes if the high-level Audio connection itself 78 | is open (not just the pipe) - the OS should set lineState when the port 79 | is opened and clear lineState when the port is closed. 80 | bytes sent before the user opens the connection or after 81 | the connection is closed are lost - just like with a UART. */ 82 | } 83 | 84 | Audio_::Audio_(void) : PluggableUSBModule(1, 2, epType) 85 | //Audio_::Audio_(void) : PluggableUSBModule(2, 3, epType) 86 | { 87 | epType[0] = EP_TYPE_ISOCHRONOUS_IN_Audio; // Audio_ENDPOINT_IN 88 | PluggableUSB().plug(this); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /lib/NDP/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Keyboard 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | NDPClass KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | init KEYWORD2 16 | setInterrupt KEYWORD2 17 | loadLog KEYWORD2 18 | poll KEYWORD2 19 | spiTransfer KEYWORD2 20 | setSpiSpeed KEYWORD2 21 | setSpiSpeedSw KEYWORD2 22 | 23 | ####################################### 24 | # Constants (LITERAL1) 25 | ####################################### 26 | -------------------------------------------------------------------------------- /lib/NDP/library.properties: -------------------------------------------------------------------------------- 1 | name=NDP 2 | version=1.0.0 3 | author=Martin Weetman, Jon Haley 4 | maintainer= 5 | sentence=Communicate with the Syntiant NDP via the Syntiant micro ilib (uilib) 6 | paragraph= 7 | category=Device Control 8 | url=http://www.syntiant.com 9 | architectures=avr,sam,samd 10 | -------------------------------------------------------------------------------- /lib/NDP/src/NDP.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_H 34 | #define NDP_H 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #include "SPI.h" 41 | 42 | #if ARDUINO < 10606 43 | #error NDP requires Arduino IDE 1.6.6 or greater. Please update your IDE. 44 | #endif 45 | 46 | #if !defined(USBCON) 47 | #error NDP can only be used with an USB MCU. 48 | #endif 49 | 50 | #define is_write_enabled(x) (1) 51 | 52 | #ifndef DOXYGEN_ARD 53 | // the following would confuse doxygen documentation tool, so skip in that case for autodoc build 54 | _Pragma("pack()") 55 | #define WEAK __attribute__((weak)) 56 | #endif 57 | 58 | extern uint8_t spiData[2048]; 59 | extern uint32_t spiSpeedGeneral; 60 | extern uint32_t spiSpeedSampleWrite; 61 | 62 | // SPI chip select, used for spiTransfer. Define in the main .ino file. 63 | extern byte SPI_CS; 64 | 65 | class NDPClass 66 | { 67 | public: 68 | NDPClass(); 69 | 70 | void init(); 71 | 72 | // pass a user-defined function to be called every time an interrupt 73 | // from the ndp is received 74 | void setInterrupt(uint8_t intPin, void (*f)(void)); 75 | 76 | // Load a uILib log buffer 77 | // returns a SYNTIANT_NDP_ERROR_ status code 78 | // NONE: load successfully completed 79 | // MORE: more of the log remains to be processed 80 | // other: error during loading the uILib log buffer 81 | int loadLog(uint8_t *buf, uint32_t numBytes); 82 | 83 | // Check for a match event. 84 | // Returns: 85 | // 0 - no match 86 | // 0 < - matched ID n + 1 87 | int poll(void); 88 | 89 | // Set the data extraction point to now, i.e. flush old data. 90 | // returns a SYNTIANT_NDP_ERROR_ status code 91 | int setExtractNow(void); 92 | 93 | // Set the data extraction point relative to the most recent match. 94 | // Call this after a match is reported if desired. 95 | // prefix (in): bytes before the match from which to begin extracting 96 | // returns a SYNTIANT_NDP_ERROR_ status code: 97 | // NONE: load successfully completed 98 | // ARG: len is greater than available buffered audio 99 | // other: other errors 100 | int setExtractMatch(unsigned int len); 101 | 102 | // Extract data from the holding tank. 103 | // data (in): buffer into which to store extracted data -- pass NULL 104 | // to determine available data without extracting any data 105 | // len (in): maximum bytes to extract (i.e. size of data) 106 | // len (out): bytes that could have been extracted if len was 107 | // 'unconstrained' 108 | // 109 | // the amount of data actually extracted can be computed as: 110 | // min(input len, returned len) 111 | // 112 | // returns a SYNTIANT_NDP_ERROR_ status code 113 | int extractData(uint8_t *data, unsigned int *len); 114 | 115 | 116 | // passed to uilib, used for all SPI transfers such as in loadLog and poll 117 | static int spiTransfer(void *d, int mcu, uint32_t address, void *_out, 118 | void *_in, unsigned int count); 119 | 120 | void setSpiSpeed(uint32_t speed); 121 | void setSpiSpeedSw(uint32_t speed); 122 | 123 | 124 | protected: 125 | struct syntiant_ndp10x_micro_device_s ndp; 126 | }; 127 | 128 | extern NDPClass NDP; 129 | 130 | #endif 131 | 132 | -------------------------------------------------------------------------------- /lib/NDP_utils/keywords.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/firmware-syntiant-tinyml/30afeb48b86159022dfc9cc14bff674304e8369e/lib/NDP_utils/keywords.txt -------------------------------------------------------------------------------- /lib/NDP_utils/library.properties: -------------------------------------------------------------------------------- 1 | name=NDP_utils 2 | version=1.0.2 3 | author=Martin Weetman, Jon Haley 4 | maintainer= 5 | sentence=Enables various functionality in conjunction with the Syntiant NDP library 6 | paragraph= 7 | category=Device Control 8 | url=http://www.syntiant.com 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_GPIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_GPIO_H 34 | #define NDP_GPIO_H 35 | 36 | // Define Arduino pins 37 | // see https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.cpp 38 | enum Arduino_GPIO_Pins 39 | { 40 | ARDUINO_PIN_11 = 11, 41 | ARDUINO_PIN_12 = 12, 42 | ARDUINO_PIN_A6 = 21, 43 | FLASH_CS = 17, // Flash Chip Select for reading/writing flash 44 | BATTERY = 19, // Battery monitor pin A4 45 | ENABLE_PDM = 25, // enable line for PDM buffer. Low = enable. set to 1 (off) this to switch from microphone to sensor mode? 46 | SD_CS = 28, 47 | SD_CARD_SENSE = 30, // SD card present sense pin 48 | USER_SWITCH = 31, // user can attach a switch here, and in the main .ino file 49 | // define the functionality when pressed 50 | NDP_INT = A1, // NDP INT pin 16 51 | LED_RED = LED_BUILTIN, 52 | LED_BLUE = A4, 53 | LED_GREEN = A5, 54 | PMU_OTG = A6, 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_PMU.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #include "NDP_PMU.h" 34 | 35 | //Writes val to address register on device 36 | void writeTo(int device, byte address, byte val) 37 | { 38 | Wire.beginTransmission(device); // start transmission to device 39 | Wire.write(address); // send register address 40 | Wire.write(val); // send value to write 41 | Wire.endTransmission(); // end transmission 42 | } 43 | 44 | //reads num bytes starting from address register on device in to buff array 45 | void readFrom(int device, byte address, int num, byte buff[]) 46 | { 47 | Wire.beginTransmission(device); // start transmission to device 48 | Wire.write(address); // sends address to read from 49 | Wire.endTransmission(); // end transmission 50 | Wire.beginTransmission(device); // start transmission to device 51 | Wire.requestFrom(device, num); // request num bytes from device 52 | 53 | int i = 0; 54 | while (Wire.available()) { 55 | buff[i] = Wire.read(); // receive a byte 56 | i++; 57 | } 58 | // device may send less than requested (abnormal) 59 | Wire.endTransmission(); // end transmission 60 | } 61 | 62 | void printPmu() 63 | { 64 | Serial2.print("SGM41512 Registers - "); 65 | 66 | byte buff[10]; 67 | for (byte i = 0; i < 0xc; i++) { // SGM41512 has 11 registers. 68 | readFrom(SGM41512, i, 1, buff); 69 | Serial2.print(i); 70 | Serial2.print(" = 0x"); 71 | Serial2.print(buff[0], HEX); 72 | Serial2.print(", "); 73 | } 74 | Serial2.println(""); 75 | } 76 | 77 | // Print LiPo battery voltage. Maximum (3v7) should give 0x3ff 78 | void printBattery() 79 | { 80 | Serial2.print("Battery = "); 81 | Serial2.print(100 * analogRead(ADC_BATTERY) / 0x3ff); 82 | Serial2.println("%"); 83 | } 84 | 85 | // Set PMU into Boost mode. This generates 5v on the PMU PMD pin 86 | void pmuBoost() 87 | { 88 | //Serial2.println("Reseting PMU Registers"); 89 | 90 | // reset PMU registers 91 | writeTo(SGM41512, RESET_AND_VERSION_REG, 0xAC); 92 | 93 | Serial2.println("Enabling boost mode"); 94 | 95 | // Set PMU_OTG pin high to enable boost mode 96 | digitalWrite(PMU_OTG, HIGH); 97 | digitalWrite(ENABLE_5V, HIGH); 98 | 99 | if (!PMIC.begin()) { 100 | Serial2.println("Failed to initialize PMIC!"); 101 | return; 102 | } 103 | 104 | // Enable boost mode, this mode allow to use the board as host and 105 | // connect guest device like keyboard 106 | if (!PMIC.enableBoostMode()) { 107 | Serial2.println("Error enabling boost mode"); 108 | } 109 | 110 | // disable watchdog 111 | PMIC.disableWatchdog(); 112 | } 113 | 114 | // Place PMU into PiPo charge mode. This cancels boost mode (if activated) 115 | void pmuCharge() 116 | { 117 | // reset PMU registers 118 | writeTo(SGM41512, RESET_AND_VERSION_REG, 0xAC); 119 | 120 | Serial2.println("Enabling battery charging mode"); 121 | 122 | // Set OTB low (no boost mode). Disable 5v out 123 | //digitalWrite(PMU_OTG, HIGH); 124 | digitalWrite(ENABLE_5V, LOW); 125 | 126 | // Reseting the registers set the voltage/current limit 127 | // and charge voltage correctly 128 | 129 | // Set the charge current to 180mA 130 | writeTo(SGM41512, CHARGE_CURRENT_CTL_REG, 0x83); 131 | // Enable the Charger 132 | if (!PMIC.enableCharge()) { 133 | Serial2.println("Error enabling battery charging mode"); 134 | } 135 | // disable watchdog 136 | PMIC.disableWatchdog(); 137 | } 138 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_PMU.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_PMU_H 34 | #define NDP_PMU_H 35 | 36 | #include "SGM41512.h" 37 | 38 | #include "NDP_GPIO.h" 39 | #include "NDP_Serial.h" 40 | 41 | // I2C address for SGM41512 42 | #define SGM41512 0x6B 43 | 44 | #define PMU_OTG A6 45 | #define ENABLE_5V 2 // enable 5v out to companion Arduino. PMU must also be placed in BOOST mode 46 | 47 | #define POWERON_CONFIG_REG 0x01 48 | #define CHARGE_CURRENT_CTL_REG 0x02 49 | #define CHARGE_TERMINATION_TIMER_CTL_REG 0x05 50 | #define RESET_AND_VERSION_REG 0x0B 51 | 52 | void writeTo(int device, byte address, byte val); 53 | void readFrom(int device, byte address, int num, byte buff[]); 54 | void printPmu(); 55 | void printBattery(); 56 | void pmuBoost(); 57 | void pmuCharge(); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_SPI_H 34 | #define NDP_SPI_H 35 | 36 | #include "NDP.h" 37 | 38 | // ilib buffer 39 | // This is the buffer that feeds the uilib from the log file 40 | // Size must be divisible by both 3 & 4 41 | extern uint8_t ilibBuf[1032] __attribute__((aligned(4))); 42 | 43 | // Flash Register bits 44 | const unsigned long FLASH_SPI_DONE = 0x00000200; // SPI Done bit 45 | const unsigned long FLASH_STATUS_WIP = 0x00000001; // Flash Write In Progress 46 | 47 | const unsigned long CHIP_CONFIG_SPICTL = 0x40009014; 48 | const unsigned long CHIP_CONFIG_SPITX = 0x40009018; 49 | const unsigned long CHIP_CONFIG_SPIRX = 0x4000901c; 50 | 51 | enum mspi_modes_e 52 | { 53 | MSPI_IDLE = 0x0, 54 | MSPI_ENABLE = 0x1, 55 | MSPI_TRANSFER = 0x2, 56 | MSPI_UPDATE = 0x3 57 | }; 58 | 59 | //Flash Commands for MX25R6435FSN (Tesolve) 60 | const unsigned long FLASH_READ = 0x03; 61 | const unsigned long FLASH_FAST_READ = 0x0b; 62 | const unsigned long FLASH_PAGE_PROGRAM = 0x02; 63 | const unsigned long FLASH_SECTOR_ERASE = 0x20; 64 | const unsigned long FLASH_BLOCK_ERASE = 0xD8; 65 | const unsigned long FLASH_CHIP_ERASE = 0x60; 66 | const unsigned long FLASH_CHIP_ERASE_2 = 0xc7; 67 | const unsigned long FLASH_WRITE_ENABLE = 0x06; // WREN 68 | const unsigned long FLASH_WRITE_DISABLE = 0x04; // WRDI 69 | const unsigned long FLASH_WRITE_STATUS_REGISTER = 0x01; // WRSR 70 | const unsigned long FLASH_READ_STATUS_REGISTER = 0x05; // WDSR 71 | const unsigned long FLASH_READ_CONFIGURATION_REGISTER = 0x15; // RDCR 72 | const unsigned long FLASH_DEEP_POWER_DOWN = 0xb9; // DP 73 | const unsigned long FLASH_SET_BURDT_LENGTH = 0xc0; // SBL 74 | const unsigned long FLASH_READ_IDENTIFICATION_REGISTER = 0x9f; // RDID 75 | const unsigned long FLASH_READ_ELECTRONIC_ID = 0xAB; // RES 76 | const unsigned long FLASH_NOP = 0x00; 77 | const unsigned long FLASH_RESET_ENABLE = 0x66; // RSTEN 78 | const unsigned long FLASH_RESET = 0x99; // RST 79 | const unsigned long FLASH_ENABLE_WRITE_STATUS = 0x50; 80 | const unsigned long FLASH_DP = 0xB9; // Flash Deep Power Down 81 | 82 | void indirectWrite(unsigned long indirectRegister, unsigned long indirectData); 83 | unsigned long indirectRead(unsigned long indirectRegister); 84 | void enableMasterSpi(); 85 | void disableMasterSpi(); 86 | void spiWait(); 87 | unsigned long reverseBytes(unsigned long value); 88 | void changeMasterSpiMode(byte mode); 89 | void writeNumBytes(unsigned long numBytes); 90 | uint32_t getFlashStatus(); 91 | void writeFlashCommand(uint32_t command); 92 | void sectorEraseCommand(uint32_t address); 93 | void flashWrite(unsigned long address, uint32_t count); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_Serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_SERIAL_H 34 | #define NDP_SERIAL_H 35 | 36 | // We define Serial2 for debugging, to not interfere with the main Serial which 37 | // is used for our management interface 38 | 39 | // Define Serial2 in the main .ino file. Serial2 can then be used in 40 | // any file that includes this header 41 | extern Uart Serial2; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_loadModel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_LOAD_MODEL_H 34 | #define NDP_LOAD_MODEL_H 35 | 36 | // Set USE_SD_H nonzero to use SD.h. 37 | // Set USE_SD_H zero to use SdFat.h. 38 | #define USE_SD_H 0 39 | 40 | #if USE_SD_H 41 | #include 42 | #else 43 | #include "SdFat.h" 44 | extern SdFat SD; 45 | #endif 46 | 47 | #include 48 | 49 | #include "NDP.h" 50 | #include "NDP_GPIO.h" 51 | #include "NDP_SPI.h" // For loadUilibFlash 52 | #include "NDP_Serial.h" // Allows us to print debug messages to a second serial port 53 | 54 | #define SD_CONFIG SdSpiConfig(SD_CS, DEDICATED_SPI) 55 | 56 | // For loading from flash (USB dongle) 57 | const unsigned long FLASH_SEGMENT_SIZE = 0x100000; 58 | const unsigned long FLASH_INDEX_LOCATION = FLASH_SEGMENT_SIZE - 0x8; 59 | const unsigned long MAGIC_NUMBER = 0xA5B6C7D8; 60 | const unsigned long CHIP_UART_CTRL = 0x40004008; 61 | 62 | // Flash Commands for SST25VF016B (Bluebank) 63 | const unsigned long FLASH_EWSR = 0x50; // Enable-Write-Status-Register 64 | const unsigned long FLASH_WRSR = 0x01; // Write-Status-Register 65 | const unsigned long FLASH_WREN = 0x06; // Write-Enable 66 | const unsigned long FLASH_RDSR = 0x05; // Read-Status-Register 67 | 68 | enum Load_BIN_error_messages 69 | { 70 | BIN_LOAD_OK = 0, 71 | NO_SD = 1, 72 | SD_NOT_INITIALIZED = 2, 73 | BIN_NOT_OPENED = 3, 74 | ERROR_LOADING_BIN = 4, 75 | ERROR_LOADING_FLASH = 5, 76 | ERROR_LOADING_SD = 6, 77 | LOADED_FROM_SERIAL_FLASH = 8 78 | }; 79 | 80 | extern uint32_t cardSectorCount; 81 | // For loadUilibFlash 82 | extern byte runningFromFlash; 83 | extern byte patchApplied; 84 | 85 | int loadModel(String model); 86 | void copySdToFlash(); 87 | bool compareFiles(File &file, SerialFlashFile &ffile); 88 | void fatFormatSd(); 89 | void formatCard(); 90 | void eraseCard(); 91 | void eraseSd(); 92 | byte flashCat(String foundFile); 93 | void loadUilibFlash(byte record); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /lib/NDP_utils/src/NDP_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef NDP_UTILS_H 34 | #define NDP_UTILS_H 35 | 36 | #include "NDP_GPIO.h" 37 | #include "NDP_SPI.h" 38 | #include "NDP_Serial.h" 39 | #include "NDP_loadModel.h" 40 | #include "NDP_PMU.h" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/PMIC_SGM41512/library.properties: -------------------------------------------------------------------------------- 1 | name=NDP 2 | version=1.0.0 3 | author=Alireza Yousefi 4 | maintainer= 5 | sentence=Library for the SGM41512 Power Management IC (PMIC) 6 | paragraph= 7 | category=Device Control 8 | url=http://www.syntiant.com 9 | architectures=avr,sam,samd 10 | -------------------------------------------------------------------------------- /lib/PMIC_SGM41512/src/SGM41512.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | #include "Wire.h" 34 | #include "Arduino.h" 35 | 36 | #ifndef _SGM41512_H_ 37 | #define _SGM41512_H_ 38 | 39 | class PMICClass { 40 | 41 | public: 42 | PMICClass(TwoWire & wire); 43 | bool begin(void); 44 | void end(void); 45 | bool enableCharge(void); 46 | bool enableBoostMode(void); 47 | 48 | // Misc Operation Control Register 49 | bool enableBATFET(void); 50 | 51 | // System Status Register 52 | int chargeStatus(void); 53 | 54 | // Mode of Operation 55 | int getOperationMode(void); 56 | 57 | // Charge Timer Control Register 58 | bool disableWatchdog(void); 59 | 60 | private: 61 | TwoWire* _wire; 62 | int readRegister(byte asddress); 63 | int writeRegister(byte address, byte val); 64 | }; 65 | 66 | extern PMICClass PMIC; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /lib/SerialFlash/.piopm: -------------------------------------------------------------------------------- 1 | {"type": "library", "name": "SerialFlash", "version": "0.0.0-alpha+sha.2b86eb1e43", "spec": {"owner": "paulstoffregen", "id": 539, "name": "SerialFlash", "requirements": null, "url": null}} -------------------------------------------------------------------------------- /lib/SerialFlash/README.md: -------------------------------------------------------------------------------- 1 | # SerialFlash 2 | 3 | SerialFlash provides low-latency, high performance access to SPI Flash memory with a filesystem-like interface for use with Arduino compatible boards. Familiar file-based functions, similar to the SD library, are used to access data. 4 | 5 | In-progress file write and erase operations do NOT block read access on other files. SerialFlash automatically allocates files with Flash page and sector awareness, and supports suspending in-progress write and erase operations, to minimize read latency even while the Flash memory is "busy" writing data. 6 | 7 | Performance oriented design does impose some usage limitations. Files are created with a fixed size which can never change or grow. Once created, files can not be renamed or deleted (except for erasing the entire chip). Files begin with all bytes erased (255). Each byte may be written only once. Files created as erasable may be fully erased, to allow new data to be written. Best performance is achieved by writing in 256 byte chunks, though individual bytes may be written. 8 | 9 | 10 | ## Hardware Compatibility 11 | 12 | ![W25Q128FV Chip](doc/w25q128fv.jpg) 13 | 14 | These chips have been tested with SerialFlash: 15 | 16 | Winbond W25Q80BV (http://www.adafruit.com/product/1564) 17 | Winbond W25Q64FV 18 | Winbond W25Q128FV 19 | Winbond W25Q256FV 20 | Micron N25Q512A 21 | Micron N25Q00AA 22 | Spansion S25FL127S 23 | Spansion S25FL256S 24 | Spansion S25FL512S 25 | 26 | SerialFlash automatically detects SPI Flash chip type and capacity to automatically handle differences between supported chips. 27 | 28 | ## Accessing Files 29 | 30 | ### Open A File 31 | 32 | SerialFlashFile file; 33 | file = SerialFlash.open("filename.bin"); 34 | if (file) { // true if the file exists 35 | 36 | ### Read Data 37 | 38 | char buffer[256]; 39 | file.read(buffer, 256); 40 | 41 | ### File Size & Positon 42 | 43 | file.size(); 44 | file.position() 45 | file.seek(number); 46 | 47 | ### Write Data 48 | 49 | file.write(buffer, 256); 50 | 51 | Several limitations apply to writing. Only previously unwritten portions of the file may be written. File sizes can never change. Writes may only be done within the file's original size. 52 | 53 | ### Erase Data 54 | 55 | file.erase(); 56 | 57 | Only files created for erasing can be erased. The entire file is erased to all 255 (0xFF) bytes, which allows the file to be written with new data. 58 | 59 | ## Managing Files 60 | 61 | ### Create New Files 62 | 63 | SerialFlash.create(filename, size); 64 | SerialFlash.createErasable(filename, size); 65 | 66 | New files must be created using these funtions. Each returns true if the file is successfully created, or false if not enough space is available. 67 | 68 | Once created, files can never be renamed or deleted. The file's size can never change. Writing additional data can NOT grow the size of file. 69 | 70 | Files created for erasing automatically increase in size to the nearest number of erasable blocks, resulting in a file that may be 4K to 128K larger than requested. 71 | 72 | ### Delete A File 73 | 74 | SerialFlash.remove(filename); 75 | 76 | The actual space used by the file is not reclaimed. However, a new file with this name may be created after the original is deleted. 77 | 78 | ### Check If A File Exists (without opening) 79 | 80 | SerialFlash.exists(filename); 81 | 82 | ### Directory Listing 83 | 84 | SerialFlash.opendir(); 85 | SerialFlash.readdir(buffer, buflen, filelen); 86 | 87 | A list of files stored in the Flash can be accessed with readdir(), which returns true for each file, or false to indicate no more files. 88 | 89 | ## Full Erase 90 | 91 | SerialFlash.erase(); 92 | 93 | while (SerialFlash.ready() == false) { 94 | // wait, 30 seconds to 2 minutes for most chips 95 | } 96 | -------------------------------------------------------------------------------- /lib/SerialFlash/doc/w25q128fv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/firmware-syntiant-tinyml/30afeb48b86159022dfc9cc14bff674304e8369e/lib/SerialFlash/doc/w25q128fv.jpg -------------------------------------------------------------------------------- /lib/SerialFlash/docs/issue_template.md: -------------------------------------------------------------------------------- 1 | Please use this form only to report code defects or bugs. 2 | 3 | For any question, even questions directly pertaining to this code, post your question on the forums related to the board you are using. 4 | 5 | Arduino: forum.arduino.cc 6 | Teensy: forum.pjrc.com 7 | ESP8266: www.esp8266.com 8 | ESP32: www.esp32.com 9 | Adafruit Feather/Metro/Trinket: forums.adafruit.com 10 | Particle Photon: community.particle.io 11 | 12 | If you are experiencing trouble but not certain of the cause, or need help using this code, ask on the appropriate forum. This is not the place to ask for support or help, even directly related to this code. Only use this form you are certain you have discovered a defect in this code! 13 | 14 | Please verify the problem occurs when using the very latest version, using the newest version of Arduino and any other related software. 15 | 16 | 17 | ----------------------------- Remove above ----------------------------- 18 | 19 | 20 | 21 | ### Description 22 | 23 | Describe your problem. 24 | 25 | 26 | 27 | ### Steps To Reproduce Problem 28 | 29 | Please give detailed instructions needed for anyone to attempt to reproduce the problem. 30 | 31 | 32 | 33 | ### Hardware & Software 34 | 35 | Board 36 | Shields / modules used 37 | Arduino IDE version 38 | Teensyduino version (if using Teensy) 39 | Version info & package name (from Tools > Boards > Board Manager) 40 | Operating system & version 41 | Any other software or hardware? 42 | 43 | 44 | ### Arduino Sketch 45 | 46 | ```cpp 47 | // Change the code below by your sketch (please try to give the smallest code which demonstrates the problem) 48 | #include 49 | 50 | // libraries: give links/details so anyone can compile your code for the same result 51 | 52 | void setup() { 53 | } 54 | 55 | void loop() { 56 | } 57 | ``` 58 | 59 | 60 | ### Errors or Incorrect Output 61 | 62 | If you see any errors or incorrect output, please show it here. Please use copy & paste to give an exact copy of the message. Details matter, so please show (not merely describe) the actual message or error exactly as it appears. 63 | 64 | 65 | -------------------------------------------------------------------------------- /lib/SerialFlash/examples/CopyFromSD/CopyFromSD.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const int SDchipSelect = 4; // Audio Shield has SD card CS on pin 10 6 | const int FlashChipSelect = 6; // digital pin for flash chip CS pin 7 | //const int FlashChipSelect = 21; // Arduino 101 built-in SPI Flash 8 | 9 | void setup() { 10 | //uncomment these if using Teensy audio shield 11 | //SPI.setSCK(14); // Audio shield has SCK on pin 14 12 | //SPI.setMOSI(7); // Audio shield has MOSI on pin 7 13 | 14 | //uncomment these if you have other SPI chips connected 15 | //to keep them disabled while using only SerialFlash 16 | //pinMode(4, INPUT_PULLUP); 17 | //pinMode(10, INPUT_PULLUP); 18 | 19 | Serial.begin(9600); 20 | 21 | // wait up to 10 seconds for Arduino Serial Monitor 22 | unsigned long startMillis = millis(); 23 | while (!Serial && (millis() - startMillis < 10000)) ; 24 | delay(100); 25 | Serial.println("Copy all files from SD Card to SPI Flash"); 26 | 27 | if (!SD.begin(SDchipSelect)) { 28 | error("Unable to access SD card"); 29 | } 30 | if (!SerialFlash.begin(FlashChipSelect)) { 31 | error("Unable to access SPI Flash chip"); 32 | } 33 | 34 | File rootdir = SD.open("/"); 35 | while (1) { 36 | // open a file from the SD card 37 | Serial.println(); 38 | File f = rootdir.openNextFile(); 39 | if (!f) break; 40 | const char *filename = f.name(); 41 | Serial.print(filename); 42 | Serial.print(" "); 43 | unsigned long length = f.size(); 44 | Serial.println(length); 45 | 46 | // check if this file is already on the Flash chip 47 | if (SerialFlash.exists(filename)) { 48 | Serial.println(" already exists on the Flash chip"); 49 | SerialFlashFile ff = SerialFlash.open(filename); 50 | if (ff && ff.size() == f.size()) { 51 | Serial.println(" size is the same, comparing data..."); 52 | if (compareFiles(f, ff) == true) { 53 | Serial.println(" files are identical :)"); 54 | f.close(); 55 | ff.close(); 56 | continue; // advance to next file 57 | } else { 58 | Serial.println(" files are different"); 59 | } 60 | } else { 61 | Serial.print(" size is different, "); 62 | Serial.print(ff.size()); 63 | Serial.println(" bytes"); 64 | } 65 | // delete the copy on the Flash chip, if different 66 | Serial.println(" delete file from Flash chip"); 67 | SerialFlash.remove(filename); 68 | } 69 | 70 | // create the file on the Flash chip and copy data 71 | if (SerialFlash.create(filename, length)) { 72 | SerialFlashFile ff = SerialFlash.open(filename); 73 | if (ff) { 74 | Serial.print(" copying"); 75 | // copy data loop 76 | unsigned long count = 0; 77 | unsigned char dotcount = 9; 78 | while (count < length) { 79 | char buf[256]; 80 | unsigned int n; 81 | n = f.read(buf, 256); 82 | ff.write(buf, n); 83 | count = count + n; 84 | Serial.print("."); 85 | if (++dotcount > 100) { 86 | Serial.println(); 87 | dotcount = 0; 88 | } 89 | } 90 | ff.close(); 91 | if (dotcount > 0) Serial.println(); 92 | } else { 93 | Serial.println(" error opening freshly created file!"); 94 | } 95 | } else { 96 | Serial.println(" unable to create file"); 97 | } 98 | f.close(); 99 | } 100 | rootdir.close(); 101 | delay(10); 102 | Serial.println("Finished All Files"); 103 | } 104 | 105 | 106 | bool compareFiles(File &file, SerialFlashFile &ffile) { 107 | file.seek(0); 108 | ffile.seek(0); 109 | unsigned long count = file.size(); 110 | while (count > 0) { 111 | char buf1[128], buf2[128]; 112 | unsigned long n = count; 113 | if (n > 128) n = 128; 114 | file.read(buf1, n); 115 | ffile.read(buf2, n); 116 | if (memcmp(buf1, buf2, n) != 0) return false; // differ 117 | count = count - n; 118 | } 119 | return true; // all data identical 120 | } 121 | 122 | 123 | void loop() { 124 | } 125 | 126 | void error(const char *message) { 127 | while (1) { 128 | Serial.println(message); 129 | delay(2500); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /lib/SerialFlash/examples/EraseEverything/EraseEverything.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const int FlashChipSelect = 6; // digital pin for flash chip CS pin 5 | //const int FlashChipSelect = 21; // Arduino 101 built-in SPI Flash 6 | 7 | SerialFlashFile file; 8 | 9 | const unsigned long testIncrement = 4096; 10 | 11 | void setup() { 12 | //uncomment these if using Teensy audio shield 13 | //SPI.setSCK(14); // Audio shield has SCK on pin 14 14 | //SPI.setMOSI(7); // Audio shield has MOSI on pin 7 15 | 16 | //uncomment these if you have other SPI chips connected 17 | //to keep them disabled while using only SerialFlash 18 | //pinMode(4, INPUT_PULLUP); 19 | //pinMode(10, INPUT_PULLUP); 20 | 21 | Serial.begin(9600); 22 | 23 | // wait up to 10 seconds for Arduino Serial Monitor 24 | unsigned long startMillis = millis(); 25 | while (!Serial && (millis() - startMillis < 10000)) ; 26 | delay(100); 27 | 28 | if (!SerialFlash.begin(FlashChipSelect)) { 29 | while (1) { 30 | Serial.println("Unable to access SPI Flash chip"); 31 | delay(1000); 32 | } 33 | } 34 | unsigned char id[5]; 35 | SerialFlash.readID(id); 36 | unsigned long size = SerialFlash.capacity(id); 37 | 38 | if (size > 0) { 39 | Serial.print("Flash Memory has "); 40 | Serial.print(size); 41 | Serial.println(" bytes."); 42 | Serial.println("Erasing ALL Flash Memory:"); 43 | // Estimate the (lengthy) wait time. 44 | Serial.print(" estimated wait: "); 45 | int seconds = (float)size / eraseBytesPerSecond(id) + 0.5; 46 | Serial.print(seconds); 47 | Serial.println(" seconds."); 48 | Serial.println(" Yes, full chip erase is SLOW!"); 49 | SerialFlash.eraseAll(); 50 | unsigned long dotMillis = millis(); 51 | unsigned char dotcount = 0; 52 | while (SerialFlash.ready() == false) { 53 | if (millis() - dotMillis > 1000) { 54 | dotMillis = dotMillis + 1000; 55 | Serial.print("."); 56 | dotcount = dotcount + 1; 57 | if (dotcount >= 60) { 58 | Serial.println(); 59 | dotcount = 0; 60 | } 61 | } 62 | } 63 | if (dotcount > 0) Serial.println(); 64 | Serial.println("Erase completed"); 65 | unsigned long elapsed = millis() - startMillis; 66 | Serial.print(" actual wait: "); 67 | Serial.print(elapsed / 1000ul); 68 | Serial.println(" seconds."); 69 | } 70 | } 71 | 72 | float eraseBytesPerSecond(const unsigned char *id) { 73 | if (id[0] == 0x20) return 152000.0; // Micron 74 | if (id[0] == 0x01) return 500000.0; // Spansion 75 | if (id[0] == 0xEF) return 419430.0; // Winbond 76 | if (id[0] == 0xC2) return 279620.0; // Macronix 77 | return 320000.0; // guess? 78 | } 79 | 80 | 81 | void loop() { 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /lib/SerialFlash/examples/ListFiles/ListFiles.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const int FlashChipSelect = 6; // digital pin for flash chip CS pin 5 | //const int FlashChipSelect = 21; // Arduino 101 built-in SPI Flash 6 | 7 | void setup() { 8 | //uncomment these if using Teensy audio shield 9 | //SPI.setSCK(14); // Audio shield has SCK on pin 14 10 | //SPI.setMOSI(7); // Audio shield has MOSI on pin 7 11 | 12 | //uncomment these if you have other SPI chips connected 13 | //to keep them disabled while using only SerialFlash 14 | //pinMode(4, INPUT_PULLUP); 15 | //pinMode(10, INPUT_PULLUP); 16 | 17 | Serial.begin(9600); 18 | 19 | // wait for Arduino Serial Monitor 20 | while (!Serial) ; 21 | delay(100); 22 | Serial.println("All Files on SPI Flash chip:"); 23 | 24 | if (!SerialFlash.begin(FlashChipSelect)) { 25 | error("Unable to access SPI Flash chip"); 26 | } 27 | 28 | SerialFlash.opendir(); 29 | while (1) { 30 | char filename[64]; 31 | uint32_t filesize; 32 | 33 | if (SerialFlash.readdir(filename, sizeof(filename), filesize)) { 34 | Serial.print(" "); 35 | Serial.print(filename); 36 | spaces(20 - strlen(filename)); 37 | Serial.print(" "); 38 | Serial.print(filesize); 39 | Serial.print(" bytes"); 40 | Serial.println(); 41 | } else { 42 | break; // no more files 43 | } 44 | } 45 | } 46 | 47 | void spaces(int num) { 48 | for (int i=0; i < num; i++) { 49 | Serial.print(" "); 50 | } 51 | } 52 | 53 | void loop() { 54 | } 55 | 56 | void error(const char *message) { 57 | while (1) { 58 | Serial.println(message); 59 | delay(2500); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/SerialFlash/examples/MP3Player/MP3Player.ino: -------------------------------------------------------------------------------- 1 | // Simple MP3 file player example 2 | // 3 | // https://forum.pjrc.com/threads/27059-MP3-Player-Lib-with-example?p=101537&viewfull=1#post101537 4 | // 5 | // Requires the prop-shield and Teensy 3.2 or 3.1 6 | // This example code is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include // https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib 14 | //#include 15 | 16 | 17 | // GUItool: begin automatically generated code 18 | //AudioPlaySdWav playSdWav1; //xy=154,422 19 | AudioPlaySdMp3 playMp31; //xy=154,422 20 | AudioMixer4 mixer1; //xy=327,432 21 | AudioOutputAnalog dac1; //xy=502,412 22 | AudioConnection patchCord1(playMp31, 0, mixer1, 0); 23 | AudioConnection patchCord2(playMp31, 1, mixer1, 1); 24 | AudioConnection patchCord3(mixer1, dac1); 25 | // GUItool: end automatically generated code 26 | 27 | 28 | #define PROP_AMP_ENABLE 5 29 | #define FLASH_CHIP_SELECT 6 30 | //#define FLASH_CHIP_SELECT 21 // Arduino 101 built-in SPI Flash 31 | 32 | void setup() { 33 | Serial.begin(9600); 34 | AudioMemory(8); //4 35 | delay(2000); 36 | 37 | // Start SerialFlash 38 | if (!SerialFlash.begin(FLASH_CHIP_SELECT)) { 39 | while (1) { 40 | Serial.println ("Cannot access SPI Flash chip"); 41 | delay (1000); 42 | } 43 | } 44 | 45 | //Set Volume 46 | mixer1.gain(0, 0.5); 47 | mixer1.gain(1, 0.5); 48 | 49 | //Start Amplifier 50 | pinMode(PROP_AMP_ENABLE, OUTPUT); 51 | digitalWrite(PROP_AMP_ENABLE, HIGH); // Enable Amplifier 52 | } 53 | 54 | void playFile(const char *filename) 55 | { 56 | SerialFlashFile ff = SerialFlash.open(filename); 57 | Serial.print("Playing file: "); 58 | Serial.println(filename); 59 | 60 | uint32_t sz = ff.size(); 61 | uint32_t pos = ff.getFlashAddress(); 62 | 63 | // Start playing the file. This sketch continues to 64 | // run while the file plays. 65 | playMp31.play(pos,sz); 66 | 67 | // Simply wait for the file to finish playing. 68 | while (playMp31.isPlaying()) { 69 | yield(); 70 | } 71 | } 72 | 73 | 74 | void loop() { 75 | playFile("rain.mp3"); 76 | delay(1000); 77 | } 78 | -------------------------------------------------------------------------------- /lib/SerialFlash/examples/ReadBenchmark/ReadBenchmark.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const int FlashChipSelect = 6; // digital pin for flash chip CS pin 5 | //const int FlashChipSelect = 21; // Arduino 101 built-in SPI Flash 6 | 7 | void setup() { 8 | //uncomment these if using Teensy audio shield 9 | //SPI.setSCK(14); // Audio shield has SCK on pin 14 10 | //SPI.setMOSI(7); // Audio shield has MOSI on pin 7 11 | 12 | //uncomment these if you have other SPI chips connected 13 | //to keep them disabled while using only SerialFlash 14 | //pinMode(4, INPUT_PULLUP); 15 | //pinMode(10, INPUT_PULLUP); 16 | 17 | Serial.begin(9600); 18 | 19 | // wait for Arduino Serial Monitor 20 | while (!Serial) ; 21 | delay(100); 22 | Serial.println("All Files on SPI Flash chip:"); 23 | 24 | if (!SerialFlash.begin(FlashChipSelect)) { 25 | while (1) { 26 | Serial.println("Unable to access SPI Flash chip"); 27 | delay(2500); 28 | } 29 | } 30 | 31 | SerialFlash.opendir(); 32 | int filecount = 0; 33 | while (1) { 34 | char filename[64]; 35 | uint32_t filesize; 36 | 37 | if (SerialFlash.readdir(filename, sizeof(filename), filesize)) { 38 | Serial.print(" "); 39 | Serial.print(filename); 40 | Serial.print(", "); 41 | Serial.print(filesize); 42 | Serial.print(" bytes"); 43 | SerialFlashFile file = SerialFlash.open(filename); 44 | if (file) { 45 | unsigned long usbegin = micros(); 46 | unsigned long n = filesize; 47 | char buffer[256]; 48 | while (n > 0) { 49 | unsigned long rd = n; 50 | if (rd > sizeof(buffer)) rd = sizeof(buffer); 51 | file.read(buffer, rd); 52 | n = n - rd; 53 | } 54 | unsigned long usend = micros(); 55 | Serial.print(", read in "); 56 | Serial.print(usend - usbegin); 57 | Serial.print(" us, speed = "); 58 | Serial.print((float)filesize * 1000.0 / (float)(usend - usbegin)); 59 | Serial.println(" kbytes/sec"); 60 | file.close(); 61 | } else { 62 | Serial.println(" error reading this file!"); 63 | } 64 | filecount = filecount + 1; 65 | } else { 66 | if (filecount == 0) { 67 | Serial.println("No files found in SerialFlash memory."); 68 | } 69 | break; // no more files 70 | } 71 | } 72 | } 73 | 74 | void loop() { 75 | } 76 | 77 | -------------------------------------------------------------------------------- /lib/SerialFlash/extras/rawfile-uploader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Uploads raw audio files to Teensy + Audio board with SPI Flash on board. To use this program, first 4 | # load the 'CopyFromSerial' example sketch. When it first runs, it will format the SPI flash chip 5 | # (this may take a long time for larger chips; a 128MB chip that I am using can take almost 10 minutes, 6 | # but smaller 16MB ones should be faster). 7 | # 8 | # While the chip is being formatted, the LED (pin 13) will toggle at 1Hz rate. When the formatting is 9 | # done, it flashes quickly (10Hz) for one second, then stays on solid. When nothing has been received 10 | # for 3 seconds, the upload is assumed to be completed, and the light goes off. 11 | # 12 | # You can start this program immediately upon plugging in the Teensy. It will buffer and wait until 13 | # the Teensy starts to read the serial data from USB. 14 | # 15 | ################### 16 | 17 | import serial, sys, os, time 18 | 19 | if (len(sys.argv) <= 2): 20 | print("Usage: '" + sys.argv[0] + " ' where:\n\t is the TTY USB port connected to Drum Master\n\t is a list of .RAW files (bash globs work).") 21 | sys.exit() 22 | 23 | #Special bytes 24 | BYTE_START = "\x7e" 25 | BYTE_ESCAPE = "\x7d" 26 | BYTE_SEPARATOR = "\x7c" 27 | 28 | #Flash size (in MB). Change this to match how much space you have on your chip. 29 | FLASH_SIZE = 16 30 | 31 | totalFileSize = 0; 32 | for i, filename in enumerate(sys.argv): 33 | if (i >= 2): 34 | totalFileSize = totalFileSize + os.path.getsize(filename) 35 | 36 | flashSizeBytes = FLASH_SIZE * 1024 * 1024 37 | if (totalFileSize > flashSizeBytes): 38 | print("Too many files selsected.\n\tTotal flash size:\t" + "{:>14,}".format(flashSizeBytes) + " bytes\n\tTotal file size:\t" + "{:>14,}".format(totalFileSize) + " bytes") 39 | sys.exit() 40 | 41 | ser = serial.Serial(sys.argv[1]) 42 | print("Uploading " + str(len(sys.argv) - 2) + " files...") 43 | for i, filename in enumerate(sys.argv): 44 | if (i >= 2): 45 | startTime = time.time(); 46 | sys.stdout.write(str(i - 1) + ": ") 47 | sys.stdout.write(filename) 48 | sys.stdout.flush() 49 | 50 | 51 | f = open(filename, "rb") 52 | fileLength = os.path.getsize(filename) 53 | try: 54 | encoded = [] 55 | #Start byte 56 | encoded.append(BYTE_START) 57 | #Filename 58 | for byte in os.path.basename(filename): 59 | encoded.append(byte) 60 | #End of filename 61 | encoded.append(BYTE_SEPARATOR) 62 | 63 | #File length (uint32_t) 64 | encoded.append(chr((fileLength >> 24) & 0xFF)); 65 | encoded.append(chr((fileLength >> 16) & 0xFF)); 66 | encoded.append(chr((fileLength >> 8) & 0xFF)); 67 | encoded.append(chr((fileLength >> 0) & 0xFF)); 68 | encoded.append(BYTE_SEPARATOR) 69 | 70 | #Binary data, with escaping 71 | for byte in f.read(): 72 | if byte == BYTE_START or byte == BYTE_ESCAPE: 73 | encoded.append(BYTE_ESCAPE) 74 | encoded.append(chr(ord(byte) ^ 0x20)) 75 | else: 76 | encoded.append(byte); 77 | 78 | #Write end of data byte 79 | encoded.append(BYTE_START) 80 | ser.write("".join(encoded)) 81 | 82 | finally: 83 | f.close() 84 | 85 | endTime = time.time(); 86 | print(" (" + str(round(fileLength / 1024 / (endTime - startTime), 2)) + " KB/s)"); 87 | 88 | print("All files uploaded") 89 | -------------------------------------------------------------------------------- /lib/SerialFlash/keywords.txt: -------------------------------------------------------------------------------- 1 | SerialFlash KEYWORD1 2 | SerialFlashFile KEYWORD1 3 | createWritable KEYWORD2 4 | erase KEYWORD2 5 | eraseAll KEYWORD2 6 | ready KEYWORD2 7 | create KEYWORD2 8 | createWritable KEYWORD2 9 | getAddress KEYWORD2 10 | -------------------------------------------------------------------------------- /lib/SerialFlash/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SerialFlash", 3 | "keywords": "serial, flash, spi", 4 | "description": "SerialFlash provides low-latency, high performance access to SPI Flash memory with a filesystem-like interface. Familiar file-based functions, similar to the SD library, are used to access data.", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/PaulStoffregen/SerialFlash.git" 8 | }, 9 | "frameworks": "arduino", 10 | "platforms": "*", 11 | "version": "0.0.0-alpha+sha.2b86eb1e43" 12 | } -------------------------------------------------------------------------------- /lib/SerialFlash/library.properties: -------------------------------------------------------------------------------- 1 | name=SerialFlash 2 | version=0.5 3 | author=Paul Stoffregen 4 | maintainer=Paul Stoffregen 5 | sentence=Access SPI Serial Flash memory with filesystem-like functions 6 | paragraph=SerialFlash provides low-latency, high performance access to SPI Flash memory with a filesystem-like interface. Familiar file-based functions, similar to the SD library, are used to access data. 7 | category=Data Storage 8 | url=https://github.com/PaulStoffregen/SerialFlash 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /lib/SerialFlash/tests.txt: -------------------------------------------------------------------------------- 1 | Test CS 2 | Board Pin Size Vendor Flash Chip HWTest CopySD 3 | ----- --- ---- ------ ---------- ------ 4 | 1 4 4M Atmel AT25SF041-SSHD-T FAIL 5 | 1 5 8M Spansion S25FL208K0RMFI041 Pass 6 | 1 6 4M Micron M25P40-VMW6TGB FAIL 7 | 1 7 16M Spansion S25FL116K0XMFI043 Pass 8 | 9 | 2 4 64M Winbond W25Q64FVSSIG Pass 10 | 2 5 128M Winbond W25Q128FVSIG Pass 11 | 2 6 64M Spansion S25FL164K0XMFI011 Pass 12 | 2 7 16M Micron M25P16-VMN6P FAIL 13 | 14 | 3 4 256M Winbond 25Q256FVFG Pass shady aliexpress vendor 15 | 3 5 512M Spansion S25FL512SAGMFIG11 Pass 16 | 3 6 256M Spansion S25FL256SAGMFIR01 Pass 17 | 3 7 1G Micron N25Q00AA13GSF40G Pass 18 | 19 | 4 4 256M Macronix MX25L25635FMI-10G Pass 20 | 4 7 256M Macronix MX25L25735FMI-10G Pass 21 | 22 | 5 4 1G Spansion S70FL01GSAGMFI011 Pass1/2 CS2 pin short to 3.3V 23 | 5 5 256M Micron N25Q256A13ESF40G Pass 24 | 5 7 256M Spansion S70FL256P0XMFI001 Pass 25 | 26 | 6 4 32M Microchip SST26VF032B-104I/SM FAIL 27 | 6 5 32M Microchip SST26VF032BA-104I/SM FAIL see issue #36 28 | 6 6 8M Winbond W25Q80BV Pass shady aliexpress vendor 29 | 30 | 7 5 1G Micron N25Q00AA Pesky Products / Tindie 31 | 7 6 2G Micron MT25QL02GCBB8E12 Pesky Products / Tindie 32 | 33 | 8 4 2G Winbond W25M02GVZEIG 34 | 8 5 1G Micron MT29F1G01ABAFDWB-IT:F 35 | 8 6 2G Micron MT29F2G01ABAGDWB-IT:G 36 | 8 7 4G Micron MT29F4G01ABAGDWB-IT:G 37 | 38 | 39 | For a photo of all these test boards: 40 | https://forum.pjrc.com/threads/31491-Will-Paul-s-SPIFlash-library-work-with-these 41 | 42 | -------------------------------------------------------------------------------- /lib/syntiant_ilib/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Syntiant Corp. All rights reserved. 2 | # Contact at http://www.syntiant.com 3 | # 4 | # This software is available to you under a choice of one of two licenses. 5 | # You may choose to be licensed under the terms of the GNU General Public 6 | # License (GPL) Version 2, available from the file LICENSE in the main 7 | # directory of this source tree, or the OpenIB.org BSD license below. Any 8 | # code involving Linux software will require selection of the GNU General 9 | # Public License (GPL) Version 2. 10 | # 11 | # OPENIB.ORG BSD LICENSE 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions are met: 15 | # 16 | # 1. Redistributions of source code must retain the above copyright notice, 17 | # this list of conditions and the following disclaimer. 18 | # 19 | # 2. Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in the 21 | # documentation and/or other materials provided with the distribution. 22 | # 23 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | # DEALINGS IN THE SOFTWARE. 30 | 31 | CFLAGS= -g3 -O3 -Wall -Werror -Wc++-compat -fpic -I. -D_FILE_OFFSET_BITS=64 \ 32 | -DSYNTIANT_NDP10X_MICRO_ARGS_CHECKS 33 | 34 | MICRO_LIBRARY=synuilib 35 | MICRO_STATIC_LIBRARY=lib$(MICRO_LIBRARY).a 36 | MICRO_DYNAMIC_LIBRARY=lib$(MICRO_LIBRARY).so 37 | MICRO_OBJS := syntiant_ndp10x_micro.o 38 | 39 | MICRO_APP=ndp10x_micro_app 40 | MICRO_APP_OBJS := ndp10x_micro_app.o 41 | 42 | $(MICRO_STATIC_LIBRARY): $(MICRO_OBJS) 43 | $(AR) rcs $@ $^ 44 | 45 | $(MICRO_DYNAMIC_LIBRARY): $(MICRO_OBJS) 46 | $(CC) -shared -o $@ $^ 47 | 48 | $(MICRO_APP): $(MICRO_APP_OBJS) $(MICRO_STATIC_LIBRARY) 49 | $(CC) $(CFLAGS) -static -o $@ $(MICRO_APP_OBJS) -L . -l$(MICRO_LIBRARY) 50 | 51 | all: $(MICRO_STATIC_LIBRARY) $(MICRO_DYNAMIC_LIBRARY) $(MICRO_APP) 52 | 53 | -include $(OBJS:.o=.d) 54 | 55 | %.o: %.c 56 | $(CC) -MM -MT $*.o $(CFLAGS) $(CPPFLAGS) $*.c > $*.d 57 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $*.c -o $*.o 58 | 59 | clean: 60 | $(RM) -f $(MICRO_STATIC_LIBRARY) $(MICRO_DYNAMIC_LIBRARY) \ 61 | $(MICRO_OBJS) *.d $(MICRO_APP) 62 | -------------------------------------------------------------------------------- /lib/syntiant_ilib/README.md: -------------------------------------------------------------------------------- 1 | 32 | 33 | # syntiant-uilib 34 | 35 | This package contains the Syntiant NDP10x Micro Interface Library 36 | (uILib). 37 | 38 | The uILib is governed by a dual copyright license affixed to each of 39 | the source files and in the prefix comment of this file. 40 | 41 | The version number of the uILib is stored in the 42 | `syntiant_ilib/syntiant_ndp_ilib_version.h` file and is also compiled 43 | into the library object code itself to be retrieved through the 44 | defined-interface for the library. 45 | 46 | The uILib uses 'uILib log files' generated from the full Syntiant NDP 47 | uILib to configure the NDP10x device with firmware. The full Syntiant 48 | NDP uILib and the capacity to generate new uILib firmware log files is 49 | not included in the uILib distribution. However, several example log 50 | files are included to permit exercise of NDP10x devices with the uILib. 51 | 52 | ## The uILib 53 | 54 | The library itself is in a single source file 55 | `syntiant_ndp10x_micro.c` with the interface header file in 56 | `syntiant_ilib/syntiant_ndp10x_micro.h`. 57 | 58 | The supplied `Makefile` can build a statically-linked (`.a`) or 59 | dynamically-linked (`.so`) library object for the uILib. 60 | Alternatively, the `syntiant_ndp10x_micro.c` C file or the generated 61 | `syntiant_ndp10x_micro.o` object file can simply be integrated into 62 | the client system's build process. 63 | 64 | ## The `ndp10x_micro_app` Sample Program 65 | 66 | The package also contains a sample program `ndp10x_micro_app.c` 67 | intended to run on a Syntiant NDP9101B0-EVL evaluation system. It can 68 | be used as a reference for other clients. 69 | 70 | The `uilib-logs` directory contains 3 uILib firmware log files to 71 | allow exercise of an NDP10x device from the `ndp10x_micro_app`: 72 | 73 | * alexa_spi.bin -- initializes the NDP10x to recognize the trigger 74 | word 'Alexa' with PCM audio input over the device SPI interface 75 | * spi_to_pdm0.bin -- switches the audio input from the SPI interface 76 | to the pdm0 microphone 77 | * pdm0_to_spi.bin -- switches the audio input from the pdm0 microphone 78 | to the SPI interface 79 | 80 | The ILib CLI script used to create these firmware log files is also in 81 | the `uilib-logs` directory named `ndp10x_micro_app_logs.txt` 82 | 83 | The `ndp10x_micro_app` sample can be tested on a single channel, 84 | 16-bit, 16K samples/second PCM audio input file to show recognition on 85 | the NDP device: 86 | ``` 87 | $ make ndp10x_micro_app 88 | . . . 89 | $ ./ndp10x_micro_app -l uilib-logs/alexa_spi.bin -P alexa.raw 90 | Loading log from uilib-logs/alexa_spi.bin 91 | butest passed 92 | Polling for keyword indefinitely 93 | 2021-08-26 14:53:13 match -> alexa 94 | $ 95 | ``` 96 | 97 | This will watch for Alexa from the pdm0 microphone for 30 seconds recording 98 | the PCM audio to `alexa_watch30.raw` and create a WAV format file 99 | `alexa_watch30.wav` using the `sox` command: 100 | ``` 101 | $ ndp10x_micro_app -l alexa_spi.bin,spi_to_pdm0.bin -p alexa_watch30.raw -D 30 102 | Loading log from alexa_spi.bin 103 | Loading log from spi_to_pdm0.bin 104 | butest passed 105 | Watching for keyword for the next 30 seconds 106 | 2021-08-27 09:38:41 match -> alexa 107 | 2021-08-27 09:38:45 match -> alexa 108 | 2021-08-27 09:38:48 match -> alexa 109 | $ sox -r 16k -b 16 -e signed-integer -c 1 alexa_watch30.raw alexa_watch30.wav 110 | ``` 111 | -------------------------------------------------------------------------------- /lib/syntiant_ilib/VERSION: -------------------------------------------------------------------------------- 1 | v65 -------------------------------------------------------------------------------- /lib/syntiant_ilib/syntiant_ilib/syntiant_ndp_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | #ifndef SYNTIANT_NDP_ERROR_H 33 | #define SYNTIANT_NDP_ERROR_H 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * @brief error codes 41 | */ 42 | enum syntiant_ndp_errors_e { 43 | SYNTIANT_NDP_ERROR_NONE = 0, /**< operation successful */ 44 | SYNTIANT_NDP_ERROR_FAIL = 1, /**< general failure */ 45 | SYNTIANT_NDP_ERROR_ARG = 2, /**< invalid argument error */ 46 | SYNTIANT_NDP_ERROR_UNINIT = 3, /**< device unintialized or no fw loaded */ 47 | SYNTIANT_NDP_ERROR_PACKAGE = 4, /**< package format error */ 48 | SYNTIANT_NDP_ERROR_UNSUP = 5, /**< operation not supported */ 49 | SYNTIANT_NDP_ERROR_NOMEM = 6, /**< out of memory */ 50 | SYNTIANT_NDP_ERROR_BUSY = 7, /**< operation in progress */ 51 | SYNTIANT_NDP_ERROR_TIMEOUT = 8, /**< operation timeout */ 52 | SYNTIANT_NDP_ERROR_MORE = 9, /**< more data is expected */ 53 | SYNTIANT_NDP_ERROR_CONFIG = 10, /**< config error */ 54 | SYNTIANT_NDP_ERROR_CRC = 11, /**< CRC mismatch */ 55 | SYNTIANT_NDP_ERROR_INVALID_NETWORK = 12, /**< invalid network id */ 56 | SYNTIANT_NDP_ERROR_DATA_REREAD = 13, /** 36 | #include 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/classifier/ei_model_types.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EDGE_IMPULSE_MODEL_TYPES_H_ 36 | #define _EDGE_IMPULSE_MODEL_TYPES_H_ 37 | 38 | #include 39 | 40 | typedef struct { 41 | uint16_t implementation_version; 42 | bool is_configured; 43 | uint32_t average_window_duration_ms; 44 | float detection_threshold; 45 | uint32_t suppression_ms; 46 | uint32_t suppression_flags; 47 | } ei_performance_calibration_config_t; 48 | 49 | #endif // _EDGE_IMPULSE_MODEL_TYPES_H_ 50 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/classifier/inferencing_engines/engines.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/arduino/ei_classifier_porting.cpp: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "../ei_classifier_porting.h" 36 | #if EI_PORTING_ARDUINO == 1 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #define EI_WEAK_FN __attribute__((weak)) 43 | 44 | EI_WEAK_FN EI_IMPULSE_ERROR ei_run_impulse_check_canceled() { 45 | return EI_IMPULSE_OK; 46 | } 47 | 48 | EI_WEAK_FN EI_IMPULSE_ERROR ei_sleep(int32_t time_ms) { 49 | delay(time_ms); 50 | return EI_IMPULSE_OK; 51 | } 52 | 53 | uint64_t ei_read_timer_ms() { 54 | return millis(); 55 | } 56 | 57 | uint64_t ei_read_timer_us() { 58 | return micros(); 59 | } 60 | 61 | void ei_serial_set_baudrate(int baudrate) 62 | { 63 | 64 | } 65 | 66 | EI_WEAK_FN void ei_putchar(char c) 67 | { 68 | Serial.write(c); 69 | } 70 | 71 | /** 72 | * Printf function uses vsnprintf and output using Arduino Serial 73 | */ 74 | __attribute__((weak)) void ei_printf(const char *format, ...) { 75 | static char print_buf[1024] = { 0 }; 76 | 77 | va_list args; 78 | va_start(args, format); 79 | int r = vsnprintf(print_buf, sizeof(print_buf), format, args); 80 | va_end(args); 81 | 82 | if (r > 0) { 83 | Serial.write(print_buf); 84 | } 85 | } 86 | 87 | __attribute__((weak)) void ei_printf_float(float f) { 88 | Serial.print(f, 6); 89 | } 90 | 91 | __attribute__((weak)) void *ei_malloc(size_t size) { 92 | return malloc(size); 93 | } 94 | 95 | __attribute__((weak)) void *ei_calloc(size_t nitems, size_t size) { 96 | return calloc(nitems, size); 97 | } 98 | 99 | __attribute__((weak)) void ei_free(void *ptr) { 100 | free(ptr); 101 | } 102 | 103 | #if defined(__cplusplus) && EI_C_LINKAGE == 1 104 | extern "C" 105 | #endif 106 | __attribute__((weak)) void DebugLog(const char* s) { 107 | ei_printf("%s", s); 108 | } 109 | 110 | #endif // EI_PORTING_ARDUINO == 1 111 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/debug_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | #ifndef TENSORFLOW_LITE_MICRO_DEBUG_LOG_H_ 16 | #define TENSORFLOW_LITE_MICRO_DEBUG_LOG_H_ 17 | 18 | // This function should be implemented by each target platform, and provide a 19 | // way for strings to be output to some text stream. For more information, see 20 | // tensorflow/lite/micro/debug_log.cc. 21 | #if defined(__cplusplus) && EI_C_LINKAGE == 1 22 | extern "C" void DebugLog(const char* s); 23 | #else 24 | void DebugLog(const char* s); 25 | #endif // defined(__cplusplus) && EI_C_LINKAGE == 1 26 | 27 | #endif // TENSORFLOW_LITE_MICRO_DEBUG_LOG_H_ 28 | 29 | -------------------------------------------------------------------------------- /src/ei_sample_storage.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef EI_SAMPLE_STORAGE_H 35 | #define EI_SAMPLE_STORAGE_H 36 | 37 | /* Include ----------------------------------------------------------------- */ 38 | #include 39 | 40 | /* SD card size defines ---------------------------------------------------- */ 41 | #define SD_BLOCK_SIZE 512 42 | #define SD_N_BLOCKS 1000 43 | #define SD_FILE_SIZE (SD_BLOCK_SIZE * SD_N_BLOCKS) 44 | 45 | /* Prototypes -------------------------------------------------------------- */ 46 | void ei_create_bin(void); 47 | void ei_write_bin(void); 48 | int ei_write_data_to_bin(uint8_t *data, uint32_t address, uint32_t length); 49 | int ei_write_last_data_to_bin(uint32_t address); 50 | uint32_t ei_read_sample_buffer(uint8_t *sample_buffer, uint32_t address_offset, uint32_t n_read_bytes); 51 | 52 | #endif -------------------------------------------------------------------------------- /src/firmware-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | -------------------------------------------------------------------------------- /src/firmware-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | The firmware-sdk provides portable code for commonly needed processing tasks. It in turn relies on drivers provided for specific targets. 4 | 5 | # Core functions 6 | Chip specific implementations must be provided for the following header files: 7 | - ei_classifier_porting.h 8 | - ei_device_info_lib.h 9 | - ei_device_interface.h 10 | 11 | # Sensors 12 | 13 | ## Camera 14 | 15 | - Ingestion (snapshot, snapshot_stream) format: 16 | The daemon (and the frame-to-jpeg debug tool) expect packed RGB 17 | (3B per pixel, as opposed to 4B with high B to 0 for inference) 18 | - Big endian format (uint8_t image[i] is R, image[i+1] is G, ... 19 | 20 | - Inference format: 21 | - The "get_data" function expects RGB encoded into floats, respecting the endianness of the platform 22 | - If you encode with bit shifting, you'll encode with the endianness of the chip 23 | - something like: static_cast((r << 16) + (g << 8 ) + b)) 24 | - The encoding is 4B, so there's a pad byte in the MSB of the float 25 | 26 | ### Porting 27 | 28 | - The top level of all firmware is chip specific. ei_image_lib provides portable, convenient functions for binding to AT commands. 29 | ``` 30 | config_ctx.take_snapshot = &ei_camera_take_snapshot_output_on_serial; 31 | config_ctx.start_snapshot_stream = &ei_camera_start_snapshot_stream; 32 | ``` 33 | - To support these two functions, one must provide a driver implementation for the following interface class: ei_camera_interface.h 34 | - This is a singleton class pattern with a port provided factory. All needed functions are prototyped in ei_camera_interface.h 35 | - (The "core" functions must also be present, see "Core functions" above) 36 | - Other support functions exist in ei_image_lib 37 | - YUV422 to RGB conversion 38 | - ei_image_nn.h supports inference, but does not need to be touched. It calls the camera factory. 39 | 40 | ### Interface notes 41 | 42 | at_get_snapshot_list : Return possible resolutions, greyscale, etc 43 | - const char **color_depth >-should be-> "Greyscale" or "RGB" -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_command_set.h: -------------------------------------------------------------------------------- 1 | #ifndef AT_COMMAND_SET_H 2 | #define AT_COMMAND_SET_H 3 | 4 | /** 5 | * @brief Default list of AT commands 6 | * VERSION: 1.6.0 7 | */ 8 | 9 | #define AT_COMMAND_VERSION "1.6.0" 10 | 11 | /*************************************************************************************************/ 12 | /* mandatory commands required by Edge Impulse CLI Tools*/ 13 | #define AT_CLEARCONFIG "CLEARCONFIG" 14 | #define AT_CLEARCONFIG_HELP_TEXT "Clears complete config and resets system" 15 | #define AT_CONFIG "CONFIG" 16 | #define AT_CONFIG_HELP_TEXT "Lists complete config" 17 | #define AT_DEVICEID "DEVICEID" 18 | #define AT_DEVICEID_ARGS "DEVICEID" 19 | #define AT_DEVICEID_HELP_TEXT "Sets the device ID" 20 | #define AT_SAMPLESETTINGS "SAMPLESETTINGS" 21 | #define AT_SAMPLESETTINGS_ARGS "LABEL,INTERVAL_MS,LENGTH_MS,[HMAC_KEY]" 22 | #define AT_SAMPLESETTINGS_HELP_TEXT "Lists or sets current sampling settings" 23 | #define AT_UPLOADSETTINGS "UPLOADSETTINGS" 24 | #define AT_UPLOADSETTINGS_ARGS "APIKEY,PATH" 25 | #define AT_UPLOADSETTINGS_HELP_TEXT "Lists or sets current upload settings" 26 | #define AT_UPLOADHOST "UPLOADHOST" 27 | #define AT_UPLOADHOST_ARGS "HOST" 28 | #define AT_UPLOADHOST_HELP_TEXT "Sets upload host" 29 | #define AT_MGMTSETTINGS "MGMTSETTINGS" 30 | #define AT_MGMTSETTINGS_ARGS "URL" 31 | #define AT_MGMTSETTINGS_HELP_TEXT "Lists or sets current management settings" 32 | #define AT_READFILE "READFILE" 33 | #define AT_READFILE_ARGS "FILENAME,[USEMAXRATE]" 34 | #define AT_READFILE_HELP_TEXT "Read a specific file (as base64)" 35 | #define AT_READBUFFER "READBUFFER" 36 | #define AT_READBUFFER_ARGS "START,LENGTH,[USEMAXRATE]" 37 | #define AT_READBUFFER_HELP_TEXT "Read from the temporary buffer (as base64)" 38 | #define AT_UNLINKFILE "UNLINKFILE" 39 | #define AT_UNLINKFILE_ARGS "FILE" 40 | #define AT_UNLINKFILE_HELP_TEXT "Unlink a specific file" 41 | #define AT_SAMPLESTART "SAMPLESTART" 42 | #define AT_SAMPLESTART_ARGS "SENSOR_NAME" 43 | #define AT_SAMPLESTART_HELP_TEXT "Start sampling" 44 | #define AT_RUNIMPULSE "RUNIMPULSE" 45 | #define AT_RUNIMPULSE_HELP_TEXT "Run the impulse" 46 | #define AT_RUNIMPULSEDEBUG "RUNIMPULSEDEBUG" 47 | #define AT_RUNIMPULSEDEBUG_HELP_TEXT "Run the impulse with extra debug output" 48 | #define AT_RUNIMPULSECONT "RUNIMPULSECONT" 49 | #define AT_RUNIMPULSECONT_HELP_TEXT "Run the impulse continuously" 50 | 51 | /*************************************************************************************************/ 52 | /* platform specific commands */ 53 | #define AT_WIFI "WIFI" 54 | #define AT_WIFI_ARGS "SSID,PASSWORD,SECURITY" 55 | #define AT_WIFI_HELP_TEXT "Lists or sets WiFi credentials" 56 | #define AT_SCANWIFI "SCANWIFI" 57 | #define AT_SCANWIFI_HELP_TEXT "Scans for WiFi networks" 58 | #define AT_SNAPSHOT "SNAPSHOT" 59 | #define AT_SNAPSHOT_ARGS "WIDTH,HEIGHT,[USEMAXRATE]" 60 | #define AT_SNAPSHOT_HELP_TEXT "Take a snapshot" 61 | #define AT_SNAPSHOTSTREAM "SNAPSHOTSTREAM" 62 | #define AT_SNAPSHOTSTREAM_ARGS "WIDTH,HEIGHT,[USEMAXRATE]" 63 | #define AT_SNAPSHOTSTREAM_HELP_TEXT "Take a stream of snapshot stream" 64 | 65 | /*************************************************************************************************/ 66 | /* optional commands (not required by Edge Impulse CLI Tools) */ 67 | #define AT_CLEARFILES "CLEARFILES" 68 | #define AT_CLEARFILES_HELP_TEXT "Clears all files from the file system, this does not clear config" 69 | #define AT_DEVICEINFO "DEVICEINFO" 70 | #define AT_DEVICEINFO_HELP_TEXT "Lists device information" 71 | #define AT_SENSORS "SENSORS" 72 | #define AT_SENSORS_HELP_TEXT "Lists sensors" 73 | #define AT_RESET "RESET" 74 | #define AT_RESET_HELP_TEXT "Reset the system" 75 | #define AT_LISTFILES "LISTFILES" 76 | #define AT_LISTFILES_HELP_TEXT "Lists all files on the device" 77 | #define AT_READRAW "READRAW" 78 | #define AT_READRAW_ARS "START,LENGTH" 79 | #define AT_READRAW_HELP_TEXT "Read raw from flash" 80 | #define AT_BOOTMODE "BOOTMODE" 81 | #define AT_BOOTMODE_HELP_TEXT "Jump to bootloader" 82 | 83 | /*************************************************************************************************/ 84 | /* HELP is not necessary as it is built-in into ATServer and 85 | any custom implementation is ignored. For documentation purposes only */ 86 | #define AT_HELP "HELP" 87 | #define AT_HELP_HELP_TEXT "Lists all commands" 88 | 89 | #endif /* AT_COMMAND_SET_H */ 90 | -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_history.h: -------------------------------------------------------------------------------- 1 | #ifndef AT_HISTORY_H 2 | #define AT_HISTORY_H 3 | #include 4 | #include 5 | 6 | class ATHistory { 7 | private: 8 | std::vector history; 9 | const size_t history_max_size; 10 | size_t history_position; 11 | 12 | public: 13 | ATHistory(size_t max_size = 10) 14 | : history_max_size(max_size) 15 | , history_position(0) {}; 16 | 17 | std::string go_back(void) 18 | { 19 | if (!is_at_begin()) { 20 | history_position--; 21 | } 22 | 23 | if (history.size() == 0) { 24 | return std::string(""); 25 | } 26 | else { 27 | return history[history_position]; 28 | } 29 | } 30 | 31 | std::string go_next(void) 32 | { 33 | if (++history_position >= history.size()) { 34 | history_position = history.size(); 35 | return std::string(""); 36 | } 37 | 38 | return history[history_position]; 39 | } 40 | 41 | bool is_at_end(void) 42 | { 43 | return history_position == history.size(); 44 | } 45 | 46 | bool is_at_begin(void) 47 | { 48 | return history_position == 0; 49 | } 50 | 51 | void add(std::string &entry) 52 | { 53 | // don't add empty entries 54 | if (entry == "") { 55 | return; 56 | } 57 | 58 | history.push_back(entry); 59 | 60 | if (history.size() > history_max_size) { 61 | history.erase(history.begin()); 62 | } 63 | 64 | history_position = history.size(); 65 | } 66 | }; 67 | 68 | #endif /* AT_HISTORY_H */ -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_parser.cpp: -------------------------------------------------------------------------------- 1 | #include "ei_at_parser.h" 2 | 3 | using namespace std; 4 | 5 | void ATParser::init_result(void) 6 | { 7 | last_result.type = AT_UNKNOWN; 8 | last_result.command.clear(); 9 | last_result.arguments.clear(); 10 | last_result.max_arg_len = 0; 11 | } 12 | 13 | const ATParseResult_t &ATParser::parse(string input) 14 | { 15 | string tmp; 16 | size_t pos = string::npos; 17 | size_t delim1 = string::npos; 18 | size_t delim2 = string::npos; 19 | 20 | this->init_result(); 21 | 22 | if (input.size() == 0) { 23 | last_result.type = AT_UNKNOWN; 24 | return last_result; 25 | } 26 | 27 | // trim leading whitespaces 28 | input = input.substr(input.find_first_not_of(" \t")); 29 | 30 | if (input.rfind("AT+", 0) != 0) { 31 | last_result.type = AT_UNKNOWN; 32 | return last_result; 33 | } 34 | 35 | //remove "AT+" 36 | input = input.substr(3); 37 | 38 | // trim spaces, newline and CR at the end 39 | input = input.erase(input.find_last_not_of(" \r\n") + 1); 40 | 41 | // extract command itself 42 | pos = input.find_first_of("?="); 43 | last_result.command = input.substr(0, pos); 44 | 45 | if (pos == string::npos) { 46 | last_result.type = AT_RUN; 47 | } 48 | else if (input.at(pos) == '=') { 49 | last_result.type = AT_WRITE; 50 | } 51 | else if (input.at(pos) == '?') { 52 | last_result.type = AT_READ; 53 | } 54 | else { 55 | last_result.type = AT_UNKNOWN; 56 | } 57 | 58 | // check if command has arguments and extract them 59 | if (pos != string::npos && input.at(pos) == '=') { 60 | delim1 = pos; 61 | delim2 = input.find_first_of(",", pos); 62 | // we have arguments, let's extract them 63 | while (delim2 != string::npos) { 64 | //TODO: support args in a quote 65 | tmp = string(input, delim1 + 1, delim2 - delim1 - 1); 66 | last_result.arguments.push_back(tmp); 67 | if (tmp.size() > last_result.max_arg_len) { 68 | last_result.max_arg_len = tmp.size(); 69 | } 70 | delim1 = delim2; 71 | delim2 = input.find_first_of(",", delim1 + 1); 72 | } 73 | //there is one more argument, behind last comma so, get it until end of command 74 | tmp = string(input, delim1 + 1); 75 | last_result.arguments.push_back(tmp); 76 | if (tmp.size() > last_result.max_arg_len) { 77 | last_result.max_arg_len = tmp.size(); 78 | } 79 | } 80 | 81 | return last_result; 82 | } 83 | -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_parser.h: -------------------------------------------------------------------------------- 1 | #ifndef AT_PARSER_H 2 | #define AT_PARSER_H 3 | #include 4 | #include 5 | 6 | enum ATCommandType_t 7 | { 8 | AT_RUN, 9 | AT_READ, 10 | AT_WRITE, 11 | AT_UNKNOWN 12 | }; 13 | 14 | typedef struct { 15 | ATCommandType_t type; 16 | std::string command; 17 | std::vector arguments; 18 | unsigned int max_arg_len; 19 | } ATParseResult_t; 20 | 21 | class ATParser { 22 | private: 23 | ATParseResult_t last_result; 24 | void init_result(void); 25 | 26 | public: 27 | ATParser() {}; 28 | ~ATParser() {}; 29 | const ATParseResult_t &parse(std::string command); 30 | }; 31 | 32 | #endif /* AT_PARSER_H */ -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_server.h: -------------------------------------------------------------------------------- 1 | #ifndef AT_SERVER_H 2 | #define AT_SERVER_H 3 | #include "ei_at_history.h" 4 | #include "ei_at_parser.h" 5 | #include "ei_line_buffer.h" 6 | #include 7 | #include 8 | #include 9 | 10 | typedef std::function ATRunHandler_t; 11 | typedef std::function ATReadHandler_t; 12 | typedef std::function ATWriteHandler_t; 13 | 14 | const size_t default_history_size = 10; 15 | 16 | typedef struct { 17 | std::string command; 18 | std::string help_text; 19 | ATRunHandler_t run_handler; 20 | ATReadHandler_t read_handler; 21 | ATWriteHandler_t write_handler; 22 | std::string write_handler_args_list; 23 | } ATCommand_t; 24 | 25 | class ATServer { 26 | private: 27 | ATHistory history; 28 | std::vector registered_commands; 29 | LineBuffer buffer; 30 | ATParser parser; 31 | void register_help_command(void); 32 | 33 | protected: 34 | ATServer(); 35 | ATServer(ATCommand_t *commands, size_t length, size_t max_history_size = default_history_size); 36 | ~ATServer(); 37 | bool print_help(void); 38 | bool execute(std::string &command); 39 | 40 | public: 41 | ATServer(ATServer &other) = delete; 42 | void operator=(const ATServer &) = delete; 43 | 44 | /* Definition of get_instance methods are in a separate file (ATServerSingleton.cpp) 45 | * See comment over there. 46 | */ 47 | static ATServer *get_instance(); 48 | static ATServer *get_instance( 49 | ATCommand_t *commands, 50 | size_t length, 51 | size_t max_history_size = default_history_size); 52 | 53 | void handle(char c); 54 | void print_prompt(void); 55 | 56 | bool register_command(ATCommand_t &command); 57 | bool register_command( 58 | const char *cmd, 59 | const char *help_text, 60 | bool (*run_handler)(void), 61 | bool (*read_handler)(void), 62 | bool (*write_handler)(const char **, const int), 63 | const char *write_handler_args_list); 64 | bool register_handlers( 65 | const char *cmd, 66 | bool (*run_handler)(void), 67 | bool (*read_handler)(void), 68 | bool (*write_handler)(const char **, const int), 69 | const char *write_handler_args_list); 70 | }; 71 | 72 | #endif /* AT_SERVER_H */ -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_at_server_singleton.cpp: -------------------------------------------------------------------------------- 1 | #include "ei_at_server.h" 2 | 3 | /* 4 | * The definition of get_instance method is here, 5 | * because AT Server is designed as a singleton class 6 | * therefore unit testing of this pattern is pretty difficult. 7 | * To avoid such issue, for the unit test of all functionalities one 8 | * can exclude this file and add a custom definition which is implementing 9 | * non-singleton class - returns a new instance for each call of get_instance 10 | */ 11 | 12 | ATServer *ATServer::get_instance() 13 | { 14 | return ATServer::get_instance(nullptr, 0, default_history_size); 15 | } 16 | 17 | ATServer *ATServer::get_instance(ATCommand_t *commands, size_t length, size_t max_history_size) 18 | { 19 | static ATServer instance(commands, length, max_history_size); 20 | 21 | return &instance; 22 | } 23 | -------------------------------------------------------------------------------- /src/firmware-sdk/at-server/ei_line_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEBUFFER_H 2 | #define LINEBUFFER_H 3 | 4 | #include 5 | 6 | class LineBuffer { 7 | private: 8 | std::string buffer; 9 | size_t position; 10 | 11 | public: 12 | LineBuffer() 13 | : buffer("") 14 | , position(0) {}; 15 | 16 | void clear() 17 | { 18 | buffer.clear(); 19 | position = 0; 20 | } 21 | 22 | void add(std::string &s) 23 | { 24 | if (position == buffer.size()) { 25 | buffer.append(s); 26 | } 27 | else { 28 | buffer.insert(position, s); 29 | } 30 | position += s.size(); 31 | } 32 | 33 | void add(const char c) 34 | { 35 | if (position == buffer.size()) { 36 | buffer.append(&c, 1); 37 | } 38 | else { 39 | buffer.insert(position, &c, 1); 40 | } 41 | position++; 42 | } 43 | 44 | bool do_backspace(void) 45 | { 46 | if (is_empty() || is_at_begin()) { 47 | return false; 48 | } 49 | 50 | buffer.erase(position - 1, 1); 51 | position--; 52 | 53 | return true; 54 | } 55 | 56 | bool do_delete(void) 57 | { 58 | if (is_empty() || is_at_end()) { 59 | return false; 60 | } 61 | 62 | buffer.erase(position, 1); 63 | 64 | return true; 65 | } 66 | 67 | bool is_at_begin(void) 68 | { 69 | return position == 0; 70 | } 71 | 72 | bool is_at_end(void) 73 | { 74 | return position == buffer.size(); 75 | } 76 | 77 | bool is_empty(void) 78 | { 79 | return buffer.size() == 0; 80 | } 81 | 82 | std::string get_string() 83 | { 84 | return buffer; 85 | } 86 | 87 | size_t get_position() 88 | { 89 | return position; 90 | } 91 | 92 | void set_position(int pos) 93 | { 94 | if (pos > (int)buffer.size()) { 95 | position = buffer.size(); 96 | } 97 | else if (pos < 0) { 98 | position = 0; 99 | } 100 | else { 101 | position = pos; 102 | } 103 | } 104 | 105 | size_t size() 106 | { 107 | return buffer.size(); 108 | } 109 | }; 110 | 111 | #endif /* LINEBUFFER_H */ -------------------------------------------------------------------------------- /src/firmware-sdk/at_base64_lib.h: -------------------------------------------------------------------------------- 1 | #ifndef _EDGE_IMPULSE_SDK_BASE64_H_ 2 | #define _EDGE_IMPULSE_SDK_BASE64_H_ 3 | 4 | /* 5 | base64.cpp and base64.h 6 | 7 | Copyright (C) 2004-2008 René Nyffenegger 8 | 9 | This source code is provided 'as-is', without any express or implied 10 | warranty. In no event will the author be held liable for any damages 11 | arising from the use of this software. 12 | 13 | Permission is granted to anyone to use this software for any purpose, 14 | including commercial applications, and to alter it and redistribute it 15 | freely, subject to the following restrictions: 16 | 17 | 1. The origin of this source code must not be misrepresented; you must not 18 | claim that you wrote the original source code. If you use this source code 19 | in a product, an acknowledgment in the product documentation would be 20 | appreciated but is not required. 21 | 22 | 2. Altered source versions must be plainly marked as such, and must not be 23 | misrepresented as being the original source code. 24 | 25 | 3. This notice may not be removed or altered from any source distribution. 26 | 27 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 28 | 29 | */ 30 | 31 | /* Include ----------------------------------------------------------------- */ 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* Function prototypes ----------------------------------------------------- */ 38 | void base64_encode(const char *input, size_t input_size, void (*putc_f)(char)); 39 | int base64_encode_buffer(const char *input, size_t input_size, char *output, size_t output_size); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/firmware-sdk/ei_camera_interface.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __EICAMERA__H__ 36 | #define __EICAMERA__H__ 37 | 38 | 39 | #include 40 | 41 | class EiCamera { 42 | public: 43 | /** 44 | * @brief Call to driver to return an image encoded in RGB88 45 | * Format should be Big Endian, or in other words, if your image 46 | * pointer is indexed as a char*, then image[0] is R, image[1] is G 47 | * image[2] is B, and image[3] is R again (no padding / word alignment) 48 | * 49 | * @param image Point to output buffer for image. 32 bit for word alignment on some platforms 50 | * @param image_size_B Size of buffer allocated ( should be 3 * hsize * vsize ) 51 | * @param hsize Horizontal size, in pixels 52 | * @param vsize Vertial size, in pixels 53 | * @return true If successful 54 | * @return false If not successful 55 | */ 56 | virtual bool ei_camera_capture_rgb888_packed_big_endian( 57 | uint8_t *image, 58 | uint32_t image_size_B, 59 | uint16_t hsize, 60 | uint16_t vsize) = 0; //pure virtual. You must provide an implementation 61 | 62 | // The following should return the minimum resolution of the camera 63 | // The image SDK will automatically crop and interpolate lower than this when needed 64 | virtual uint16_t get_min_width() = 0; 65 | virtual uint16_t get_min_height() = 0; 66 | 67 | // the following are optional 68 | 69 | virtual bool init() 70 | { 71 | return true; 72 | } 73 | virtual bool deinit() 74 | { 75 | return true; 76 | } 77 | 78 | /** 79 | * @brief Implementation must provide a singleton getter 80 | * 81 | * @return EiCamera* 82 | */ 83 | static EiCamera *get_camera(); 84 | }; 85 | #endif //!__EICAMERA__H__ 86 | -------------------------------------------------------------------------------- /src/firmware-sdk/ei_config_types.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _EI_CONFIG_TYPES_H 35 | #define _EI_CONFIG_TYPES_H 36 | 37 | /** ei sampler callback function, call with sample data */ 38 | typedef bool (*sampler_callback)(const void *sample_buf, uint32_t byteLenght); 39 | typedef bool (*starter_callback)(sampler_callback callback, float sample_interval_ms); 40 | 41 | // return types 42 | typedef enum { 43 | EI_CONFIG_OK = 0, 44 | EI_CONFIG_BOUNDS_ERROR = -1, 45 | EI_CONFIG_CONTEXT_ERROR = -2, 46 | EI_CONFIG_NO_CONTEXT = -8, 47 | EI_CONFIG_WIFI_CONN_FAILED = -9, 48 | EI_CONFIG_NOT_IMPLEMENTED = -10, 49 | } EI_CONFIG_ERROR; 50 | 51 | // same as https://github.com/ARMmbed/mbed-os/blob/d4122b0b3a091d3f1130f3bb0d91c96f9183e2de/features/netsocket/nsapi_types.h#L115 52 | typedef enum { 53 | EI_SECURITY_NONE = 0x0, /*!< open access point */ 54 | EI_SECURITY_WEP = 0x1, /*!< phrase conforms to WEP */ 55 | EI_SECURITY_WPA = 0x2, /*!< phrase conforms to WPA */ 56 | EI_SECURITY_WPA2 = 0x3, /*!< phrase conforms to WPA2 */ 57 | EI_SECURITY_WPA_WPA2 = 0x4, /*!< phrase conforms to WPA/WPA2 */ 58 | EI_SECURITY_PAP = 0x5, /*!< phrase conforms to PPP authentication context */ 59 | EI_SECURITY_CHAP = 0x6, /*!< phrase conforms to PPP authentication context */ 60 | EI_SECURITY_EAP_TLS = 0x7, /*!< phrase conforms to EAP-TLS */ 61 | EI_SECURITY_PEAP = 0x8, /*!< phrase conforms to PEAP */ 62 | EI_SECURITY_UNKNOWN = 0xFF, /*!< unknown/unsupported security in scan results */ 63 | } ei_config_security_t; 64 | 65 | 66 | // All the possible configuration options we can set 67 | typedef struct { 68 | char wifi_ssid[128]; 69 | char wifi_password[128]; 70 | ei_config_security_t wifi_security; 71 | float sample_interval_ms; 72 | uint32_t sample_length_ms; 73 | char sample_label[128]; 74 | char sample_hmac_key[33]; 75 | char upload_host[128]; 76 | char upload_path[128]; 77 | char upload_api_key[128]; 78 | char mgmt_url[128]; 79 | uint32_t magic; 80 | } ei_config_t; 81 | 82 | #endif -------------------------------------------------------------------------------- /src/firmware-sdk/ei_device_interface.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __EI_DEVICE_INTERFACE__H__ 36 | #define __EI_DEVICE_INTERFACE__H__ 37 | 38 | 39 | // also grab everything for classifying 40 | #include "edge-impulse-sdk/porting/ei_classifier_porting.h" 41 | 42 | /* Function prototypes ----------------------------------------------------- */ 43 | //TODO: remove as it is device specific and wil be superseded by AT Server 44 | void ei_command_line_handle(void); 45 | //TODO: redeclared in ei_device_lib.h 46 | bool ei_user_invoke_stop_lib(void); 47 | //TODO: do we need it in the FW SDK? 48 | void ei_serial_setup(void); 49 | 50 | //TODO: remove as it is device specific 51 | void ei_write_string(char *data, int length); 52 | 53 | //TODO: move to a one header with all method requied by FW SDK 54 | char ei_getchar(); 55 | 56 | 57 | #endif //!__EI_DEVICE_INTERFACE__H__ 58 | -------------------------------------------------------------------------------- /src/firmware-sdk/ei_device_lib.cpp: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "firmware-sdk/ei_device_lib.h" 36 | #include "firmware-sdk/ei_device_interface.h" 37 | 38 | /** 39 | * @brief Call this function periocally during inference to 40 | * detect a user stop command 41 | * 42 | * @return true if user requested stop 43 | */ 44 | extern bool ei_user_invoke_stop_lib(void) 45 | { 46 | char ch; 47 | while(1) { 48 | ch = ei_getchar(); 49 | if(ch == 0) { return false; } 50 | if(ch == 'b') { return true; } 51 | } 52 | } -------------------------------------------------------------------------------- /src/firmware-sdk/ei_device_lib.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __EI_DEVICE_LIB__H__ 36 | #define __EI_DEVICE_LIB__H__ 37 | 38 | /** 39 | * @brief Call this function periocally during inference to 40 | * detect a user stop command 41 | * 42 | * @return true if user requested stop 43 | */ 44 | bool ei_user_invoke_stop_lib(void); 45 | #endif //!__EI_DEVICE_LIB__H__ 46 | -------------------------------------------------------------------------------- /src/firmware-sdk/ei_fusion.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EI_FUSION_H 36 | #define _EI_FUSION_H 37 | 38 | /* Include ----------------------------------------------------------------- */ 39 | #include "ei_config_types.h" 40 | #include "ei_fusion_sensors_config.h" 41 | #include "sensor_aq.h" 42 | 43 | #define EI_MAX_FREQUENCIES 5 44 | 45 | /** Format used in input list. Can either contain sensor names or axes names */ 46 | typedef enum 47 | { 48 | SENSOR_FORMAT = 0, 49 | AXIS_FORMAT 50 | 51 | } ei_fusion_list_format; 52 | 53 | /** 54 | * Information about the fusion structure, name, number of axis, sampling frequencies, axis name, and reference to read sensor function 55 | */ 56 | typedef struct { 57 | // Name of sensor to show up in Studio 58 | const char *name; 59 | // Number of sensor axis to sample 60 | int num_axis; 61 | // List of sensor sampling frequencies 62 | float frequencies[EI_MAX_FREQUENCIES]; 63 | // Sensor axes, note that I declare this not as a pointer to have a more fluent interface 64 | sensor_aq_sensor sensors[EI_MAX_SENSOR_AXES]; 65 | // Reference to read sensor function that should return pointer to float array of raw sensor data 66 | fusion_sample_format_t *(*read_data)(int n_samples); 67 | // Axis used 68 | int axis_flag_used; 69 | } ei_device_fusion_sensor_t; 70 | 71 | /* Function prototypes ----------------------------------------------------- */ 72 | bool ei_add_sensor_to_fusion_list(ei_device_fusion_sensor_t sensor); 73 | void ei_built_sensor_fusion_list(void); 74 | bool ei_connect_fusion_list(const char *input_list, ei_fusion_list_format format); 75 | void ei_fusion_read_axis_data(void); 76 | bool ei_fusion_sample_start(sampler_callback callsampler, float sample_interval_ms); 77 | bool ei_fusion_setup_data_sampling(); 78 | 79 | #endif -------------------------------------------------------------------------------- /src/firmware-sdk/jpeg/JPEGENC.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // JPEG Encoder 3 | // 4 | // written by Larry Bank 5 | // bitbank@pobox.com 6 | // Arduino port started 7/22/2021 7 | // Original JPEG code written 20+ years ago :) 8 | // The goal of this code is to encode JPEG images on embedded systems 9 | // 10 | // Copyright 2021 BitBank Software, Inc. All Rights Reserved. 11 | // Licensed under the Apache License, Version 2.0 (the "License"); 12 | // you may not use this file except in compliance with the License. 13 | // You may obtain a copy of the License at 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | //=========================================================================== 21 | // 22 | #include "JPEGENC.h" 23 | 24 | // Include the C code which does the actual work 25 | #include "jpeg.h" 26 | 27 | // 28 | // File (SD/MMC) based initialization 29 | // 30 | int JPEGClass::open(const char *szFilename, JPEG_OPEN_CALLBACK *pfnOpen, JPEG_CLOSE_CALLBACK *pfnClose, JPEG_READ_CALLBACK *pfnRead, JPEG_WRITE_CALLBACK *pfnWrite, JPEG_SEEK_CALLBACK *pfnSeek) 31 | { 32 | memset(&_jpeg, 0, sizeof(JPEGIMAGE)); 33 | _jpeg.pfnRead = pfnRead; 34 | _jpeg.pfnWrite = pfnWrite; 35 | _jpeg.pfnSeek = pfnSeek; 36 | _jpeg.pfnOpen = pfnOpen; 37 | _jpeg.pfnClose = pfnClose; 38 | _jpeg.JPEGFile.fHandle = (*pfnOpen)(szFilename); 39 | _jpeg.pHighWater = &_jpeg.ucFileBuf[JPEG_FILE_BUF_SIZE - 512]; 40 | if (_jpeg.JPEGFile.fHandle == NULL) { 41 | _jpeg.iError = JPEG_INVALID_FILE; 42 | return JPEG_INVALID_FILE; 43 | } 44 | return JPEG_SUCCESS; 45 | 46 | } /* open() */ 47 | 48 | int JPEGClass::open(uint8_t *pOutput, int iBufferSize) 49 | { 50 | memset(&_jpeg, 0, sizeof(JPEGIMAGE)); 51 | _jpeg.pOutput = pOutput; 52 | _jpeg.iBufferSize = iBufferSize; 53 | _jpeg.pHighWater = &pOutput[iBufferSize - 512]; 54 | 55 | return JPEG_SUCCESS; 56 | } /* open() */ 57 | 58 | // 59 | // return the last error (if any) 60 | // 61 | int JPEGClass::getLastError() 62 | { 63 | return _jpeg.iError; 64 | } /* getLastError() */ 65 | // 66 | // Close the file - not needed when decoding from memory 67 | // 68 | int JPEGClass::close() 69 | { 70 | JPEGEncodeEnd(&_jpeg); 71 | if (_jpeg.pfnClose) 72 | (*_jpeg.pfnClose)(&_jpeg.JPEGFile); 73 | return _jpeg.iDataSize; 74 | } /* close() */ 75 | 76 | int JPEGClass::encodeBegin(JPEGENCODE *pEncode, int iWidth, int iHeight, uint8_t ucPixelType, uint8_t ucSubSample, uint8_t ucQFactor) 77 | { 78 | return JPEGEncodeBegin(&_jpeg, pEncode, iWidth, iHeight, ucPixelType, ucSubSample, ucQFactor); 79 | } /* encodeBegin() */ 80 | 81 | int JPEGClass::addMCU(JPEGENCODE *pEncode, uint8_t *pPixels, int iPitch) 82 | { 83 | return JPEGAddMCU(&_jpeg, pEncode, pPixels, iPitch); 84 | } /* addMCU() */ 85 | -------------------------------------------------------------------------------- /src/firmware-sdk/jpeg/encode_as_jpg.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODE_AS_JPG_H_ 2 | #define ENCODE_AS_JPG_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "JPEGENC.h" 11 | #include "edge-impulse-sdk/dsp/numpy.hpp" 12 | #include "edge-impulse-sdk/dsp/numpy_types.h" 13 | 14 | int encode_as_jpg(uint8_t *framebuffer, size_t framebuffer_size, int width, int height, uint8_t *out_buffer, size_t out_buffer_size, size_t *out_size) { 15 | static JPEGClass jpg; 16 | JPEGENCODE jpe; 17 | 18 | int rc = jpg.open(out_buffer, out_buffer_size); 19 | if (rc != JPEG_SUCCESS) { 20 | return rc; 21 | } 22 | 23 | rc = jpg.encodeBegin(&jpe, width, height, JPEG_PIXEL_GRAYSCALE, JPEG_SUBSAMPLE_444, JPEG_Q_BEST); 24 | if (rc != JPEG_SUCCESS) { 25 | return rc; 26 | } 27 | 28 | int imcuCount = ((width + jpe.cx-1)/ jpe.cx) * ((height + jpe.cy-1) / jpe.cy); 29 | 30 | int bytePp = 1; 31 | int pitch = bytePp * width; 32 | 33 | for (int i=0; i < imcuCount && rc == JPEG_SUCCESS; i++) { 34 | // pass a pointer to the upper left corner of each MCU 35 | // the JPEGENCODE structure is updated by addMCU() after 36 | // each call 37 | rc = jpg.addMCU(&jpe, &framebuffer[(jpe.x * bytePp) + (jpe.y * pitch)], pitch); 38 | if (rc != JPEG_SUCCESS) { 39 | return rc; 40 | } 41 | } 42 | 43 | *out_size = jpg.close(); 44 | 45 | return 0; 46 | } 47 | 48 | int encode_bw_signal_as_jpg(signal_t *signal, int width, int height, uint8_t *out_buffer, size_t out_buffer_size, size_t *out_size) { 49 | static JPEGClass jpg; 50 | JPEGENCODE jpe; 51 | float *encode_buffer = NULL; 52 | uint8_t *encode_buffer_u8 = NULL; 53 | 54 | int rc = jpg.open(out_buffer, out_buffer_size); 55 | if (rc != JPEG_SUCCESS) { 56 | return rc; 57 | } 58 | 59 | rc = jpg.encodeBegin(&jpe, width, height, JPEG_PIXEL_GRAYSCALE, JPEG_SUBSAMPLE_444, JPEG_Q_BEST); 60 | if (rc != JPEG_SUCCESS) { 61 | return rc; 62 | } 63 | 64 | int imcu_count = ((width + jpe.cx-1)/ jpe.cx) * ((height + jpe.cy-1) / jpe.cy); 65 | 66 | int bytePp = 1; 67 | int pitch = bytePp * width; 68 | 69 | // We read through the signal paged... 70 | int buf_len = width * 8; 71 | 72 | int last_offset = 0; 73 | int max_offset_diff = 0; 74 | 75 | encode_buffer = (float*)malloc(buf_len * 4); 76 | if (!encode_buffer) { 77 | rc = JPEG_MEM_ERROR; 78 | goto cleanup; 79 | } 80 | encode_buffer_u8 = (uint8_t*)malloc(buf_len); 81 | if (!encode_buffer_u8) { 82 | rc = JPEG_MEM_ERROR; 83 | goto cleanup; 84 | } 85 | 86 | for (int i = 0; i < imcu_count; i++) { 87 | // pass a pointer to the upper left corner of each MCU 88 | // the JPEGENCODE structure is updated by addMCU() after 89 | // each call 90 | 91 | int offset = (jpe.x * bytePp) + (jpe.y * pitch); 92 | rc = signal->get_data(offset, buf_len, encode_buffer); 93 | if (rc != 0) { 94 | goto cleanup; 95 | } 96 | 97 | for (size_t ix = 0; ix < buf_len; ix++) { 98 | encode_buffer_u8[ix] = static_cast(encode_buffer[ix]) & 0xff; 99 | } 100 | 101 | rc = jpg.addMCU(&jpe, encode_buffer_u8, pitch); 102 | if (rc != JPEG_SUCCESS) { 103 | goto cleanup; 104 | } 105 | 106 | if (offset - last_offset > max_offset_diff) { 107 | max_offset_diff = offset - last_offset; 108 | } 109 | 110 | last_offset = offset; 111 | } 112 | 113 | printf("Max_offset_diff %d\n", max_offset_diff); 114 | 115 | rc = JPEG_SUCCESS; 116 | 117 | cleanup: 118 | *out_size = jpg.close(); 119 | 120 | free(encode_buffer); 121 | free(encode_buffer_u8); 122 | 123 | return rc; 124 | } 125 | 126 | #endif // ENCODE_AS_JPG_H 127 | -------------------------------------------------------------------------------- /src/ingestion-sdk-c/ei_config_types.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _EI_CONFIG_TYPES_H 35 | #define _EI_CONFIG_TYPES_H 36 | 37 | // return types 38 | typedef enum { 39 | EI_CONFIG_OK = 0, 40 | EI_CONFIG_BOUNDS_ERROR = -1, 41 | EI_CONFIG_CONTEXT_ERROR = -2, 42 | EI_CONFIG_NO_CONTEXT = -8, 43 | EI_CONFIG_WIFI_CONN_FAILED = -9, 44 | } EI_CONFIG_ERROR; 45 | 46 | // same as https://github.com/ARMmbed/mbed-os/blob/d4122b0b3a091d3f1130f3bb0d91c96f9183e2de/features/netsocket/nsapi_types.h#L115 47 | typedef enum { 48 | EI_SECURITY_NONE = 0x0, /*!< open access point */ 49 | EI_SECURITY_WEP = 0x1, /*!< phrase conforms to WEP */ 50 | EI_SECURITY_WPA = 0x2, /*!< phrase conforms to WPA */ 51 | EI_SECURITY_WPA2 = 0x3, /*!< phrase conforms to WPA2 */ 52 | EI_SECURITY_WPA_WPA2 = 0x4, /*!< phrase conforms to WPA/WPA2 */ 53 | EI_SECURITY_PAP = 0x5, /*!< phrase conforms to PPP authentication context */ 54 | EI_SECURITY_CHAP = 0x6, /*!< phrase conforms to PPP authentication context */ 55 | EI_SECURITY_EAP_TLS = 0x7, /*!< phrase conforms to EAP-TLS */ 56 | EI_SECURITY_PEAP = 0x8, /*!< phrase conforms to PEAP */ 57 | EI_SECURITY_UNKNOWN = 0xFF, /*!< unknown/unsupported security in scan results */ 58 | } ei_config_security_t; 59 | 60 | 61 | // All the possible configuration options we can set 62 | typedef struct { 63 | char wifi_ssid[128]; 64 | char wifi_password[128]; 65 | ei_config_security_t wifi_security; 66 | float sample_interval_ms; 67 | uint32_t sample_length_ms; 68 | char sample_label[128]; 69 | char sample_hmac_key[33]; 70 | char upload_host[128]; 71 | char upload_path[128]; 72 | char upload_api_key[128]; 73 | char mgmt_url[128]; 74 | uint32_t magic; 75 | } ei_config_t; 76 | 77 | #endif -------------------------------------------------------------------------------- /src/ingestion-sdk-platform/syntiant/ei_device_syntiant_samd.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef EI_DEVICE_SYNTIANT_SAMD 36 | #define EI_DEVICE_SYNTIANT_SAMD 37 | 38 | /* Include ----------------------------------------------------------------- */ 39 | #include "ei_device_info.h" 40 | #include "firmware-sdk/ei_device_memory.h" 41 | 42 | 43 | /** Number of sensors used */ 44 | #define EI_DEVICE_N_SENSORS 2 45 | 46 | typedef enum 47 | { 48 | eiStateIdle = 0, 49 | eiStateErasingFlash, 50 | eiStateSampling, 51 | eiStateUploading, 52 | eiStateFinished 53 | 54 | }tEiState; 55 | 56 | 57 | /** C Callback types */ 58 | typedef int (*c_callback)(uint8_t out_buffer[32], size_t *out_size); 59 | typedef bool (*c_callback_status)(void); 60 | typedef bool (*c_callback_read_sample_buffer)(size_t begin, size_t length, void(*data_fn)(uint8_t*, size_t)); 61 | 62 | /** 63 | * @brief Class description and implementation of device specific 64 | * characteristics 65 | */ 66 | class EiDeviceSyntiant : public EiDeviceInfo 67 | { 68 | private: 69 | ei_device_sensor_t sensors[EI_DEVICE_N_SENSORS]; 70 | public: 71 | EiDeviceSyntiant(void); 72 | 73 | int get_id(uint8_t out_buffer[32], size_t *out_size); 74 | const char *get_id_pointer(void); 75 | int get_type(uint8_t out_buffer[32], size_t *out_size); 76 | const char *get_type_pointer(void); 77 | bool get_wifi_connection_status(void); 78 | bool get_wifi_present_status(); 79 | bool get_sensor_list(const ei_device_sensor_t **sensor_list, size_t *sensor_list_size); 80 | void delay_ms(uint32_t milliseconds); 81 | void setup_led_control(void); 82 | void set_state(tEiState state); 83 | 84 | c_callback get_id_function(void); 85 | c_callback get_type_function(void); 86 | c_callback_status get_wifi_connection_status_function(void); 87 | c_callback_status get_wifi_present_status_function(void); 88 | c_callback_read_sample_buffer get_read_sample_buffer_function(void); 89 | 90 | }; 91 | 92 | /* Function prototypes ----------------------------------------------------- */ 93 | bool ei_command_line_handle(void); 94 | void ei_start_stop_run_impulse(bool start); 95 | bool ei_run_impulse_active(void); 96 | void ei_printf(const char *format, ...); 97 | void ei_printf_float(float f); 98 | void ei_printfloat(int n_decimals, int n, ...); 99 | 100 | void ei_write_string(char *data, int length); 101 | void ei_putchar(char cChar); 102 | 103 | /* Reference to object for external usage ---------------------------------- */ 104 | extern EiDeviceSyntiant EiDevice; 105 | 106 | #endif -------------------------------------------------------------------------------- /src/ingestion-sdk-platform/syntiant/ei_syntiant_fs_commands.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef EI_SYNTIANT_FS_COMMANDS_H 35 | #define EI_SYNTIANT_FS_COMMANDS_H 36 | 37 | /* Include ----------------------------------------------------------------- */ 38 | #include 39 | 40 | #define SYNTIANT_FS_BLOCK_ERASE_TIME_MS 90 41 | 42 | /** Eta fs return values */ 43 | typedef enum 44 | { 45 | SYNTIANT_FS_CMD_OK = 0, /**!< All is well */ 46 | SYNTIANT_FS_CMD_NOT_INIT, /**!< FS is not initialised */ 47 | SYNTIANT_FS_CMD_READ_ERROR, /**!< Error occured during read */ 48 | SYNTIANT_FS_CMD_WRITE_ERROR, /**!< Error occured during write */ 49 | SYNTIANT_FS_CMD_ERASE_ERROR, /**!< Erase error occured */ 50 | SYNTIANT_FS_CMD_NULL_POINTER, /**!< Null pointer parsed */ 51 | 52 | }ei_syntiant_ret_t; 53 | 54 | 55 | /** Number of retries for SPI Flash */ 56 | #define MX25R_RETRY 10000 57 | 58 | /** SPI Flash Memory layout */ 59 | #define MX25R_PAGE_SIZE 256 /**!< Page program size */ 60 | #define MX25R_SECTOR_SIZE 4096 /**!< Size of sector */ 61 | #define MX25R_BLOCK32_SIZE (MX25R_SECTOR_SIZE * 8) /**!< 32K Block */ 62 | #define MX25R_BLOCK64_SIZE (MX25R_BLOCK32_SIZE * 2)/**!< 64K Block */ 63 | #define MX25R_CHIP_SIZE (MX25R_BLOCK64_SIZE * 128)/**!< 64Mb on chip */ 64 | 65 | /** MX25R Register defines */ 66 | #define MX25R_PP 0x02 /**!< Program page */ 67 | #define MX25R_READ 0x03 /**!< Read data command */ 68 | #define MX25R_RDSR 0x05 /**!< Status Register */ 69 | #define MX25R_WREN 0x06 /**!< Write enable bit */ 70 | #define MX25R_SE 0x20 /**!< Sector erase */ 71 | #define MX25R_PGM 0x7A /**!< Resume programming */ 72 | #define MX25R_BE 0xD8 /**!< Block (64K) erase */ 73 | 74 | /** MX25R Status register bit defines */ 75 | 76 | #define MX25R_STAT_SRWD (1<<7) /**!< Status reg write protect */ 77 | #define MX25R_STAT_QE (1<<6) /**!< Quad enable */ 78 | #define MX25R_STAT_BP3 (1<<5) /**!< Level of protect block */ 79 | #define MX25R_STAT_BP2 (1<<4) /**!< Level of protect block */ 80 | #define MX25R_STAT_BP1 (1<<3) /**!< Level of protect block */ 81 | #define MX25R_STAT_BP0 (1<<2) /**!< Level of protect block */ 82 | #define MX25R_STAT_WEL (1<<1) /**!< Write enable latch */ 83 | #define MX25R_STAT_WIP (1<<0) /**!< Write in progress bit */ 84 | 85 | 86 | /* Prototypes -------------------------------------------------------------- */ 87 | int ei_syntiant_fs_load_config(uint32_t *config, uint32_t config_size); 88 | int ei_syntiant_fs_save_config(const uint32_t *config, uint32_t config_size); 89 | 90 | int ei_syntiant_fs_erase_sampledata(uint32_t start_block, uint32_t end_address); 91 | int ei_syntiant_fs_write_samples(const void *sample_buffer, uint32_t address_offset, uint32_t n_samples); 92 | int ei_syntiant_fs_end_write(uint32_t address_offset); 93 | int ei_syntiant_fs_read_sample_data(void *sample_buffer, uint32_t address_offset, uint32_t n_read_bytes); 94 | uint32_t ei_syntiant_fs_get_block_size(void); 95 | uint32_t ei_syntiant_fs_get_n_available_sample_blocks(void); 96 | 97 | #endif -------------------------------------------------------------------------------- /src/model-parameters/model_variables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | 32 | #ifndef _EI_CLASSIFIER_MODEL_VARIABLES_H_ 33 | #define _EI_CLASSIFIER_MODEL_VARIABLES_H_ 34 | 35 | #include 36 | #include "model_metadata.h" 37 | 38 | 39 | #include "edge-impulse-sdk/classifier/ei_model_types.h" 40 | #include "edge-impulse-sdk/classifier/inferencing_engines/engines.h" 41 | 42 | const char* ei_classifier_inferencing_categories[] = { "no", "noise", "yes" }; 43 | 44 | uint8_t ei_dsp_config_3_axes[] = { 0 }; 45 | const uint8_t ei_dsp_config_3_axes_size = 1; 46 | ei_dsp_config_audio_syntiant_t ei_dsp_config_3 = { 47 | 1, // int implementationVersion 48 | 1, // int length of axes 49 | 0.032f, // float frame_length 50 | 0.024f, // float frame_stride 51 | 40, // int num_filters 52 | 512, // int fft_length 53 | 0, // int low_frequency 54 | 0, // int high_frequency 55 | 0.96875f, // float pre_cof 56 | "gpu" // select extractor 57 | }; 58 | 59 | #define EI_DSP_PARAMS_GENERATED 1 60 | 61 | 62 | 63 | const ei_performance_calibration_config_t ei_calibration = { 64 | 1, /* integer version number */ 65 | false, /* has configured performance calibration */ 66 | (int32_t)(EI_CLASSIFIER_RAW_SAMPLE_COUNT / ((EI_CLASSIFIER_FREQUENCY > 0) ? EI_CLASSIFIER_FREQUENCY : 1)) * 1000, /* Model window */ 67 | 0.8f, /* Default threshold */ 68 | (int32_t)(EI_CLASSIFIER_RAW_SAMPLE_COUNT / ((EI_CLASSIFIER_FREQUENCY > 0) ? EI_CLASSIFIER_FREQUENCY : 1)) * 500, /* Half of model window */ 69 | 0 /* Don't use flags */ 70 | }; 71 | 72 | 73 | #endif // _EI_CLASSIFIER_MODEL_METADATA_H_ 74 | -------------------------------------------------------------------------------- /src/repl/at_base64.h: -------------------------------------------------------------------------------- 1 | #ifndef _EDGE_IMPULSE_SDK_BASE64_H_ 2 | #define _EDGE_IMPULSE_SDK_BASE64_H_ 3 | 4 | /* 5 | base64.cpp and base64.h 6 | 7 | Copyright (C) 2004-2008 René Nyffenegger 8 | 9 | This source code is provided 'as-is', without any express or implied 10 | warranty. In no event will the author be held liable for any damages 11 | arising from the use of this software. 12 | 13 | Permission is granted to anyone to use this software for any purpose, 14 | including commercial applications, and to alter it and redistribute it 15 | freely, subject to the following restrictions: 16 | 17 | 1. The origin of this source code must not be misrepresented; you must not 18 | claim that you wrote the original source code. If you use this source code 19 | in a product, an acknowledgment in the product documentation would be 20 | appreciated but is not required. 21 | 22 | 2. Altered source versions must be plainly marked as such, and must not be 23 | misrepresented as being the original source code. 24 | 25 | 3. This notice may not be removed or altered from any source distribution. 26 | 27 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 28 | 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | static const char *base64_chars = 38 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 39 | "abcdefghijklmnopqrstuvwxyz" 40 | "0123456789+/"; 41 | 42 | 43 | static inline bool is_base64(unsigned char c) { 44 | return (isalnum(c) || (c == '+') || (c == '/')); 45 | } 46 | 47 | int base64_encode(const char *input, size_t input_size, char *output, size_t output_size) { 48 | size_t output_size_check = floor(input_size / 3 * 4); 49 | size_t mod = input_size % 3; 50 | output_size_check += mod; 51 | 52 | if (output_size < output_size_check) { 53 | return -10; 54 | } 55 | 56 | int i = 0; 57 | int j = 0; 58 | unsigned char char_array_3[3]; 59 | unsigned char char_array_4[4]; 60 | size_t output_ix = 0; 61 | 62 | while (input_size--) { 63 | char_array_3[i++] = *(input++); 64 | if (i == 3) { 65 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 66 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); 67 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); 68 | char_array_4[3] = char_array_3[2] & 0x3f; 69 | 70 | for(i = 0; (i < 4) ; i++) { 71 | output[output_ix++] = base64_chars[char_array_4[i]]; 72 | } 73 | i = 0; 74 | } 75 | } 76 | 77 | if (i) { 78 | for(j = i; j < 3; j++) { 79 | char_array_3[j] = '\0'; 80 | } 81 | 82 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 83 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); 84 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); 85 | char_array_4[3] = char_array_3[2] & 0x3f; 86 | 87 | for (j = 0; (j < i + 1); j++) { 88 | output[output_ix++] = base64_chars[char_array_4[j]]; 89 | } 90 | 91 | while((i++ < 3)) { 92 | output[output_ix++] = '='; 93 | } 94 | } 95 | 96 | return output_ix; 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/repl/repl.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef REPL_H 36 | #define REPL_H 37 | 38 | 39 | /* Prototypes -------------------------------------------------------------- */ 40 | void rx_callback(char c); 41 | 42 | #endif -------------------------------------------------------------------------------- /src/sensor_aq_mbedtls/sensor_aq_mbedtls_hs256.cpp: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | // #ifndef _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 36 | // #define _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 37 | 38 | /** 39 | * HMAC SHA256 implementation using Mbed TLS 40 | */ 41 | 42 | #include 43 | #include "firmware-sdk/sensor_aq.h" 44 | // #include "mbedtls/md.h" 45 | // #include "mbedtls/sha256.h" 46 | //#include "mbed_trace.h" 47 | // #include "ei_mbedtls_md.h" 48 | 49 | //#ifdef MBEDTLS_MD_C 50 | #include "edge-impulse-sdk/porting/ei_classifier_porting.h" 51 | 52 | typedef struct { 53 | // mbedtls_md_context_t md_ctx; 54 | char hmac_key[33]; 55 | } sensor_aq_mbedtls_hs256_ctx_t; 56 | 57 | static int sensor_aq_mbedtls_hs256_init(sensor_aq_signing_ctx_t *aq_ctx) { 58 | sensor_aq_mbedtls_hs256_ctx_t *hs_ctx = (sensor_aq_mbedtls_hs256_ctx_t*)aq_ctx->ctx; 59 | 60 | int err; 61 | 62 | //mbedtls_md_init(&hs_ctx->md_ctx); 63 | // memset(&hs_ctx->md_ctx, 0, sizeof( mbedtls_md_context_t ) ); 64 | 65 | err = 0;//ei_mbedtls_md_setup(&hs_ctx->md_ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256) , 1); //use hmac 66 | if (err != 0) { 67 | return err; 68 | } 69 | 70 | return 0;//ei_mbedtls_md_hmac_starts(&hs_ctx->md_ctx, (const unsigned char *)hs_ctx->hmac_key, strlen(hs_ctx->hmac_key)); 71 | } 72 | 73 | static int sensor_aq_mbedtls_hs256_update(sensor_aq_signing_ctx_t *aq_ctx, const uint8_t *buffer, size_t buffer_size) { 74 | sensor_aq_mbedtls_hs256_ctx_t *hs_ctx = (sensor_aq_mbedtls_hs256_ctx_t*)aq_ctx->ctx; 75 | 76 | return 0;//ei_mbedtls_md_hmac_update(&hs_ctx->md_ctx, buffer, buffer_size); 77 | } 78 | 79 | static int sensor_aq_mbedtls_hs256_finish(sensor_aq_signing_ctx_t *aq_ctx, uint8_t *buffer) { 80 | sensor_aq_mbedtls_hs256_ctx_t *hs_ctx = (sensor_aq_mbedtls_hs256_ctx_t*)aq_ctx->ctx; 81 | 82 | int ret = 0;//ei_mbedtls_md_hmac_finish(&hs_ctx->md_ctx, buffer); 83 | // mbedtls_md_free(&hs_ctx->md_ctx); 84 | return ret; 85 | } 86 | 87 | /** 88 | * Construct a new signing context for HMAC SHA256 using Mbed TLS 89 | * 90 | * @param aq_ctx An empty signing context (can declare it without arguments) 91 | * @param hs_ctx An empty sensor_aq_mbedtls_hs256_ctx_t context (can declare it on the stack without arguments) 92 | * @param hmac_key The secret key - **NOTE: this is limited to 32 characters, the rest will be truncated** 93 | */ 94 | void sensor_aq_init_mbedtls_hs256_context(sensor_aq_signing_ctx_t *aq_ctx, sensor_aq_mbedtls_hs256_ctx_t *hs_ctx, const char *hmac_key) { 95 | memcpy(hs_ctx->hmac_key, hmac_key, 32); 96 | hs_ctx->hmac_key[32] = 0; 97 | 98 | if (strlen(hmac_key) > 32) { 99 | ei_printf("!!! sensor_aq_init_mbedtls_hs256_context, HMAC key is longer than 32 characters - will be truncated !!!\n"); 100 | } 101 | 102 | aq_ctx->alg = "HS256"; // JWS algorithm 103 | aq_ctx->signature_length = 32; 104 | aq_ctx->ctx = (void*)NULL; 105 | aq_ctx->init = &sensor_aq_mbedtls_hs256_init; 106 | aq_ctx->set_protected = NULL; 107 | aq_ctx->update = &sensor_aq_mbedtls_hs256_update; 108 | aq_ctx->finish = &sensor_aq_mbedtls_hs256_finish; 109 | } 110 | 111 | // #else 112 | 113 | // #error "sensor_aq_mbedtls_hs256 loaded but Mbed TLS was not found, or MBEDTLS_MD_C was disabled" 114 | 115 | // #endif // MBEDTLS_MD_C 116 | 117 | // #endif // _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 118 | -------------------------------------------------------------------------------- /src/sensor_aq_mbedtls/sensor_aq_mbedtls_hs256.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 36 | #define _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 37 | 38 | /** 39 | * HMAC SHA256 implementation using Mbed TLS 40 | */ 41 | 42 | //#include 43 | #include "firmware-sdk/sensor_aq.h" 44 | // #include "mbedtls/md.h" 45 | //#include "mbedtls/sha256.h" 46 | //#include "mbed_trace.h" 47 | //#include "ei_mbedtls_md.h" 48 | 49 | //#ifdef MBEDTLS_MD_C 50 | 51 | typedef struct { 52 | // mbedtls_md_context_t md_ctx; 53 | char hmac_key[33]; 54 | } sensor_aq_mbedtls_hs256_ctx_t; 55 | 56 | /** 57 | * Construct a new signing context for HMAC SHA256 using Mbed TLS 58 | * 59 | * @param aq_ctx An empty signing context (can declare it without arguments) 60 | * @param hs_ctx An empty sensor_aq_mbedtls_hs256_ctx_t context (can declare it on the stack without arguments) 61 | * @param hmac_key The secret key - **NOTE: this is limited to 32 characters, the rest will be truncated** 62 | */ 63 | void sensor_aq_init_mbedtls_hs256_context(sensor_aq_signing_ctx_t *aq_ctx, sensor_aq_mbedtls_hs256_ctx_t *hs_ctx, const char *hmac_key); 64 | 65 | // #else 66 | 67 | // #error "sensor_aq_mbedtls_hs256 loaded but Mbed TLS was not found, or MBEDTLS_MD_C was disabled" 68 | 69 | // #endif // MBEDTLS_MD_C 70 | 71 | #endif // _EDGE_IMPULSE_SIGNING_MBEDTLS_HMAC_SHA256_H_ 72 | -------------------------------------------------------------------------------- /src/sensors/ei_fusion_sensors_config.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef EI_FUSION_SENSORS_CONFIG_H 36 | #define EI_FUSION_SENSORS_CONFIG_H 37 | 38 | #define NUM_FUSION_SENSORS 3 // number of fusable sensor modules 39 | #define NUM_MAX_FUSIONS 3 // max number of sensor module combinations 40 | #define FUSION_FREQUENCY 12.5f // sampling frequency for fusion samples 41 | #define NUM_MAX_FUSION_AXIS 20 // max number of axis to sample 42 | #define SIZEOF_SENSOR_NAME 20 // char alloc for sensor module name 43 | 44 | /** Format used for fusion */ 45 | typedef float fusion_sample_format_t; 46 | 47 | #endif // EI_FUSION_SENSORS_CONFIG_H -------------------------------------------------------------------------------- /src/sensors/ei_inertialsensor.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef EI_INERTIAL_SENSOR 36 | #define EI_INERTIAL_SENSOR 37 | 38 | /* Include ----------------------------------------------------------------- */ 39 | #include "ei_sampler.h" 40 | 41 | 42 | /** Number of axis used and sample data format */ 43 | typedef float sample_format_t; 44 | #define N_AXIS_SAMPLED 6 45 | #define SIZEOF_N_AXIS_SAMPLED (sizeof(sample_format_t) * N_AXIS_SAMPLED) 46 | 47 | 48 | /* Function prototypes ----------------------------------------------------- */ 49 | bool ei_inertial_init(void); 50 | int ei_inertial_read_data(void); 51 | bool ei_inertial_sample_start(sampler_callback callback, float sample_interval_ms); 52 | bool ei_inertial_setup_data_sampling(void); 53 | void ei_intertial_read_data_one(void); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/sensors/ei_sampler.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EI_SAMPLER_H 36 | #define _EI_SAMPLER_H 37 | 38 | #include "firmware-sdk/ei_config_types.h" 39 | 40 | /* Function prototypes ----------------------------------------------------- */ 41 | bool ei_sampler_start_sampling(void *v_ptr_payload, starter_callback ei_sample_start, uint32_t sample_size); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/syntiant.h: -------------------------------------------------------------------------------- 1 | #ifndef SYNTIANT_H 2 | #define SYNTIANT_H 3 | 4 | /* Pin allocation defines for Syntiant connector SL2 */ 5 | #define OUT_1_PIN 15 6 | #define OUT_2_PIN 7 7 | #define OUT_3_PIN 6 8 | 9 | /* Macro functions for Pin 5 on SL2 */ 10 | #define OUT_1_HIGH() digitalWrite(OUT_1_PIN, HIGH) 11 | #define OUT_1_LOW() digitalWrite(OUT_1_PIN, LOW) 12 | #define OUT_1_TOGGLE() digitalWrite(OUT_1_PIN, !digitalRead(OUT_1_PIN)) 13 | 14 | /* Macro functions for Pin 6 on SL2 */ 15 | #define OUT_2_HIGH() digitalWrite(OUT_2_PIN, HIGH) 16 | #define OUT_2_LOW() digitalWrite(OUT_2_PIN, LOW) 17 | #define OUT_2_TOGGLE() digitalWrite(OUT_2_PIN, !digitalRead(OUT_2_PIN)) 18 | 19 | /* Macro functions for Pin 7 on SL2 */ 20 | #define OUT_3_HIGH() digitalWrite(OUT_3_PIN, HIGH) 21 | #define OUT_3_LOW() digitalWrite(OUT_3_PIN, LOW) 22 | #define OUT_3_TOGGLE() digitalWrite(OUT_3_PIN, !digitalRead(J4_4_PIN)) 23 | 24 | /* Macro functions for Built in LED */ 25 | #define LED_HIGH() digitalWrite(LED_BUILTIN, HIGH) 26 | #define LED_LOW() digitalWrite(LED_BUILTIN, LOW) 27 | #define LED_TOGGLE() digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)) 28 | 29 | /* Prototypes -------------------------------------------------------------- */ 30 | void syntiant_setup(void); 31 | void syntiant_loop(void); 32 | 33 | void syntiant_get_imu(float *dest_imu); 34 | 35 | #endif -------------------------------------------------------------------------------- /syntiant_arduino_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Syntiant Corp. All rights reserved. 3 | * Contact at http://www.syntiant.com 4 | * 5 | * This software is available to you under a choice of one of two licenses. 6 | * You may choose to be licensed under the terms of the GNU General Public 7 | * License (GPL) Version 2, available from the file LICENSE in the main 8 | * directory of this source tree, or the OpenIB.org BSD license below. Any 9 | * code involving Linux software will require selection of the GNU General 10 | * Public License (GPL) Version 2. 11 | * 12 | * OPENIB.ORG BSD LICENSE 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | #ifndef SYNTIANT_ARDUINO_VERSION_H 33 | #define SYNTIANT_ARDUINO_VERSION_H 34 | #define SYNTIANT_ARDUINO_VERSION "v11" 35 | #endif 36 | --------------------------------------------------------------------------------